| garciadeblas | ec15323 | 2025-08-01 10:13:03 +0200 | [diff] [blame] | 1 | *** 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 *** |
| 16 | Documentation [GITOPS-04] Cluster creation in Openshift via ACM |
| 17 | |
| 18 | Library OperatingSystem |
| 19 | Library String |
| 20 | Library Collections |
| 21 | Library Process |
| 22 | |
| 23 | Resource ../lib/advanced_cluster_mgmt_lib.resource |
| 24 | Resource ../lib/vim_lib.resource |
| 25 | |
| 26 | Test Tags gitops_04 cluster_gitops |
| 27 | |
| 28 | Suite Teardown Run Keyword And Ignore Error Suite Cleanup |
| 29 | |
| 30 | |
| 31 | *** Variables *** |
| 32 | # OKA packages |
| 33 | ${OKA_FOLDER} '%{PACKAGES_FOLDER}/oka' |
| 34 | ${OKA1_PKG} apps/jenkins |
| 35 | ${OKA1_NAME} jenkins |
| 36 | ${OKA1_PROFILE} app-profile |
| 37 | ${OKA_NS_PKG} apps/namespace |
| 38 | ${OKA_NS_NAME} namespace |
| 39 | ${OKA_NS_PROFILE} app-profile |
| 40 | |
| 41 | # VIM and Clusters |
| 42 | ${VIM_NAME} gitops04vim |
| 43 | ${ACM_CLUSTER_NAME} acm-gitops04 |
| 44 | ${ACM_CLUSTER_DESCRIPTION} "ACM Cluster for gitops04 Robot test suite" |
| 45 | ${CLUSTER_NAME} gitops04 |
| 46 | ${CLUSTER_DESCRIPTION} "Cluster for gitops04 Robot test suite" |
| 47 | ${CLUSTER_VM_SIZE} m1.large |
| 48 | ${CLUSTER_NODES} 1 |
| 49 | ${REGION_NAME} northeurope |
| 50 | ${RESOURCE_GROUP} OSM-CTIO |
| 51 | ${KUBERNETES_VERSION} "1.31.7" |
| 52 | ${OPENSHIFT_RELEASE} "4.18.13-multi" |
| 53 | ${CLUSTER_CONFIG} --config '{"openshift": {"openshift-release": ${OPENSHIFT_RELEASE}, "worker-cores": "8", "workder-memory": "16", "worker-disk": "100", "storage-class": "ocs-storagecluster-ceph-rbd", "base-domain": "base.domain.com", "acm-cluster": ${ACM_CLUSTER_NAME}, "hosted-clusters-project": "clusters"}}' |
| 54 | |
| 55 | # KSUs |
| 56 | ${KSU_NS_NAME} jenkins-ns |
| 57 | ${KSU1_NAME} jenkins |
| 58 | ${KSU1_PARAMS} ${CURDIR}/../resources/gitops-jenkins-params.yaml |
| 59 | ${KSU_NS_ID} ${EMPTY} |
| 60 | ${KSU1_ID} ${EMPTY} |
| 61 | |
| 62 | |
| 63 | *** Test Cases *** |
| 64 | Create Dummy VIM For The Testsuite |
| 65 | [Documentation] Create dummy VIM for the testsuite. |
| 66 | [Tags] vim acm-cluster create |
| 67 | ${vim_id}= Create VIM Target ${VIM_NAME} u p http://localhost/dummy t dummy |
| 68 | Set Suite Variable ${VIM_ID} ${vim_id} |
| 69 | |
| 70 | Add OKA Packages For The Testsuite |
| 71 | [Documentation] Add OKA packages for the testsuite. |
| 72 | [Tags] oka create |
| 73 | Add OKA Package ${OKA_NS_NAME} '${OKA_FOLDER}/${OKA_NS_PKG}' ${OKA_NS_PROFILE} |
| 74 | Add OKA Package ${OKA1_NAME} '${OKA_FOLDER}/${OKA1_PKG}' ${OKA1_PROFILE} |
| 75 | |
| 76 | Register ACM Cluster For Testsuite |
| 77 | [Documentation] Register ACM K8s cluster for the testsuite. |
| 78 | [Tags] acm-cluster create |
| 79 | ${id}= Register Cluster ${ACM_CLUSTER_NAME} ${VIM_NAME} %{ACM_CLUSTER_KUBECONFIG_CREDENTIALS} ${ACM_CLUSTER_DESCRIPTION} |
| 80 | Set Suite Variable ${ACM_CLUSTER_ID} ${id} |
| 81 | Log ${ACM_CLUSTER_ID} |
| 82 | |
| 83 | Get Cluster Kubeconfig |
| 84 | [Documentation] Get Kubeconfig for the ACM cluster. |
| 85 | [Tags] acm-cluster |
| 86 | ${rc} ${stdout}= Run And Return Rc And Output |
| 87 | ... osm cluster-show ${ACM_CLUSTER_NAME} -o jsonpath='{.credentials}' | yq -y |
| 88 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 89 | Log ${stdout} |
| 90 | |
| 91 | Create Openshift Cluster |
| 92 | [Documentation] Create Openshift K8s cluster for the testsuite. |
| 93 | [Tags] cluster create |
| 94 | ${id}= Create Cluster ${CLUSTER_NAME} ${VIM_NAME} ${CLUSTER_DESCRIPTION} ${CLUSTER_VM_SIZE} ${KUBERNETES_VERSION} ${CLUSTER_NODES} ${REGION_NAME} ${RESOURCE_GROUP} ${CLUSTER_CONFIG} |
| 95 | Set Suite Variable ${CLUSTER_ID} ${id} |
| 96 | Log ${CLUSTER_ID} |
| 97 | |
| 98 | Get Openshift Cluster Kubeconfig |
| 99 | [Documentation] Get Kubeconfig for the Openshift cluster. |
| 100 | [Tags] cluster |
| 101 | ${rc} ${stdout}= Run And Return Rc And Output |
| 102 | ... osm cluster-show ${CLUSTER_NAME} -o jsonpath='{.credentials}' | yq -y |
| 103 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 104 | Log ${stdout} |
| 105 | |
| 106 | Create KSU Namespace For All KSUs |
| 107 | [Documentation] Create KSU based on ${OKA_NS_NAME} with params. |
| 108 | [Tags] ksu ksu-ns create |
| 109 | ${id}= Create KSU ${KSU_NS_NAME} ${KSU_NS_NAME} ${CLUSTER_NAME} app-profile ${OKA_NS_NAME} ${OKA_FOLDER}/apps/jenkins-ns-params.yaml |
| 110 | Set Suite Variable ${KSU_NS_ID} ${id} |
| 111 | Log ${KSU_NS_ID} |
| 112 | |
| 113 | Create KSU1 With Params |
| 114 | [Documentation] Create KSU based on ${OKA1_NAME} with params. |
| 115 | [Tags] ksu ksu1 create |
| 116 | ${id}= Create KSU ${KSU1_NAME} ${KSU1_NAME} ${CLUSTER_NAME} app-profile ${OKA1_NAME} ${KSU1_PARAMS} |
| 117 | Set Suite Variable ${KSU1_ID} ${id} |
| 118 | Log ${KSU1_ID} |
| 119 | |
| 120 | Delete KSU1 |
| 121 | [Documentation] Delete KSU1 based on ${OKA1_NAME}. |
| 122 | [Tags] cleanup ksu ksu1 |
| 123 | IF '${KSU1_ID}' != '' |
| 124 | ${KSU_TO_BE_DELETED}= Set Variable ${KSU1_ID} |
| 125 | ELSE |
| 126 | ${KSU_TO_BE_DELETED}= Set Variable ${KSU1_NAME} |
| 127 | END |
| 128 | Delete KSU ${KSU_TO_BE_DELETED} |
| 129 | |
| 130 | Delete KSU Namespace |
| 131 | [Documentation] Delete KSU based on ${OKA_NS_NAME}. |
| 132 | [Tags] cleanup ksu ksu-ns |
| 133 | IF '${KSU_NS_ID}' != '' |
| 134 | ${KSU_TO_BE_DELETED}= Set Variable ${KSU_NS_ID} |
| 135 | ELSE |
| 136 | ${KSU_TO_BE_DELETED}= Set Variable ${KSU_NS_NAME} |
| 137 | END |
| 138 | Delete KSU ${KSU_TO_BE_DELETED} |
| 139 | |
| 140 | Delete Cluster For Testsuite |
| 141 | [Documentation] Delete K8s cluster for the testsuite. |
| 142 | [Tags] cleanup cluster |
| 143 | Delete Cluster ${CLUSTER_NAME} |
| 144 | |
| 145 | Deregister ACM Cluster For Testsuite |
| 146 | [Documentation] Deregister ACM K8s cluster for the testsuite. |
| 147 | [Tags] cleanup acm-cluster |
| 148 | Deregister Cluster ${ACM_CLUSTER_NAME} |
| 149 | |
| 150 | Delete Dummy VIM For The Testsuite |
| 151 | [Documentation] Delete dummy VIM for the testsuite. |
| 152 | [Tags] vim acm-cluster cleanup |
| 153 | Delete VIM Target ${VIM_NAME} |
| 154 | |
| 155 | Delete OKA Packages For The Testsuite |
| 156 | [Documentation] Delete OKA packages for the testsuite. |
| 157 | [Tags] cleanup oka |
| 158 | Delete OKA Package ${OKA_NS_NAME} |
| 159 | Delete OKA Package ${OKA1_NAME} |
| 160 | |
| 161 | |
| 162 | *** Keywords *** |
| 163 | Suite Cleanup |
| 164 | [Documentation] Test Suit Cleanup: Deleting cluster, KSUs, OKAs |
| 165 | Run Keyword If Any Tests Failed Delete Cluster ${CLUSTER_NAME} |
| 166 | Run Keyword If Any Tests Failed Deregister Cluster ${ACM_CLUSTER_NAME} |
| 167 | Run Keyword If Any Tests Failed Delete VIM Target ${VIM_NAME} |
| 168 | Run Keyword If Any Tests Failed Delete OKA Package ${OKA_NS_NAME} |
| 169 | Run Keyword If Any Tests Failed Delete OKA Package ${OKA1_NAME} |