1 # Copyright 2020 Canonical Ltd.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 Documentation [K8s-01] Create K8s cluster.
18 Library OperatingSystem
23 Library %{ROBOT_DEVOPS_FOLDER}/lib/renderTemplate.py
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
30 Force Tags k8s_01 cluster_k8s
32 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
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
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
55 ${kubeconfig_file} /home/ubuntu/.kube/config
58 ${ns_name} k8s-cluster
60 # SSH keys and username to be used
61 ${publickey} %{HOME}/.ssh/id_rsa.pub
62 ${privatekey} %{HOME}/.ssh/id_rsa
66 # Template and config file to use
67 ${template} k8s_juju_template.yaml
68 ${config_file} config.yaml
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}
78 Create Controller VNF Descriptor
80 Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg1}'
83 Create Machines VNF Descriptor
85 Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg2}'
88 Create K8s Cluster NS Descriptor
90 Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
93 Instantiate K8s Cluster Network Service
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}
96 Set Suite Variable ${ns_id} ${id}
99 Get Management Ip Addresses
101 ${ip_addr_1} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_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}
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}
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}
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}
115 Set Suite Variable ${vnf_5_ip_addr} ${ip_addr_5}
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}
133 Check kubeconfig file
135 Check If remote File Exists ${vnf_5_ip_addr} ${username} ${password} ${privatekey} ${kubeconfig_file}
147 Delete NSD ${nsd_name}
150 Delete Controller VNF Descriptor
153 Delete VNFD ${vnfd_name1}
155 Delete Machines VNF Descriptor
158 Delete VNFD ${vnfd_name2}
163 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
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}