Apply cluster_heal tag to heal tests instead of cluster_main
[osm/tests.git] / robot-systest / testsuite / heal_04-autohealing.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-04] Autohealing of NS
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_04   cluster_heal   daily   regression
30
31 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
32
33
34 *** Variables ***
35 # NS and VNF descriptor package folder and ids
36 ${vnfd_pkg}   autoheal_vnf
37 ${vnfd_name}   autoheal_vnfd
38 ${vdu_name}   autoheal_vnfd-VM
39 ${vnf_index}   autoheal-basic-1
40 ${nsd_pkg}   autoheal_ns
41 ${nsd_name}   autoheal_nsd
42 # NS instance name and configuration
43 ${ns_name}   heal_04
44 ${ns_config}   {vld: [ {name: mgmt, vim-network-name: %{VIM_MGMT_NET}} ] }
45
46 # SSH keys and username to be used
47 ${publickey}   %{HOME}/.ssh/id_rsa.pub
48 ${privatekey}   %{HOME}/.ssh/id_rsa
49 ${username}   ubuntu
50 ${password}   ${EMPTY}
51
52 ${success_return_code}   0
53
54 #Healing wait time
55 ${healing_pol_time}   15sec
56 ${healing_max_wait_time}   10m
57
58 *** Test Cases ***
59 Create VNF Descriptors
60     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd_pkg}'
61
62
63 Create NS Descriptor
64     Create NSD   '%{PACKAGES_FOLDER}/${nsd_pkg}'
65
66
67 Network Service Instance Test
68     ${id}=   Create Network Service   ${nsd_name}   %{VIM_TARGET}   ${ns_name}   ${ns_config}   ${publickey}
69     Set Suite Variable   ${ns_id}   ${id}
70
71
72 Get NS Id
73     [Tags]   cleanup
74     ${variables}   Get Variables
75     IF   not "\${ns_id}" in "${variables}"
76         ${id}=   Get Ns Id   ${ns_name}
77         Set Suite Variable   ${ns_id}   ${id}
78     END
79
80
81 Get VNF Info
82     Variable Should Exist   ${ns_id}   msg=NS is not available
83     ${ip_addr}=   Get Vnf Management Ip Address   ${ns_id}   ${vnf_index}
84     log   ${ip_addr}
85     Set Suite Variable   ${vnf_ip_addr}   ${ip_addr}
86
87     ${vnf_id}=   Get Vnf Id   ${ns_id}   ${vnf_index}
88     Set Suite Variable   ${vnf_autoheal_id}   ${vnf_id}
89     ${id}=   Get VNF VIM ID   ${vnf_id}
90     Set Suite Variable   ${vdu_autoheal_id}   ${id}
91     log   ${vdu_autoheal_id}
92
93     @{autoheal_ip_list}=   Get Vnf Vdur IPs   ${vnf_autoheal_id}
94     Set Suite Variable   @{autoheal_ip_list}   @{autoheal_ip_list}
95     log   @{autoheal_ip_list}
96
97
98 Stop Autoheal VDU
99     Variable Should Exist   ${vdu_autoheal_id}   msg=VDU is not available
100     Halt Server   ${vdu_autoheal_id}
101     Sleep   30
102
103
104 Wait For Autohealing To Be Completed
105     ${healing_max_wait_time}=   Convert Time   ${healing_max_wait_time}   result_format=number
106     ${healing_max_wait_time}=   Evaluate   ${healing_max_wait_time} * ${vim_timeout_multiplier}
107     Wait Until Keyword Succeeds   ${healing_max_wait_time}   ${healing_pol_time}   Get Operations By Type   ${ns_id}   heal
108     ${stdout}=   Get Operations By Type   ${ns_id}   heal
109     Wait Until Keyword Succeeds   ${healing_max_wait_time}   ${healing_pol_time}   Check For NS Operation Ended   ${stdout}
110     Check For NS Operation Completed   ${stdout}
111
112
113 Check VNF After Healing
114     Variable Should Exist   ${vnf_autoheal_id}   msg=VNF is not available
115
116     @{ip_list}=   Get Vnf Vdur IPs   ${vnf_autoheal_id}
117     log   @{ip_list}
118     Should Be Equal   ${ip_list}   ${autoheal_ip_list}   IP addresses have changed after healing
119
120     ${id}=   Get VNF VIM ID   ${vnf_autoheal_id}
121     log   ${id}
122     Should Not Be Equal   ${id}   ${vdu_autoheal_id}   VDU id has not changed after healing
123
124
125 Delete NS Instance
126     [Tags]   cleanup
127     Delete NS   ${ns_name}
128
129
130 Delete NS Descriptor
131     [Tags]   cleanup
132     Delete NSD   ${nsd_name}
133
134
135 Delete VNF Descriptors
136     [Tags]   cleanup
137     Delete VNFD   ${vnfd_name}
138
139 *** Keywords ***
140 Suite Cleanup
141     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
142
143     Run Keyword If Any Tests Failed   Delete NS   ${ns_name}
144     Run Keyword If Any Tests Failed   Delete NSD   ${nsd_name}
145     Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_name}