blob: b87a174fa04ce3ca8017be3ff8ec44995444e6ab [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
calvinosanc19b272c52020-07-03 17:28:12 +02002# 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
garciadeblas7a9e0312023-12-11 22:24:46 +010016
calvinosanc19b272c52020-07-03 17:28:12 +020017*** Settings ***
garciadeblasf4ebaa82022-06-23 13:33:26 +020018Documentation [K8s-01] Create K8s cluster.
garciadeblas4cf45d72021-04-08 13:52:22 +020019
calvinosanc19b272c52020-07-03 17:28:12 +020020Library OperatingSystem
21Library String
22Library Collections
23Library Process
24Library SSHLibrary
garciadeblas7a9e0312023-12-11 22:24:46 +010025Library ../lib/renderTemplate.py
calvinosanc19b272c52020-07-03 17:28:12 +020026
garciadeblas7a9e0312023-12-11 22:24:46 +010027Resource ../lib/vnfd_lib.resource
28Resource ../lib/nsd_lib.resource
29Resource ../lib/ns_lib.resource
30Resource ../lib/ssh_lib.resource
calvinosanc19b272c52020-07-03 17:28:12 +020031
garciadeblas7a9e0312023-12-11 22:24:46 +010032Test Tags k8s_01 cluster_k8s
garciadeblas4cf45d72021-04-08 13:52:22 +020033
garciadeblasd225e552020-10-02 16:10:14 +000034Suite Teardown Run Keyword And Ignore Error Suite Cleanup
calvinosanc19b272c52020-07-03 17:28:12 +020035
36
37*** Variables ***
almagiab4697d32021-05-25 08:56:17 +020038# NS and VNF descriptor package files
garciadeblas7a9e0312023-12-11 22:24:46 +010039${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
almagiab4697d32021-05-25 08:56:17 +020045
46# VNF Member indexes
garciadeblas7a9e0312023-12-11 22:24:46 +010047${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
almagiab4697d32021-05-25 08:56:17 +020052
53# Kubeconfig file
garciadeblas7a9e0312023-12-11 22:24:46 +010054${KUBECONFIG_FILE} /home/ubuntu/.kube/config
almagiab4697d32021-05-25 08:56:17 +020055
56# NS instance name
garciadeblas7a9e0312023-12-11 22:24:46 +010057${NS_NAME} k8s-cluster
almagiab4697d32021-05-25 08:56:17 +020058
59# SSH keys and username to be used
garciadeblas7a9e0312023-12-11 22:24:46 +010060${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub
61${PRIVATEKEY} %{HOME}/.ssh/id_rsa
62${USERNAME} ubuntu
63${PASSWORD} ${EMPTY}
calvinosanc19b272c52020-07-03 17:28:12 +020064
almagiab4697d32021-05-25 08:56:17 +020065# Template and config file to use
garciadeblas7a9e0312023-12-11 22:24:46 +010066${TEMPLATE} k8s_juju_template.yaml
67${CONFIG_FILE} config.yaml
almagiab4697d32021-05-25 08:56:17 +020068
calvinosanc19b272c52020-07-03 17:28:12 +020069
70*** Test Cases ***
71Render a template
garciadeblas7a9e0312023-12-11 22:24:46 +010072 [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}
garciadeblasf4ebaa82022-06-23 13:33:26 +020074 Log To Console \n${stdout}
calvinosanc19b272c52020-07-03 17:28:12 +020075
76Create Controller VNF Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +010077 [Documentation] Upload first VNF package for the testsuite.
78 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG1}'
almagiab4697d32021-05-25 08:56:17 +020079
calvinosanc19b272c52020-07-03 17:28:12 +020080Create Machines VNF Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +010081 [Documentation] Upload second VNF package for the testsuite.
82 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG2}'
almagiab4697d32021-05-25 08:56:17 +020083
calvinosanc19b272c52020-07-03 17:28:12 +020084Create K8s Cluster NS Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +010085 [Documentation] Upload NS package for the testsuite.
86 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
almagiab4697d32021-05-25 08:56:17 +020087
calvinosanc19b272c52020-07-03 17:28:12 +020088Instantiate K8s Cluster Network Service
garciadeblas7a9e0312023-12-11 22:24:46 +010089 [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}
almagiab4697d32021-05-25 08:56:17 +020092
calvinosanc19b272c52020-07-03 17:28:12 +020093Get Management Ip Addresses
garciadeblas7a9e0312023-12-11 22:24:46 +010094 [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}
garciadeblas321726f2022-12-21 11:43:06 +010096 Log ${ip_addr_1}
garciadeblas7a9e0312023-12-11 22:24:46 +010097 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}
garciadeblas321726f2022-12-21 11:43:06 +010099 Log ${ip_addr_2}
garciadeblas7a9e0312023-12-11 22:24:46 +0100100 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}
garciadeblas321726f2022-12-21 11:43:06 +0100102 Log ${ip_addr_3}
garciadeblas7a9e0312023-12-11 22:24:46 +0100103 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}
garciadeblas321726f2022-12-21 11:43:06 +0100105 Log ${ip_addr_4}
garciadeblas7a9e0312023-12-11 22:24:46 +0100106 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}
garciadeblas321726f2022-12-21 11:43:06 +0100108 Log ${ip_addr_5}
garciadeblas7a9e0312023-12-11 22:24:46 +0100109 Set Suite Variable ${VNF_5_IP_ADDR} ${ip_addr_5}
almagiab4697d32021-05-25 08:56:17 +0200110
calvinosanc19b272c52020-07-03 17:28:12 +0200111Test SSH Access
garciadeblas7a9e0312023-12-11 22:24:46 +0100112 [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
garciadeblas23ff8f92023-12-11 16:26:40 +0100118 Sleep 30s Waiting ssh daemon to be up
garciadeblas7a9e0312023-12-11 22:24:46 +0100119 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}
garciadeblas23ff8f92023-12-11 16:26:40 +0100124
garciadeblas7a9e0312023-12-11 22:24:46 +0100125Check 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}
almagiab4697d32021-05-25 08:56:17 +0200128
calvinosanc19b272c52020-07-03 17:28:12 +0200129Delete NS Instance
garciadeblas7a9e0312023-12-11 22:24:46 +0100130 [Documentation] Delete NS instance.
garciadeblas4cf45d72021-04-08 13:52:22 +0200131 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100132 Delete NS ${NS_NAME}
calvinosanc19b272c52020-07-03 17:28:12 +0200133
134Delete NS Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +0100135 [Documentation] Delete NS package from OSM.
garciadeblas4cf45d72021-04-08 13:52:22 +0200136 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100137 Delete NSD ${NSD_NAME}
calvinosanc19b272c52020-07-03 17:28:12 +0200138
139Delete Controller VNF Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +0100140 [Documentation] Delete first VNF package from OSM.
garciadeblas4cf45d72021-04-08 13:52:22 +0200141 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100142 Delete VNFD ${VNFD_NAME1}
calvinosanc19b272c52020-07-03 17:28:12 +0200143
144Delete Machines VNF Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +0100145 [Documentation] Delete second VNF package from OSM.
garciadeblas4cf45d72021-04-08 13:52:22 +0200146 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100147 Delete VNFD ${VNFD_NAME2}
calvinosanc19b272c52020-07-03 17:28:12 +0200148
149
150*** Keywords ***
garciadeblasd225e552020-10-02 16:10:14 +0000151Suite Cleanup
garciadeblasf4ebaa82022-06-23 13:33:26 +0200152 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
garciadeblas7a9e0312023-12-11 22:24:46 +0100153 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}