blob: 6733c6ce4a17f75b604bdd7d6146776a0647d67f [file] [log] [blame]
calvinosanc19b272c52020-07-03 17:28:12 +02001# 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 ***
garciadeblas4cf45d72021-04-08 13:52:22 +020016Documentation [K8s-01] Create K8s cluster.
17
calvinosanc19b272c52020-07-03 17:28:12 +020018Library OperatingSystem
19Library String
20Library Collections
21Library Process
22Library SSHLibrary
23Library %{ROBOT_DEVOPS_FOLDER}/lib/renderTemplate.py
24
25Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
26Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
27Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
28Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
29
garciadeblas8a4366f2021-04-15 15:27:40 +020030Force Tags k8s_01 cluster_k8s regression
garciadeblas4cf45d72021-04-08 13:52:22 +020031
garciadeblasd225e552020-10-02 16:10:14 +000032Suite Teardown Run Keyword And Ignore Error Suite Cleanup
calvinosanc19b272c52020-07-03 17:28:12 +020033
34
35*** Variables ***
almagiab4697d32021-05-25 08:56:17 +020036# 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
calvinosanc19b272c52020-07-03 17:28:12 +020063${username} ubuntu
64${password} ${EMPTY}
65
almagiab4697d32021-05-25 08:56:17 +020066# Template and config file to use
67${template} k8s_juju_template.yaml
68${config_file} config.yaml
69
calvinosanc19b272c52020-07-03 17:28:12 +020070
71*** Test Cases ***
72Render a template
calvinosanc19b272c52020-07-03 17:28:12 +020073
almagiab4697d32021-05-25 08:56:17 +020074 ${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}
calvinosanc19b272c52020-07-03 17:28:12 +020075 Log To Console \n${stdout}
76
almagiab4697d32021-05-25 08:56:17 +020077
calvinosanc19b272c52020-07-03 17:28:12 +020078Create Controller VNF Descriptor
calvinosanc19b272c52020-07-03 17:28:12 +020079
80 Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg1}'
81
almagiab4697d32021-05-25 08:56:17 +020082
calvinosanc19b272c52020-07-03 17:28:12 +020083Create Machines VNF Descriptor
calvinosanc19b272c52020-07-03 17:28:12 +020084
85 Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg2}'
86
almagiab4697d32021-05-25 08:56:17 +020087
calvinosanc19b272c52020-07-03 17:28:12 +020088Create K8s Cluster NS Descriptor
calvinosanc19b272c52020-07-03 17:28:12 +020089
90 Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
91
almagiab4697d32021-05-25 08:56:17 +020092
calvinosanc19b272c52020-07-03 17:28:12 +020093Instantiate K8s Cluster Network Service
calvinosanc19b272c52020-07-03 17:28:12 +020094
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}
97
almagiab4697d32021-05-25 08:56:17 +020098
calvinosanc19b272c52020-07-03 17:28:12 +020099Get Management Ip Addresses
calvinosanc19b272c52020-07-03 17:28:12 +0200100
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}
116
almagiab4697d32021-05-25 08:56:17 +0200117
calvinosanc19b272c52020-07-03 17:28:12 +0200118Test SSH Access
calvinosanc19b272c52020-07-03 17:28:12 +0200119
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}
131
almagiab4697d32021-05-25 08:56:17 +0200132
calvinosanc19b272c52020-07-03 17:28:12 +0200133Check kubeconfig file
calvinosanc19b272c52020-07-03 17:28:12 +0200134
135 Check If remote File Exists ${vnf_5_ip_addr} ${username} ${password} ${privatekey} ${kubeconfig_file}
136
almagiab4697d32021-05-25 08:56:17 +0200137
calvinosanc19b272c52020-07-03 17:28:12 +0200138Delete NS Instance
garciadeblas4cf45d72021-04-08 13:52:22 +0200139 [Tags] cleanup
calvinosanc19b272c52020-07-03 17:28:12 +0200140
141 Delete NS ${ns_name}
142
143
144Delete NS Descriptor
garciadeblas4cf45d72021-04-08 13:52:22 +0200145 [Tags] cleanup
calvinosanc19b272c52020-07-03 17:28:12 +0200146
147 Delete NSD ${nsd_name}
148
149
150Delete Controller VNF Descriptor
garciadeblas4cf45d72021-04-08 13:52:22 +0200151 [Tags] cleanup
calvinosanc19b272c52020-07-03 17:28:12 +0200152
153 Delete VNFD ${vnfd_name1}
154
155Delete Machines VNF Descriptor
garciadeblas4cf45d72021-04-08 13:52:22 +0200156 [Tags] cleanup
calvinosanc19b272c52020-07-03 17:28:12 +0200157
158 Delete VNFD ${vnfd_name2}
159
160
161*** Keywords ***
garciadeblasd225e552020-10-02 16:10:14 +0000162Suite Cleanup
calvinosanc19b272c52020-07-03 17:28:12 +0200163 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
164
garciadeblasd225e552020-10-02 16:10:14 +0000165 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}