74ad8d3f095bb709a5fa6fce7753001f6d2d55d5
[csit.git] / resources / libraries / robot / shared / default.robot
1 # Copyright (c) 2016 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 | Resource | resources/libraries/robot/vm/qemu.robot
16 | Resource | resources/libraries/robot/vm/double_qemu_setup.robot
17 | Variables | resources/libraries/python/topology.py
18 | Variables | resources/libraries/python/VatHistory.py
19 | Library | resources.libraries.python.topology.Topology
20 | Library | resources.libraries.python.VatHistory
21 | Library | resources.libraries.python.CpuUtils
22 | Library | resources.libraries.python.DUTSetup
23 | Library | resources.libraries.python.SchedUtils
24 | Library | resources.libraries.python.TGSetup
25 | Library | resources.libraries.python.L2Util
26 | Library | resources.libraries.python.Tap
27 | Library | resources.libraries.python.VppCounters
28 | Library | resources.libraries.python.VPPUtil
29 | Library | resources.libraries.python.Trace
30 | Library | Collections
31
32 *** Keywords ***
33 | Configure all DUTs before test
34 | | [Documentation] | Setup all DUTs in topology before test execution.
35 | | ...
36 | | Setup All DUTs | ${nodes}
37
38 | Configure all TGs for traffic script
39 | | [Documentation] | Prepare all TGs before traffic scripts execution.
40 | | ...
41 | | All TGs Set Interface Default Driver | ${nodes}
42
43 | Show Vpp Errors On All DUTs
44 | | [Documentation] | Show VPP errors verbose on all DUTs.
45 | | ...
46 | | ${duts}= | Get Matches | ${nodes} | DUT*
47 | | :FOR | ${dut} | IN | @{duts}
48 | | | Vpp Show Errors | ${nodes['${dut}']}
49
50 | Show VPP trace dump on all DUTs
51 | | [Documentation] | Save API trace and dump output on all DUTs.
52 | | ...
53 | | ${duts}= | Get Matches | ${nodes} | DUT*
54 | | :FOR | ${dut} | IN | @{duts}
55 | | | Vpp api trace save | ${nodes['${dut}']}
56 | | | Vpp api trace dump | ${nodes['${dut}']}
57
58 | Show Bridge Domain Data On All DUTs
59 | | [Documentation] | Show Bridge Domain data on all DUTs.
60 | | ...
61 | | ${duts}= | Get Matches | ${nodes} | DUT*
62 | | :FOR | ${dut} | IN | @{duts}
63 | | | Vpp Get Bridge Domain Data | ${nodes['${dut}']}
64
65 | Setup Scheduler Policy for Vpp On All DUTs
66 | | [Documentation] | Set realtime scheduling policy (SCHED_RR) with priority 1
67 | | ... | on all VPP worker threads on all DUTs.
68 | | ...
69 | | ${duts}= | Get Matches | ${nodes} | DUT*
70 | | :FOR | ${dut} | IN | @{duts}
71 | | | Set VPP Scheduling rr | ${nodes['${dut}']}
72
73 | Configure crypto device on all DUTs
74 | | [Documentation] | Verify if Crypto QAT device virtual functions are
75 | | ... | initialized on all DUTs. If parameter force_init is set to True, then
76 | | ... | try to initialize.
77 | | ...
78 | | ... | *Arguments:*
79 | | ... | - ${force_init} - Try to initialize. Type: boolean
80 | | ...
81 | | ... | *Example:*
82 | | ...
83 | | ... | \| Configure crypto device on all DUTs \| ${True} \|
84 | | ...
85 | | [Arguments] | ${force_init}=${False}
86 | | ...
87 | | ${duts}= | Get Matches | ${nodes} | DUT*
88 | | :FOR | ${dut} | IN | @{duts}
89 | | | Crypto Device Verify | ${nodes['${dut}']} | force_init=${force_init}
90
91 | Configure kernel module on all DUTs
92 | | [Documentation] | Verify if specific kernel module is loaded on all DUTs.
93 | | ... | If parameter force_load is set to True, then try to initialize.
94 | | ...
95 | | ... | *Arguments:*
96 | | ... | - ${module} - Module to verify. Type: string
97 | | ... | - ${force_load} - Try to load module. Type: boolean
98 | | ...
99 | | ... | *Example:*
100 | | ...
101 | | ... | \| Configure kernel module on all DUTs \| ${True} \|
102 | | ...
103 | | [Arguments] | ${module} | ${force_load}=${False}
104 | | ...
105 | | ${duts}= | Get Matches | ${nodes} | DUT*
106 | | :FOR | ${dut} | IN | @{duts}
107 | | | Kernel Module Verify | ${nodes['${dut}']} | ${module}
108 | | | ... | force_load=${force_load}
109
110 | Create base startup configuration of VPP on all DUTs
111 | | [Documentation] | Create base startup configuration of VPP to all DUTs.
112 | | ...
113 | | ${duts}= | Get Matches | ${nodes} | DUT*
114 | | :FOR | ${dut} | IN | @{duts}
115 | | | Import Library | resources.libraries.python.VppConfigGenerator
116 | | | ... | WITH NAME | ${dut}
117 | | | Run keyword | ${dut}.Set Node |  ${nodes['${dut}']}
118 | | | Run keyword | ${dut}.Add Unix Log
119 | | | Run keyword | ${dut}.Add Unix CLI Listen
120 | | | Run keyword | ${dut}.Add Unix Nodaemon
121 | | | Run keyword | ${dut}.Add DPDK Socketmem | "1024,1024"
122 | | | Run keyword | ${dut}.Add Heapsize | "3G"
123 | | | Run keyword | ${dut}.Add IP6 Hash Buckets | "2000000"
124 | | | Run keyword | ${dut}.Add IP6 Heap Size | "3G"
125
126 | Add '${m}' worker threads and '${n}' rxqueues in 3-node single-link circular topology
127 | | [Documentation] | Setup M worker threads and N rxqueues in vpp startup\
128 | | ... | configuration on all DUTs in 3-node single-link topology.
129 | | ...
130 | | ${m_int}= | Convert To Integer | ${m}
131 | | ${dut1_numa}= | Get interfaces numa node | ${dut1}
132 | | ... | ${dut1_if1} | ${dut1_if2}
133 | | ${dut2_numa}= | Get interfaces numa node | ${dut2}
134 | | ... | ${dut2_if1} | ${dut2_if2}
135 | | ${dut1_cpu_main}= | Cpu list per node str | ${dut1} | ${dut1_numa}
136 | | ... | skip_cnt=${1} | cpu_cnt=${1}
137 | | ${dut1_cpu_w}= | Cpu list per node str | ${dut1} | ${dut1_numa}
138 | | ... | skip_cnt=${2} | cpu_cnt=${m_int}
139 | | ${dut2_cpu_main}= | Cpu list per node str | ${dut2} | ${dut2_numa}
140 | | ... | skip_cnt=${1} | cpu_cnt=${1}
141 | | ${dut2_cpu_w}= | Cpu list per node str | ${dut2} | ${dut2_numa}
142 | | ... | skip_cnt=${2} | cpu_cnt=${m_int}
143 | | Run keyword | DUT1.Add CPU Main Core | ${dut1_cpu_main}
144 | | Run keyword | DUT2.Add CPU Main Core | ${dut2_cpu_main}
145 | | Run keyword | DUT1.Add CPU Corelist Workers | ${dut1_cpu_w}
146 | | Run keyword | DUT2.Add CPU Corelist Workers | ${dut2_cpu_w}
147 | | Run keyword | DUT1.Add DPDK Dev Default RXQ | ${n}
148 | | Run keyword | DUT2.Add DPDK Dev Default RXQ | ${n}
149
150 | Add '${m}' worker threads and '${n}' rxqueues in 2-node single-link circular topology
151 | | [Documentation] | Setup M worker threads and N rxqueues in vpp startup\
152 | | ... | configuration on all DUTs in 2-node single-link topology.
153 | | ...
154 | | ${m_int}= | Convert To Integer | ${m}
155 | | ${dut1_numa}= | Get interfaces numa node | ${dut1}
156 | | ... | ${dut1_if1} | ${dut1_if2}
157 | | ${dut1_cpu_main}= | Cpu list per node str | ${dut1} | ${dut1_numa}
158 | | ... | skip_cnt=${1} | cpu_cnt=${1}
159 | | ${dut1_cpu_w}= | Cpu list per node str | ${dut1} | ${dut1_numa}
160 | | ... | skip_cnt=${2} | cpu_cnt=${m_int}
161 | | Run keyword | DUT1.Add CPU Main Core | ${dut1_cpu_main}
162 | | Run keyword | DUT1.Add CPU Corelist Workers | ${dut1_cpu_w}
163 | | Run keyword | DUT1.Add DPDK Dev Default RXQ | ${n}
164
165 | Add '${m}' worker threads using SMT and '${n}' rxqueues in 3-node single-link circular topology
166 | | [Documentation] | Setup M worker threads using SMT and N rxqueues in vpp\
167 | | ... | startup configuration on all DUTs in 3-node single-link topology.
168 | | ...
169 | | ${m_int}= | Convert To Integer | ${m}
170 | | ${dut1_numa}= | Get interfaces numa node | ${dut1}
171 | | ... | ${dut1_if1} | ${dut1_if2}
172 | | ${dut2_numa}= | Get interfaces numa node | ${dut2}
173 | | ... | ${dut2_if1} | ${dut2_if2}
174 | | ${dut1_cpu_main}= | Cpu list per node str | ${dut1} | ${dut1_numa}
175 | | ... | skip_cnt=${1} | cpu_cnt=${1} | smt_used=${True}
176 | | ${dut1_cpu_w}= | Cpu list per node str | ${dut1} | ${dut1_numa}
177 | | ... | skip_cnt=${2} | cpu_cnt=${m_int} | smt_used=${True}
178 | | ${dut2_cpu_main}= | Cpu list per node str | ${dut2} | ${dut2_numa}
179 | | ... | skip_cnt=${1} | cpu_cnt=${1} | smt_used=${True}
180 | | ${dut2_cpu_w}= | Cpu list per node str | ${dut2} | ${dut2_numa}
181 | | ... | skip_cnt=${2} | cpu_cnt=${m_int} | smt_used=${True}
182 | | Run keyword | DUT1.Add CPU Main Core | ${dut1_cpu_main}
183 | | Run keyword | DUT2.Add CPU Main Core | ${dut2_cpu_main}
184 | | Run keyword | DUT1.Add CPU Corelist Workers | ${dut1_cpu_w}
185 | | Run keyword | DUT2.Add CPU Corelist Workers | ${dut2_cpu_w}
186 | | Run keyword | DUT1.Add DPDK Dev Default RXQ | ${n}
187 | | Run keyword | DUT2.Add DPDK Dev Default RXQ | ${n}
188
189 | Add '${m}' worker threads using SMT and '${n}' rxqueues in 2-node single-link circular topology
190 | | [Documentation] | Setup M worker threads and N rxqueues in vpp startup\
191 | | ... | configuration on all DUTs in 2-node single-link topology.
192 | | ...
193 | | ${m_int}= | Convert To Integer | ${m}
194 | | ${dut1_numa}= | Get interfaces numa node | ${dut1}
195 | | ... | ${dut1_if1} | ${dut1_if2}
196 | | ${dut1_cpu_main}= | Cpu list per node str | ${dut1} | ${dut1_numa}
197 | | ... | skip_cnt=${1} | cpu_cnt=${1} | smt_used=${True}
198 | | ${dut1_cpu_w}= | Cpu list per node str | ${dut1} | ${dut1_numa}
199 | | ... | skip_cnt=${2} | cpu_cnt=${m_int} | smt_used=${True}
200 | | Run keyword | DUT1.Add CPU Main Core | ${dut1_cpu_main}
201 | | Run keyword | DUT1.Add CPU Corelist Workers | ${dut1_cpu_w}
202 | | Run keyword | DUT1.Add DPDK Dev Default RXQ | ${n}
203
204 | Add no multi seg to all DUTs
205 | | [Documentation] | Add No Multi Seg to VPP startup configuration to all DUTs.
206 | | ...
207 | | ${duts}= | Get Matches | ${nodes} | DUT*
208 | | :FOR | ${dut} | IN | @{duts}
209 | | | Run keyword | ${dut}.Add DPDK No Multi Seg
210
211 | Add DPDK dev default RXD to all DUTs
212 | | [Documentation] | Add DPDK num-rx-desc to VPP startup configuration to all
213 | | ... | DUTs.
214 | | ...
215 | | ... | *Arguments:*
216 | | ... | - rxd - Number of RX descriptors. Type: string
217 | | ...
218 | | ... | *Example:*
219 | | ...
220 | | ... | \| Add DPDK dev default RXD to all DUTs \| ${rxd} \|
221 | | ...
222 | | [Arguments] | ${rxd}
223 | | ...
224 | | ${duts}= | Get Matches | ${nodes} | DUT*
225 | | :FOR | ${dut} | IN | @{duts}
226 | | | Run keyword | ${dut}.Add DPDK Dev Default RXD | ${rxd}
227
228 | Add DPDK dev default TXD to all DUTs
229 | | [Documentation] | Add DPDK num-tx-desc to VPP startup configuration to all
230 | | ... | DUTs.
231 | | ...
232 | | ... | *Arguments:*
233 | | ... | - txd - Number of TX descriptors. Type: string
234 | | ...
235 | | ... | *Example:*
236 | | ...
237 | | ... | \| Add DPDK dev default TXD to all DUTs \| ${txd} \|
238 | | ...
239 | | [Arguments] | ${txd}
240 | | ...
241 | | ${duts}= | Get Matches | ${nodes} | DUT*
242 | | :FOR | ${dut} | IN | @{duts}
243 | | | Run keyword | ${dut}.Add DPDK Dev Default TXD | ${txd}
244
245 | Add NAT to all DUTs
246 | | [Documentation] | Add NAT configuration to all DUTs.
247 | | ...
248 | | ${duts}= | Get Matches | ${nodes} | DUT*
249 | | :FOR | ${dut} | IN | @{duts}
250 | | | Run keyword | ${dut}.Add NAT
251
252 | Add cryptodev to all DUTs
253 | | [Documentation] | Add Cryptodev to VPP startup configuration to all DUTs.
254 | | ...
255 | | ... | *Arguments:*
256 | | ... | - ${count} - Number of QAT devices. Type: integer
257 | | ...
258 | | ... | *Example:*
259 | | ...
260 | | ... | \| Add cryptodev to all DUTs \| ${4} \|
261 | | ...
262 | | [Arguments] | ${count}
263 | | ${duts}= | Get Matches | ${nodes} | DUT*
264 | | :FOR | ${dut} | IN | @{duts}
265 | | | Run keyword | ${dut}.Add DPDK Cryptodev | ${count}
266
267 | Add crypto SW device on all DUTs
268 | | [Documentation] | Add required number of crypto SW devices to VPP startup
269 | | ... | configuration on all DUTs.
270 | | ...
271 | | ... | *Arguments:*
272 | | ... | - ${count} - Number of SW crypto devices. Type: integer
273 | | ...
274 | | ... | *Example:*
275 | | ...
276 | | ... | \| Add SW cryptodev on all DUTs \| ${4} \|
277 | | ...
278 | | [Arguments] | ${count}
279 | | ${duts}= | Get Matches | ${nodes} | DUT*
280 | | :FOR | ${dut} | IN | @{duts}
281 | | | Run keyword | ${dut}.Add DPDK SW Cryptodev | ${count}
282
283 | Apply startup configuration on all VPP DUTs
284 | | [Documentation] | Write startup configuration and restart VPP on all DUTs.
285 | | ...
286 | | ... | *Arguments:*
287 | | ... | - ${restart_vpp} - Whether to restart VPP (Optional). Type: boolean
288 | | ...
289 | | ... | *Example:*
290 | | ...
291 | | ... | \| Apply startup configuration on all VPP DUTs \| ${False} \|
292 | | ...
293 | | [Arguments] | ${restart_vpp}=${True}
294 | | ...
295 | | ${duts}= | Get Matches | ${nodes} | DUT*
296 | | :FOR | ${dut} | IN | @{duts}
297 | | | Run keyword | ${dut}.Apply Config | restart_vpp=${restart_vpp}
298 | | Update All Interface Data On All Nodes | ${nodes} | skip_tg=${True}
299
300 | Save VPP PIDs
301 | | [Documentation] | Get PIDs of VPP processes from all DUTs in topology and\
302 | | ... | set it as a test variable. The PIDs are stored as dictionary items\
303 | | ... | where the key is the host and the value is the PID.
304 | | ...
305 | | ${setup_vpp_pids}= | Get VPP PIDs | ${nodes}
306 | | ${keys}= | Get Dictionary Keys | ${setup_vpp_pids}
307 | | :FOR | ${key} | IN | @{keys}
308 | | | ${pid}= | Get From Dictionary | ${setup_vpp_pids} | ${key}
309 | | | Run Keyword If | $pid is None | FAIL | No VPP PID found on node ${key}
310 | | | Run Keyword If | ',' in '${pid}'
311 | | | ... | FAIL | More then one VPP PID found on node ${key}: ${pid}
312 | | Set Test Variable | ${setup_vpp_pids}
313
314 | Verify VPP PID in Teardown
315 | | [Documentation] | Check if the VPP PIDs on all DUTs are the same at the end\
316 | | ... | of test as they were at the begining. If they are not, only a message\
317 | | ... | is printed on console and to log. The test will not fail.
318 | | ...
319 | | ${teardown_vpp_pids}= | Get VPP PIDs | ${nodes}
320 | | ${err_msg}= | Catenate | ${SUITE NAME} - ${TEST NAME}
321 | | ... | \nThe VPP PIDs are not equal!\nTest Setup VPP PIDs:
322 | | ... | ${setup_vpp_pids}\nTest Teardown VPP PIDs: ${teardown_vpp_pids}
323 | | ${rc} | ${msg}= | Run keyword and ignore error
324 | | ... | Dictionaries Should Be Equal
325 | | ... | ${setup_vpp_pids} | ${teardown_vpp_pids}
326 | | Run Keyword And Return If | '${rc}'=='FAIL' | Log | ${err_msg}
327 | | ... | console=yes | level=WARN
328
329 | Set up functional test
330 | | [Documentation] | Common test setup for functional tests.
331 | | ...
332 | | Configure all DUTs before test
333 | | Save VPP PIDs
334 | | Configure all TGs for traffic script
335 | | Update All Interface Data On All Nodes | ${nodes}
336 | | Reset VAT History On All DUTs | ${nodes}
337
338 | Tear down functional test
339 | | [Documentation] | Common test teardown for functional tests.
340 | | ...
341 | | Remove All Added Ports On All DUTs From Topology | ${nodes}
342 | | Show Packet Trace on All DUTs | ${nodes}
343 | | Show VAT History On All DUTs | ${nodes}
344 | | Vpp Show Errors On All DUTs | ${nodes}
345 | | Verify VPP PID in Teardown
346
347 | Tear down LISP functional test
348 | | [Documentation] | Common test teardown for functional tests with LISP.
349 | | ...
350 | | Remove All Added Ports On All DUTs From Topology | ${nodes}
351 | | Show Packet Trace on All DUTs | ${nodes}
352 | | Show VAT History On All DUTs | ${nodes}
353 | | Show Vpp Settings | ${nodes['DUT1']}
354 | | Show Vpp Settings | ${nodes['DUT2']}
355 | | Vpp Show Errors On All DUTs | ${nodes}
356 | | Verify VPP PID in Teardown
357
358 | Tear down LISP functional test with QEMU
359 | | [Documentation] | Common test teardown for functional tests with LISP and\
360 | | ... | QEMU.
361 | | ...
362 | | ... | *Arguments:*
363 | | ... | - vm_node - VM to stop. Type: string
364 | | ...
365 | | ... | *Example:*
366 | | ...
367 | | ... | \| Tear down LISP functional test with QEMU \| ${vm_node} \|
368 | | ...
369 | | [Arguments] | ${vm_node}
370 | | ...
371 | | Remove All Added Ports On All DUTs From Topology | ${nodes}
372 | | Show Packet Trace on All DUTs | ${nodes}
373 | | Show VAT History On All DUTs | ${nodes}
374 | | Show Vpp Settings | ${nodes['DUT1']}
375 | | Show Vpp Settings | ${nodes['DUT2']}
376 | | Vpp Show Errors On All DUTs | ${nodes}
377 | | Stop and clear QEMU | ${nodes['DUT1']} | ${vm_node}
378 | | Verify VPP PID in Teardown
379
380 | Set up TAP functional test
381 | | [Documentation] | Common test setup for functional tests with TAP.
382 | | ...
383 | | Set up functional test
384 | | Clean Up Namespaces | ${nodes['DUT1']}
385
386 | Tear down TAP functional test
387 | | [Documentation] | Common test teardown for functional tests with TAP.
388 | | ...
389 | | Tear down functional test
390 | | Clean Up Namespaces | ${nodes['DUT1']}
391
392 | Tear down TAP functional test with Linux bridge
393 | | [Documentation] | Common test teardown for functional tests with TAP and
394 | | ... | a Linux bridge.
395 | | ...
396 | | ... | *Arguments:*
397 | | ... | - bid_TAP - Bridge name. Type: string
398 | | ...
399 | | ... | *Example:*
400 | | ...
401 | | ... | \| Tear down TAP functional test with Linux bridge \| ${bid_TAP} \|
402 | | ...
403 | | [Arguments] | ${bid_TAP}
404 | | ...
405 | | Tear down functional test
406 | | Linux Del Bridge | ${nodes['DUT1']} | ${bid_TAP}
407 | | Clean Up Namespaces | ${nodes['DUT1']}
408
409 | Tear down FDS functional test
410 | | [Documentation] | Common test teardown for FDS functional tests.
411 | | ...
412 | | ... | *Arguments:*
413 | | ... | - dut1_node - Node Nr.1 where to clean qemu. Type: dictionary
414 | | ... | - qemu_node1 - VM Nr.1 node info dictionary. Type: string
415 | | ... | - dut2_node - Node Nr.2 where to clean qemu. Type: dictionary
416 | | ... | - qemu_node2 - VM Nr.2 node info dictionary. Type: string
417 | | ...
418 | | ... | *Example:*
419 | | ...
420 | | ... | \| Tear down FDS functional test \| ${dut1_node} \| ${qemu_node1}\
421 | | ... | \| ${dut2_node} \| ${qemu_node2} \|
422 | | ...
423 | | [Arguments] | ${dut1_node} | ${qemu_node1} | ${dut2_node}
424 | | ... | ${qemu_node2}
425 | | ...
426 | | Tear down functional test
427 | | Tear down QEMU | ${dut1_node} | ${qemu_node1} | qemu_node1
428 | | Tear down QEMU | ${dut2_node} | ${qemu_node2} | qemu_node2
429
430 | Stop VPP Service on DUT
431 | | [Documentation] | Stop the VPP service on the specified node.
432 | | ...
433 | | ... | *Arguments:*
434 | | ... | - node - information about a DUT node. Type: dictionary
435 | | ...
436 | | ... | *Example:*
437 | | ...
438 | | ... | \| Stop VPP Service on DUT \| ${nodes['DUT1']} \|
439 | | ...
440 | | [Arguments] | ${node}
441 | | Stop VPP Service | ${node}
442
443 | Start VPP Service on DUT
444 | | [Documentation] | Start the VPP service on the specified node.
445 | | ...
446 | | ... | *Arguments:*
447 | | ... | - node - information about a DUT node. Type: dictionary
448 | | ...
449 | | ... | *Example:*
450 | | ...
451 | | ... | \| Start VPP Service on DUT \| ${nodes['DUT1']} \|
452 | | ...
453 | | [Arguments] | ${node}
454 | | Start VPP Service | ${node}