blob: 048e7adfc8542d2c4e0843fec2bdaf24f94a0ecd [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
garciadeblasf4ebaa82022-06-23 13:33:26 +02002# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
garciadeblas7a9e0312023-12-11 22:24:46 +010014
garciadeblasf4ebaa82022-06-23 13:33:26 +020015*** Settings ***
16Documentation [HEAL-04] Autohealing of NS
garciadeblasb731aac2022-06-25 18:29:22 +020017
garciadeblasf4ebaa82022-06-23 13:33:26 +020018Library OperatingSystem
19Library String
20Library Collections
21Library Process
22Library SSHLibrary
garciadeblasb731aac2022-06-25 18:29:22 +020023
garciadeblas7a9e0312023-12-11 22:24:46 +010024Resource ../lib/vnfd_lib.resource
25Resource ../lib/vnf_lib.resource
26Resource ../lib/nsd_lib.resource
27Resource ../lib/ns_lib.resource
28Resource ../lib/ns_operation_lib.resource
29Resource ../lib/ssh_lib.resource
30Resource ../lib/openstack_lib.resource
garciadeblasf4ebaa82022-06-23 13:33:26 +020031
garciadeblas166c8912023-12-16 10:51:48 +010032Test Tags heal_04 cluster_heal daily regression
garciadeblasb731aac2022-06-25 18:29:22 +020033
34Suite Teardown Run Keyword And Ignore Error Suite Cleanup
35
36
garciadeblasf4ebaa82022-06-23 13:33:26 +020037*** Variables ***
38# NS and VNF descriptor package folder and ids
garciadeblas7a9e0312023-12-11 22:24:46 +010039${VNFD_PKG} autoheal_vnf
40${VNFD_NAME} autoheal_vnfd
41${VDU_NAME} autoheal_vnfd-VM
42${VNF_INDEX} autoheal-basic-1
43${NSD_PKG} autoheal_ns
44${NSD_NAME} autoheal_nsd
garciadeblasf4ebaa82022-06-23 13:33:26 +020045# NS instance name and configuration
garciadeblas7a9e0312023-12-11 22:24:46 +010046${NS_NAME} heal_04
47${NS_CONFIG} {vld: [ {name: mgmt, vim-network-name: %{VIM_MGMT_NET}} ] }
garciadeblasf4ebaa82022-06-23 13:33:26 +020048
49# SSH keys and username to be used
garciadeblas7a9e0312023-12-11 22:24:46 +010050${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub
51${PRIVATEKEY} %{HOME}/.ssh/id_rsa
52${USERNAME} ubuntu
53${PASSWORD} ${EMPTY}
garciadeblasf4ebaa82022-06-23 13:33:26 +020054
garciadeblas7a9e0312023-12-11 22:24:46 +010055${SUCCESS_RETURN_CODE} 0
garciadeblasf4ebaa82022-06-23 13:33:26 +020056
garciadeblas7a9e0312023-12-11 22:24:46 +010057# Healing wait time
58${HEALING_POL_TIME} 15sec
59${HEALING_MAX_WAIT_TIME} 10m
garciadeblasf4ebaa82022-06-23 13:33:26 +020060
garciadeblas7a9e0312023-12-11 22:24:46 +010061@{VIM_VDUS} @{EMPTY}
aguilardbd91f862022-12-20 15:13:02 +000062
63
garciadeblasf4ebaa82022-06-23 13:33:26 +020064*** Test Cases ***
65Create VNF Descriptors
garciadeblas7a9e0312023-12-11 22:24:46 +010066 [Documentation] Upload VNF package for the testsuite.
67 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG}'
garciadeblasf4ebaa82022-06-23 13:33:26 +020068
69Create NS Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +010070 [Documentation] Upload NS package for the testsuite.
71 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
garciadeblasf4ebaa82022-06-23 13:33:26 +020072
73Network Service Instance Test
garciadeblas7a9e0312023-12-11 22:24:46 +010074 [Documentation] Instantiate NS for the testsuite.
75 ${id}= Create Network Service ${NSD_NAME} %{VIM_TARGET} ${NS_NAME} ${NS_CONFIG} ${PUBLICKEY}
76 Set Suite Variable ${NS_ID} ${id}
garciadeblasf4ebaa82022-06-23 13:33:26 +020077
78Get NS Id
garciadeblas7a9e0312023-12-11 22:24:46 +010079 [Documentation] Get NS identifier and stores as suite variable to be used later on.
garciadeblasf4ebaa82022-06-23 13:33:26 +020080 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +010081 ${variables}= Get Variables
garciadeblas23ff8f92023-12-11 16:26:40 +010082 IF not "\${ns_id}" in "${variables}"
garciadeblas7a9e0312023-12-11 22:24:46 +010083 ${id}= Get Ns Id ${NS_NAME}
84 Set Suite Variable ${NS_ID} ${id}
garciadeblasf4ebaa82022-06-23 13:33:26 +020085 END
86
aguilardbd91f862022-12-20 15:13:02 +000087Get VIM Objects
garciadeblas7a9e0312023-12-11 22:24:46 +010088 [Documentation] Retrieve all VMs and volumes from the NS and stores them in VIM_VDUS and VIM_VOLUMES lists.
89 Variable Should Exist ${NS_ID} msg=NS is not available
90 @{vnf_id_list}= Get Ns Vnf List ${NS_ID}
garciadeblas321726f2022-12-21 11:43:06 +010091 Log ${vnf_id_list}
aguilardbd91f862022-12-20 15:13:02 +000092 FOR ${vnf_id} IN @{vnf_id_list}
garciadeblas321726f2022-12-21 11:43:06 +010093 Log ${vnf_id}
aguilardbd91f862022-12-20 15:13:02 +000094 ${id}= Get VNF VIM ID ${vnf_id}
95 @{vdu_ids}= Split String ${id}
garciadeblas7a9e0312023-12-11 22:24:46 +010096 Append To List ${VIM_VDUS} @{vdu_ids}
aguilardbd91f862022-12-20 15:13:02 +000097 END
garciadeblas7a9e0312023-12-11 22:24:46 +010098 Log Many @{VIM_VDUS}
aguilardbd91f862022-12-20 15:13:02 +000099
garciadeblasf4ebaa82022-06-23 13:33:26 +0200100Get VNF Info
garciadeblas7a9e0312023-12-11 22:24:46 +0100101 [Documentation] Get VDU ID and IP addresses of the VNF and stores them to be used later on.
102 Variable Should Exist ${NS_ID} msg=NS is not available
103 ${ip_addr}= Get Vnf Management Ip Address ${NS_ID} ${VNF_INDEX}
garciadeblas321726f2022-12-21 11:43:06 +0100104 Log ${ip_addr}
garciadeblas7a9e0312023-12-11 22:24:46 +0100105 Set Suite Variable ${VNF_IP_ADDR} ${ip_addr}
106 ${vnf_id}= Get Vnf Id ${NS_ID} ${VNF_INDEX}
107 Set Suite Variable ${VNF_AUTOHEAL_ID} ${vnf_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200108 ${id}= Get VNF VIM ID ${vnf_id}
garciadeblas7a9e0312023-12-11 22:24:46 +0100109 Set Suite Variable ${VDU_AUTOHEAL_ID} ${id}
110 Log ${VDU_AUTOHEAL_ID}
111 @{AUTOHEAL_IP_LIST}= Get Vnf Vdur IPs ${VNF_AUTOHEAL_ID}
112 Set Suite Variable @{AUTOHEAL_IP_LIST} @{AUTOHEAL_IP_LIST}
113 Log @{AUTOHEAL_IP_LIST}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200114
115Stop Autoheal VDU
garciadeblas7a9e0312023-12-11 22:24:46 +0100116 [Documentation] Stop one VM of the VNF.
117 Variable Should Exist ${VDU_AUTOHEAL_ID} msg=VDU is not available
118 Halt Server ${VDU_AUTOHEAL_ID}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200119 Sleep 30
120
garciadeblasf4ebaa82022-06-23 13:33:26 +0200121Wait For Autohealing To Be Completed
garciadeblas7a9e0312023-12-11 22:24:46 +0100122 [Documentation] Wait for auto-healing to be completed. OSM will detect that the VM is down and will re-create it.
123 ${healing_max_wait_time}= Convert Time ${HEALING_MAX_WAIT_TIME} result_format=number
124 ${healing_max_wait_time}= Evaluate ${healing_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER}
125 Wait Until Keyword Succeeds ${healing_max_wait_time} ${HEALING_POL_TIME} Get Operations By Type ${NS_ID} heal
126 ${stdout}= Get Operations By Type ${NS_ID} heal
127 Wait Until Keyword Succeeds ${healing_max_wait_time} ${HEALING_POL_TIME} Check For NS Operation Ended ${stdout}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200128 Check For NS Operation Completed ${stdout}
129
garciadeblasf4ebaa82022-06-23 13:33:26 +0200130Check VNF After Healing
garciadeblas7a9e0312023-12-11 22:24:46 +0100131 [Documentation] Check that the ID of the VM and the IP addresses have not changed after healing.
132 Variable Should Exist ${VNF_AUTOHEAL_ID} msg=VNF is not available
133 @{ip_list}= Get Vnf Vdur IPs ${VNF_AUTOHEAL_ID}
garciadeblas321726f2022-12-21 11:43:06 +0100134 Log @{ip_list}
garciadeblas7a9e0312023-12-11 22:24:46 +0100135 Should Be Equal ${ip_list} ${AUTOHEAL_IP_LIST} IP addresses have changed after healing
136 ${id}= Get VNF VIM ID ${VNF_AUTOHEAL_ID}
garciadeblas321726f2022-12-21 11:43:06 +0100137 Log ${id}
garciadeblas7a9e0312023-12-11 22:24:46 +0100138 Should Not Be Equal ${id} ${VDU_AUTOHEAL_ID} VDU id has not changed after healing
garciadeblasf4ebaa82022-06-23 13:33:26 +0200139
aguilardbd91f862022-12-20 15:13:02 +0000140Update VIM Objects
garciadeblas7a9e0312023-12-11 22:24:46 +0100141 [Documentation] Retrieve all VMs from the NS and stores them in VIM_VDUS.
142 ... This is done again to guarantee that all objects are cleaned in the VIM in case the heal operation
143 ... added new objects.
144 Variable Should Exist ${NS_ID} msg=NS is not available
145 @{vnf_id_list}= Get Ns Vnf List ${NS_ID}
aguilardbd91f862022-12-20 15:13:02 +0000146 FOR ${vnf_id} IN @{vnf_id_list}
147 ${id}= Get VNF VIM ID ${vnf_id}
148 @{vdu_ids}= Split String ${id}
149 FOR ${id} IN @{vdu_ids}
garciadeblas7a9e0312023-12-11 22:24:46 +0100150 IF not "${id}" in "@{VIM_VDUS}"
151 Append To List ${VIM_VDUS} ${id}
aguilardbd91f862022-12-20 15:13:02 +0000152 END
153 END
154 END
garciadeblas7a9e0312023-12-11 22:24:46 +0100155 Log Many @{VIM_VDUS}
aguilardbd91f862022-12-20 15:13:02 +0000156
garciadeblasf4ebaa82022-06-23 13:33:26 +0200157Delete NS Instance
garciadeblas7a9e0312023-12-11 22:24:46 +0100158 [Documentation] Delete NS instance.
garciadeblasf4ebaa82022-06-23 13:33:26 +0200159 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100160 Delete NS ${NS_NAME}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200161
162Delete NS Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +0100163 [Documentation] Delete NS package from OSM.
garciadeblasf4ebaa82022-06-23 13:33:26 +0200164 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100165 Delete NSD ${NSD_NAME}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200166
167Delete VNF Descriptors
garciadeblas7a9e0312023-12-11 22:24:46 +0100168 [Documentation] Delete VNF package from OSM.
garciadeblasf4ebaa82022-06-23 13:33:26 +0200169 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100170 Delete VNFD ${VNFD_NAME}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200171
garciadeblas7a9e0312023-12-11 22:24:46 +0100172Delete Objects In VIM
173 [Documentation] Delete any remaining objects (volumes, VMs, etc.) in the VIM.
aguilardbd91f862022-12-20 15:13:02 +0000174 [Tags] cleanup
175 ${error}= Set Variable 0
garciadeblas7a9e0312023-12-11 22:24:46 +0100176 FOR ${vdu_id} IN @{VIM_VDUS}
garciadeblas321726f2022-12-21 11:43:06 +0100177 Log Checking if server ${vdu_id} is still in VIM
aguilardbd91f862022-12-20 15:13:02 +0000178 ${status}= Run Keyword And Ignore Error Get Server Property ${vdu_id} id
garciadeblas321726f2022-12-21 11:43:06 +0100179 Log ${status}[0]
garciadeblas23ff8f92023-12-11 16:26:40 +0100180 IF '${status}[0]' == 'PASS'
aguilardbd91f862022-12-20 15:13:02 +0000181 ${error}= Set Variable 1
garciadeblas321726f2022-12-21 11:43:06 +0100182 Log Deleting server ${vdu_id}
aguilardbd91f862022-12-20 15:13:02 +0000183 Run Keyword And Ignore Error Delete Server ${vdu_id}
184 END
185 END
186 IF ${error}==1
187 Fail Some objects created by test were not deleted in VIM
188 END
189
190
garciadeblasf4ebaa82022-06-23 13:33:26 +0200191*** Keywords ***
192Suite Cleanup
193 [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim
garciadeblas7a9e0312023-12-11 22:24:46 +0100194 Run Keyword If Any Tests Failed Delete NS ${NS_NAME}
195 Run Keyword If Any Tests Failed Delete NSD ${NSD_NAME}
196 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME}