blob: 0895da7dd4e10ca9afd80afc84d9653ebae27a5e [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
2# Copyright 2020 Canonical Ltd.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17*** Settings ***
18Documentation Library providing keywords for CRUD operations over Kubernetes clusters with OSM client.
19Library OperatingSystem
20
21
22*** Variables ***
23${SUCCESS_RETURN_CODE} 0
24${K8SCLUSTER_LAUNCH_MAX_WAIT_TIME} 6min
25${K8SCLUSTER_LAUNCH_POL_TIME} 30sec
26${K8SCLUSTER_DELETE_MAX_WAIT_TIME} 2min
27${K8SCLUSTER_DELETE_POL_TIME} 15sec
28
29
30*** Keywords ***
31Create K8s Cluster
32 [Documentation] Register a Kubernetes cluster in OSM using the name, version and credentials passed as arguments.
33 [Arguments] ${k8scluster_creds} ${k8scluster_version} ${k8scluster_vim} ${k8scluster_net} ${k8scluster_name}
34 ${rc} ${stdout}= Run And Return Rc And Output osm k8scluster-add --creds ${k8scluster_creds} --version ${k8scluster_version} --vim ${k8scluster_vim} --k8s-nets '{"net1": "${k8scluster_net}"}' ${k8scluster_name} --description "Robot cluster"
35 Log ${stdout}
36 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
37 Wait Until Keyword Succeeds ${K8SCLUSTER_LAUNCH_MAX_WAIT_TIME} ${K8SCLUSTER_LAUNCH_POL_TIME} Check For K8s Cluster To Be Ready ${k8scluster_name}
38 Check For K8s Cluster To Be Enabled ${k8scluster_name}
39 RETURN ${stdout}
40
41Delete K8s Cluster
42 [Documentation] Unregister/delete a Kubernetes cluster from OSM.
43 [Arguments] ${k8scluster_name}
44 ${rc} ${stdout}= Run And Return Rc And Output osm k8scluster-delete ${k8scluster_name}
45 Log ${stdout}
46 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
47 Wait Until Keyword Succeeds ${K8SCLUSTER_DELETE_MAX_WAIT_TIME} ${K8SCLUSTER_DELETE_POL_TIME} Check For K8s Cluster To Be Deleted ${k8scluster_name}
48
49Get K8s Cluster
50 [Documentation] Get the list of Kubernetes clusters in OSM, and return it.
51 ${rc} ${stdout}= Run And Return Rc And Output osm k8scluster-list
52 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
53 Log ${stdout}
54 RETURN ${stdout}
55
56Check For K8s Cluster
57 [Documentation] Check if a Kubernetes cluster identified by name exists in OSM, and return it.
58 [Arguments] ${k8scluster_name}
59 ${rc} ${stdout}= Run And Return Rc And Output osm k8scluster-list --filter name="${k8scluster_name}"
60 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
61 RETURN ${stdout}
62
63Check For K8s Cluster To Be Deleted
64 [Documentation] Check if a Kubernetes cluster identified by name is not present in OSM.
65 [Arguments] ${k8scluster_name}
66 ${rc} ${stdout}= Run And Return Rc And Output osm k8scluster-list --filter name="${k8scluster_name}" | awk '{print $2}' | grep ${k8scluster_name}
67 Log ${rc},${stdout}
68 Should Be Empty ${stdout}
69
70Check For K8s Cluster To Be Ready
71 [Documentation] Check if a Kubernetes cluster registered in OSM is ready (the state must be ENABLED or DEGRADED).
72 [Arguments] ${k8scluster_name}
73 ${rc} ${stdout}= Run And Return Rc And Output osm k8scluster-list --filter name="${k8scluster_name}" --filter _admin.operationalState="ENABLED,DEGRADED"
74 Log ${rc},${stdout}
75 ${rc} ${stdout}= Run And Return Rc And Output echo "${stdout}" | awk '{print $2}' | grep ${k8scluster_name}
76 Log ${rc},${stdout}
77 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
78 Should Be Equal As Strings ${stdout} ${k8scluster_name}
79
80Check For K8s Cluster To Be Enabled
81 [Documentation] Check if the state of Kubernetes cluster registered in OSM is ENABLED.
82 [Arguments] ${k8scluster_name}
83 ${rc} ${stdout}= Run And Return Rc And Output osm k8scluster-show ${k8scluster_name}
84 Log ${rc},${stdout}
85 ${rc} ${stdout}= Run And Return Rc And Output osm k8scluster-list --filter name="${k8scluster_name}" --filter _admin.operationalState="ENABLED"
86 Log ${rc},${stdout}
87 ${rc} ${stdout}= Run And Return Rc And Output echo "${stdout}" | awk '{print $2}' | grep ${k8scluster_name}
88 Log ${rc},${stdout}
89 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
90 Should Be Equal As Strings ${stdout} ${k8scluster_name}