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
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 Documentation [HEAL-03] Healing of multiple VDUs
18 Library OperatingSystem
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
32 Test Tags heal_03 cluster_heal daily
34 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
38 # NS and VNF descriptor package folder and ids
39 ${VNFD_VOLUMES_PKG} several_volumes_vnf
40 ${VNFD_VOLUMES_NAME} several_volumes-vnf
41 ${VDU_VOLUMES_NAME} several_volumes-VM
42 ${VNF_SEVERAL_INDEX} several_volumes_vnf
43 ${VNFD_CHARM_PKG} charm-packages/native_manual_scale_charm_vnf
44 ${VNFD_CHARM_NAME} native_manual_scale_charm-vnf
45 ${VDU_CHARM_NAME} mgmtVM
46 ${VNF_CHARM_INDEX} charm_vnf
47 ${VNF_CHARM_SCALING_GROUP} manual-scaling_mgmtVM
48 ${VNF_CHARM_CLOUDINIT_FILE} /root/helloworld.txt
49 ${VNF_CHARM_DAY1_FILE} /home/ubuntu/first-touch
50 ${NSD_PKG} volumes_nativecharm_ns
51 ${NSD_NAME} volumes_nativecharm-ns
53 # NS instance name and configuration
55 ${NS_CONFIG} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
57 ${SCALE_WAIT_TIME} 5min
59 # SSH keys and username to be used
60 ${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub
61 ${PRIVATEKEY} %{HOME}/.ssh/id_rsa
65 ${SUCCESS_RETURN_CODE} 0
68 @{VIM_VOLUMES} @{EMPTY}
72 Create VNF Descriptors
73 [Documentation] Upload VNF packages for the testsuite.
74 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_CHARM_PKG}'
75 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_VOLUMES_PKG}'
78 [Documentation] Upload NS package for the testsuite.
79 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
81 Network Service Instance Test
82 [Documentation] Instantiate NS for the testsuite.
83 ${id}= Create Network Service ${NSD_NAME} %{VIM_TARGET} ${NS_NAME} ${NS_CONFIG} ${PUBLICKEY} ${NS_TIMEOUT}
84 Set Suite Variable ${NS_ID} ${id}
87 [Documentation] Get NS identifier and stores as suite variable to be used later on.
89 ${variables}= Get Variables
90 IF not "\${ns_id}" in "${variables}"
91 ${id}= Get Ns Id ${NS_NAME}
92 Set Suite Variable ${NS_ID} ${id}
96 [Documentation] Perform a manual scale-out operation of the charm VNF.
97 ${vnf_id}= Get Vnf Id ${NS_ID} ${VNF_CHARM_INDEX}
98 Set Suite Variable ${VNF_CHARM_ID} ${vnf_id}
99 @{vdur_list}= Get Vnf Vdur Names ${VNF_CHARM_ID}
100 ${vdurs}= Get Length ${vdur_list}
101 Set Suite Variable ${INITIAL_VDUR_COUNT} ${vdurs}
102 Execute Manual VNF Scale ${NS_NAME} ${VNF_CHARM_INDEX} ${VNF_CHARM_SCALING_GROUP} SCALE_OUT ${SCALE_WAIT_TIME}
103 @{vdur_list}= Get Vnf Vdur Names ${VNF_CHARM_ID}
104 ${vdurs}= Get Length ${vdur_list}
105 IF ${vdurs} != ${INITIAL_VDUR_COUNT} + 1 Fail msg=There is no new VDU records in the VNF after Scale Out
108 [Documentation] Retrieve all VMs and volumes from the NS and stores them in VIM_VDUS and VIM_VOLUMES lists.
109 Variable Should Exist ${NS_ID} msg=NS is not available
110 @{vnf_id_list}= Get Ns Vnf List ${NS_ID}
112 FOR ${vnf_id} IN @{vnf_id_list}
114 ${id}= Get VNF VIM ID ${vnf_id}
115 @{vdu_ids}= Split String ${id}
116 Append To List ${VIM_VDUS} @{vdu_ids}
118 FOR ${vdu_id} IN @{VIM_VDUS}
119 ${volumes_attached}= Get Server Property ${vdu_id} volumes_attached
120 ${match}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1
121 IF ${match} != @{EMPTY}
122 IF not "${match}[0]" in "@{VIM_VOLUMES}"
123 Append To List ${VIM_VOLUMES} ${match}[0]
128 Log Many @{VIM_VOLUMES}
131 [Documentation] Get VDU ID and IP addresses of the charm VNF and stores them in VDU_CHARM_IDS and CHARM_IP_LIST.
132 Variable Should Exist ${NS_ID} msg=NS is not available
133 ${variables}= Get Variables
134 IF not "\${vnf_charm_id}" in "${variables}"
135 ${vnf_id}= Get Vnf Id ${NS_ID} ${VNF_CHARM_INDEX}
136 Set Suite Variable ${VNF_CHARM_ID} ${vnf_id}
138 ${id}= Get VNF VIM ID ${VNF_CHARM_ID}
139 @{vdu_charm_ids}= Split String ${id}
140 Set Suite Variable @{VDU_CHARM_IDS} @{vdu_charm_ids}
141 Log ${VDU_CHARM_IDS}[1]
142 @{charm_ip_list}= Get Vnf Vdur IPs ${VNF_CHARM_ID}
143 Set Suite Variable @{CHARM_IP_LIST} @{charm_ip_list}
146 [Documentation] Get info about volumes and VM of the VNF with several volumes and stores them in suite variables.
147 Variable Should Exist ${NS_ID} msg=NS is not available
148 ${ip_addr}= Get Vnf Management Ip Address ${NS_ID} ${VNF_SEVERAL_INDEX}
150 Set Suite Variable ${VNF_VOLUMES_IP_ADDR} ${ip_addr}
151 ${vnf_id}= Get Vnf Id ${NS_ID} ${VNF_SEVERAL_INDEX}
152 Set Suite Variable ${VNF_VOLUMES_ID} ${vnf_id}
153 ${id}= Get VNF VIM ID ${vnf_id}
154 Set Suite Variable ${VDU_VOLUMES_ID} ${id}
155 Log ${VDU_VOLUMES_ID}
156 @{volumes_ip_list}= Get Vnf Vdur IPs ${VNF_VOLUMES_ID}
157 Set Suite Variable @{VOLUMES_IP_LIST} @{volumes_ip_list}
158 Log @{VOLUMES_IP_LIST}
161 [Documentation] Stop all VMs.
162 Variable Should Exist @{VDU_CHARM_IDS} msg=Charm VDUs are not available
163 Variable Should Exist ${VDU_VOLUMES_ID} msg=Volume VDU is not available
164 Stop Server ${VDU_CHARM_IDS}[1]
165 Stop Server ${VDU_CHARM_IDS}[2]
166 Stop Server ${VDU_VOLUMES_ID}
170 [Documentation] Heal manually via OSM commands all stopped VMs . They should be started again.
171 Variable Should Exist ${VNF_CHARM_ID} msg=Charm VNF is not available
172 Variable Should Exist ${VNF_VOLUMES_ID} msg=Volume VNF is not available
173 Heal Network Service ${NS_ID} --vnf ${VNF_VOLUMES_ID} --cause "Heal myvdu1 of several_volumes_vnf" --vdu several_volumes-VM --vnf ${VNF_CHARM_ID} --cause "Heal two VMs of native_manual_scale_charm_vnf" --vdu mgmtVM --count-index 1 --run-day1 --vdu mgmtVM --count-index 2
175 Check VNFs After Healing
176 [Documentation] Check that the IDs of the VM and volumes have not changed after healing.
177 Variable Should Exist ${VNF_CHARM_ID} msg=Charm VNF is not available
178 Variable Should Exist ${VNF_VOLUMES_ID} msg=Volume VNF is not available
179 ${id}= Get VNF VIM ID ${VNF_CHARM_ID}
180 @{ids}= Split String ${id}
181 Should Be Equal ${VDU_CHARM_IDS}[0] ${ids}[0] VDU[0] id has changed after healing
182 Should Not Be Equal ${VDU_CHARM_IDS}[1] ${ids}[1] VDU[1] id has not changed after healing
183 Should Not Be Equal ${VDU_CHARM_IDS}[2] ${ids}[2] VDU[2] id has not changed after healing
184 ${id}= Get VNF VIM ID ${VNF_VOLUMES_ID}
185 Should Not Be Equal ${id} ${VDU_VOLUMES_ID} VDU id has not changed after healing
186 ${ip}= Get Vdu Attribute ${VNF_CHARM_ID} ip-address 1
187 ${stdout}= Execute Remote Command Check Rc Return Output ${ip} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} sudo ls ${VNF_CHARM_CLOUDINIT_FILE}
189 Check If Remote File Exists ${ip} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} ${VNF_CHARM_DAY1_FILE}
192 [Documentation] Retrieve all VMs and volumes from the NS and stores them in VIM_VDUS and VIM_VOLUMES lists.
193 ... This is done again to guarantee that all objects are cleaned in the VIM in case the heal operation
194 ... added new objects.
195 Variable Should Exist ${NS_ID} msg=NS is not available
196 @{vdu_updated}= Create List
197 @{vnf_id_list}= Get Ns Vnf List ${NS_ID}
198 FOR ${vnf_id} IN @{vnf_id_list}
199 ${id}= Get VNF VIM ID ${vnf_id}
200 @{vdu_ids}= Split String ${id}
201 Append To List ${vdu_updated} @{vdu_ids}
202 FOR ${id} IN @{vdu_ids}
203 IF not "${id}" in "@{VIM_VDUS}"
204 Append To List ${VIM_VDUS} ${id}
208 FOR ${vdu_id} IN @{vdu_updated}
209 ${volumes_attached}= Get Server Property ${vdu_id} volumes_attached
210 ${match}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1
211 IF ${match} != @{EMPTY}
212 IF not "${match}[0]" in "@{VIM_VOLUMES}"
213 Append To List ${VIM_VOLUMES} ${match}[0]
218 Log Many @{VIM_VOLUMES}
221 [Documentation] Delete NS instance.
226 [Documentation] Delete NS package from OSM.
228 Delete NSD ${NSD_NAME}
230 Delete VNF Descriptors
231 [Documentation] Delete VNF packages from OSM.
233 Delete VNFD ${VNFD_VOLUMES_NAME}
234 Delete VNFD ${VNFD_CHARM_NAME}
236 Delete Objects In VIM
237 [Documentation] Delete any remaining objects (volumes, VMs, etc.) in the VIM.
239 ${error}= Set Variable 0
240 FOR ${vol_id} IN @{VIM_VOLUMES}
241 Log Checking if volume ${vol_id} is still in VIM
242 ${exists}= Check If Volume Exists ${vol_id}
244 ${error}= Set Variable 1
245 Log Deleting volume ${vol_id}
246 Run Keyword And Ignore Error Delete Volume ${vol_id}
249 FOR ${vdu_id} IN @{VIM_VDUS}
250 Log Checking if server ${vdu_id} is still in VIM
251 ${status}= Run Keyword And Ignore Error Get Server Property ${vdu_id} id
253 IF '${status}[0]' == 'PASS'
254 ${error}= Set Variable 1
255 Log Deleting server ${vdu_id}
256 Run Keyword And Ignore Error Delete Server ${vdu_id}
260 Fail Some objects created by test were not deleted in VIM
266 [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim
267 Run Keyword If Any Tests Failed Delete NS ${NS_NAME}
268 Run Keyword If Any Tests Failed Delete NSD ${NSD_NAME}
269 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_VOLUMES_NAME}
270 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_CHARM_NAME}