| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 1 | *** Comments *** |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 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 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 16 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 17 | *** Settings *** |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 18 | Documentation [K8s-01] Create K8s cluster. |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 19 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 20 | Library OperatingSystem |
| 21 | Library String |
| 22 | Library Collections |
| 23 | Library Process |
| 24 | Library SSHLibrary |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 25 | Library ../lib/renderTemplate.py |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 26 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 27 | Resource ../lib/vnfd_lib.resource |
| 28 | Resource ../lib/nsd_lib.resource |
| 29 | Resource ../lib/ns_lib.resource |
| 30 | Resource ../lib/ssh_lib.resource |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 31 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 32 | Test Tags k8s_01 cluster_k8s |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 33 | |
| garciadeblas | d225e55 | 2020-10-02 16:10:14 +0000 | [diff] [blame] | 34 | Suite Teardown Run Keyword And Ignore Error Suite Cleanup |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 35 | |
| 36 | |
| 37 | *** Variables *** |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 38 | # NS and VNF descriptor package files |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 39 | ${VNFD_PKG1} k8s_jujucontroller_vnf.tar.gz |
| 40 | ${VNFD_PKG2} k8s_jujumachine_vnf.tar.gz |
| 41 | ${NSD_PKG} k8s_juju_ns.tar.gz |
| 42 | ${VNFD_NAME1} k8s_jujucontroller_vnf |
| 43 | ${VNFD_NAME2} k8s_jujumachine_vnf |
| 44 | ${NSD_NAME} k8s_juju |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 45 | |
| 46 | # VNF Member indexes |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 47 | ${VNF_MEMBER_INDEX_1} k8s_vnf1 |
| 48 | ${VNF_MEMBER_INDEX_2} k8s_vnf2 |
| 49 | ${VNF_MEMBER_INDEX_3} k8s_vnf3 |
| 50 | ${VNF_MEMBER_INDEX_4} k8s_vnf4 |
| 51 | ${VNF_MEMBER_INDEX_5} k8s_juju |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 52 | |
| 53 | # Kubeconfig file |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 54 | ${KUBECONFIG_FILE} /home/ubuntu/.kube/config |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 55 | |
| 56 | # NS instance name |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 57 | ${NS_NAME} k8s-cluster |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 58 | |
| 59 | # SSH keys and username to be used |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 60 | ${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub |
| 61 | ${PRIVATEKEY} %{HOME}/.ssh/id_rsa |
| 62 | ${USERNAME} ubuntu |
| 63 | ${PASSWORD} ${EMPTY} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 64 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 65 | # Template and config file to use |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 66 | ${TEMPLATE} k8s_juju_template.yaml |
| 67 | ${CONFIG_FILE} config.yaml |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 68 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 69 | |
| 70 | *** Test Cases *** |
| 71 | Render a template |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 72 | [Documentation] Generate from a template the instantiation parameters that will be used for the NS instance. |
| 73 | ${stdout}= Render Template ../resources/${TEMPLATE} ../resources/${CONFIG_FILE} IP_VM1=%{IP_VM1} IP_VM2=%{IP_VM2} IP_VM3=%{IP_VM3} IP_VM4=%{IP_VM4} IP_JUJU=%{IP_JUJU} NETWORK=%{VIM_MGMT_NET} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 74 | Log To Console \n${stdout} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 75 | |
| 76 | Create Controller VNF Descriptor |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 77 | [Documentation] Upload first VNF package for the testsuite. |
| 78 | Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG1}' |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 79 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 80 | Create Machines VNF Descriptor |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 81 | [Documentation] Upload second VNF package for the testsuite. |
| 82 | Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG2}' |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 83 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 84 | Create K8s Cluster NS Descriptor |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 85 | [Documentation] Upload NS package for the testsuite. |
| 86 | Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}' |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 87 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 88 | Instantiate K8s Cluster Network Service |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 89 | [Documentation] Instantiate NS for the testsuite. |
| 90 | ${id}= Create Network Service ${NSD_NAME} %{VIM_TARGET} ${NS_NAME} ns_config=${EMPTY} publickey=${PUBLICKEY} ns_launch_max_wait_time=70min config_file=%{ROBOT_DEVOPS_FOLDER}/resources/${CONFIG_FILE} |
| 91 | Set Suite Variable ${NS_ID} ${id} |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 92 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 93 | Get Management Ip Addresses |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 94 | [Documentation] Get the mgmt IP addresses of the five VNF of the NS. |
| 95 | ${ip_addr_1}= Get Vnf Management Ip Address ${NS_ID} ${VNF_MEMBER_INDEX_1} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 96 | Log ${ip_addr_1} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 97 | Set Suite Variable ${VNF_1_IP_ADDR} ${ip_addr_1} |
| 98 | ${ip_addr_2}= Get Vnf Management Ip Address ${NS_ID} ${VNF_MEMBER_INDEX_2} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 99 | Log ${ip_addr_2} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 100 | Set Suite Variable ${VNF_2_IP_ADDR} ${ip_addr_2} |
| 101 | ${ip_addr_3}= Get Vnf Management Ip Address ${NS_ID} ${VNF_MEMBER_INDEX_3} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 102 | Log ${ip_addr_3} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 103 | Set Suite Variable ${VNF_3_IP_ADDR} ${ip_addr_3} |
| 104 | ${ip_addr_4}= Get Vnf Management Ip Address ${NS_ID} ${VNF_MEMBER_INDEX_4} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 105 | Log ${ip_addr_4} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 106 | Set Suite Variable ${VNF_4_IP_ADDR} ${ip_addr_4} |
| 107 | ${ip_addr_5}= Get Vnf Management Ip Address ${NS_ID} ${VNF_MEMBER_INDEX_5} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 108 | Log ${ip_addr_5} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 109 | Set Suite Variable ${VNF_5_IP_ADDR} ${ip_addr_5} |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 110 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 111 | Test SSH Access |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 112 | [Documentation] Check that the five VNF are accessible via SSH in their respective mgmt IP address. |
| 113 | Variable Should Exist ${VNF_1_IP_ADDR} msg=IP address of the management VNF '${VNF_MEMBER_INDEX_1}' is not available |
| 114 | Variable Should Exist ${VNF_2_IP_ADDR} msg=IP address of the management VNF '${VNF_MEMBER_INDEX_2}' is not available |
| 115 | Variable Should Exist ${VNF_3_IP_ADDR} msg=IP address of the management VNF '${VNF_MEMBER_INDEX_3}' is not available |
| 116 | Variable Should Exist ${VNF_4_IP_ADDR} msg=IP address of the management VNF '${VNF_MEMBER_INDEX_4}' is not available |
| 117 | Variable Should Exist ${VNF_5_IP_ADDR} msg=IP address of the management VNF '${VNF_MEMBER_INDEX_5}' is not available |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame] | 118 | Sleep 30s Waiting ssh daemon to be up |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 119 | Test SSH Connection ${VNF_1_IP_ADDR} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} |
| 120 | Test SSH Connection ${VNF_2_IP_ADDR} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} |
| 121 | Test SSH Connection ${VNF_3_IP_ADDR} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} |
| 122 | Test SSH Connection ${VNF_4_IP_ADDR} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} |
| 123 | Test SSH Connection ${VNF_5_IP_ADDR} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame] | 124 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 125 | Check Kubeconfig File |
| 126 | [Documentation] Check that the Kubeconfig file of the provisioned cluster is present in the VNF. |
| 127 | Check If Remote File Exists ${VNF_5_IP_ADDR} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} ${KUBECONFIG_FILE} |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 128 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 129 | Delete NS Instance |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 130 | [Documentation] Delete NS instance. |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 131 | [Tags] cleanup |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 132 | Delete NS ${NS_NAME} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 133 | |
| 134 | Delete NS Descriptor |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 135 | [Documentation] Delete NS package from OSM. |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 136 | [Tags] cleanup |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 137 | Delete NSD ${NSD_NAME} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 138 | |
| 139 | Delete Controller VNF Descriptor |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 140 | [Documentation] Delete first VNF package from OSM. |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 141 | [Tags] cleanup |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 142 | Delete VNFD ${VNFD_NAME1} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 143 | |
| 144 | Delete Machines VNF Descriptor |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 145 | [Documentation] Delete second VNF package from OSM. |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 146 | [Tags] cleanup |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 147 | Delete VNFD ${VNFD_NAME2} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 148 | |
| 149 | |
| 150 | *** Keywords *** |
| garciadeblas | d225e55 | 2020-10-02 16:10:14 +0000 | [diff] [blame] | 151 | Suite Cleanup |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 152 | [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame^] | 153 | Run Keyword If Any Tests Failed Delete NS ${NS_NAME} |
| 154 | Run Keyword If Any Tests Failed Delete NSD ${NSD_NAME} |
| 155 | Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME1} |
| 156 | Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME2} |