Python3: resources and libraries
[csit.git] / resources / libraries / robot / shared / testing_path.robot
1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | resources.libraries.python.InterfaceUtil
16 | Library | resources.libraries.python.NodePath
17
18 *** Keywords ***
19 | Configure path in 2-node circular topology
20 | | [Documentation] | Compute path for testing on two given nodes in circular
21 | | ... | topology and set corresponding test case variables.
22 | |
23 | | ... | *Arguments:*
24 | | ... | - ${tg_node} - TG node. Type: dictionary
25 | | ... | - ${dut_node} - DUT node. Type: dictionary
26 | | ... | - ${tg2_node} - Node where the path ends. Must be the same as TG node
27 | | ... | parameter in circular topology. Type: dictionary
28 | |
29 | | ... | *Return:*
30 | | ... | - No value returned
31 | |
32 | | ... | _NOTE:_ This KW sets following test case variables:
33 | | ... | - ${tg_node} - TG node.
34 | | ... | - ${tg_to_dut_if1} - 1st TG interface towards DUT.
35 | | ... | - ${tg_to_dut_if2} - 2nd TG interface towards DUT.
36 | | ... | - ${dut_node} - DUT node.
37 | | ... | - ${dut_to_tg_if1} - 1st DUT interface towards TG.
38 | | ... | - ${dut_to_tg_if2} - 2nd DUT interface towards TG.
39 | | ... | - ${tg_to_dut_if1_mac}
40 | | ... | - ${tg_to_dut_if2_mac}
41 | | ... | - ${dut_to_tg_if1_mac}
42 | | ... | - ${dut_to_tg_if2_mac}
43 | |
44 | | ... | *Example:*
45 | |
46 | | ... | \| Given Configure path in 2-node circular topology \| ${nodes['TG']} \
47 | | ... | \| ${nodes['DUT1']} \| ${nodes['TG']} \|
48 | |
49 | | [Arguments] | ${tg_node} | ${dut_node} | ${tg2_node}
50 | | Should Be Equal | ${tg_node} | ${tg2_node}
51 | | Append Nodes | ${tg_node} | ${dut_node} | ${tg_node}
52 | | Compute Path | always_same_link=${FALSE}
53 | | ${tg_to_dut_if1} | ${tmp}= | First Interface
54 | | ${tg_to_dut_if2} | ${tmp}= | Last Interface
55 | | ${dut_to_tg_if1} | ${tmp}= | First Ingress Interface
56 | | ${dut_to_tg_if2} | ${tmp}= | Last Egress Interface
57 | | ${tg_to_dut_if1_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut_if1}
58 | | ${tg_to_dut_if2_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut_if2}
59 | | ${dut_to_tg_if1_mac}= | Get interface mac | ${dut_node} | ${dut_to_tg_if1}
60 | | ${dut_to_tg_if2_mac}= | Get interface mac | ${dut_node} | ${dut_to_tg_if2}
61 | | Set Test Variable | ${tg_to_dut_if1}
62 | | Set Test Variable | ${tg_to_dut_if2}
63 | | Set Test Variable | ${dut_to_tg_if1}
64 | | Set Test Variable | ${dut_to_tg_if2}
65 | | Set Test Variable | ${tg_to_dut_if1_mac}
66 | | Set Test Variable | ${tg_to_dut_if2_mac}
67 | | Set Test Variable | ${dut_to_tg_if1_mac}
68 | | Set Test Variable | ${dut_to_tg_if2_mac}
69 | | Set Test Variable | ${tg_node}
70 | | Set Test Variable | ${dut_node}
71
72 | Set interfaces in 2-node circular topology up
73 | | [Documentation] | Set UP state on interfaces in 2-node path on nodes and
74 | | ... | wait for all interfaces are ready. Requires more than one link
75 | | ... | between nodes.
76 | |
77 | | ... | *Arguments:*
78 | | ... | - No arguments.
79 | |
80 | | ... | *Return:*
81 | | ... | - No value returned.
82 | |
83 | | ... | _NOTE:_ This KW uses test variables sets in
84 | | ... | "Configure path in 2-node circular topology" KW.
85 | |
86 | | ... | *Example:*
87 | |
88 | | ... | \| Given Configure path in 2-node circular topology \| ${nodes['TG']} \
89 | | ... | \| ${nodes['DUT1']} \| ${nodes['TG']} \|
90 | | ... | \| And Set interfaces in 2-node circular topology up \|
91 | |
92 | | Set Interface State | ${tg_node} | ${tg_to_dut_if1} | up
93 | | Set Interface State | ${tg_node} | ${tg_to_dut_if2} | up
94 | | Set Interface State | ${dut_node} | ${dut_to_tg_if1} | up
95 | | Set Interface State | ${dut_node} | ${dut_to_tg_if2} | up
96 | | Vpp Node Interfaces Ready Wait | ${dut_node}
97
98 | Configure path in 3-node circular topology
99 | | [Documentation] | Compute path for testing on three given nodes in circular
100 | | ... | topology and set corresponding test case variables.
101 | |
102 | | ... | *Arguments:*
103 | | ... | - ${tg_node} - TG node. Type: dictionary
104 | | ... | - ${dut1_node} - DUT1 node. Type: dictionary
105 | | ... | - ${dut2_node} - DUT2 node. Type: dictionary
106 | | ... | - ${tg2_node} - Node where the path ends. Must be the same as TG node
107 | | ... | parameter in circular topology. Type: dictionary
108 | |
109 | | ... | *Return:*
110 | | ... | - No value returned
111 | | ... |
112 | | ... | _NOTE:_ This KW sets following test case variables:
113 | | ... | - ${tg_node} - TG node.
114 | | ... | - ${tg_to_dut1} - TG interface towards DUT1.
115 | | ... | - ${tg_to_dut2} - TG interface towards DUT2.
116 | | ... | - ${dut1_node} - DUT1 node.
117 | | ... | - ${dut1_to_tg} - DUT1 interface towards TG.
118 | | ... | - ${dut1_to_dut2} - DUT1 interface towards DUT2.
119 | | ... | - ${dut2_node} - DUT2 node.
120 | | ... | - ${dut2_to_tg} - DUT2 interface towards TG.
121 | | ... | - ${dut2_to_dut1} - DUT2 interface towards DUT1.
122 | | ... | - ${tg_to_dut1_mac}
123 | | ... | - ${tg_to_dut2_mac}
124 | | ... | - ${dut1_to_tg_mac}
125 | | ... | - ${dut1_to_dut2_mac}
126 | | ... | - ${dut2_to_tg_mac}
127 | | ... | - ${dut2_to_dut1_mac}
128 | |
129 | | ... | *Example:*
130 | |
131 | | ... | \| Given Configure path in 3-node circular topology \| ${nodes['TG']} \
132 | | ... | \| ${nodes['DUT1']} \| ${nodes['DUT2']} \| ${nodes['TG']} \|
133 | |
134 | | [Arguments] | ${tg_node} | ${dut1_node} | ${dut2_node} | ${tg2_node}
135 | | Should Be Equal | ${tg_node} | ${tg2_node}
136 | | Append Nodes | ${tg_node} | ${dut1_node} | ${dut2_node} | ${tg_node}
137 | | Compute Path
138 | | ${tg_to_dut1} | ${tmp}= | Next Interface
139 | | ${dut1_to_tg} | ${tmp}= | Next Interface
140 | | ${dut1_to_dut2} | ${tmp}= | Next Interface
141 | | ${dut2_to_dut1} | ${tmp}= | Next Interface
142 | | ${dut2_to_tg} | ${tmp}= | Next Interface
143 | | ${tg_to_dut2} | ${tmp}= | Next Interface
144 | | ${tg_to_dut1_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut1}
145 | | ${tg_to_dut2_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut2}
146 | | ${dut1_to_tg_mac}= | Get interface mac | ${dut1_node} | ${dut1_to_tg}
147 | | ${dut1_to_dut2_mac}= | Get interface mac | ${dut1_node} | ${dut1_to_dut2}
148 | | ${dut2_to_tg_mac}= | Get interface mac | ${dut2_node} | ${dut2_to_tg}
149 | | ${dut2_to_dut1_mac}= | Get interface mac | ${dut2_node} | ${dut2_to_dut1}
150 | | Set Test Variable | ${tg_to_dut1}
151 | | Set Test Variable | ${dut1_to_tg}
152 | | Set Test Variable | ${tg_to_dut2}
153 | | Set Test Variable | ${dut2_to_tg}
154 | | Set Test Variable | ${dut1_to_dut2}
155 | | Set Test Variable | ${dut2_to_dut1}
156 | | Set Test Variable | ${tg_to_dut1_mac}
157 | | Set Test Variable | ${tg_to_dut2_mac}
158 | | Set Test Variable | ${dut1_to_tg_mac}
159 | | Set Test Variable | ${dut1_to_dut2_mac}
160 | | Set Test Variable | ${dut2_to_tg_mac}
161 | | Set Test Variable | ${dut2_to_dut1_mac}
162 | | Set Test Variable | ${tg_node}
163 | | Set Test Variable | ${dut1_node}
164 | | Set Test Variable | ${dut2_node}
165
166 | Set interfaces in 3-node circular topology up
167 | | [Documentation]
168 | | ... | Set UP state on interfaces in 3-node path on nodes and \
169 | | ... | wait until all interfaces are ready.
170 | |
171 | | ... | *Arguments:*
172 | | ... | - No arguments.
173 | |
174 | | ... | *Return:*
175 | | ... | - No value returned.
176 | |
177 | | ... | _NOTE:_ This KW uses test variables sets in
178 | | ... |         "Configure path in 3-node circular topology" KW.
179 | |
180 | | ... | *Example:*
181 | |
182 | | ... | \| Given Configure path in 3-node circular topology \| ${nodes['TG']} \
183 | | ... | \| ${nodes['DUT1']} \| ${nodes['TG']} \|
184 | | ... | \| And Set interfaces in 3-node circular topology up \|
185 | |
186 | | Set Interface State | ${tg_node} | ${tg_to_dut1} | up
187 | | Set Interface State | ${tg_node} | ${tg_to_dut2} | up
188 | | Set Interface State | ${dut1_node} | ${dut1_to_tg} | up
189 | | Set Interface State | ${dut1_node} | ${dut1_to_dut2} | up
190 | | Set Interface State | ${dut2_node} | ${dut2_to_tg} | up
191 | | Set Interface State | ${dut2_node} | ${dut2_to_dut1} | up
192 | | Vpp Node Interfaces Ready Wait | ${dut1_node}
193 | | Vpp Node Interfaces Ready Wait | ${dut2_node}
194
195 | Configure path in double-link 3-node circular topology
196 | | [Documentation]
197 | | ... | Compute path for testing on three given nodes in circular \
198 | | ... | topology with double link and set corresponding \
199 | | ... | test case variables.
200 | |
201 | | ... | *Arguments:*
202 | | ... | - ${tg_node} - TG node. Type: dictionary
203 | | ... | - ${dut1_node} - DUT1 node. Type: dictionary
204 | | ... | - ${dut2_node} - DUT2 node. Type: dictionary
205 | | ... | - ${tg2_node} - Node where the path ends. Must be the same as TG node
206 | | ... |   parameter in circular topology. Type: dictionary
207 | |
208 | | ... | *Return:*
209 | | ... | - No value returned.
210 | | ... |
211 | | ... | _NOTE:_ This KW sets following test case variables:
212 | | ... | - ${tg_node} - TG node.
213 | | ... | - ${tg_to_dut1_if1} - TG interface towards DUT1 interface 1.
214 | | ... | - ${tg_to_dut1_if2} - TG interface towards DUT1 interface 2.
215 | | ... | - ${tg_to_dut1_mac_if1} - TG towards DUT1 MAC address interface 1.
216 | | ... | - ${tg_to_dut1_mac_if2} - TG towards DUT1 MAC address interface 2.
217 | | ... | - ${tg_to_dut2_if1} - TG interface towards DUT2 interface 1.
218 | | ... | - ${tg_to_dut2_if2} - TG interface towards DUT2 interface 2.
219 | | ... | - ${tg_to_dut2_mac_if1} - TG towards DUT2 MAC address interface 1.
220 | | ... | - ${tg_to_dut2_mac_if2} - TG towards DUT2 MAC address interface 2.
221 | | ... | - ${dut1_node} - DUT1 node.
222 | | ... | - ${dut1_to_tg_if1} - DUT1 interface towards TG interface 1.
223 | | ... | - ${dut1_to_tg_if2} - DUT1 interface towards TG interface 2.
224 | | ... | - ${dut1_to_tg_mac_if1} - DUT1 towards TG MAC address interface 1.
225 | | ... | - ${dut1_to_tg_mac_if2} - DUT1 towards TG MAC address interface 2.
226 | | ... | - ${dut1_to_dut2_if1} - DUT1 interface towards DUT2 interface 1.
227 | | ... | - ${dut1_to_dut2_if2} - DUT1 interface towards DUT2 interface 2.
228 | | ... | - ${dut1_to_dut2_mac_if1} - DUT1 towards DUT2 MAC address interface 1.
229 | | ... | - ${dut1_to_dut2_mac_if2} - DUT1 towards DUT2 MAC address interface 2.
230 | | ... | - ${dut2_node} - DUT2 node.
231 | | ... | - ${dut2_to_tg_if1} - DUT2 interface towards TG interface 1.
232 | | ... | - ${dut2_to_tg_if2} - DUT2 interface towards TG interface 2.
233 | | ... | - ${dut2_to_tg_mac_if1} - DUT2 towards TG MAC address interface 1.
234 | | ... | - ${dut2_to_tg_mac_if2} - DUT2 towards TG MAC address interface 2.
235 | | ... | - ${dut2_to_dut1_if1} - DUT2 interface towards DUT1 interface 1.
236 | | ... | - ${dut2_to_dut1_if2} - DUT2 interface towards DUT1 interface 2.
237 | | ... | - ${dut2_to_dut1_mac_if1} - DUT2 towards DUT1 MAC address interface 1.
238 | | ... | - ${dut2_to_dut1_mac_if2} - DUT2 towards DUT1 MAC address interface 2.
239 | |
240 | | ... | *Example:*
241 | |
242 | | ... | \| Configure path in double-link 3-node circular topology \| ${nodes['TG']} \
243 | | ... | \| ${nodes['DUT1']} \| ${nodes['DUT2']} \| ${nodes['TG']} \|
244 | |
245 | | [Arguments] | ${tg_node} | ${dut1_node} | ${dut2_node} | ${tg2_node}
246 | | Should Be Equal | ${tg_node} | ${tg2_node}
247 | | # Compute path TG - DUT1 with two links in between
248 | | Append Nodes | ${tg_node} | ${dut1_node} | ${tg_node}
249 | | Compute Path | always_same_link=${FALSE}
250 | | ${tg_to_dut1_if1} | ${tmp}= | First Interface
251 | | ${tg_to_dut1_if2} | ${tmp}= | Last Interface
252 | | ${dut1_to_tg_if1} | ${tmp}= | First Ingress Interface
253 | | ${dut1_to_tg_if2} | ${tmp}= | Last Egress Interface
254 | | # Compute path TG - DUT2 with two links in between
255 | | Clear Path
256 | | Append Nodes | ${tg_node} | ${dut2_node} | ${tg_node}
257 | | Compute Path | always_same_link=${FALSE}
258 | | ${tg_to_dut2_if1} | ${tmp}= | First Interface
259 | | ${tg_to_dut2_if2} | ${tmp}= | Last Interface
260 | | ${dut2_to_tg_if1} | ${tmp}= | First Ingress Interface
261 | | ${dut2_to_tg_if2} | ${tmp}= | Last Egress Interface
262 | | # Compute path DUT1 - DUT2 with one link in between
263 | | Clear Path
264 | | Append Nodes | ${dut1_node} | ${dut2_node} | ${dut1_node}
265 | | Compute Path | always_same_link=${FALSE}
266 | | ${dut1_to_dut2_if1} | ${tmp}= | First Interface
267 | | ${dut1_to_dut2_if2} | ${tmp}= | Last Interface
268 | | ${dut2_to_dut1_if1} | ${tmp}= | First Ingress Interface
269 | | ${dut2_to_dut1_if2} | ${tmp}= | Last Egress Interface
270 | | # Set test variables
271 | | Set Test Variable | ${tg_to_dut1_if1}
272 | | Set Test Variable | ${tg_to_dut1_if2}
273 | | Set Test Variable | ${tg_to_dut2_if1}
274 | | Set Test Variable | ${tg_to_dut2_if2}
275 | | Set Test Variable | ${dut1_to_tg_if1}
276 | | Set Test Variable | ${dut1_to_tg_if2}
277 | | Set Test Variable | ${dut2_to_tg_if1}
278 | | Set Test Variable | ${dut2_to_tg_if2}
279 | | Set Test Variable | ${dut1_to_dut2_if1}
280 | | Set Test Variable | ${dut1_to_dut2_if2}
281 | | Set Test Variable | ${dut2_to_dut1_if1}
282 | | Set Test Variable | ${dut2_to_dut1_if2}
283 | | Set Test Variable | ${tg_node}
284 | | Set Test Variable | ${dut1_node}
285 | | Set Test Variable | ${dut2_node}
286 | | # Set Mac Addresses
287 | | ${tg_to_dut1_if1_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut1_if1}
288 | | ${tg_to_dut1_if2_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut1_if2}
289 | | ${tg_to_dut2_if1_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut2_if1}
290 | | ${tg_to_dut2_if2_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut2_if2}
291 | | ${dut1_to_tg_if1_mac}= | Get interface mac | ${dut1_node}
292 | | ... | ${dut1_to_tg_if1}
293 | | ${dut1_to_tg_if2_mac}= | Get interface mac | ${dut1_node}
294 | | ... | ${dut1_to_tg_if2}
295 | | ${dut1_to_dut2_if1_mac}= | Get interface mac | ${dut1_node}
296 | | ... | ${dut1_to_dut2_if1}
297 | | ${dut1_to_dut2_if2_mac}= | Get interface mac | ${dut1_node}
298 | | ... | ${dut1_to_dut2_if2}
299 | | ${dut2_to_tg_if1_mac}= | Get interface mac | ${dut2_node}
300 | | ... | ${dut2_to_tg_if1}
301 | | ${dut2_to_tg_if2_mac}= | Get interface mac | ${dut2_node}
302 | | ... | ${dut2_to_tg_if2}
303 | | ${dut2_to_dut1_if1_mac}= | Get interface mac | ${dut2_node}
304 | | ... | ${dut2_to_dut1_if1}
305 | | ${dut2_to_dut1_if2_mac}= | Get interface mac | ${dut2_node}
306 | | ... | ${dut2_to_dut1_if2}
307 | | Set Test Variable | ${tg_to_dut1_if1_mac}
308 | | Set Test Variable | ${tg_to_dut1_if2_mac}
309 | | Set Test Variable | ${tg_to_dut2_if1_mac}
310 | | Set Test Variable | ${tg_to_dut2_if2_mac}
311 | | Set Test Variable | ${dut1_to_tg_if1_mac}
312 | | Set Test Variable | ${dut1_to_tg_if2_mac}
313 | | Set Test Variable | ${dut1_to_dut2_if1_mac}
314 | | Set Test Variable | ${dut1_to_dut2_if2_mac}
315 | | Set Test Variable | ${dut2_to_tg_if1_mac}
316 | | Set Test Variable | ${dut2_to_tg_if2_mac}
317 | | Set Test Variable | ${dut2_to_dut1_if1_mac}
318 | | Set Test Variable | ${dut2_to_dut1_if2_mac}
319
320 | Set interfaces in double-link 3-node circular topology up
321 | | [Documentation]
322 | | ... | Set UP state on interfaces in 3-node double link path \
323 | | ... | wait until all interfaces are ready.
324 | |
325 | | ... | *Arguments:*
326 | | ... | - No arguments.
327 | |
328 | | ... | *Return:*
329 | | ... | - No value returned.
330 | |
331 | | ... | _NOTE:_ This KW uses test variables sets in
332 | | ... | "Configure path in double-link 3-node circular topology" KW.
333 | |
334 | | ... | *Example:*
335 | |
336 | | ... | \| Configure path in double-link 3-node circular topology \| ${nodes['TG']} \
337 | | ... | \| ${nodes['DUT1']} \| ${nodes['TG']} \|
338 | | ... | \| Interfaces in Double-Link 3-node testing are UP \|
339 | |
340 | | Set Interface State | ${tg_node} | ${tg_to_dut1_if1} | up
341 | | Set Interface State | ${tg_node} | ${tg_to_dut1_if2} | up
342 | | Set Interface State | ${tg_node} | ${tg_to_dut2_if1} | up
343 | | Set Interface State | ${tg_node} | ${tg_to_dut2_if2} | up
344 | | Set Interface State | ${dut1_node} | ${dut1_to_tg_if1} | up
345 | | Set Interface State | ${dut1_node} | ${dut1_to_tg_if2} | up
346 | | Set Interface State | ${dut2_node} | ${dut2_to_tg_if1} | up
347 | | Set Interface State | ${dut2_node} | ${dut2_to_tg_if2} | up
348 | | Set Interface State | ${dut1_node} | ${dut1_to_dut2_if1} | up
349 | | Set Interface State | ${dut1_node} | ${dut1_to_dut2_if2} | up
350 | | Set Interface State | ${dut2_node} | ${dut2_to_dut1_if1} | up
351 | | Set Interface State | ${dut2_node} | ${dut2_to_dut1_if2} | up
352 | | Vpp Node Interfaces Ready Wait | ${dut1_node}
353 | | Vpp Node Interfaces Ready Wait | ${dut2_node}
354
355 | Configure interfaces in path up
356 | | [Documentation]
357 | | ... | Set UP state on interfaces in 2-node or 3-node path on nodes and \
358 | | ... | wait until all interfaces are ready.
359 | |
360 | | ... | *Arguments:*
361 | | ... | - No arguments.
362 | |
363 | | ... | *Return:*
364 | | ... | - No value returned.
365 | |
366 | | ... | _NOTE:_ This KW uses test variables sets in\
367 | | ... | "Configure path in 2-node circular topology" or\
368 | | ... | "Configure path in 3-node circular topology" KW.
369 | |
370 | | ... | *Example:*
371 | |
372 | | ... | \| Configure interfaces in path up \|
373 | |
374 | | ${dut2_status} | ${value}= | Run Keyword And Ignore Error
375 | | ... | Variable Should Exist | ${dut2}
376 | |
377 | | Run Keyword If | '${dut2_status}' == 'PASS'
378 | | ... | Set interfaces in 3-node circular topology up
379 | | ... | ELSE
380 | | ... | Set interfaces in 2-node circular topology up