blob: 2718639ce4d5fa574594cf67f8e07b788c7d8f7c [file] [log] [blame]
*** Comments ***
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*** Settings ***
Documentation Library providing keywords for CRUD operations over app instances
... with OSM client.
Library OperatingSystem
Library String
*** Variables ***
${SUCCESS_RETURN_CODE} 0
${APP_CREATION_MAX_WAIT_TIME} 7min
${APP_CREATION_POL_TIME} 30sec
${APP_DELETION_MAX_WAIT_TIME} 5min
${APP_DELETION_POL_TIME} 15sec
*** Keywords ***
Create App Instance
[Documentation] Create an App Instance in OSM
[Arguments] ${app_name} ${app_description} ${profile} ${profile_type} ${oka_name} ${app_model_file}=${EMPTY} ${app_params_file}=${EMPTY} ${app_secret_params_file}=${EMPTY} ${wait_flag}=True
${app_params}= Set Variable ${EMPTY}
IF "${app_model_file}" != "${EMPTY}"
${app_params}= Catenate ${app_params} --model ${app_model_file}
END
IF "${app_params_file}" != "${EMPTY}"
${app_params}= Catenate ${app_params} --params ${app_params_file}
END
IF "${app_secret_params_file}" != "${EMPTY}"
${app_params}= Catenate ${app_params} --secret-params ${app_secret_params_file}
END
${rc} ${stdout}= Run And Return Rc And Output
... osm app-create ${app_name} --description ${app_description} --oka ${oka_name} --profile ${profile} --profile-type ${profile_type} ${app_params}
Log ${rc},${stdout}
Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=App Instance creation failed: ${stdout}
${app_id}= Set Variable ${stdout}
Log ${app_id}
IF ${wait_flag} == True
Wait Until Keyword Succeeds ${APP_CREATION_MAX_WAIT_TIME} ${APP_CREATION_POL_TIME}
... Check For App Instance To Be Ready ${app_id}
END
RETURN ${app_id}
Delete App Instance
[Documentation] Delete App Instance from OSM
[Arguments] ${app_name} ${wait_flag}=True
${rc} ${stdout}= Run And Return Rc And Output
... osm app-delete ${app_name}
Log ${rc},${stdout}
Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=App Instance deletion failed: ${stdout}
IF ${wait_flag} == True
Wait Until Keyword Succeeds ${APP_DELETION_MAX_WAIT_TIME} ${APP_DELETION_POL_TIME}
... Check For App Instance To Be Deleted ${app_name}
END
Check For App Instance To Be Ready
[Documentation] Check if an App Instance is ready (the resourceState must be READY).
[Arguments] ${app_name}
${rc} ${stdout}= Run And Return Rc And Output osm app-show ${app_name}
Log ${rc},${stdout}
${rc} ${stdout}= Run And Return Rc And Output osm app-show ${app_name} -o jsonpath='{.resourceState}'
Log ${rc},${stdout}
Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
Should Be Equal As Strings ${stdout} READY
Check For App Instance To Be Deleted
[Documentation] Check if an App Instance identified by app_name is not present in OSM.
[Arguments] ${app_name}
${rc} ${output}= Run And Return Rc And Output osm app-show ${app_name}
Log ${rc},${output}
${matches}= Get Regexp Matches ${app_name} ^[0-9a-fA-F-]{36}$
Log ${matches}
IF ${matches} != @{EMPTY}
Log ${app_name} is a valid UUID
# ${rc} ${stdout}= Run And Return Rc And Output osm app-list --filter _id="${app_name}" | grep ${app_name}
${rc} ${stdout}= Run And Return Rc And Output osm app-list --filter _id="${app_name}" -o jsonpath='[*]._id'| grep -E "\^${app_name}\$"
ELSE
Log ${app_name} is not a valid UUID, so it will be treated as a name
# ${rc} ${stdout}= Run And Return Rc And Output osm app-list --filter name="${app_name}" | grep ${app_name}
${rc} ${stdout}= Run And Return Rc And Output osm app-list --filter name="${app_name}" -o jsonpath='[*].name'| grep -E "\^${app_name}\$"
END
Log ${rc},${stdout}
Should Be Empty ${stdout}