blob: eedd94b4b77b678051a3a975597bcd42fc659986 [file] [log] [blame]
aguilard845c2ea2022-04-08 09:36:03 +00001# 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 ***
garciadeblasf4ebaa82022-06-23 13:33:26 +020014Documentation [HEAL-02] Healing of scaled charm VDUs
aguilard845c2ea2022-04-08 09:36:03 +000015
16Library OperatingSystem
17Library String
18Library Collections
19Library Process
20Library SSHLibrary
21
22Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
23Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnf_lib.robot
24Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
25Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
26Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
27Resource %{ROBOT_DEVOPS_FOLDER}/lib/openstack_lib.robot
28
garciadeblasd7f75d72022-06-25 18:38:32 +020029Force Tags heal_02 cluster_heal daily
aguilard845c2ea2022-04-08 09:36:03 +000030
31
32Suite 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
Gabriel Cuba8f994cc2023-05-12 13:44:16 -050052${flavor_name} osm.heal_02
aguilard845c2ea2022-04-08 09:36:03 +000053${ns_name} heal_02
garciadeblasf01b9a42023-06-02 14:43:43 +020054${ns_timeout} 6min
aguilard845c2ea2022-04-08 09:36:03 +000055${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
aguilardbd91f862022-12-20 15:13:02 +000065@{vim_vdus} @{EMPTY}
66@{vim_volumes} @{EMPTY}
67
aguilard845c2ea2022-04-08 09:36:03 +000068
69*** Test Cases ***
70Create VNF Descriptors
aguilard845c2ea2022-04-08 09:36:03 +000071 Create VNFD '%{PACKAGES_FOLDER}/${vnfd_charm_pkg}'
72 Create VNFD '%{PACKAGES_FOLDER}/${vnfd_volumes_pkg}'
73
74
75Create NS Descriptor
aguilard845c2ea2022-04-08 09:36:03 +000076 Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
77
78
Gabriel Cuba8f994cc2023-05-12 13:44:16 -050079Create Test Flavor
80 ${id}= Create Flavor ${flavor_name}
81 Set Suite Variable ${flavor_id} ${id}
82
83
aguilard845c2ea2022-04-08 09:36:03 +000084Network Service Instance Test
Gabriel Cuba8f994cc2023-05-12 13:44:16 -050085 ${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}}]}] }
garciadeblasf01b9a42023-06-02 14:43:43 +020086 ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey} ${ns_timeout}
aguilard845c2ea2022-04-08 09:36:03 +000087 Set Suite Variable ${ns_id} ${id}
88
89
90Get NS Id
Mark Beierl58710332022-08-03 14:14:14 -040091 [Tags] cleanup
aguilard845c2ea2022-04-08 09:36:03 +000092 ${variables} Get Variables
93 IF not "\${ns_id}" in "${variables}"
94 ${id}= Get Ns Id ${ns_name}
95 Set Suite Variable ${ns_id} ${id}
96 END
97
98
99Scale Out Charm VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +0200100 ${vnf_id}= Get Vnf Id ${ns_id} ${vnf_charm_index}
aguilard845c2ea2022-04-08 09:36:03 +0000101 Set Suite Variable ${vnf_charm_id} ${vnf_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200102 @{vdur_list}= Get Vnf Vdur Names ${vnf_charm_id}
103 ${vdurs}= Get Length ${vdur_list}
aguilard845c2ea2022-04-08 09:36:03 +0000104 Set Suite Variable ${initial_vdur_count} ${vdurs}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200105 Execute Manual VNF Scale ${ns_name} ${vnf_charm_index} ${vnf_charm_scaling_group} SCALE_OUT ${scale_wait_time}
106 @{vdur_list}= Get Vnf Vdur Names ${vnf_charm_id}
107 ${vdurs}= Get Length ${vdur_list}
aguilard10320252022-07-01 12:06:41 +0000108 Run Keyword If ${vdurs} != ${initial_vdur_count} + 1 Fail msg=There is no new VDU records in the VNF after Scale Out
aguilard845c2ea2022-04-08 09:36:03 +0000109
110
aguilardbd91f862022-12-20 15:13:02 +0000111Get VIM Objects
112 Variable Should Exist ${ns_id} msg=NS is not available
113 @{vnf_id_list}= Get Ns Vnf List ${ns_id}
garciadeblas321726f2022-12-21 11:43:06 +0100114 Log ${vnf_id_list}
aguilardbd91f862022-12-20 15:13:02 +0000115 FOR ${vnf_id} IN @{vnf_id_list}
garciadeblas321726f2022-12-21 11:43:06 +0100116 Log ${vnf_id}
aguilardbd91f862022-12-20 15:13:02 +0000117 ${id}= Get VNF VIM ID ${vnf_id}
118 @{vdu_ids}= Split String ${id}
119 Append To List ${vim_vdus} @{vdu_ids}
120 END
121 FOR ${vdu_id} IN @{vim_vdus}
122 ${volumes_attached}= Get Server Property ${vdu_id} volumes_attached
123 ${match}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1
124 IF ${match} != @{EMPTY}
125 IF not "${match}[0]" in "@{vim_volumes}"
126 Append To List ${vim_volumes} ${match}[0]
127 END
128 END
129 END
garciadeblas321726f2022-12-21 11:43:06 +0100130 Log Many @{vim_vdus}
131 Log Many @{vim_volumes}
aguilardbd91f862022-12-20 15:13:02 +0000132
133
aguilard845c2ea2022-04-08 09:36:03 +0000134Get Charm VNF Info
garciadeblasf4ebaa82022-06-23 13:33:26 +0200135 Variable Should Exist ${ns_id} msg=NS is not available
aguilard845c2ea2022-04-08 09:36:03 +0000136 ${variables} Get Variables
137 IF not "\${vnf_charm_id}" in "${variables}"
garciadeblasf4ebaa82022-06-23 13:33:26 +0200138 ${vnf_id}= Get Vnf Id ${ns_id} ${vnf_charm_index}
aguilard845c2ea2022-04-08 09:36:03 +0000139 Set Suite Variable ${vnf_charm_id} ${vnf_id}
140 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200141 ${id}= Get VNF VIM ID ${vnf_charm_id}
142 @{vdu_charm_ids}= Split String ${id}
aguilard845c2ea2022-04-08 09:36:03 +0000143 Set Suite Variable @{vdu_charm_ids} @{vdu_charm_ids}
garciadeblas321726f2022-12-21 11:43:06 +0100144 Log ${vdu_charm_ids}[1]
garciadeblasf4ebaa82022-06-23 13:33:26 +0200145 @{charm_ip_list}= Get Vnf Vdur IPs ${vnf_charm_id}
aguilard845c2ea2022-04-08 09:36:03 +0000146 Set Suite Variable @{charm_ip_list} @{charm_ip_list}
147
148
aguilard8f18bfd2022-06-22 10:44:20 +0000149Halt Charm VDU
garciadeblasf4ebaa82022-06-23 13:33:26 +0200150 Variable Should Exist @{vdu_charm_ids} msg=VDU is not available
aguilard8f18bfd2022-06-22 10:44:20 +0000151 Halt Server ${vdu_charm_ids}[1]
aguilard845c2ea2022-04-08 09:36:03 +0000152 Sleep 15
153
154
155Heal Charm VDU
garciadeblasf4ebaa82022-06-23 13:33:26 +0200156 Variable Should Exist ${vnf_charm_id} msg=VNF is not available
aguilard845c2ea2022-04-08 09:36:03 +0000157 Heal Network Service ${ns_id} --vnf ${vnf_charm_id} --cause "Heal VM of charm_vnf" --vdu ${vdu_charm_name} --count-index 1 --run-day1
158
159
160Check VNF After Healing
garciadeblasf4ebaa82022-06-23 13:33:26 +0200161 Variable Should Exist ${vnf_charm_id} msg=VNF is not available
aguilard845c2ea2022-04-08 09:36:03 +0000162
garciadeblasf4ebaa82022-06-23 13:33:26 +0200163 @{ip_list}= Get Vnf Vdur IPs ${vnf_charm_id}
aguilard845c2ea2022-04-08 09:36:03 +0000164 Should Be Equal ${ip_list} ${charm_ip_list} IP addresses have changed after healing
165
garciadeblasf4ebaa82022-06-23 13:33:26 +0200166 ${id}= Get VNF VIM ID ${vnf_charm_id}
167 @{ids}= Split String ${id}
aguilard845c2ea2022-04-08 09:36:03 +0000168 Should Be Equal ${vdu_charm_ids}[0] ${ids}[0] VDU[0] id has changed after healing
169 Should Not Be Equal ${vdu_charm_ids}[1] ${ids}[1] VDU[1] id has not changed after healing
170 Should Be Equal ${vdu_charm_ids}[2] ${ids}[2] VDU[2] id has changed after healing
171
garciadeblasf4ebaa82022-06-23 13:33:26 +0200172 ${ip}= Get Vdu Attribute ${vnf_charm_id} ip-address 1
aguilard845c2ea2022-04-08 09:36:03 +0000173 ${stdout}= Execute Remote Command Check Rc Return Output ${ip} ${username} ${password} ${privatekey} sudo ls ${vnf_charm_cloudinit_file}
garciadeblas321726f2022-12-21 11:43:06 +0100174 Log ${stdout}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200175 Check If remote File Exists ${ip} ${username} ${password} ${privatekey} ${vnf_charm_day1_file}
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500176 ${vim_info}= Get Vdu Attribute ${vnf_charm_id} vim_info
177 Should Contain ${vim_info} flavor: {id: ${flavor_id}, msg=Flavor ID is incorrect
aguilard845c2ea2022-04-08 09:36:03 +0000178
179
aguilardbd91f862022-12-20 15:13:02 +0000180Update VIM Objects
181 Variable Should Exist ${ns_id} msg=NS is not available
182 @{vdu_updated}= Create List
183 @{vnf_id_list}= Get Ns Vnf List ${ns_id}
184 FOR ${vnf_id} IN @{vnf_id_list}
185 ${id}= Get VNF VIM ID ${vnf_id}
186 @{vdu_ids}= Split String ${id}
187 Append To List ${vdu_updated} @{vdu_ids}
188 FOR ${id} IN @{vdu_ids}
189 IF not "${id}" in "@{vim_vdus}"
190 Append To List ${vim_vdus} ${id}
191 END
192 END
193 END
194 FOR ${vdu_id} IN @{vdu_updated}
195 ${volumes_attached}= Get Server Property ${vdu_id} volumes_attached
196 ${match}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1
197 IF ${match} != @{EMPTY}
198 IF not "${match}[0]" in "@{vim_volumes}"
199 Append To List ${vim_volumes} ${match}[0]
200 END
201 END
202 END
garciadeblas321726f2022-12-21 11:43:06 +0100203 Log Many @{vim_vdus}
204 Log Many @{vim_volumes}
aguilardbd91f862022-12-20 15:13:02 +0000205
206
aguilard845c2ea2022-04-08 09:36:03 +0000207Delete NS Instance
208 [Tags] cleanup
209 Delete NS ${ns_name}
210
211
212Delete NS Descriptor
213 [Tags] cleanup
214 Delete NSD ${nsd_name}
215
216
217Delete VNF Descriptors
218 [Tags] cleanup
219 Delete VNFD ${vnfd_volumes_name}
220 Delete VNFD ${vnfd_charm_name}
221
222
aguilardbd91f862022-12-20 15:13:02 +0000223Delete Objects in VIM
224 [Tags] cleanup
225 ${error}= Set Variable 0
226 FOR ${vol_id} IN @{vim_volumes}
garciadeblas321726f2022-12-21 11:43:06 +0100227 Log Checking if volume ${vol_id} is still in VIM
aguilardbd91f862022-12-20 15:13:02 +0000228 ${exists}= Check If Volume Exists ${vol_id}
229 IF ${exists}!=0
230 ${error}= Set Variable 1
garciadeblas321726f2022-12-21 11:43:06 +0100231 Log Deleting volume ${vol_id}
aguilardbd91f862022-12-20 15:13:02 +0000232 Run Keyword And Ignore Error Delete Volume ${vol_id}
233 END
234 END
235 FOR ${vdu_id} IN @{vim_vdus}
garciadeblas321726f2022-12-21 11:43:06 +0100236 Log Checking if server ${vdu_id} is still in VIM
aguilardbd91f862022-12-20 15:13:02 +0000237 ${status}= Run Keyword And Ignore Error Get Server Property ${vdu_id} id
garciadeblas321726f2022-12-21 11:43:06 +0100238 Log ${status}[0]
aguilardbd91f862022-12-20 15:13:02 +0000239 IF '${status}[0]' == 'PASS'
240 ${error}= Set Variable 1
garciadeblas321726f2022-12-21 11:43:06 +0100241 Log Deleting server ${vdu_id}
aguilardbd91f862022-12-20 15:13:02 +0000242 Run Keyword And Ignore Error Delete Server ${vdu_id}
243 END
244 END
245 IF ${error}==1
246 Fail Some objects created by test were not deleted in VIM
247 END
248
249
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500250Delete flavor
251 Delete Flavor ${flavor_id}
252
253
aguilard845c2ea2022-04-08 09:36:03 +0000254*** Keywords ***
255Suite Cleanup
garciadeblasf4ebaa82022-06-23 13:33:26 +0200256 [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim
aguilard845c2ea2022-04-08 09:36:03 +0000257
garciadeblasf4ebaa82022-06-23 13:33:26 +0200258 Run Keyword If Any Tests Failed Delete NS ${ns_name}
259 Run Keyword If Any Tests Failed Delete NSD ${nsd_name}
260 Run Keyword If Any Tests Failed Delete VNFD ${vnfd_volumes_name}
261 Run Keyword If Any Tests Failed Delete VNFD ${vnfd_charm_name}
aguilardbd91f862022-12-20 15:13:02 +0000262 Run Keyword If Any Tests Failed Delete Objects in VIM
Gabriel Cuba8f994cc2023-05-12 13:44:16 -0500263 Run Keyword If Any Tests Failed Delete Flavor ${flavor_id}