blob: 562e2f4431cd90687d4400c64ff55c4ea3808203 [file] [log] [blame]
garciadeblas353aeb52025-02-13 10:23:34 +01001*** Comments ***
garciadeblas353aeb52025-02-13 10:23:34 +01002# 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 clusters,
17... OKAs and KSUs with OSM client.
18Library OperatingSystem
19Library String
20
21
22*** Variables ***
23${SUCCESS_RETURN_CODE} 0
garciadeblasd39b8642025-10-08 16:59:09 +020024${CLUSTER_CREATE_MAX_WAIT_TIME} 16min
25${CLUSTER_CREATE_POL_TIME} 30sec
26${CLUSTER_REGISTER_MAX_WAIT_TIME} 16min
garciadeblas590e2952025-04-23 17:05:03 +020027${CLUSTER_REGISTER_POL_TIME} 30sec
garciadeblas353aeb52025-02-13 10:23:34 +010028${CLUSTER_DELETE_MAX_WAIT_TIME} 12min
29${CLUSTER_DELETE_POL_TIME} 30sec
30${OKA_OPERATION_MAX_WAIT_TIME} 5min
31${OKA_OPERATION_POL_TIME} 15sec
garciadeblas76790672025-02-26 11:18:33 +010032${KSU_CREATION_MAX_WAIT_TIME} 7min
garciadeblas353aeb52025-02-13 10:23:34 +010033${KSU_CREATION_POL_TIME} 30sec
garciadeblas76790672025-02-26 11:18:33 +010034${KSU_DELETION_MAX_WAIT_TIME} 5min
garciadeblas353aeb52025-02-13 10:23:34 +010035${KSU_DELETION_POL_TIME} 15sec
36
37
38*** Keywords ***
39Create Cluster
40 [Documentation] Create a Kubernetes cluster in OSM using the name, version, nodes, etc., passed as arguments.
garciadeblasc7088602025-07-31 18:23:48 +020041 [Arguments] ${name} ${vim_account} ${description} ${vm_size} ${version} ${nodes} ${region} ${resource_group} ${cluster_config}=${EMPTY} ${wait_flag}=True
garciadeblas353aeb52025-02-13 10:23:34 +010042 ${command}= Catenate
43 ... osm cluster-create ${name}
44 ... --node-count ${nodes}
45 ... --node-size ${vm_size}
46 ... --version ${version}
47 ... --vim-account ${vim_account}
48 ... --description ${description}
49 ... --region-name ${region}
50 ... --resource-group ${resource_group}
garciadeblasc7088602025-07-31 18:23:48 +020051 IF "${cluster_config}" != "${EMPTY}"
52 ${command}= Catenate ${command} ${cluster_config}
53 END
garciadeblas353aeb52025-02-13 10:23:34 +010054 ${rc} ${stdout}= Run And Return Rc And Output ${command}
55 Log ${rc},${stdout}
56 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=Cluster creation failed: ${stdout}
57 ${cluster_id}= Set Variable ${stdout}
58 Log ${cluster_id}
59 Check Cluster Age Keys ${cluster_id}
60 IF ${wait_flag} == True
garciadeblasd39b8642025-10-08 16:59:09 +020061 Wait Until Keyword Succeeds ${CLUSTER_CREATE_MAX_WAIT_TIME} ${CLUSTER_CREATE_POL_TIME}
garciadeblas590e2952025-04-23 17:05:03 +020062 ... Check For Cluster To Be Ready ${name}
63 END
64 RETURN ${cluster_id}
65
66Register Cluster
67 [Documentation] Register a Kubernetes cluster in OSM using a provided name and kubeconfig credentials.
garciadeblasec153232025-08-01 10:13:03 +020068 [Arguments] ${name} ${vim_account} ${creds} ${description} ${bootstrap_flag}=True ${openshift_flag}=False ${wait_flag}=True
garciadeblas590e2952025-04-23 17:05:03 +020069 ${command}= Catenate
70 ... osm cluster-register ${name}
71 ... --vim-account ${vim_account}
72 ... --creds ${creds}
73 ... --description ${description}
74 IF ${bootstrap_flag} == True
garciadeblasc50555f2025-06-17 12:40:07 +020075 ${command}= Catenate ${command} --bootstrap
garciadeblas590e2952025-04-23 17:05:03 +020076 ELSE
garciadeblasc50555f2025-06-17 12:40:07 +020077 ${command}= Catenate ${command} --no-bootstrap
garciadeblas590e2952025-04-23 17:05:03 +020078 END
garciadeblasec153232025-08-01 10:13:03 +020079 IF ${openshift_flag} == True
80 ${command}= Catenate ${command} --openshift
81 END
garciadeblas590e2952025-04-23 17:05:03 +020082 ${rc} ${stdout}= Run And Return Rc And Output ${command}
83 Log ${rc},${stdout}
84 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=Cluster registration failed: ${stdout}
85 ${cluster_id}= Set Variable ${stdout}
86 Log ${cluster_id}
87 Check Cluster Age Keys ${cluster_id}
88 IF ${wait_flag} == True
garciadeblasd39b8642025-10-08 16:59:09 +020089 Wait Until Keyword Succeeds ${CLUSTER_REGISTER_MAX_WAIT_TIME} ${CLUSTER_REGISTER_POL_TIME}
garciadeblas353aeb52025-02-13 10:23:34 +010090 ... Check For Cluster To Be Ready ${name}
91 END
92 RETURN ${cluster_id}
93
94Check Cluster Age Keys
95 [Documentation] Check AGE keys in the cluster
96 [Arguments] ${cluster_name}
97 ${rc} ${stdout}= Run And Return Rc And Output
98 ... osm cluster-show ${cluster_name} -o jsonpath='{.age_privkey}'
99 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
100 # TODO: Check if privkey contains the expected value
101 Log privkey is ${stdout}
102 ${rc} ${stdout}= Run And Return Rc And Output
103 ... osm cluster-show ${cluster_name} -o jsonpath='{.age_pubkey}'
104 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
105 # TODO: Check if pubkey contains the expected value
106 Log pubkey is ${stdout}
107
108Delete Cluster
garciadeblas590e2952025-04-23 17:05:03 +0200109 [Documentation] Delete a Kubernetes cluster from OSM.
garciadeblas353aeb52025-02-13 10:23:34 +0100110 [Arguments] ${cluster_name} ${wait_flag}=True
111 ${rc} ${stdout}= Run And Return Rc And Output osm cluster-delete ${cluster_name}
112 Log ${rc},${stdout}
113 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=Cluster deletion failed: ${stdout}
114 IF ${wait_flag} == True
115 Wait Until Keyword Succeeds ${CLUSTER_DELETE_MAX_WAIT_TIME} ${CLUSTER_DELETE_POL_TIME}
116 ... Check For Cluster Deletion Status ${cluster_name}
117 END
118
garciadeblas590e2952025-04-23 17:05:03 +0200119Deregister Cluster
120 [Documentation] Deregister a Kubernetes cluster from OSM.
121 [Arguments] ${cluster_name} ${wait_flag}=True
122 ${rc} ${stdout}= Run And Return Rc And Output osm cluster-deregister ${cluster_name}
123 Log ${rc},${stdout}
124 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=Cluster deregistration failed: ${stdout}
125 IF ${wait_flag} == True
126 Wait Until Keyword Succeeds ${CLUSTER_DELETE_MAX_WAIT_TIME} ${CLUSTER_DELETE_POL_TIME}
127 ... Check For Cluster Deletion Status ${cluster_name}
128 END
129
garciadeblas353aeb52025-02-13 10:23:34 +0100130Check For Cluster Deletion Status
131 [Documentation] Check if a Kubernetes cluster identified by name is deleted or in error state.
132 [Arguments] ${cluster_name}
133 ${rc} ${output}= Run And Return Rc And Output osm cluster-show ${cluster_name}
134 Log ${rc},${output}
135 ${rc} ${resourceState}= Run And Return Rc And Output osm cluster-show ${cluster_name} -o jsonpath='{.resourceState}'
136 Log ${rc},${resourceState}
garciadeblasd851b7f2026-02-14 11:11:41 +0100137 IF "${rc}" == "${SUCCESS_RETURN_CODE}" and "${resourceState}" == "ERROR"
garciadeblas353aeb52025-02-13 10:23:34 +0100138 Fail Cluster is in error state and will not be deleted.
139 ELSE
140 Log Either the cluster ${cluster_name} has been deleted or it is in a valid state.
141 Check For Cluster To Be Deleted ${cluster_name}
142 END
143
144Get Clusters
145 [Documentation] Get the list of Kubernetes clusters in OSM, and return it.
146 ${rc} ${stdout}= Run And Return Rc And Output osm cluster-list
147 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
148 Log ${stdout}
149 RETURN ${stdout}
150
151Check For Cluster To Be Ready
152 [Documentation] Check if a Kubernetes cluster is ready (the resourceState must be READY).
153 [Arguments] ${cluster_name}
154 ${rc} ${stdout}= Run And Return Rc And Output osm cluster-show ${cluster_name}
155 Log ${rc},${stdout}
156 ${rc} ${stdout}= Run And Return Rc And Output osm cluster-show ${cluster_name} -o jsonpath='{.resourceState}'
157 Log ${rc},${stdout}
158 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
159 Should Be Equal As Strings ${stdout} READY
160
161Check For Cluster To Be Deleted
162 [Documentation] Check if a Kubernetes cluster identified by name is not present in OSM.
163 [Arguments] ${cluster_name}
164 ${matches}= Get Regexp Matches ${cluster_name} ^[0-9a-fA-F-]{36}$
165 Log ${matches}
166 IF ${matches} != @{EMPTY}
167 Log ${cluster_name} is a valid UUID
garciadeblas71ae92c2025-04-25 13:18:58 +0200168 # ${rc} ${stdout}= Run And Return Rc And Output osm cluster-list --filter _id="${cluster_name}" | grep ${cluster_name}
garciadeblasc25ac022025-06-17 12:32:23 +0200169 ${rc} ${stdout}= Run And Return Rc And Output osm cluster-list --filter _id="${cluster_name}" -o jsonpath='[*]._id'| grep -E "\^${cluster_name}\$"
garciadeblas353aeb52025-02-13 10:23:34 +0100170 ELSE
171 Log ${cluster_name} is not a valid UUID, so it will be treated as a name
garciadeblas71ae92c2025-04-25 13:18:58 +0200172 # ${rc} ${stdout}= Run And Return Rc And Output osm cluster-list --filter name="${cluster_name}" | grep ${cluster_name}
garciadeblasc25ac022025-06-17 12:32:23 +0200173 ${rc} ${stdout}= Run And Return Rc And Output osm cluster-list --filter name="${cluster_name}" -o jsonpath='[*].name'| grep -E "\^${cluster_name}\$"
garciadeblas353aeb52025-02-13 10:23:34 +0100174 END
175 Log ${rc},${stdout}
176 Should Be Empty ${stdout}
177
178Add OKA Package
179 [Documentation] Add OKA package to OSM
180 [Arguments] ${oka_name} ${oka_folder} ${oka_profile} ${wait_flag}=True
181 ${rc} ${stdout}= Run And Return Rc And Output
182 ... osm oka-add ${oka_name} ${oka_folder} --description ${oka_name} --profile-type ${oka_profile}
183 Log ${rc},${stdout}
184 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=OKA addition failed: ${stdout}
185 ${oka_id}= Set Variable ${stdout}
186 Log ${oka_id}
187 IF ${wait_flag} == True
188 Wait Until Keyword Succeeds ${OKA_OPERATION_MAX_WAIT_TIME} ${OKA_OPERATION_POL_TIME}
189 ... Check For OKA To Be Ready ${oka_id}
190 END
191 RETURN ${oka_id}
192
193Delete OKA Package
194 [Documentation] Delete OKA package from OSM
195 [Arguments] ${oka_name} ${wait_flag}=True
196 ${rc} ${stdout}= Run And Return Rc And Output
197 ... osm oka-delete ${oka_name}
198 Log ${rc},${stdout}
199 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=OKA deletion failed: ${stdout}
200 IF ${wait_flag} == True
201 Wait Until Keyword Succeeds ${OKA_OPERATION_MAX_WAIT_TIME} ${OKA_OPERATION_POL_TIME}
202 ... Check For OKA To Be Deleted ${oka_name}
203 END
204
205Check For OKA To Be Ready
206 [Documentation] Check if an OKA is ready (the resourceState must be READY).
207 [Arguments] ${oka_name}
208 ${rc} ${stdout}= Run And Return Rc And Output osm oka-show ${oka_name}
209 Log ${rc},${stdout}
210 ${rc} ${stdout}= Run And Return Rc And Output osm oka-show ${oka_name} -o jsonpath='{.resourceState}'
211 Log ${rc},${stdout}
212 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
213 Should Be Equal As Strings ${stdout} READY
214
215Check For OKA To Be Deleted
216 [Documentation] Check if an OKA identified by oka_name is not present in OSM.
217 [Arguments] ${oka_name}
218 ${rc} ${output}= Run And Return Rc And Output osm oka-show ${oka_name}
219 Log ${rc},${output}
220 ${matches}= Get Regexp Matches ${oka_name} ^[0-9a-fA-F-]{36}$
221 Log ${matches}
222 IF ${matches} != @{EMPTY}
223 Log ${oka_name} is a valid UUID
garciadeblas71ae92c2025-04-25 13:18:58 +0200224 # ${rc} ${stdout}= Run And Return Rc And Output osm oka-list --filter _id="${oka_name}" | grep ${oka_name}
garciadeblasc25ac022025-06-17 12:32:23 +0200225 ${rc} ${stdout}= Run And Return Rc And Output osm oka-list --filter _id="${oka_name}" -o jsonpath='[*]._id'| grep -E "\^${oka_name}\$"
garciadeblas353aeb52025-02-13 10:23:34 +0100226 ELSE
227 Log ${oka_name} is not a valid UUID, so it will be treated as a name
garciadeblas71ae92c2025-04-25 13:18:58 +0200228 # ${rc} ${stdout}= Run And Return Rc And Output osm oka-list --filter name="${oka_name}" | grep ${oka_name}
garciadeblasc25ac022025-06-17 12:32:23 +0200229 ${rc} ${stdout}= Run And Return Rc And Output osm oka-list --filter name="${oka_name}" -o jsonpath='[*].name'| grep -E "\^${oka_name}\$"
garciadeblas353aeb52025-02-13 10:23:34 +0100230 END
231 Log ${rc},${stdout}
232 Should Be Empty ${stdout}
233
234Create KSU
235 [Documentation] Create a KSU
garciadeblas76790672025-02-26 11:18:33 +0100236 [Arguments] ${ksu_name} ${ksu_description} ${profile} ${profile_type} ${oka_name} ${ksu_params_file}=${EMPTY} ${wait_flag}=True
237 IF "${ksu_params_file}" != "${EMPTY}"
238 ${rc} ${stdout}= Run And Return Rc And Output
239 ... osm ksu-create --ksu ${ksu_name} --description ${ksu_description} --profile ${profile} --profile-type ${profile_type} --oka ${oka_name} --params ${ksu_params_file}
240 ELSE
241 ${rc} ${stdout}= Run And Return Rc And Output
242 ... osm ksu-create --ksu ${ksu_name} --description ${ksu_description} --profile ${profile} --profile-type ${profile_type} --oka ${oka_name}
243 END
garciadeblas353aeb52025-02-13 10:23:34 +0100244 Log ${rc},${stdout}
245 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=KSU creation failed: ${stdout}
246 ${ksu_id}= Set Variable ${stdout}
247 Log ${ksu_id}
248 IF ${wait_flag} == True
249 Wait Until Keyword Succeeds ${KSU_CREATION_MAX_WAIT_TIME} ${KSU_CREATION_POL_TIME}
250 ... Check For KSU To Be Ready ${ksu_id}
251 END
252 RETURN ${ksu_id}
253
254Delete KSU
255 [Documentation] Delete KSU from OSM
256 [Arguments] ${ksu_name} ${wait_flag}=True
257 ${rc} ${stdout}= Run And Return Rc And Output
258 ... osm ksu-delete ${ksu_name}
259 Log ${rc},${stdout}
260 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=KSU deletion failed: ${stdout}
261 IF ${wait_flag} == True
262 Wait Until Keyword Succeeds ${KSU_DELETION_MAX_WAIT_TIME} ${KSU_DELETION_POL_TIME}
263 ... Check For KSU To Be Deleted ${ksu_name}
264 END
265
266Check For KSU To Be Ready
267 [Documentation] Check if a KSU is ready (the resourceState must be READY).
268 [Arguments] ${ksu_name}
269 ${rc} ${stdout}= Run And Return Rc And Output osm ksu-show ${ksu_name}
270 Log ${rc},${stdout}
271 ${rc} ${stdout}= Run And Return Rc And Output osm ksu-show ${ksu_name} -o jsonpath='{.resourceState}'
272 Log ${rc},${stdout}
273 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
274 Should Be Equal As Strings ${stdout} READY
275
276Check For KSU To Be Deleted
277 [Documentation] Check if a KSU identified by ksu_name is not present in OSM.
278 [Arguments] ${ksu_name}
279 ${rc} ${output}= Run And Return Rc And Output osm ksu-show ${ksu_name}
280 Log ${rc},${output}
281 ${matches}= Get Regexp Matches ${ksu_name} ^[0-9a-fA-F-]{36}$
282 Log ${matches}
283 IF ${matches} != @{EMPTY}
284 Log ${ksu_name} is a valid UUID
garciadeblas590e2952025-04-23 17:05:03 +0200285 # ${rc} ${stdout}= Run And Return Rc And Output osm ksu-list --filter _id="${ksu_name}" | grep ${ksu_name}
garciadeblasc25ac022025-06-17 12:32:23 +0200286 ${rc} ${stdout}= Run And Return Rc And Output osm ksu-list --filter _id="${ksu_name}" -o jsonpath='[*]._id'| grep -E "\^${ksu_name}\$"
garciadeblas353aeb52025-02-13 10:23:34 +0100287 ELSE
288 Log ${ksu_name} is not a valid UUID, so it will be treated as a name
garciadeblas590e2952025-04-23 17:05:03 +0200289 # ${rc} ${stdout}= Run And Return Rc And Output osm ksu-list --filter name="${ksu_name}" | grep ${ksu_name}
290 ${rc} ${stdout}= Run And Return Rc And Output osm ksu-list --filter name="${ksu_name}" -o jsonpath='[*].name'| grep -E "\^${ksu_name}\$"
garciadeblas353aeb52025-02-13 10:23:34 +0100291 END
292 Log ${rc},${stdout}
293 Should Be Empty ${stdout}