| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | # you may not use this file except in compliance with the License. |
| 3 | # You may obtain a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | # See the License for the specific language governing permissions and |
| 11 | # limitations under the License. |
| 12 | |
| 13 | *** Settings *** |
| 14 | Documentation [HEAL-04] Autohealing of NS |
| garciadeblas | b731aac | 2022-06-25 18:29:22 +0200 | [diff] [blame] | 15 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 16 | Library OperatingSystem |
| 17 | Library String |
| 18 | Library Collections |
| 19 | Library Process |
| 20 | Library SSHLibrary |
| garciadeblas | b731aac | 2022-06-25 18:29:22 +0200 | [diff] [blame] | 21 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 22 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot |
| 23 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnf_lib.robot |
| 24 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot |
| 25 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot |
| 26 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot |
| 27 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/openstack_lib.robot |
| 28 | |
| garciadeblas | d7f75d7 | 2022-06-25 18:38:32 +0200 | [diff] [blame] | 29 | Force Tags heal_04 cluster_heal daily |
| garciadeblas | b731aac | 2022-06-25 18:29:22 +0200 | [diff] [blame] | 30 | |
| 31 | Suite Teardown Run Keyword And Ignore Error Suite Cleanup |
| 32 | |
| 33 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 34 | *** Variables *** |
| 35 | # NS and VNF descriptor package folder and ids |
| 36 | ${vnfd_pkg} autoheal_vnf |
| 37 | ${vnfd_name} autoheal_vnfd |
| 38 | ${vdu_name} autoheal_vnfd-VM |
| 39 | ${vnf_index} autoheal-basic-1 |
| 40 | ${nsd_pkg} autoheal_ns |
| 41 | ${nsd_name} autoheal_nsd |
| 42 | # NS instance name and configuration |
| 43 | ${ns_name} heal_04 |
| 44 | ${ns_config} {vld: [ {name: mgmt, vim-network-name: %{VIM_MGMT_NET}} ] } |
| 45 | |
| 46 | # SSH keys and username to be used |
| 47 | ${publickey} %{HOME}/.ssh/id_rsa.pub |
| 48 | ${privatekey} %{HOME}/.ssh/id_rsa |
| 49 | ${username} ubuntu |
| 50 | ${password} ${EMPTY} |
| 51 | |
| 52 | ${success_return_code} 0 |
| 53 | |
| 54 | #Healing wait time |
| 55 | ${healing_pol_time} 15sec |
| 56 | ${healing_max_wait_time} 10m |
| 57 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 58 | @{vim_vdus} @{EMPTY} |
| 59 | |
| 60 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 61 | *** Test Cases *** |
| 62 | Create VNF Descriptors |
| 63 | Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}' |
| 64 | |
| 65 | |
| 66 | Create NS Descriptor |
| 67 | Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}' |
| 68 | |
| 69 | |
| 70 | Network Service Instance Test |
| 71 | ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey} |
| 72 | Set Suite Variable ${ns_id} ${id} |
| 73 | |
| 74 | |
| 75 | Get NS Id |
| 76 | [Tags] cleanup |
| 77 | ${variables} Get Variables |
| 78 | IF not "\${ns_id}" in "${variables}" |
| 79 | ${id}= Get Ns Id ${ns_name} |
| 80 | Set Suite Variable ${ns_id} ${id} |
| 81 | END |
| 82 | |
| 83 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 84 | Get VIM Objects |
| 85 | Variable Should Exist ${ns_id} msg=NS is not available |
| 86 | @{vnf_id_list}= Get Ns Vnf List ${ns_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 87 | Log ${vnf_id_list} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 88 | FOR ${vnf_id} IN @{vnf_id_list} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 89 | Log ${vnf_id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 90 | ${id}= Get VNF VIM ID ${vnf_id} |
| 91 | @{vdu_ids}= Split String ${id} |
| 92 | Append To List ${vim_vdus} @{vdu_ids} |
| 93 | END |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 94 | Log Many @{vim_vdus} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 95 | |
| 96 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 97 | Get VNF Info |
| 98 | Variable Should Exist ${ns_id} msg=NS is not available |
| 99 | ${ip_addr}= Get Vnf Management Ip Address ${ns_id} ${vnf_index} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 100 | Log ${ip_addr} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 101 | Set Suite Variable ${vnf_ip_addr} ${ip_addr} |
| 102 | |
| 103 | ${vnf_id}= Get Vnf Id ${ns_id} ${vnf_index} |
| 104 | Set Suite Variable ${vnf_autoheal_id} ${vnf_id} |
| 105 | ${id}= Get VNF VIM ID ${vnf_id} |
| 106 | Set Suite Variable ${vdu_autoheal_id} ${id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 107 | Log ${vdu_autoheal_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 108 | |
| 109 | @{autoheal_ip_list}= Get Vnf Vdur IPs ${vnf_autoheal_id} |
| 110 | Set Suite Variable @{autoheal_ip_list} @{autoheal_ip_list} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 111 | Log @{autoheal_ip_list} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 112 | |
| 113 | |
| 114 | Stop Autoheal VDU |
| 115 | Variable Should Exist ${vdu_autoheal_id} msg=VDU is not available |
| 116 | Halt Server ${vdu_autoheal_id} |
| 117 | Sleep 30 |
| 118 | |
| 119 | |
| 120 | Wait For Autohealing To Be Completed |
| 121 | ${healing_max_wait_time}= Convert Time ${healing_max_wait_time} result_format=number |
| 122 | ${healing_max_wait_time}= Evaluate ${healing_max_wait_time} * ${vim_timeout_multiplier} |
| 123 | Wait Until Keyword Succeeds ${healing_max_wait_time} ${healing_pol_time} Get Operations By Type ${ns_id} heal |
| 124 | ${stdout}= Get Operations By Type ${ns_id} heal |
| 125 | Wait Until Keyword Succeeds ${healing_max_wait_time} ${healing_pol_time} Check For NS Operation Ended ${stdout} |
| 126 | Check For NS Operation Completed ${stdout} |
| 127 | |
| 128 | |
| 129 | Check VNF After Healing |
| 130 | Variable Should Exist ${vnf_autoheal_id} msg=VNF is not available |
| 131 | |
| 132 | @{ip_list}= Get Vnf Vdur IPs ${vnf_autoheal_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 133 | Log @{ip_list} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 134 | Should Be Equal ${ip_list} ${autoheal_ip_list} IP addresses have changed after healing |
| 135 | |
| 136 | ${id}= Get VNF VIM ID ${vnf_autoheal_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 137 | Log ${id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 138 | Should Not Be Equal ${id} ${vdu_autoheal_id} VDU id has not changed after healing |
| 139 | |
| 140 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 141 | Update VIM Objects |
| 142 | Variable Should Exist ${ns_id} msg=NS is not available |
| 143 | @{vnf_id_list}= Get Ns Vnf List ${ns_id} |
| 144 | FOR ${vnf_id} IN @{vnf_id_list} |
| 145 | ${id}= Get VNF VIM ID ${vnf_id} |
| 146 | @{vdu_ids}= Split String ${id} |
| 147 | FOR ${id} IN @{vdu_ids} |
| 148 | IF not "${id}" in "@{vim_vdus}" |
| 149 | Append To List ${vim_vdus} ${id} |
| 150 | END |
| 151 | END |
| 152 | END |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 153 | Log Many @{vim_vdus} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 154 | |
| 155 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 156 | Delete NS Instance |
| 157 | [Tags] cleanup |
| 158 | Delete NS ${ns_name} |
| 159 | |
| 160 | |
| 161 | Delete NS Descriptor |
| 162 | [Tags] cleanup |
| 163 | Delete NSD ${nsd_name} |
| 164 | |
| 165 | |
| 166 | Delete VNF Descriptors |
| 167 | [Tags] cleanup |
| 168 | Delete VNFD ${vnfd_name} |
| 169 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 170 | |
| 171 | Delete Objects in VIM |
| 172 | [Tags] cleanup |
| 173 | ${error}= Set Variable 0 |
| 174 | FOR ${vdu_id} IN @{vim_vdus} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 175 | Log Checking if server ${vdu_id} is still in VIM |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 176 | ${status}= Run Keyword And Ignore Error Get Server Property ${vdu_id} id |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 177 | Log ${status}[0] |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 178 | IF '${status}[0]' == 'PASS' |
| 179 | ${error}= Set Variable 1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 180 | Log Deleting server ${vdu_id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 181 | Run Keyword And Ignore Error Delete Server ${vdu_id} |
| 182 | END |
| 183 | END |
| 184 | IF ${error}==1 |
| 185 | Fail Some objects created by test were not deleted in VIM |
| 186 | END |
| 187 | |
| 188 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 189 | *** Keywords *** |
| 190 | Suite Cleanup |
| 191 | [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim |
| 192 | |
| 193 | Run Keyword If Any Tests Failed Delete NS ${ns_name} |
| 194 | Run Keyword If Any Tests Failed Delete NSD ${nsd_name} |
| 195 | Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name} |