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