2 # Copyright 2020 Canonical Ltd.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 Documentation [K8s-01] Create K8s cluster.
20 Library OperatingSystem
25 Library ../lib/renderTemplate.py
27 Resource ../lib/vnfd_lib.resource
28 Resource ../lib/nsd_lib.resource
29 Resource ../lib/ns_lib.resource
30 Resource ../lib/ssh_lib.resource
32 Test Tags k8s_01 cluster_k8s
34 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
38 # NS and VNF descriptor package files
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
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
54 ${KUBECONFIG_FILE} /home/ubuntu/.kube/config
57 ${NS_NAME} k8s-cluster
59 # SSH keys and username to be used
60 ${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub
61 ${PRIVATEKEY} %{HOME}/.ssh/id_rsa
65 # Template and config file to use
66 ${TEMPLATE} k8s_juju_template.yaml
67 ${CONFIG_FILE} config.yaml
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}
74 Log To Console \n${stdout}
76 Create Controller VNF Descriptor
77 [Documentation] Upload first VNF package for the testsuite.
78 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG1}'
80 Create Machines VNF Descriptor
81 [Documentation] Upload second VNF package for the testsuite.
82 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG2}'
84 Create K8s Cluster NS Descriptor
85 [Documentation] Upload NS package for the testsuite.
86 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
88 Instantiate K8s Cluster Network Service
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}
93 Get Management Ip Addresses
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}
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}
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}
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}
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}
109 Set Suite Variable ${VNF_5_IP_ADDR} ${ip_addr_5}
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
118 Sleep 30s Waiting ssh daemon to be up
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}
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}
130 [Documentation] Delete NS instance.
135 [Documentation] Delete NS package from OSM.
137 Delete NSD ${NSD_NAME}
139 Delete Controller VNF Descriptor
140 [Documentation] Delete first VNF package from OSM.
142 Delete VNFD ${VNFD_NAME1}
144 Delete Machines VNF Descriptor
145 [Documentation] Delete second VNF package from OSM.
147 Delete VNFD ${VNFD_NAME2}
152 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
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}