| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 1 | *** Comments *** |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 2 | # 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 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 14 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 15 | *** Settings *** |
| 16 | Documentation [HEAL-04] Autohealing of NS |
| garciadeblas | b731aac | 2022-06-25 18:29:22 +0200 | [diff] [blame] | 17 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 18 | Library OperatingSystem |
| 19 | Library String |
| 20 | Library Collections |
| 21 | Library Process |
| 22 | Library SSHLibrary |
| garciadeblas | b731aac | 2022-06-25 18:29:22 +0200 | [diff] [blame] | 23 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 24 | Resource ../lib/vnfd_lib.resource |
| 25 | Resource ../lib/vnf_lib.resource |
| 26 | Resource ../lib/nsd_lib.resource |
| 27 | Resource ../lib/ns_lib.resource |
| 28 | Resource ../lib/ns_operation_lib.resource |
| 29 | Resource ../lib/ssh_lib.resource |
| 30 | Resource ../lib/openstack_lib.resource |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 31 | |
| garciadeblas | 166c891 | 2023-12-16 10:51:48 +0100 | [diff] [blame] | 32 | Test Tags heal_04 cluster_heal daily regression |
| garciadeblas | b731aac | 2022-06-25 18:29:22 +0200 | [diff] [blame] | 33 | |
| 34 | Suite Teardown Run Keyword And Ignore Error Suite Cleanup |
| 35 | |
| 36 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 37 | *** Variables *** |
| 38 | # NS and VNF descriptor package folder and ids |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 39 | ${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 |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 45 | # NS instance name and configuration |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 46 | ${NS_NAME} heal_04 |
| 47 | ${NS_CONFIG} {vld: [ {name: mgmt, vim-network-name: %{VIM_MGMT_NET}} ] } |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 48 | |
| 49 | # SSH keys and username to be used |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 50 | ${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub |
| 51 | ${PRIVATEKEY} %{HOME}/.ssh/id_rsa |
| 52 | ${USERNAME} ubuntu |
| 53 | ${PASSWORD} ${EMPTY} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 54 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 55 | ${SUCCESS_RETURN_CODE} 0 |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 56 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 57 | # Healing wait time |
| 58 | ${HEALING_POL_TIME} 15sec |
| 59 | ${HEALING_MAX_WAIT_TIME} 10m |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 60 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 61 | @{VIM_VDUS} @{EMPTY} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 62 | |
| 63 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 64 | *** Test Cases *** |
| 65 | Create VNF Descriptors |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 66 | [Documentation] Upload VNF package for the testsuite. |
| 67 | Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG}' |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 68 | |
| 69 | Create NS Descriptor |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 70 | [Documentation] Upload NS package for the testsuite. |
| 71 | Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}' |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 72 | |
| 73 | Network Service Instance Test |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 74 | [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} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 77 | |
| 78 | Get NS Id |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 79 | [Documentation] Get NS identifier and stores as suite variable to be used later on. |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 80 | [Tags] cleanup |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 81 | ${variables}= Get Variables |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame] | 82 | IF not "\${ns_id}" in "${variables}" |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 83 | ${id}= Get Ns Id ${NS_NAME} |
| 84 | Set Suite Variable ${NS_ID} ${id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 85 | END |
| 86 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 87 | Get VIM Objects |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 88 | [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} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 91 | Log ${vnf_id_list} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 92 | FOR ${vnf_id} IN @{vnf_id_list} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 93 | Log ${vnf_id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 94 | ${id}= Get VNF VIM ID ${vnf_id} |
| 95 | @{vdu_ids}= Split String ${id} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 96 | Append To List ${VIM_VDUS} @{vdu_ids} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 97 | END |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 98 | Log Many @{VIM_VDUS} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 99 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 100 | Get VNF Info |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 101 | [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} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 104 | Log ${ip_addr} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 105 | 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} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 108 | ${id}= Get VNF VIM ID ${vnf_id} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 109 | 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} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 114 | |
| 115 | Stop Autoheal VDU |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 116 | [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} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 119 | Sleep 30 |
| 120 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 121 | Wait For Autohealing To Be Completed |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 122 | [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} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 128 | Check For NS Operation Completed ${stdout} |
| 129 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 130 | Check VNF After Healing |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 131 | [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} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 134 | Log @{ip_list} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 135 | Should Be Equal ${ip_list} ${AUTOHEAL_IP_LIST} IP addresses have changed after healing |
| 136 | ${id}= Get VNF VIM ID ${VNF_AUTOHEAL_ID} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 137 | Log ${id} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 138 | Should Not Be Equal ${id} ${VDU_AUTOHEAL_ID} VDU id has not changed after healing |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 139 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 140 | Update VIM Objects |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 141 | [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} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 146 | 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} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 150 | IF not "${id}" in "@{VIM_VDUS}" |
| 151 | Append To List ${VIM_VDUS} ${id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 152 | END |
| 153 | END |
| 154 | END |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 155 | Log Many @{VIM_VDUS} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 156 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 157 | Delete NS Instance |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 158 | [Documentation] Delete NS instance. |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 159 | [Tags] cleanup |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 160 | Delete NS ${NS_NAME} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 161 | |
| 162 | Delete NS Descriptor |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 163 | [Documentation] Delete NS package from OSM. |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 164 | [Tags] cleanup |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 165 | Delete NSD ${NSD_NAME} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 166 | |
| 167 | Delete VNF Descriptors |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 168 | [Documentation] Delete VNF package from OSM. |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 169 | [Tags] cleanup |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 170 | Delete VNFD ${VNFD_NAME} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 171 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 172 | Delete Objects In VIM |
| 173 | [Documentation] Delete any remaining objects (volumes, VMs, etc.) in the VIM. |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 174 | [Tags] cleanup |
| 175 | ${error}= Set Variable 0 |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 176 | FOR ${vdu_id} IN @{VIM_VDUS} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 177 | Log Checking if server ${vdu_id} is still in VIM |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 178 | ${status}= Run Keyword And Ignore Error Get Server Property ${vdu_id} id |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 179 | Log ${status}[0] |
| garciadeblas | 23ff8f9 | 2023-12-11 16:26:40 +0100 | [diff] [blame] | 180 | IF '${status}[0]' == 'PASS' |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 181 | ${error}= Set Variable 1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 182 | Log Deleting server ${vdu_id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 183 | 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 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 191 | *** Keywords *** |
| 192 | Suite Cleanup |
| 193 | [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 194 | 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} |