Feature 11049: Cluster management with CAPI in Openstack-based clouds 08/15308/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 31 Jul 2025 16:23:48 +0000 (18:23 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 1 Aug 2025 08:34:01 +0000 (10:34 +0200)
Change-Id: Ic71d9119ec00ad8e2a83a25c384ecb51d2970eae
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
robot-systest/lib/advanced_cluster_mgmt_lib.resource
robot-systest/resources/gitops-jenkins-params.yaml [new file with mode: 0644]
robot-systest/resources/gitops_02-jenkins-params.yaml [deleted file]
robot-systest/testsuite/gitops_02-declarative_cluster_registration_oka_ksu.robot
robot-systest/testsuite/gitops_03-capi_cluster_creation.robot [new file with mode: 0644]

index 84ce1a2..fa2d47d 100644 (file)
@@ -40,7 +40,7 @@ ${KSU_DELETION_POL_TIME}   15sec
 *** Keywords ***
 Create Cluster
     [Documentation]   Create a Kubernetes cluster in OSM using the name, version, nodes, etc., passed as arguments.
-    [Arguments]   ${name}   ${vim_account}   ${description}   ${vm_size}   ${version}   ${nodes}   ${region}   ${resource_group}   ${wait_flag}=True
+    [Arguments]   ${name}   ${vim_account}   ${description}   ${vm_size}   ${version}   ${nodes}   ${region}   ${resource_group}   ${cluster_config}=${EMPTY}   ${wait_flag}=True
     ${command}=   Catenate
     ...   osm cluster-create ${name}
     ...   --node-count ${nodes}
@@ -50,6 +50,9 @@ Create Cluster
     ...   --description ${description}
     ...   --region-name ${region}
     ...   --resource-group ${resource_group}
+    IF   "${cluster_config}" != "${EMPTY}"
+        ${command}=   Catenate   ${command}   ${cluster_config}
+    END
     ${rc}   ${stdout}=   Run And Return Rc And Output   ${command}
     Log   ${rc},${stdout}
     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}   msg=Cluster creation failed: ${stdout}
diff --git a/robot-systest/resources/gitops-jenkins-params.yaml b/robot-systest/resources/gitops-jenkins-params.yaml
new file mode 100644 (file)
index 0000000..b6b77a2
--- /dev/null
@@ -0,0 +1,23 @@
+# 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.
+
+namespace: jenkins
+inline_values:
+  service:
+    ports:
+      http: "8080"
+      https: "8443"
+secret_values:
+  jenkinsUser: admin
+  jenkinsPassword: myJ3nk1n2P2ssw0rd
+
diff --git a/robot-systest/resources/gitops_02-jenkins-params.yaml b/robot-systest/resources/gitops_02-jenkins-params.yaml
deleted file mode 100644 (file)
index b6b77a2..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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.
-
-namespace: jenkins
-inline_values:
-  service:
-    ports:
-      http: "8080"
-      https: "8443"
-secret_values:
-  jenkinsUser: admin
-  jenkinsPassword: myJ3nk1n2P2ssw0rd
-
index 4ea6cfc..e0b99f5 100644 (file)
@@ -50,7 +50,7 @@ ${CLUSTER_DESCRIPTION}   "Cluster for gitops02 Robot test suite"
 ${KSU_NS_NAME}   jenkins-ns
 ${KSU1_NAME}   testacme
 ${KSU2_NAME}   jenkins
-${KSU2_PARAMS}   ${CURDIR}/../resources/gitops_02-jenkins-params.yaml
+${KSU2_PARAMS}   ${CURDIR}/../resources/gitops-jenkins-params.yaml
 ${KSU_NS_ID}   ${EMPTY}
 ${KSU1_ID}   ${EMPTY}
 ${KSU2_ID}   ${EMPTY}
diff --git a/robot-systest/testsuite/gitops_03-capi_cluster_creation.robot b/robot-systest/testsuite/gitops_03-capi_cluster_creation.robot
new file mode 100644 (file)
index 0000000..394fd84
--- /dev/null
@@ -0,0 +1,133 @@
+*** 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   [GITOPS-03] Cluster creation in Openstack with CAPI
+
+Library   OperatingSystem
+Library   String
+Library   Collections
+Library   Process
+
+Resource   ../lib/advanced_cluster_mgmt_lib.resource
+
+Test Tags   gitops_03   cluster_gitops
+
+Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
+
+
+*** Variables ***
+# OKA packages
+${OKA_FOLDER}   '%{PACKAGES_FOLDER}/oka'
+${OKA1_PKG}   apps/jenkins
+${OKA1_NAME}   jenkins
+${OKA1_PROFILE}   app-profile
+${OKA_NS_PKG}   apps/namespace
+${OKA_NS_NAME}   namespace
+${OKA_NS_PROFILE}   app-profile
+
+# Cluster
+${CLUSTER_NAME}   gitops03
+${CLUSTER_DESCRIPTION}   "Cluster for gitops03 Robot test suite"
+${CLUSTER_VM_SIZE}   m1.large
+${CLUSTER_NODES}   1
+${REGION_NAME}   northeurope
+${RESOURCE_GROUP}   OSM-CTIO
+${KUBERNETES_VERSION}   "1.31.7"
+${CLUSTER_CONTROL_PLANE_VM_SIZE}   m1.large
+${CLUSTER_CONTROL_PLANE_NODES}   1
+${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}"}}'
+
+# KSUs
+${KSU_NS_NAME}   jenkins-ns
+${KSU1_NAME}   jenkins
+${KSU1_PARAMS}   ${CURDIR}/../resources/gitops-jenkins-params.yaml
+${KSU_NS_ID}   ${EMPTY}
+${KSU1_ID}   ${EMPTY}
+
+
+*** Test Cases ***
+Add OKA Packages For The Testsuite
+    [Documentation]   Add OKA packages for the testsuite.
+    [Tags]   oka   create
+    Add OKA Package   ${OKA_NS_NAME}   '${OKA_FOLDER}/${OKA_NS_PKG}'   ${OKA_NS_PROFILE}
+    Add OKA Package   ${OKA1_NAME}   '${OKA_FOLDER}/${OKA1_PKG}'   ${OKA1_PROFILE}
+
+Create Cluster For Testsuite in Openstack
+    [Documentation]   Create K8s cluster for the testsuite.
+    [Tags]   cluster   create
+    ${id}=   Create Cluster   ${CLUSTER_NAME}   %{VIM_TARGET}   ${CLUSTER_DESCRIPTION}   ${CLUSTER_VM_SIZE}   ${KUBERNETES_VERSION}   ${CLUSTER_NODES}   ${REGION_NAME}   ${RESOURCE_GROUP}   ${CLUSTER_CONFIG}
+    Set Suite Variable   ${CLUSTER_ID}   ${id}
+    Log   ${CLUSTER_ID}
+
+Get Cluster Kubeconfig
+    [Documentation]   Get Kubeconfig for the cluster.
+    [Tags]   cluster
+    ${rc}   ${stdout}=   Run And Return Rc And Output
+    ...    osm cluster-show ${CLUSTER_NAME} -o jsonpath='{.credentials}' | yq -y
+    Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
+    Log   ${stdout}
+
+Create KSU Namespace For All KSUs
+    [Documentation]   Create KSU based on ${OKA_NS_NAME} with params.
+    [Tags]   ksu   ksu-ns   create
+    ${id}=   Create KSU   ${KSU_NS_NAME}   ${KSU_NS_NAME}   ${CLUSTER_NAME}   app-profile   ${OKA_NS_NAME}   ${OKA_FOLDER}/apps/jenkins-ns-params.yaml
+    Set Suite Variable   ${KSU_NS_ID}   ${id}
+    Log   ${KSU_NS_ID}
+
+Create KSU1 With Params
+    [Documentation]   Create KSU based on ${OKA1_NAME} with params.
+    [Tags]   ksu   ksu1   create
+    ${id}=   Create KSU   ${KSU1_NAME}   ${KSU1_NAME}   ${CLUSTER_NAME}   app-profile   ${OKA1_NAME}   ${KSU1_PARAMS}
+    Set Suite Variable   ${KSU1_ID}   ${id}
+    Log   ${KSU1_ID}
+
+Delete KSU1
+    [Documentation]   Delete KSU1 based on ${OKA1_NAME}.
+    [Tags]   cleanup   ksu   ksu1
+    IF   '${KSU1_ID}' != ''
+       ${KSU_TO_BE_DELETED}=   Set Variable   ${KSU1_ID}
+    ELSE
+       ${KSU_TO_BE_DELETED}=   Set Variable   ${KSU1_NAME}
+    END
+    Delete KSU   ${KSU_TO_BE_DELETED}
+
+Delete KSU Namespace
+    [Documentation]   Delete KSU based on ${OKA_NS_NAME}.
+    [Tags]   cleanup   ksu   ksu-ns
+    IF   '${KSU_NS_ID}' != ''
+       ${KSU_TO_BE_DELETED}=   Set Variable   ${KSU_NS_ID}
+    ELSE
+       ${KSU_TO_BE_DELETED}=   Set Variable   ${KSU_NS_NAME}
+    END
+    Delete KSU   ${KSU_TO_BE_DELETED}
+
+Delete Cluster For Testsuite
+    [Documentation]   Delete K8s cluster for the testsuite.
+    [Tags]   cleanup   cluster
+    Delete Cluster   ${CLUSTER_NAME}
+
+Delete OKA Packages For The Testsuite
+    [Documentation]   Delete OKA packages for the testsuite.
+    [Tags]   cleanup   oka
+    Delete OKA Package   ${OKA_NS_NAME}
+    Delete OKA Package   ${OKA1_NAME}
+
+
+*** Keywords ***
+Suite Cleanup
+    [Documentation]   Test Suit Cleanup: Deleting cluster, KSUs, OKAs
+    Run Keyword If Any Tests Failed   Delete Cluster   ${CLUSTER_NAME}
+    Run Keyword If Any Tests Failed   Delete OKA Package   ${OKA_NS_NAME}
+    Run Keyword If Any Tests Failed   Delete OKA Package   ${OKA1_NAME}