blob: 394fd84b7354945d7713e1d1bfe10b654ffe9a08 [file] [log] [blame]
garciadeblasc7088602025-07-31 18:23:48 +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 [GITOPS-03] Cluster creation in Openstack with CAPI
17
18Library OperatingSystem
19Library String
20Library Collections
21Library Process
22
23Resource ../lib/advanced_cluster_mgmt_lib.resource
24
25Test Tags gitops_03 cluster_gitops
26
27Suite Teardown Run Keyword And Ignore Error Suite Cleanup
28
29
30*** Variables ***
31# OKA packages
32${OKA_FOLDER} '%{PACKAGES_FOLDER}/oka'
33${OKA1_PKG} apps/jenkins
34${OKA1_NAME} jenkins
35${OKA1_PROFILE} app-profile
36${OKA_NS_PKG} apps/namespace
37${OKA_NS_NAME} namespace
38${OKA_NS_PROFILE} app-profile
39
40# Cluster
41${CLUSTER_NAME} gitops03
42${CLUSTER_DESCRIPTION} "Cluster for gitops03 Robot test suite"
43${CLUSTER_VM_SIZE} m1.large
44${CLUSTER_NODES} 1
45${REGION_NAME} northeurope
46${RESOURCE_GROUP} OSM-CTIO
47${KUBERNETES_VERSION} "1.31.7"
48${CLUSTER_CONTROL_PLANE_VM_SIZE} m1.large
49${CLUSTER_CONTROL_PLANE_NODES} 1
50${CLUSTER_CONFIG} --config '{"capi-openstack": {"dns-nameservers": "8.8.8.8", "failure-domain": "nova", "external-network-id": "21ea5d92-24f1-40ab-8d28-83230e277a49", "ssh-key-name": "jenkins", "control_plane_node_size": "${CLUSTER_CONTROL_PLANE_VM_SIZE}", "control_plane_node_count": "${CLUSTER_CONTROL_PLANE_NODES}"}}'
51
52# KSUs
53${KSU_NS_NAME} jenkins-ns
54${KSU1_NAME} jenkins
55${KSU1_PARAMS} ${CURDIR}/../resources/gitops-jenkins-params.yaml
56${KSU_NS_ID} ${EMPTY}
57${KSU1_ID} ${EMPTY}
58
59
60*** Test Cases ***
61Add OKA Packages For The Testsuite
62 [Documentation] Add OKA packages for the testsuite.
63 [Tags] oka create
64 Add OKA Package ${OKA_NS_NAME} '${OKA_FOLDER}/${OKA_NS_PKG}' ${OKA_NS_PROFILE}
65 Add OKA Package ${OKA1_NAME} '${OKA_FOLDER}/${OKA1_PKG}' ${OKA1_PROFILE}
66
67Create Cluster For Testsuite in Openstack
68 [Documentation] Create K8s cluster for the testsuite.
69 [Tags] cluster create
70 ${id}= Create Cluster ${CLUSTER_NAME} %{VIM_TARGET} ${CLUSTER_DESCRIPTION} ${CLUSTER_VM_SIZE} ${KUBERNETES_VERSION} ${CLUSTER_NODES} ${REGION_NAME} ${RESOURCE_GROUP} ${CLUSTER_CONFIG}
71 Set Suite Variable ${CLUSTER_ID} ${id}
72 Log ${CLUSTER_ID}
73
74Get Cluster Kubeconfig
75 [Documentation] Get Kubeconfig for the cluster.
76 [Tags] cluster
77 ${rc} ${stdout}= Run And Return Rc And Output
78 ... osm cluster-show ${CLUSTER_NAME} -o jsonpath='{.credentials}' | yq -y
79 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
80 Log ${stdout}
81
82Create KSU Namespace For All KSUs
83 [Documentation] Create KSU based on ${OKA_NS_NAME} with params.
84 [Tags] ksu ksu-ns create
85 ${id}= Create KSU ${KSU_NS_NAME} ${KSU_NS_NAME} ${CLUSTER_NAME} app-profile ${OKA_NS_NAME} ${OKA_FOLDER}/apps/jenkins-ns-params.yaml
86 Set Suite Variable ${KSU_NS_ID} ${id}
87 Log ${KSU_NS_ID}
88
89Create KSU1 With Params
90 [Documentation] Create KSU based on ${OKA1_NAME} with params.
91 [Tags] ksu ksu1 create
92 ${id}= Create KSU ${KSU1_NAME} ${KSU1_NAME} ${CLUSTER_NAME} app-profile ${OKA1_NAME} ${KSU1_PARAMS}
93 Set Suite Variable ${KSU1_ID} ${id}
94 Log ${KSU1_ID}
95
96Delete KSU1
97 [Documentation] Delete KSU1 based on ${OKA1_NAME}.
98 [Tags] cleanup ksu ksu1
99 IF '${KSU1_ID}' != ''
100 ${KSU_TO_BE_DELETED}= Set Variable ${KSU1_ID}
101 ELSE
102 ${KSU_TO_BE_DELETED}= Set Variable ${KSU1_NAME}
103 END
104 Delete KSU ${KSU_TO_BE_DELETED}
105
106Delete KSU Namespace
107 [Documentation] Delete KSU based on ${OKA_NS_NAME}.
108 [Tags] cleanup ksu ksu-ns
109 IF '${KSU_NS_ID}' != ''
110 ${KSU_TO_BE_DELETED}= Set Variable ${KSU_NS_ID}
111 ELSE
112 ${KSU_TO_BE_DELETED}= Set Variable ${KSU_NS_NAME}
113 END
114 Delete KSU ${KSU_TO_BE_DELETED}
115
116Delete Cluster For Testsuite
117 [Documentation] Delete K8s cluster for the testsuite.
118 [Tags] cleanup cluster
119 Delete Cluster ${CLUSTER_NAME}
120
121Delete OKA Packages For The Testsuite
122 [Documentation] Delete OKA packages for the testsuite.
123 [Tags] cleanup oka
124 Delete OKA Package ${OKA_NS_NAME}
125 Delete OKA Package ${OKA1_NAME}
126
127
128*** Keywords ***
129Suite Cleanup
130 [Documentation] Test Suit Cleanup: Deleting cluster, KSUs, OKAs
131 Run Keyword If Any Tests Failed Delete Cluster ${CLUSTER_NAME}
132 Run Keyword If Any Tests Failed Delete OKA Package ${OKA_NS_NAME}
133 Run Keyword If Any Tests Failed Delete OKA Package ${OKA1_NAME}