blob: 2718639ce4d5fa574594cf67f8e07b788c7d8f7c [file] [log] [blame]
garciadeblas5a8e5722025-07-28 19:16:39 +02001*** Comments ***
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14
15*** Settings ***
16Documentation Library providing keywords for CRUD operations over app instances
17... with OSM client.
18Library OperatingSystem
19Library String
20
21
22*** Variables ***
23${SUCCESS_RETURN_CODE} 0
24${APP_CREATION_MAX_WAIT_TIME} 7min
25${APP_CREATION_POL_TIME} 30sec
26${APP_DELETION_MAX_WAIT_TIME} 5min
27${APP_DELETION_POL_TIME} 15sec
28
29
30*** Keywords ***
31Create App Instance
32 [Documentation] Create an App Instance in OSM
33 [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
34 ${app_params}= Set Variable ${EMPTY}
35 IF "${app_model_file}" != "${EMPTY}"
36 ${app_params}= Catenate ${app_params} --model ${app_model_file}
37 END
38 IF "${app_params_file}" != "${EMPTY}"
39 ${app_params}= Catenate ${app_params} --params ${app_params_file}
40 END
41 IF "${app_secret_params_file}" != "${EMPTY}"
42 ${app_params}= Catenate ${app_params} --secret-params ${app_secret_params_file}
43 END
44 ${rc} ${stdout}= Run And Return Rc And Output
45 ... osm app-create ${app_name} --description ${app_description} --oka ${oka_name} --profile ${profile} --profile-type ${profile_type} ${app_params}
46 Log ${rc},${stdout}
47 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=App Instance creation failed: ${stdout}
48 ${app_id}= Set Variable ${stdout}
49 Log ${app_id}
50 IF ${wait_flag} == True
51 Wait Until Keyword Succeeds ${APP_CREATION_MAX_WAIT_TIME} ${APP_CREATION_POL_TIME}
52 ... Check For App Instance To Be Ready ${app_id}
53 END
54 RETURN ${app_id}
55
56Delete App Instance
57 [Documentation] Delete App Instance from OSM
58 [Arguments] ${app_name} ${wait_flag}=True
59 ${rc} ${stdout}= Run And Return Rc And Output
60 ... osm app-delete ${app_name}
61 Log ${rc},${stdout}
62 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=App Instance deletion failed: ${stdout}
63 IF ${wait_flag} == True
64 Wait Until Keyword Succeeds ${APP_DELETION_MAX_WAIT_TIME} ${APP_DELETION_POL_TIME}
65 ... Check For App Instance To Be Deleted ${app_name}
66 END
67
68Check For App Instance To Be Ready
69 [Documentation] Check if an App Instance is ready (the resourceState must be READY).
70 [Arguments] ${app_name}
71 ${rc} ${stdout}= Run And Return Rc And Output osm app-show ${app_name}
72 Log ${rc},${stdout}
73 ${rc} ${stdout}= Run And Return Rc And Output osm app-show ${app_name} -o jsonpath='{.resourceState}'
74 Log ${rc},${stdout}
75 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
76 Should Be Equal As Strings ${stdout} READY
77
78Check For App Instance To Be Deleted
79 [Documentation] Check if an App Instance identified by app_name is not present in OSM.
80 [Arguments] ${app_name}
81 ${rc} ${output}= Run And Return Rc And Output osm app-show ${app_name}
82 Log ${rc},${output}
83 ${matches}= Get Regexp Matches ${app_name} ^[0-9a-fA-F-]{36}$
84 Log ${matches}
85 IF ${matches} != @{EMPTY}
86 Log ${app_name} is a valid UUID
87 # ${rc} ${stdout}= Run And Return Rc And Output osm app-list --filter _id="${app_name}" | grep ${app_name}
88 ${rc} ${stdout}= Run And Return Rc And Output osm app-list --filter _id="${app_name}" -o jsonpath='[*]._id'| grep -E "\^${app_name}\$"
89 ELSE
90 Log ${app_name} is not a valid UUID, so it will be treated as a name
91 # ${rc} ${stdout}= Run And Return Rc And Output osm app-list --filter name="${app_name}" | grep ${app_name}
92 ${rc} ${stdout}= Run And Return Rc And Output osm app-list --filter name="${app_name}" -o jsonpath='[*].name'| grep -E "\^${app_name}\$"
93 END
94 Log ${rc},${stdout}
95 Should Be Empty ${stdout}