Update tags in all testsuites
[osm/tests.git] / robot-systest / testsuite / slice_02-shared_network_slicing.robot
1 #   Copyright 2020 Atos
2 #
3 #   Licensed under the Apache License, Version 2.0 (the "License");
4 #   you may not use this file except in compliance with the License.
5 #   You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #   Unless required by applicable law or agreed to in writing, software
10 #   distributed under the License is distributed on an "AS IS" BASIS,
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #   See the License for the specific language governing permissions and
13 #   limitations under the License.
14
15 *** Settings ***
16 Documentation     [SLICE-02] Shared Network Slicing.
17
18 Library   OperatingSystem
19 Library   String
20 Library   Collections
21 Library   Process
22 Library   SSHLibrary
23
24 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
25 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
26 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nst_lib.robot
27 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nsi_lib.robot
28 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
29 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/connectivity_lib.robot
30 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
31
32 Variables   %{ROBOT_DEVOPS_FOLDER}/resources/slice_02-shared_network_slicing_data.py
33
34 Force Tags   slice_02   cluster_slices   daily   regression
35
36 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
37
38
39 *** Variables ***
40
41 ${ns_id}   ${EMPTY}
42 ${username}   ubuntu
43 ${password}   ${EMPTY}
44 ${vnf_member_index}   middle
45 ${vnf_ip_addr}   ${EMPTY}
46 ${nst_config}   {netslice-vld: [ {name: slice_vld_mgmt, vim-network-name: %{VIM_MGMT_NET}} ] }
47
48
49 *** Test Cases ***
50
51 Create Slice VNF Descriptors
52     [Documentation]   Onboards all the VNFDs required for the test: vnfd1_pkg and vnfd2_pkg (in the variables file)
53
54     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd1_pkg}'
55     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd2_pkg}'
56
57
58 Create Slice NS Descriptors
59     [Documentation]   Onboards all the NSDs required for the test: nsd1_pkg and nsd2_pkg (in the variables file)
60
61     Create NSD   '%{PACKAGES_FOLDER}/${nsd1_pkg}'
62     Create NSD   '%{PACKAGES_FOLDER}/${nsd2_pkg}'
63
64 Create Slice Templates
65     [Documentation]   Onboards the Network Slice Templates: nst, nst2 (in the variables file)
66
67     Create NST   '%{PACKAGES_FOLDER}/${nst}'
68     Create NST   '%{PACKAGES_FOLDER}/${nst2}'
69
70 Network Slice First Instance
71     [Documentation]   Instantiates the First NST recently onboarded (nst_name) and sets the instantiation id as a suite variable (nsi_id)
72     ...               The slice contains 3 NS (1 shared)
73
74     ${id}=   Create Network Slice       ${nst_name}   %{VIM_TARGET}   ${slice_name}   ${nst_config}   ${publickey}
75     Set Suite Variable   ${nsi_id}   ${id}
76
77
78 Network Slice Second Instance
79      [Documentation]   Instantiates the Second NST recently onboarded (nst2_name) and sets the instantiation id as a suite variable (nsi2_id)
80     ...               The slice contains 2 NS (1 shared)
81
82     ${id}=   Create Network Slice       ${nst2_name}   %{VIM_TARGET}   ${slice2_name}   ${nst_config}   ${publickey}
83     Set Suite Variable   ${nsi2_id}   ${id}
84
85
86 First Network Slice Ns Count
87     [Documentation]   Counts the NS in both slice instances and shoul be equal to 4
88
89     ${slice1_count}=   Get Slice Ns Count       ${slice_name}
90     ${slice2_count}=   Get Slice Ns Count       ${slice2_name}
91     ${together}=   Evaluate   ${slice1_count} + ${slice2_count}
92     Should Be Equal As Integers   ${together}   4
93
94
95 Get Middle Vnf Management Ip
96     [Documentation]   Obtains the management IP of the shared NS main (only) VNF and sets it as a suite variable (mgmt_vnf_ip)
97
98     ${middle_ns_id}=   Run and Return RC and Output   osm ns-list | grep ${middle_ns_name} | awk '{print $4}' 2>&1
99     ${vnf_ip}   Get Vnf Management Ip Address   ${middle_ns_id}[1]   ${vnf_member_index}
100     Run Keyword If   '${vnf_ip}' == '${EMPTY}'    Fatal Error    Variable \$\{ vnf_ip\} Empty
101     Set Suite Variable   ${mgmt_vnf_ip}   ${vnf_ip}
102
103
104 Get First Slice Vnf IPs
105     [Documentation]   Obtains the list of IPs addresses in the first slice and sets the list as a suite variable (slice1_vnfs_ips)
106
107     # Get all the ns_id in the slice except the middle one
108     @{ip_list}   Get Slice Vnf Ip Addresses   ${slice_name}
109     Should Be True   ${ip_list} is not None
110     Set Suite Variable   ${slice1_vnfs_ips}   ${ip_list}
111
112
113 Test Middle Ns Ping
114     [Documentation]   Pings the slice middle vnf (mgmt_vnf_ip)
115
116     Sleep   60s   Waiting for the network to be up
117     # Ping to the middle VNF
118     Test Connectivity  ${mgmt_vnf_ip}
119
120
121 Test Middle Vnf SSH Access
122     [Documentation]   SSH access to the slice middle vnf (mgmt_vnf_ip) with the credentials provided in the variables file
123
124     Sleep   30s   Waiting ssh daemon to be up
125     Test SSH Connection  ${mgmt_vnf_ip}  ${username}  ${password}  ${privatekey}
126
127
128 Test First Slice Connectivity
129     [Documentation]   SSH access to the slice middle vnf (mgmt_vnf_ip) with the credentials provided in the variables file
130     ...                 and pings all the IP addresses in the list (slice1_vnfs_ips)
131
132     Ping Many   ${mgmt_vnf_ip}  ${username}  ${password}  ${privatekey}   @{slice1_vnfs_ips}
133
134
135 Delete Slice One Instance
136     [Documentation]   Stops the slice instance (slice_name)
137
138     [Tags]   cleanup
139
140     Delete NSI   ${slice_name}
141
142
143 Second Network Slice Ns Count
144     [Documentation]   Counts the NS in both slice instances and should be equal to 2
145     
146     ${slice1_count}=   Get Slice Ns Count       ${slice_name}
147     ${slice2_count}=   Get Slice Ns Count       ${slice2_name}
148     ${together}=   Evaluate   ${slice1_count} + ${slice2_count}
149     Should Be Equal As Integers   ${together}   2
150
151 Get Second Slice Vnf IPs
152     [Documentation]   Obtains the list of IPs addresses in the second slice and sets the list as a suite variable (slice2_vnfs_ips)
153
154     # Get all the ns_id in the slice
155     @{ip_list}   Get Slice Vnf Ip Addresses   ${slice2_name}
156     Should Be True   ${ip_list} is not None
157     Set Suite Variable   ${slice2_vnfs_ips}   ${ip_list}
158
159
160 Test Second Slice Connectivity
161     [Documentation]   SSH access to the slice middle vnf (mgmt_vnf_ip) with the credentials provided in the variables file
162     ...                 and pings all the IP addresses in the list (slice2_vnfs_ips)
163
164     Ping Many   ${mgmt_vnf_ip}  ${username}  ${password}  ${privatekey}   @{slice2_vnfs_ips}
165
166
167 Delete Slice Two Instance
168     [Documentation]   Stops the slice instance (slice2_name)
169
170     [Tags]   cleanup
171
172     Delete NSI   ${slice2_name}
173
174
175 Delete Slice One Template
176     [Documentation]   Deletes the NST (nst_name) from OSM
177
178     [Tags]   cleanup
179
180     Delete NST   ${nst_name}
181
182
183 Delete Slice Two Template
184     [Documentation]   Deletes the NST (nst2_name) from OSM
185
186     [Tags]   cleanup
187
188     Delete NST   ${nst2_name}
189
190
191 Delete NS Descriptors
192     [Documentation]   Deletes all the NSDs created for the test: nsd1_name, nsd2_name
193
194     [Tags]   cleanup
195
196     Delete NSD   ${nsd1_name}
197     Delete NSD   ${nsd2_name}
198
199
200 Delete VNF Descriptors
201     [Documentation]   Deletes all the VNFDs created for the test: vnfd1_name, vnfd2_name
202
203     [Tags]   cleanup
204
205     Delete VNFD   ${vnfd1_name}
206     Delete VNFD   ${vnfd2_name}
207
208
209 *** Keywords ***
210 Suite Cleanup
211     [Documentation]  Test Suit Cleanup: Deleting Descriptors, instance and templates
212
213     Run Keyword If Any Tests Failed  Delete NSI   ${slice_name}
214     Run Keyword If Any Tests Failed  Delete NSI   ${slice2_name}
215
216     Run Keyword If Any Tests Failed  Delete NST   ${nst_name}
217     Run Keyword If Any Tests Failed  Delete NST   ${nst2_name}
218
219     Run Keyword If Any Tests Failed  Delete NSD   ${nsd1_name}
220     Run Keyword If Any Tests Failed  Delete NSD   ${nsd2_name}
221
222     Run Keyword If Any Tests Failed  Delete VNFD   ${vnfd1_name}
223     Run Keyword If Any Tests Failed  Delete VNFD   ${vnfd2_name}
224
225
226