Test for 1609 bug
[osm/tests.git] / robot-systest / testsuite / basic_20-manual_native_charm_vdu_scaling.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     [BASIC-20] Manual VDU Scaling to test juju applications are scaling for native charms (testing Bug-1609).
15
16 Library   OperatingSystem
17 Library   String
18 Library   Collections
19
20 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
21 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
22 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
23 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
24
25 Force Tags   basic_20   cluster_main   daily   regression
26
27 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
28
29
30 *** Variables ***
31 # NS and VNF descriptor package folder and ids
32 ${vnfd_pkg}   charm-packages/native_manual_scale_charm_vnf
33 ${vnfd_name}   native_manual_scale_charm-vnf
34 ${nsd_pkg}   charm-packages/native_manual_scale_charm_ns
35 ${nsd_name}   native_manual_scale_charm-ns
36
37 # NS instance name and configuration
38 ${ns_name}   basic_20_manual_vdu_scaling_test
39 ${ns_config}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
40 ${vnf_member_index}  1
41
42 # SSH public key file
43 ${publickey}   %{HOME}/.ssh/id_rsa.pub
44
45 # Scaling group name of VDU instances
46 ${scaling_group}   manual-scaling_mgmtVM
47
48 *** Test Cases ***
49 Create VNF Descriptor
50
51     Create VNFD  '%{PACKAGES_FOLDER}/${vnfd_pkg}'
52
53 Create NS Descriptor
54
55     Create NSD  '%{PACKAGES_FOLDER}/${nsd_pkg}'
56
57
58 Instantiate Network Service
59
60     ${id}=  Create Network Service  ${nsd_name}  %{VIM_TARGET}  ${ns_name}  ${ns_config}  ${publickey}
61     Set Suite Variable  ${ns_id}  ${id}
62
63
64 Get Vnf Id
65
66     Variable Should Exist  ${ns_id}  msg=Network service instance is not available
67     @{vnfr_list}=  Get Ns Vnfr Ids  ${ns_id}
68     Log List  ${vnfr_list}
69     Set Suite Variable  ${vnf_id}  ${vnfr_list}[0]
70
71
72 Get Vdus Before Scale Out
73     [Documentation]     Get the number of VDU records before the manual scaling.
74
75     @{vdur_list}=  Get Vnf Vdur Names  ${vnf_id}
76     Log List  ${vdur_list}
77     ${vdurs}=  Get Length  ${vdur_list}
78     Set Suite Variable  ${initial_vdur_count}  ${vdurs}
79
80
81 Get Application Name Before Scale Out
82     [Documentation]    Get the application names.
83
84     @{name_list}=  Get Application Names  ${ns_name}
85     Log List  ${name_list}
86     Set Suite Variable  ${application_list}  ${name_list}
87
88
89 Check Number of Duplicated Application Name Before Scale Out
90     [Documentation]    Check the application names if there are 2 application name in the application list.
91
92     ${count_duplicated}=  Get Length  ${application_list}
93     Run Keyword Unless  ${count_duplicated} == 2  Fail  msg=There are not 2 application name in the application list before Scale Out
94
95
96 Check Number of not Duplicated Application Name Before Scale Out
97     [Documentation]    Check the application if there is only one application in the Juju model.
98
99     ${app_list}=  Remove Duplicates  ${application_list}
100     Log List  ${app_list}
101     ${count}=  Get Length  ${app_list}
102     Run Keyword Unless  1 == ${count}  Fail  msg=There is not only 1 application in the Juju model before Scale Out
103
104
105 Perform Manual Vdu Scale Out
106
107     Variable Should Exist  ${ns_id}  msg=Network service instance is not available
108     ${ns_op_id}=  Execute Manual VNF Scale  ${ns_name}  ${vnf_member_index}  ${scaling_group}  SCALE_OUT
109
110
111 Check Vdus After Scale Out
112     [Documentation]     Check whether there is one more VDU after scaling or not.
113
114     Variable Should Exist  ${ns_id}  msg=Network service instance is not available
115     @{vdur_list}=  Get Vnf Vdur Names  ${vnf_id}
116     Log List  ${vdur_list}
117     ${vdurs}=  Get Length  ${vdur_list}
118     Run Keyword Unless  ${vdurs} == ${initial_vdur_count} + 1  Fail  msg=There is no new VDU records in the VNF after Scale Out
119
120
121 Get Application Name After Scale Out
122     [Documentation]    Get the application names.
123
124     @{name_list}=  Get Application Names  ${ns_name}
125     Log List  ${name_list}
126     Set Suite Variable  ${application_list}  ${name_list}
127
128
129 Check Number of Duplicated Application Name After Scale Out
130     [Documentation]    Check the application names if there are 3 application name in the application list.
131
132     ${count_duplicated}=  Get Length  ${application_list}
133     Run Keyword Unless  ${count_duplicated} == 3  Fail  msg=There are not 2 application name in the application list after Scale Out
134
135
136 Check Number of not Duplicated Application Name After Scale Out
137     [Documentation]    Check the application if there is only one application in the Juju model.
138
139     ${app_list}=  Remove Duplicates  ${application_list}
140     Log List  ${app_list}
141     ${count}=  Get Length  ${app_list}
142     Run Keyword Unless  1 == ${count}  Fail  msg=There is not only 1 application in the Juju model after Scale Out
143
144
145 Perform Manual Vdu Scale In
146
147     Variable Should Exist  ${ns_id}  msg=Network service instance is not available
148     ${ns_op_id}=  Execute Manual VNF Scale  ${ns_name}  ${vnf_member_index}  ${scaling_group}  SCALE_IN
149
150
151 Check Vdus After Scaling In
152     [Documentation]     Check whether there is one less VDU after scaling or not.
153
154     Variable Should Exist  ${ns_id}  msg=Network service instance is not available
155     @{vdur_list}=  Get Vnf Vdur Names  ${vnf_id}
156     Log List  ${vdur_list}
157     ${vdurs}=  Get Length  ${vdur_list}
158     Run Keyword Unless  ${vdurs} == ${initial_vdur_count}  Fail  msg=There is the same number of VDU records in the VNF after Scale In
159
160
161 Get Application Name After Scale In
162     [Documentation]    Get the application names.
163
164     @{name_list}=  Get Application Names  ${ns_name}
165     Log List  ${name_list}
166     Set Suite Variable  ${application_list}  ${name_list}
167
168
169 Check Number of Duplicated Application Name After Scale In
170     [Documentation]    Check the application names if there are 2 application name in the application list.
171
172     ${count_duplicated}=  Get Length  ${application_list}
173     Run Keyword Unless  ${count_duplicated} == 2  Fail  msg=There are not 2 application name in the application list after Scale In
174
175
176 Check Number of not Duplicated Application Name After Scale In
177     [Documentation]    Check the application if there is only one application in the Juju model.
178
179     ${app_list}=  Remove Duplicates  ${application_list}
180     Log List  ${app_list}
181     ${count}=  Get Length  ${app_list}
182     Run Keyword Unless  1 == ${count}  Fail  msg=There is not only 1 application in the Juju model after Scale In
183
184
185 Delete NS Instance
186     [Tags]   cleanup
187
188     Delete NS  ${ns_name}
189
190
191 Delete NS Descriptor
192     [Tags]   cleanup
193
194     Delete NSD  ${nsd_name}
195
196
197 Delete VNF Descriptor
198     [Tags]   cleanup
199
200     Delete VNFD  ${vnfd_name}
201
202
203 *** Keywords ***
204 Suite Cleanup
205     [Documentation]  Test Suite Cleanup: Deleting descriptors and NS instance
206
207     Run Keyword If Any Tests Failed  Delete NS  ${ns_name}
208
209     Run Keyword If Any Tests Failed  Delete NSD  ${nsd_name}
210
211     Run Keyword If Any Tests Failed  Delete VNFD  ${vnfd_name}
212