Initial tests contributions
[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 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/nsd_lib.robot
24 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nst_lib.robot
25 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nsi_lib.robot
26 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
27 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/connectivity_lib.robot
28 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
29
30 Variables   %{ROBOT_DEVOPS_FOLDER}/resources/slice_02-shared_network_slicing_data.py
31
32 Suite Teardown   Run Keyword And Ignore Error   Test Cleanup
33
34
35 *** Variables ***
36
37 ${ns_id}   ${EMPTY}
38 ${username}   ubuntu
39 ${password}   ${EMPTY}
40 ${vnf_member_index}   middle
41 ${vnf_ip_addr}   ${EMPTY}
42 ${nst_config}   {netslice-vld: [ {name: slice_vld_mgmt, vim-network-name: %{VIM_MGMT_NET}} ] }
43
44
45 *** Test Cases ***
46
47 Create Slice VNF Descriptors
48     [Documentation]   Onboards all the VNFDs required for the test: vnfd1_pkg and vnfd2_pkg (in the variables file)
49
50     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
51
52     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd1_pkg}'
53     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd2_pkg}'
54
55
56 Create Slice NS Descriptors
57     [Documentation]   Onboards all the NSDs required for the test: nsd1_pkg and nsd2_pkg (in the variables file)
58
59     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
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     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
68
69     Create NST   '%{PACKAGES_FOLDER}/${nst}'
70     Create NST   '%{PACKAGES_FOLDER}/${nst2}'
71
72 Network Slice First Instance
73     [Documentation]   Instantiates the First NST recently onboarded (nst_name) and sets the instantiation id as a suite variable (nsi_id)
74     ...               The slice contains 3 NS (1 shared)
75
76     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
77
78     ${id}=   Create Network Slice       ${nst_name}   %{VIM_TARGET}   ${slice_name}   ${nst_config}   ${publickey}
79     Set Suite Variable   ${nsi_id}   ${id}
80
81
82 Network Slice Second Instance
83      [Documentation]   Instantiates the Second NST recently onboarded (nst2_name) and sets the instantiation id as a suite variable (nsi2_id)
84     ...               The slice contains 2 NS (1 shared)
85
86     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
87
88     ${id}=   Create Network Slice       ${nst2_name}   %{VIM_TARGET}   ${slice2_name}   ${nst_config}   ${publickey}
89     Set Suite Variable   ${nsi2_id}   ${id}
90
91
92 First Network Slice Ns Count
93     [Documentation]   Counts the NS in both slice instances and shoul be equal to 4
94
95     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
96
97     ${slice1_count}=   Get Slice Ns Count       ${slice_name}
98     ${slice2_count}=   Get Slice Ns Count       ${slice2_name}
99     ${together}=   Evaluate   ${slice1_count} + ${slice2_count}
100     Should Be Equal As Integers   ${together}   4
101
102
103 Get Middle Vnf Management Ip
104     [Documentation]   Obtains the management IP of the shared NS main (only) VNF and sets it as a suite variable (mgmt_vnf_ip)
105
106     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
107
108     ${middle_ns_id}=   Run and Return RC and Output   osm ns-list | grep ${middle_ns_name} | awk '{print $4}' 2>&1
109     ${vnf_ip}   Get Vnf Management Ip Address   ${middle_ns_id}[1]   ${vnf_member_index}
110     Run Keyword If   '${vnf_ip}' == '${EMPTY}'    Fatal Error    Variable \$\{ vnf_ip\} Empty
111     Set Suite Variable   ${mgmt_vnf_ip}   ${vnf_ip}
112
113
114 Get First Slice Vnf IPs
115     [Documentation]   Obtains the list of IPs addresses in the first slice and sets the list as a suite variable (slice1_vnfs_ips)
116
117     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
118
119     # Get all the ns_id in the slice except the middle one
120     @{ip_list}   Get Slice Vnf Ip Addresses   ${slice_name}
121     Should Be True   ${ip_list} is not None
122     Set Suite Variable   ${slice1_vnfs_ips}   ${ip_list}
123
124
125 Test Middle Ns Ping
126     [Documentation]   Pings the slice middle vnf (mgmt_vnf_ip)
127
128     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
129
130     Sleep   60s   Waiting for the network to be up
131     # Ping to the middle VNF
132     Test Connectivity  ${mgmt_vnf_ip}
133
134
135 Test Middle Vnf SSH Access
136     [Documentation]   SSH access to the slice middle vnf (mgmt_vnf_ip) with the credentials provided in the variables file
137
138     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
139
140     Sleep   30s   Waiting ssh daemon to be up
141     Test SSH Connection  ${mgmt_vnf_ip}  ${username}  ${password}  ${privatekey}
142
143
144 Test First Slice Connectivity
145     [Documentation]   SSH access to the slice middle vnf (mgmt_vnf_ip) with the credentials provided in the variables file
146     ...                 and pings all the IP addresses in the list (slice1_vnfs_ips)
147
148     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
149
150     Ping Many   ${mgmt_vnf_ip}  ${username}  ${password}  ${privatekey}   @{slice1_vnfs_ips}
151
152
153 Stop Slice One Instance
154     [Documentation]   Stops the slice instance (slice_name)
155
156     [Tags]   shared_network_slicing   SLICING-02   sanity   regression   cleanup
157
158     Delete NSI   ${slice_name}
159
160
161 Second Network Slice Ns Count
162     [Documentation]   Counts the NS in both slice instances and should be equal to 2
163     
164     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
165
166     ${slice1_count}=   Get Slice Ns Count       ${slice_name}
167     ${slice2_count}=   Get Slice Ns Count       ${slice2_name}
168     ${together}=   Evaluate   ${slice1_count} + ${slice2_count}
169     Should Be Equal As Integers   ${together}   2
170
171 Get Second Slice Vnf IPs
172     [Documentation]   Obtains the list of IPs addresses in the second slice and sets the list as a suite variable (slice2_vnfs_ips)
173
174     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
175
176     # Get all the ns_id in the slice
177     @{ip_list}   Get Slice Vnf Ip Addresses   ${slice2_name}
178     Should Be True   ${ip_list} is not None
179     Set Suite Variable   ${slice2_vnfs_ips}   ${ip_list}
180
181
182 Test Second Slice Connectivity
183     [Documentation]   SSH access to the slice middle vnf (mgmt_vnf_ip) with the credentials provided in the variables file
184     ...                 and pings all the IP addresses in the list (slice2_vnfs_ips)
185
186     [Tags]   shared_network_slicing   SLICING-02   sanity   regression
187
188     Ping Many   ${mgmt_vnf_ip}  ${username}  ${password}  ${privatekey}   @{slice2_vnfs_ips}
189
190
191 Stop Slice Two Instance
192     [Documentation]   Stops the slice instance (slice2_name)
193
194     [Tags]   shared_network_slicing   SLICING-02   sanity   regression   cleanup
195
196     Delete NSI   ${slice2_name}
197
198
199 Delete Slice One Template
200     [Documentation]   Deletes the NST (nst_name) from OSM
201
202     [Tags]   shared_network_slicing   SLICING-02   sanity   regression   cleanup
203
204     Delete NST   ${nst_name}
205
206
207 Delete Slice Two Template
208     [Documentation]   Deletes the NST (nst2_name) from OSM
209
210     [Tags]   shared_network_slicing   SLICING-02   sanity   regression   cleanup
211
212     Delete NST   ${nst2_name}
213
214
215 Delete NS Descriptors
216     [Documentation]   Deletes all the NSDs created for the test: nsd1_name, nsd2_name
217
218     [Tags]   shared_network_slicing   SLICING-02   sanity   regression   cleanup
219
220     Delete NSD   ${nsd1_name}
221     Delete NSD   ${nsd2_name}
222
223
224 Delete VNF Descriptors
225     [Documentation]   Deletes all the VNFDs created for the test: vnfd1_name, vnfd2_name
226
227     [Tags]   shared_network_slicing   SLICING-02   sanity   regression   cleanup
228
229     Delete VNFD   ${vnfd1_name}
230     Delete VNFD   ${vnfd2_name}
231
232
233 *** Keywords ***
234 Test Cleanup
235     [Documentation]  Test Suit Cleanup: Deleting Descriptors, instance and templates
236
237     Run Keyword If Test Failed  Delete NST   ${nst_name}
238     Run Keyword If Test Failed  Delete NST   ${nst2_name}
239
240     Run Keyword If Test Failed  Delete NSD   ${nsd1_name}
241     Run Keyword If Test Failed  Delete NSD   ${nsd2_name}
242
243     Run Keyword If Test Failed  Delete VNFD   ${vnfd1_name}
244     Run Keyword If Test Failed  Delete VNFD   ${vnfd2_name}
245
246
247