f53415721b995da27a31e4612c17eff11a37b81f
[osm/tests.git] / robot-systest / testsuite / heal_03-multiple_healing.robot
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-03] Healing of multiple VDUs
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
29 Force Tags   heal_03   cluster_heal   daily   regression
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
52 ${ns_name}   heal_03
53 ${ns_config}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
54 ${scale_wait_time}   4min
55
56 # SSH keys and username to be used
57 ${publickey}   %{HOME}/.ssh/id_rsa.pub
58 ${privatekey}   %{HOME}/.ssh/id_rsa
59 ${username}   ubuntu
60 ${password}   ${EMPTY}
61
62 ${success_return_code}   0
63
64
65 *** Test Cases ***
66 Create VNF Descriptors
67     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd_charm_pkg}'
68     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd_volumes_pkg}'
69
70
71 Create NS Descriptor
72     Create NSD   '%{PACKAGES_FOLDER}/${nsd_pkg}'
73
74
75 Network Service Instance Test
76     ${id}=   Create Network Service   ${nsd_name}   %{VIM_TARGET}   ${ns_name}   ${ns_config}   ${publickey}
77     Set Suite Variable   ${ns_id}   ${id}
78
79
80 Get NS Id
81     [Tags]   cleanup
82     ${variables}   Get Variables
83     IF   not "\${ns_id}" in "${variables}"
84         ${id}=   Get Ns Id   ${ns_name}
85         Set Suite Variable   ${ns_id}   ${id}
86     END
87
88
89 Scale Out Charm VNF
90     ${vnf_id}=   Get Vnf Id   ${ns_id}   ${vnf_charm_index}
91     Set Suite Variable   ${vnf_charm_id}   ${vnf_id}
92     @{vdur_list}=   Get Vnf Vdur Names   ${vnf_charm_id}
93     ${vdurs}=   Get Length   ${vdur_list}
94     Set Suite Variable   ${initial_vdur_count}   ${vdurs}
95     Execute Manual VNF Scale   ${ns_name}   ${vnf_charm_index}   ${vnf_charm_scaling_group}   SCALE_OUT   ${scale_wait_time}
96     @{vdur_list}=   Get Vnf Vdur Names   ${vnf_charm_id}
97     ${vdurs}=   Get Length   ${vdur_list}
98     Run Keyword If   ${vdurs} != ${initial_vdur_count} + 1   Fail   msg=There is no new VDU records in the VNF after Scale Out
99
100
101 Get Charm VNF Info
102     Variable Should Exist   ${ns_id}   msg=NS is not available
103     ${variables}   Get Variables
104     IF   not "\${vnf_charm_id}" in "${variables}"
105         ${vnf_id}=   Get Vnf Id   ${ns_id}   ${vnf_charm_index}
106         Set Suite Variable   ${vnf_charm_id}   ${vnf_id}
107     END
108     ${id}=   Get VNF VIM ID   ${vnf_charm_id}
109     @{vdu_charm_ids}=   Split String   ${id}
110     Set Suite Variable   @{vdu_charm_ids}   @{vdu_charm_ids}
111     log   ${vdu_charm_ids}[1]
112     @{charm_ip_list}=   Get Vnf Vdur IPs   ${vnf_charm_id}
113     Set Suite Variable   @{charm_ip_list}   @{charm_ip_list}
114
115
116 Get Volume VNF Info
117     Variable Should Exist   ${ns_id}   msg=NS is not available
118     ${ip_addr}=   Get Vnf Management Ip Address   ${ns_id}   ${vnf_several_index}
119     log   ${ip_addr}
120     Set Suite Variable   ${vnf_volumes_ip_addr}   ${ip_addr}
121
122     ${vnf_id}=   Get Vnf Id   ${ns_id}   ${vnf_several_index}
123     Set Suite Variable   ${vnf_volumes_id}   ${vnf_id}
124     ${id}=   Get VNF VIM ID   ${vnf_id}
125     Set Suite Variable   ${vdu_volumes_id}   ${id}
126     log   ${vdu_volumes_id}
127
128     @{volumes_ip_list}=   Get Vnf Vdur IPs   ${vnf_volumes_id}
129     Set Suite Variable   @{volumes_ip_list}   @{volumes_ip_list}
130     log   @{volumes_ip_list}
131
132
133 Stop VDUs
134     Variable Should Exist   @{vdu_charm_ids}   msg=Charm VDUs are not available
135     Variable Should Exist   ${vdu_volumes_id}   msg=Volume VDU is not available
136     Stop Server   ${vdu_charm_ids}[1]
137     Stop Server   ${vdu_charm_ids}[2]
138     Stop Server   ${vdu_volumes_id}
139     Sleep   30
140
141
142 Heal VDUs
143     Variable Should Exist   ${vnf_charm_id}   msg=Charm VNF is not available
144     Variable Should Exist   ${vnf_volumes_id}   msg=Volume VNF is not available
145     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
146
147
148 Check VNFs After Healing
149     Variable Should Exist   ${vnf_charm_id}   msg=Charm VNF is not available
150     Variable Should Exist   ${vnf_volumes_id}   msg=Volume VNF is not available
151     ${id}=   Get VNF VIM ID   ${vnf_charm_id}
152     @{ids}=   Split String   ${id}
153     Should Be Equal   ${vdu_charm_ids}[0]   ${ids}[0]   VDU[0] id has changed after healing
154     Should Not Be Equal   ${vdu_charm_ids}[1]   ${ids}[1]   VDU[1] id has not changed after healing
155     Should Not Be Equal   ${vdu_charm_ids}[2]   ${ids}[2]   VDU[2] id has not changed after healing
156
157     ${id}=   Get VNF VIM ID   ${vnf_volumes_id}
158     Should Not Be Equal   ${id}   ${vdu_volumes_id}   VDU id has not changed after healing
159
160     ${ip}=   Get Vdu Attribute   ${vnf_charm_id}   ip-address   1
161     ${stdout}=   Execute Remote Command Check Rc Return Output   ${ip}   ${username}   ${password}   ${privatekey}   sudo ls ${vnf_charm_cloudinit_file}
162     log   ${stdout}
163     Check If remote File Exists   ${ip}   ${username}   ${password}   ${privatekey}   ${vnf_charm_day1_file}
164
165
166 Delete NS Instance
167     [Tags]   cleanup
168     Delete NS   ${ns_name}
169
170
171 Delete NS Descriptor
172     [Tags]   cleanup
173     Delete NSD   ${nsd_name}
174
175
176 Delete VNF Descriptors
177     [Tags]   cleanup
178     Delete VNFD   ${vnfd_volumes_name}
179     Delete VNFD   ${vnfd_charm_name}
180
181
182 *** Keywords ***
183 Suite Cleanup
184     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
185
186     Run Keyword If Any Tests Failed   Delete NS   ${ns_name}
187     Run Keyword If Any Tests Failed   Delete NSD   ${nsd_name}
188     Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_volumes_name}
189     Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_charm_name}