| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 1 | # Copyright 2020 Canonical Ltd. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | *** Settings *** |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 16 | Documentation [K8s-01] Create K8s cluster. |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 17 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 18 | Library OperatingSystem |
| 19 | Library String |
| 20 | Library Collections |
| 21 | Library Process |
| 22 | Library SSHLibrary |
| 23 | Library %{ROBOT_DEVOPS_FOLDER}/lib/renderTemplate.py |
| 24 | |
| 25 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot |
| 26 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot |
| 27 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot |
| 28 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot |
| 29 | |
| garciadeblas | 0d264a6 | 2022-10-13 12:11:24 +0200 | [diff] [blame^] | 30 | Force Tags k8s_01 cluster_k8s |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 31 | |
| garciadeblas | d225e55 | 2020-10-02 16:10:14 +0000 | [diff] [blame] | 32 | Suite Teardown Run Keyword And Ignore Error Suite Cleanup |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 33 | |
| 34 | |
| 35 | *** Variables *** |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 36 | # NS and VNF descriptor package files |
| 37 | ${vnfd_pkg1} k8s_jujucontroller_vnf.tar.gz |
| 38 | ${vnfd_pkg2} k8s_jujumachine_vnf.tar.gz |
| 39 | ${nsd_pkg} k8s_juju_ns.tar.gz |
| 40 | ${vnfd_name1} k8s_jujucontroller_vnf |
| 41 | ${vnfd_name2} k8s_jujumachine_vnf |
| 42 | ${nsd_name} k8s_juju |
| 43 | |
| 44 | # VNF Member indexes |
| 45 | ${vnf_member_index_1} k8s_vnf1 |
| 46 | ${vnf_member_index_2} k8s_vnf2 |
| 47 | ${vnf_member_index_3} k8s_vnf3 |
| 48 | ${vnf_member_index_4} k8s_vnf4 |
| 49 | ${vnf_member_index_5} k8s_juju |
| 50 | |
| 51 | # Username |
| 52 | ${username} ubuntu |
| 53 | |
| 54 | # Kubeconfig file |
| 55 | ${kubeconfig_file} /home/ubuntu/.kube/config |
| 56 | |
| 57 | # NS instance name |
| 58 | ${ns_name} k8s-cluster |
| 59 | |
| 60 | # SSH keys and username to be used |
| 61 | ${publickey} %{HOME}/.ssh/id_rsa.pub |
| 62 | ${privatekey} %{HOME}/.ssh/id_rsa |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 63 | ${username} ubuntu |
| 64 | ${password} ${EMPTY} |
| 65 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 66 | # Template and config file to use |
| 67 | ${template} k8s_juju_template.yaml |
| 68 | ${config_file} config.yaml |
| 69 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 70 | |
| 71 | *** Test Cases *** |
| 72 | Render a template |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 73 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 74 | ${stdout}= Render template %{ROBOT_DEVOPS_FOLDER}/resources/${template} %{ROBOT_DEVOPS_FOLDER}/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} |
| 75 | Log To Console \n${stdout} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 76 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 77 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 78 | Create Controller VNF Descriptor |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 79 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 80 | Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg1}' |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 81 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 82 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 83 | Create Machines VNF Descriptor |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 84 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 85 | Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg2}' |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 86 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 87 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 88 | Create K8s Cluster NS Descriptor |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 89 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 90 | Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}' |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 91 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 92 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 93 | Instantiate K8s Cluster Network Service |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 94 | |
| garciadeblas | 61bbf92 | 2022-06-25 18:12:53 +0200 | [diff] [blame] | 95 | ${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} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 96 | Set Suite Variable ${ns_id} ${id} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 97 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 98 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 99 | Get Management Ip Addresses |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 100 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 101 | ${ip_addr_1} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_1} |
| 102 | log ${ip_addr_1} |
| 103 | Set Suite Variable ${vnf_1_ip_addr} ${ip_addr_1} |
| 104 | ${ip_addr_2} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_2} |
| 105 | log ${ip_addr_2} |
| 106 | Set Suite Variable ${vnf_2_ip_addr} ${ip_addr_2} |
| 107 | ${ip_addr_3} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_3} |
| 108 | log ${ip_addr_3} |
| 109 | Set Suite Variable ${vnf_3_ip_addr} ${ip_addr_3} |
| 110 | ${ip_addr_4} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_4} |
| 111 | log ${ip_addr_4} |
| 112 | Set Suite Variable ${vnf_4_ip_addr} ${ip_addr_4} |
| 113 | ${ip_addr_5} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_5} |
| 114 | log ${ip_addr_5} |
| 115 | Set Suite Variable ${vnf_5_ip_addr} ${ip_addr_5} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 116 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 117 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 118 | Test SSH Access |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 119 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 120 | Variable Should Exist ${vnf_1_ip_addr} msg=IP address of the management VNF '${vnf_member_index_1}' is not available |
| 121 | Variable Should Exist ${vnf_2_ip_addr} msg=IP address of the management VNF '${vnf_member_index_2}' is not available |
| 122 | Variable Should Exist ${vnf_3_ip_addr} msg=IP address of the management VNF '${vnf_member_index_3}' is not available |
| 123 | Variable Should Exist ${vnf_4_ip_addr} msg=IP address of the management VNF '${vnf_member_index_4}' is not available |
| 124 | Variable Should Exist ${vnf_5_ip_addr} msg=IP address of the management VNF '${vnf_member_index_5}' is not available |
| 125 | Sleep 30s Waiting ssh daemon to be up |
| 126 | Test SSH Connection ${vnf_1_ip_addr} ${username} ${password} ${privatekey} |
| 127 | Test SSH Connection ${vnf_2_ip_addr} ${username} ${password} ${privatekey} |
| 128 | Test SSH Connection ${vnf_3_ip_addr} ${username} ${password} ${privatekey} |
| 129 | Test SSH Connection ${vnf_4_ip_addr} ${username} ${password} ${privatekey} |
| 130 | Test SSH Connection ${vnf_5_ip_addr} ${username} ${password} ${privatekey} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 131 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 132 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 133 | Check kubeconfig file |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 134 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 135 | Check If remote File Exists ${vnf_5_ip_addr} ${username} ${password} ${privatekey} ${kubeconfig_file} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 136 | |
| almagia | b4697d3 | 2021-05-25 08:56:17 +0200 | [diff] [blame] | 137 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 138 | Delete NS Instance |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 139 | [Tags] cleanup |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 140 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 141 | Delete NS ${ns_name} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 142 | |
| 143 | |
| 144 | Delete NS Descriptor |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 145 | [Tags] cleanup |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 146 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 147 | Delete NSD ${nsd_name} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 148 | |
| 149 | |
| 150 | Delete Controller VNF Descriptor |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 151 | [Tags] cleanup |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 152 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 153 | Delete VNFD ${vnfd_name1} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 154 | |
| 155 | Delete Machines VNF Descriptor |
| garciadeblas | 4cf45d7 | 2021-04-08 13:52:22 +0200 | [diff] [blame] | 156 | [Tags] cleanup |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 157 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 158 | Delete VNFD ${vnfd_name2} |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 159 | |
| 160 | |
| 161 | *** Keywords *** |
| garciadeblas | d225e55 | 2020-10-02 16:10:14 +0000 | [diff] [blame] | 162 | Suite Cleanup |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 163 | [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 164 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 165 | Run Keyword If Any Tests Failed Delete NS ${ns_name} |
| 166 | Run Keyword If Any Tests Failed Delete NSD ${nsd_name} |
| 167 | Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name} |