| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [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 *** |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 14 | Documentation [HEAL-02] Healing of scaled charm VDUs |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 15 | |
| 16 | Library OperatingSystem |
| 17 | Library String |
| 18 | Library Collections |
| 19 | Library Process |
| 20 | Library SSHLibrary |
| 21 | |
| 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_02 cluster_heal daily |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 30 | |
| 31 | |
| 32 | Suite Teardown Run Keyword And Ignore Error Suite Cleanup |
| 33 | |
| 34 | |
| 35 | *** Variables *** |
| 36 | # NS and VNF descriptor package folder and ids |
| 37 | ${vnfd_volumes_pkg} several_volumes_vnf |
| 38 | ${vnfd_volumes_name} several_volumes-vnf |
| 39 | ${vdu_volumes_name} several_volumes-VM |
| 40 | ${vnf_several_index} several_volumes_vnf |
| 41 | ${vnfd_charm_pkg} charm-packages/native_manual_scale_charm_vnf |
| 42 | ${vnfd_charm_name} native_manual_scale_charm-vnf |
| 43 | ${vdu_charm_name} mgmtVM |
| 44 | ${vnf_charm_index} charm_vnf |
| 45 | ${vnf_charm_scaling_group} manual-scaling_mgmtVM |
| 46 | ${vnf_charm_cloudinit_file} /root/helloworld.txt |
| 47 | ${vnf_charm_day1_file} /home/ubuntu/first-touch |
| 48 | ${nsd_pkg} volumes_nativecharm_ns |
| 49 | ${nsd_name} volumes_nativecharm-ns |
| 50 | |
| 51 | # NS instance name and configuration |
| aguilard | f9be550 | 2023-06-20 10:51:16 +0000 | [diff] [blame] | 52 | ${flavor_name_prefix} osm.heal02 |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 53 | ${ns_name} heal_02 |
| garciadeblas | f01b9a4 | 2023-06-02 14:43:43 +0200 | [diff] [blame] | 54 | ${ns_timeout} 6min |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 55 | ${scale_wait_time} 4min |
| 56 | |
| 57 | # SSH keys and username to be used |
| 58 | ${publickey} %{HOME}/.ssh/id_rsa.pub |
| 59 | ${privatekey} %{HOME}/.ssh/id_rsa |
| 60 | ${username} ubuntu |
| 61 | ${password} ${EMPTY} |
| 62 | |
| 63 | ${success_return_code} 0 |
| 64 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 65 | @{vim_vdus} @{EMPTY} |
| 66 | @{vim_volumes} @{EMPTY} |
| 67 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 68 | |
| 69 | *** Test Cases *** |
| 70 | Create VNF Descriptors |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 71 | Create VNFD '%{PACKAGES_FOLDER}/${vnfd_charm_pkg}' |
| 72 | Create VNFD '%{PACKAGES_FOLDER}/${vnfd_volumes_pkg}' |
| 73 | |
| 74 | |
| 75 | Create NS Descriptor |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 76 | Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}' |
| 77 | |
| 78 | |
| Gabriel Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 79 | Create Test Flavor |
| aguilard | f9be550 | 2023-06-20 10:51:16 +0000 | [diff] [blame] | 80 | ${rand}= Generate Random String 6 [NUMBERS] |
| 81 | ${flavor_name}= Catenate SEPARATOR=_ ${flavor_name_prefix} ${rand} |
| aguilard | 83eed18 | 2023-06-20 07:40:33 +0000 | [diff] [blame] | 82 | ${id}= Create Flavor ${flavor_name} 1 1024 10 |
| Gabriel Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 83 | Set Suite Variable ${flavor_id} ${id} |
| 84 | |
| 85 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 86 | Network Service Instance Test |
| Gabriel Cuba | 8f994cc | 2023-05-12 13:44:16 -0500 | [diff] [blame] | 87 | ${ns_config}= Set Variable {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}}],vnf: [ {member-vnf-index: charm_vnf, vdu: [{ id: mgmtVM, vim-flavor-id: ${flavor_id}}]}] } |
| garciadeblas | f01b9a4 | 2023-06-02 14:43:43 +0200 | [diff] [blame] | 88 | ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey} ${ns_timeout} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 89 | Set Suite Variable ${ns_id} ${id} |
| 90 | |
| 91 | |
| 92 | Get NS Id |
| Mark Beierl | 5871033 | 2022-08-03 14:14:14 -0400 | [diff] [blame] | 93 | [Tags] cleanup |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 94 | ${variables} Get Variables |
| 95 | IF not "\${ns_id}" in "${variables}" |
| 96 | ${id}= Get Ns Id ${ns_name} |
| 97 | Set Suite Variable ${ns_id} ${id} |
| 98 | END |
| 99 | |
| 100 | |
| 101 | Scale Out Charm VNF |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 102 | ${vnf_id}= Get Vnf Id ${ns_id} ${vnf_charm_index} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 103 | Set Suite Variable ${vnf_charm_id} ${vnf_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 104 | @{vdur_list}= Get Vnf Vdur Names ${vnf_charm_id} |
| 105 | ${vdurs}= Get Length ${vdur_list} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 106 | Set Suite Variable ${initial_vdur_count} ${vdurs} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 107 | Execute Manual VNF Scale ${ns_name} ${vnf_charm_index} ${vnf_charm_scaling_group} SCALE_OUT ${scale_wait_time} |
| 108 | @{vdur_list}= Get Vnf Vdur Names ${vnf_charm_id} |
| 109 | ${vdurs}= Get Length ${vdur_list} |
| aguilard | 1032025 | 2022-07-01 12:06:41 +0000 | [diff] [blame] | 110 | Run Keyword If ${vdurs} != ${initial_vdur_count} + 1 Fail msg=There is no new VDU records in the VNF after Scale Out |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 111 | |
| 112 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 113 | Get VIM Objects |
| 114 | Variable Should Exist ${ns_id} msg=NS is not available |
| 115 | @{vnf_id_list}= Get Ns Vnf List ${ns_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 116 | Log ${vnf_id_list} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 117 | FOR ${vnf_id} IN @{vnf_id_list} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 118 | Log ${vnf_id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 119 | ${id}= Get VNF VIM ID ${vnf_id} |
| 120 | @{vdu_ids}= Split String ${id} |
| 121 | Append To List ${vim_vdus} @{vdu_ids} |
| 122 | END |
| 123 | FOR ${vdu_id} IN @{vim_vdus} |
| 124 | ${volumes_attached}= Get Server Property ${vdu_id} volumes_attached |
| 125 | ${match}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1 |
| 126 | IF ${match} != @{EMPTY} |
| 127 | IF not "${match}[0]" in "@{vim_volumes}" |
| 128 | Append To List ${vim_volumes} ${match}[0] |
| 129 | END |
| 130 | END |
| 131 | END |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 132 | Log Many @{vim_vdus} |
| 133 | Log Many @{vim_volumes} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 134 | |
| 135 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 136 | Get Charm VNF Info |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 137 | Variable Should Exist ${ns_id} msg=NS is not available |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 138 | ${variables} Get Variables |
| 139 | IF not "\${vnf_charm_id}" in "${variables}" |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 140 | ${vnf_id}= Get Vnf Id ${ns_id} ${vnf_charm_index} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 141 | Set Suite Variable ${vnf_charm_id} ${vnf_id} |
| 142 | END |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 143 | ${id}= Get VNF VIM ID ${vnf_charm_id} |
| 144 | @{vdu_charm_ids}= Split String ${id} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 145 | Set Suite Variable @{vdu_charm_ids} @{vdu_charm_ids} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 146 | Log ${vdu_charm_ids}[1] |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 147 | @{charm_ip_list}= Get Vnf Vdur IPs ${vnf_charm_id} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 148 | Set Suite Variable @{charm_ip_list} @{charm_ip_list} |
| 149 | |
| 150 | |
| aguilard | 8f18bfd | 2022-06-22 10:44:20 +0000 | [diff] [blame] | 151 | Halt Charm VDU |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 152 | Variable Should Exist @{vdu_charm_ids} msg=VDU is not available |
| aguilard | 8f18bfd | 2022-06-22 10:44:20 +0000 | [diff] [blame] | 153 | Halt Server ${vdu_charm_ids}[1] |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 154 | Sleep 15 |
| 155 | |
| 156 | |
| 157 | Heal Charm VDU |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 158 | Variable Should Exist ${vnf_charm_id} msg=VNF is not available |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 159 | Heal Network Service ${ns_id} --vnf ${vnf_charm_id} --cause "Heal VM of charm_vnf" --vdu ${vdu_charm_name} --count-index 1 --run-day1 |
| 160 | |
| 161 | |
| 162 | Check VNF After Healing |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 163 | Variable Should Exist ${vnf_charm_id} msg=VNF is not available |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 164 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 165 | @{ip_list}= Get Vnf Vdur IPs ${vnf_charm_id} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 166 | Should Be Equal ${ip_list} ${charm_ip_list} IP addresses have changed after healing |
| 167 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 168 | ${id}= Get VNF VIM ID ${vnf_charm_id} |
| 169 | @{ids}= Split String ${id} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 170 | Should Be Equal ${vdu_charm_ids}[0] ${ids}[0] VDU[0] id has changed after healing |
| 171 | Should Not Be Equal ${vdu_charm_ids}[1] ${ids}[1] VDU[1] id has not changed after healing |
| 172 | Should Be Equal ${vdu_charm_ids}[2] ${ids}[2] VDU[2] id has changed after healing |
| 173 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 174 | ${ip}= Get Vdu Attribute ${vnf_charm_id} ip-address 1 |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 175 | ${stdout}= Execute Remote Command Check Rc Return Output ${ip} ${username} ${password} ${privatekey} sudo ls ${vnf_charm_cloudinit_file} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 176 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 177 | Check If remote File Exists ${ip} ${username} ${password} ${privatekey} ${vnf_charm_day1_file} |
| garciadeblas | 8218c9a | 2023-06-19 12:48:04 +0200 | [diff] [blame] | 178 | ${vim_info}= Get Vdu Attribute ${vnf_charm_id} vim_info 1 |
| 179 | Should Contain ${vim_info} id: ${flavor_id} msg=Flavor ID is incorrect |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 180 | |
| 181 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 182 | Update VIM Objects |
| 183 | Variable Should Exist ${ns_id} msg=NS is not available |
| 184 | @{vdu_updated}= Create List |
| 185 | @{vnf_id_list}= Get Ns Vnf List ${ns_id} |
| 186 | FOR ${vnf_id} IN @{vnf_id_list} |
| 187 | ${id}= Get VNF VIM ID ${vnf_id} |
| 188 | @{vdu_ids}= Split String ${id} |
| 189 | Append To List ${vdu_updated} @{vdu_ids} |
| 190 | FOR ${id} IN @{vdu_ids} |
| 191 | IF not "${id}" in "@{vim_vdus}" |
| 192 | Append To List ${vim_vdus} ${id} |
| 193 | END |
| 194 | END |
| 195 | END |
| 196 | FOR ${vdu_id} IN @{vdu_updated} |
| 197 | ${volumes_attached}= Get Server Property ${vdu_id} volumes_attached |
| 198 | ${match}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1 |
| 199 | IF ${match} != @{EMPTY} |
| 200 | IF not "${match}[0]" in "@{vim_volumes}" |
| 201 | Append To List ${vim_volumes} ${match}[0] |
| 202 | END |
| 203 | END |
| 204 | END |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 205 | Log Many @{vim_vdus} |
| 206 | Log Many @{vim_volumes} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 207 | |
| 208 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 209 | Delete NS Instance |
| 210 | [Tags] cleanup |
| 211 | Delete NS ${ns_name} |
| 212 | |
| 213 | |
| 214 | Delete NS Descriptor |
| 215 | [Tags] cleanup |
| 216 | Delete NSD ${nsd_name} |
| 217 | |
| 218 | |
| 219 | Delete VNF Descriptors |
| 220 | [Tags] cleanup |
| 221 | Delete VNFD ${vnfd_volumes_name} |
| 222 | Delete VNFD ${vnfd_charm_name} |
| 223 | |
| 224 | |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 225 | Delete Objects in VIM |
| 226 | [Tags] cleanup |
| aguilard | 83eed18 | 2023-06-20 07:40:33 +0000 | [diff] [blame] | 227 | Delete Flavor ${flavor_id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 228 | ${error}= Set Variable 0 |
| 229 | FOR ${vol_id} IN @{vim_volumes} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 230 | Log Checking if volume ${vol_id} is still in VIM |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 231 | ${exists}= Check If Volume Exists ${vol_id} |
| 232 | IF ${exists}!=0 |
| 233 | ${error}= Set Variable 1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 234 | Log Deleting volume ${vol_id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 235 | Run Keyword And Ignore Error Delete Volume ${vol_id} |
| 236 | END |
| 237 | END |
| 238 | FOR ${vdu_id} IN @{vim_vdus} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 239 | Log Checking if server ${vdu_id} is still in VIM |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 240 | ${status}= Run Keyword And Ignore Error Get Server Property ${vdu_id} id |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 241 | Log ${status}[0] |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 242 | IF '${status}[0]' == 'PASS' |
| 243 | ${error}= Set Variable 1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 244 | Log Deleting server ${vdu_id} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 245 | Run Keyword And Ignore Error Delete Server ${vdu_id} |
| 246 | END |
| 247 | END |
| 248 | IF ${error}==1 |
| 249 | Fail Some objects created by test were not deleted in VIM |
| 250 | END |
| 251 | |
| 252 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 253 | *** Keywords *** |
| 254 | Suite Cleanup |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 255 | [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 256 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 257 | Run Keyword If Any Tests Failed Delete NS ${ns_name} |
| 258 | Run Keyword If Any Tests Failed Delete NSD ${nsd_name} |
| 259 | Run Keyword If Any Tests Failed Delete VNFD ${vnfd_volumes_name} |
| 260 | Run Keyword If Any Tests Failed Delete VNFD ${vnfd_charm_name} |
| aguilard | bd91f86 | 2022-12-20 15:13:02 +0000 | [diff] [blame] | 261 | Run Keyword If Any Tests Failed Delete Objects in VIM |