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-04] Autohealing of NS
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_04 cluster_heal daily regression
34 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
38 # NS and VNF descriptor package folder and ids
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
45 # NS instance name and configuration
47 ${NS_CONFIG} {vld: [ {name: mgmt, vim-network-name: %{VIM_MGMT_NET}} ] }
49 # SSH keys and username to be used
50 ${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub
51 ${PRIVATEKEY} %{HOME}/.ssh/id_rsa
55 ${SUCCESS_RETURN_CODE} 0
58 ${HEALING_POL_TIME} 15sec
59 ${HEALING_MAX_WAIT_TIME} 10m
65 Create VNF Descriptors
66 [Documentation] Upload VNF package for the testsuite.
67 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG}'
70 [Documentation] Upload NS package for the testsuite.
71 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
73 Network Service Instance Test
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}
79 [Documentation] Get NS identifier and stores as suite variable to be used later on.
81 ${variables}= Get Variables
82 IF not "\${ns_id}" in "${variables}"
83 ${id}= Get Ns Id ${NS_NAME}
84 Set Suite Variable ${NS_ID} ${id}
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}
92 FOR ${vnf_id} IN @{vnf_id_list}
94 ${id}= Get VNF VIM ID ${vnf_id}
95 @{vdu_ids}= Split String ${id}
96 Append To List ${VIM_VDUS} @{vdu_ids}
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}
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}
108 ${id}= Get VNF VIM ID ${vnf_id}
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}
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}
121 Wait For Autohealing To Be Completed
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}
128 Check For NS Operation Completed ${stdout}
130 Check VNF After Healing
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}
135 Should Be Equal ${ip_list} ${AUTOHEAL_IP_LIST} IP addresses have changed after healing
136 ${id}= Get VNF VIM ID ${VNF_AUTOHEAL_ID}
138 Should Not Be Equal ${id} ${VDU_AUTOHEAL_ID} VDU id has not changed after healing
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}
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}
150 IF not "${id}" in "@{VIM_VDUS}"
151 Append To List ${VIM_VDUS} ${id}
158 [Documentation] Delete NS instance.
163 [Documentation] Delete NS package from OSM.
165 Delete NSD ${NSD_NAME}
167 Delete VNF Descriptors
168 [Documentation] Delete VNF package from OSM.
170 Delete VNFD ${VNFD_NAME}
172 Delete Objects In VIM
173 [Documentation] Delete any remaining objects (volumes, VMs, etc.) in the VIM.
175 ${error}= Set Variable 0
176 FOR ${vdu_id} IN @{VIM_VDUS}
177 Log Checking if server ${vdu_id} is still in VIM
178 ${status}= Run Keyword And Ignore Error Get Server Property ${vdu_id} id
180 IF '${status}[0]' == 'PASS'
181 ${error}= Set Variable 1
182 Log Deleting server ${vdu_id}
183 Run Keyword And Ignore Error Delete Server ${vdu_id}
187 Fail Some objects created by test were not deleted in VIM
193 [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim
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}