Introduce simple VAT history per test case
[csit.git] / resources / libraries / robot / 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 | Variables | resources/libraries/python/topology.py
16 | Variables | resources/libraries/python/VatHistory.py
17 | Library | resources.libraries.python.topology.Topology
18 | Library | resources.libraries.python.VatHistory
19 | Library | resources.libraries.python.CpuUtils
20 | Library | resources.libraries.python.DUTSetup
21 | Library | resources.libraries.python.SchedUtils
22 | Library | resources.libraries.python.TGSetup
23 | Library | resources/libraries/python/VppConfigGenerator.py
24 | Library | resources/libraries/python/VppCounters.py
25 | Library | Collections
26
27 *** Keywords ***
28 | Setup all DUTs before test
29 | | [Documentation] | Setup all DUTs in topology before test execution.
30 | | Setup All DUTs | ${nodes}
31
32 | Setup all TGs before traffic script
33 | | [Documentation] | Prepare all TGs before traffic scripts execution.
34 | | All TGs Set Interface Default Driver | ${nodes}
35
36 | Show Vpp Version On All DUTs
37 | | [Documentation] | Show VPP version verbose on all DUTs.
38 | | ${duts}= | Get Matches | ${nodes} | DUT*
39 | | :FOR | ${dut} | IN | @{duts}
40 | | | Vpp show version verbose | ${nodes['${dut}']}
41
42 | Show Vpp Errors On All DUTs
43 | | [Documentation] | Show VPP errors verbose on all DUTs.
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 | | ${duts}= | Get Matches | ${nodes} | DUT*
51 | | :FOR | ${dut} | IN | @{duts}
52 | | | Vpp api trace save | ${nodes['${dut}']}
53 | | | Vpp api trace dump | ${nodes['${dut}']}
54
55 | Show Vpp Vhost On All DUTs
56 | | [Documentation] | Show Vhost User on all DUTs
57 | | ${duts}= | Get Matches | ${nodes} | DUT*
58 | | :FOR | ${dut} | IN | @{duts}
59 | | | Vpp Show Vhost | ${nodes['${dut}']}
60
61 | Setup Scheduler Policy for Vpp On All DUTs
62 | | [Documentation] | Set realtime scheduling policy (SCHED_RR) with priority 1
63 | | ...             | on all VPP worker threads on all DUTs.
64 | | ${duts}= | Get Matches | ${nodes} | DUT*
65 | | :FOR | ${dut} | IN | @{duts}
66 | | | Set VPP Scheduling rr | ${nodes['${dut}']}
67
68 | Add '${m}' worker threads and rxqueues '${n}' in 3-node single-link topo
69 | | [Documentation] | Setup M worker threads and N rxqueues in vpp startup
70 | | ...             | configuration on all DUTs in 3-node single-link topology.
71 | | ${m_int}= | Convert To Integer | ${m}
72 | | ${dut1_numa}= | Get interfaces numa node | ${dut1}
73 | | ...           | ${dut1_if1} | ${dut1_if2}
74 | | ${dut2_numa}= | Get interfaces numa node | ${dut2}
75 | | ...           | ${dut2_if1} | ${dut2_if2}
76 | | ${dut1_cpu_main}= | Cpu list per node str | ${dut1} | ${dut1_numa}
77 | | ...               | cpu_cnt=${1}
78 | | ${dut1_cpu_w}= | Cpu list per node str | ${dut1} | ${dut1_numa}
79 | | ...            | skip_cnt=${1} | cpu_cnt=${m_int}
80 | | ${dut2_cpu_main}= | Cpu list per node str | ${dut2} | ${dut2_numa}
81 | | ...               | cpu_cnt=${1}
82 | | ${dut2_cpu_w}= | Cpu list per node str | ${dut2} | ${dut2_numa}
83 | | ...            | skip_cnt=${1} | cpu_cnt=${m_int}
84 | | ${dut1_cpu}= | Catenate | main-core | ${dut1_cpu_main}
85 | | ...          | corelist-workers | ${dut1_cpu_w}
86 | | ${dut2_cpu}= | Catenate | main-core | ${dut2_cpu_main}
87 | | ...          | corelist-workers | ${dut2_cpu_w}
88 | | ${rxqueues}= | Catenate | num-rx-queues | ${n}
89 | | Add CPU config | ${dut1} | ${dut1_cpu}
90 | | Add CPU config | ${dut2} | ${dut2_cpu}
91 | | Add rxqueues config | ${dut1} | ${rxqueues}
92 | | Add rxqueues config | ${dut2} | ${rxqueues}
93
94 | Add '${m}' worker threads and rxqueues '${n}' in 2-node single-link topo
95 | | [Documentation] | Setup M worker threads and N rxqueues in vpp startup
96 | | ... | configuration on all DUTs in 2-node single-link topology.
97 | | ${m_int}= | Convert To Integer | ${m}
98 | | ${dut1_numa}= | Get interfaces numa node | ${dut1}
99 | | ... | ${dut1_if1} | ${dut1_if2}
100 | | ${dut1_cpu_main}= | Cpu list per node str | ${dut1} | ${dut1_numa}
101 | | ... | cpu_cnt=${1} | skip_cnt=${1}
102 | | ${dut1_cpu_w}= | Cpu list per node str | ${dut1} | ${dut1_numa}
103 | | ... | skip_cnt=${2} | cpu_cnt=${m_int}
104 | | ${dut1_cpu}= | Catenate | main-core | ${dut1_cpu_main}
105 | | ... | corelist-workers | ${dut1_cpu_w}
106 | | ${rxqueues}= | Catenate | num-rx-queues | ${n}
107 | | Add CPU config | ${dut1} | ${dut1_cpu}
108 | | Add rxqueues config | ${dut1} | ${rxqueues}
109
110 | Add worker threads and rxqueues to all DUTs
111 | | [Documentation] | Setup worker threads and rxqueues in VPP startup
112 | | ...             | configuration to all DUTs
113 | | ...
114 | | ... | *Arguments:*
115 | | ... | - ${cpu} - CPU configuration. Type: string
116 | | ... | - ${rxqueues} - rxqueues configuration. Type: string
117 | | ...
118 | | ... | *Example:*
119 | | ...
120 | | ... | \| Add worker threads and rxqueues to all DUTs \| main-core 0 \
121 | | ... | \| rxqueues 2
122 | | [Arguments] | ${cpu} | ${rxqueues}
123 | | ${duts}= | Get Matches | ${nodes} | DUT*
124 | | :FOR | ${dut} | IN | @{duts}
125 | | | Add CPU config | ${nodes['${dut}']}
126 | | | ...            | ${cpu}
127 | | | Add rxqueues config | ${nodes['${dut}']}
128 | | | ...            | ${rxqueues}
129
130 | Add all PCI devices to all DUTs
131 | | [Documentation] | Add all available PCI devices from topology file to VPP
132 | | ...             | startup configuration to all DUTs
133 | | ${duts}= | Get Matches | ${nodes} | DUT*
134 | | :FOR | ${dut} | IN | @{duts}
135 | | | Add PCI all devices | ${nodes['${dut}']}
136
137 | Add PCI device to DUT
138 | | [Documentation] | Add PCI device to VPP startup configuration
139 | | ...             | to DUT specified as argument
140 | | ...
141 | | ... | *Arguments:*
142 | | ... | - ${node} - DUT node. Type: dictionary
143 | | ... | - ${pci_address} - PCI address. Type: string
144 | | ...
145 | | ... | *Example:*
146 | | ...
147 | | ... | \| Add PCI device to DUT \| ${nodes['DUT1']} \
148 | | ... | \| 0000:00:00.0
149 | | [Arguments] | ${node} | ${pci_address}
150 | | Add PCI device | ${node} | ${pci_address}
151
152 | Add Heapsize Config to all DUTs
153 | | [Documentation] | Add Add Heapsize Config to VPP startup configuration
154 | | ...             | to all DUTs
155 | | ... | *Arguments:*
156 | | ... | - ${heapsize} - Heapsize string (5G, 200M, ...)
157 | | [Arguments] | ${heapsize}
158 | | ${duts}= | Get Matches | ${nodes} | DUT*
159 | | :FOR | ${dut} | IN | @{duts}
160 | | | Add Heapsize Config | ${nodes['${dut}']} | ${heapsize}
161
162 | Add No Multi Seg to all DUTs
163 | | [Documentation] | Add No Multi Seg to VPP startup configuration to all
164 | | ...             | DUTs
165 | | ${duts}= | Get Matches | ${nodes} | DUT*
166 | | :FOR | ${dut} | IN | @{duts}
167 | | | Add No Multi Seg Config | ${nodes['${dut}']}
168
169 | Add Enable Vhost User to all DUTs
170 | | [Documentation] | Add Enable Vhost User to VPP startup configuration to all
171 | | ...             | DUTs
172 | | ${duts}= | Get Matches | ${nodes} | DUT*
173 | | :FOR | ${dut} | IN | @{duts}
174 | | | Add Enable Vhost User Config | ${nodes['${dut}']}
175
176 | Remove startup configuration of VPP from all DUTs
177 | | [Documentation] | Remove VPP startup configuration from all DUTs
178 | | ${duts}= | Get Matches | ${nodes} | DUT*
179 | | :FOR | ${dut} | IN | @{duts}
180 | | | Remove All PCI Devices | ${nodes['${dut}']}
181 | | | Remove All CPU Config | ${nodes['${dut}']}
182 | | | Remove Socketmem Config | ${nodes['${dut}']}
183 | | | Remove Heapsize Config | ${nodes['${dut}']}
184 | | | Remove Rxqueues Config | ${nodes['${dut}']}
185 | | | Remove No Multi Seg Config | ${nodes['${dut}']}
186 | | | Remove Enable Vhost User Config | ${nodes['${dut}']}
187
188 | Setup default startup configuration of VPP on all DUTs
189 | | [Documentation] | Setup default startup configuration of VPP to all DUTs
190 | | Remove startup configuration of VPP from all DUTs
191 | | Add '1' worker threads and rxqueues '1' in 3-node single-link topo
192 | | Add all PCI devices to all DUTs
193 | | Apply startup configuration on all VPP DUTs
194
195 | Setup 2-node startup configuration of VPP on all DUTs
196 | | [Documentation] | Setup default startup configuration of VPP to all DUTs
197 | | Remove startup configuration of VPP from all DUTs
198 | | Add '1' worker threads and rxqueues '1' in 2-node single-link topo
199 | | Add all PCI devices to all DUTs
200 | | Apply startup configuration on all VPP DUTs
201
202 | Apply startup configuration on all VPP DUTs
203 | | [Documentation] | Apply startup configuration of VPP and restart VPP on all
204 | | ...             | DUTs
205 | | ${duts}= | Get Matches | ${nodes} | DUT*
206 | | :FOR | ${dut} | IN | @{duts}
207 | | | Apply Config | ${nodes['${dut}']}
208 | | Update All Interface Data On All Nodes | ${nodes} | skip_tg=${TRUE}
209
210 | Save VPP PIDs
211 | | [Documentation] | Get PIDs of VPP processes from all DUTs in topology and
212 | | ... | set it as a test variable. The PIDs are stored as dictionary items
213 | | ... | where the key is the host and the value is the PID.
214 | | ...
215 | | ${setup_vpp_pids}= | Get VPP PIDs | ${nodes}
216 | | Set Test Variable | ${setup_vpp_pids}
217
218 | Check VPP PID in Teardown
219 | | [Documentation] | Check if the VPP PIDs on all DUTs are the same at the end
220 | | ... | of test as they were at the begining. If they are not, only a message
221 | | ... | is printed on console and to log. The test will not fail.
222 | | ...
223 | | ${teardown_vpp_pids}= | Get VPP PIDs | ${nodes}
224 | | ${err_msg}= | Catenate | \nThe VPP PIDs are not equal!\nTest Setup VPP PIDs:
225 | | ... | ${setup_vpp_pids}\nTest Teardown VPP PIDs: ${teardown_vpp_pids}
226 | | ${rc} | ${msg}= | Run keyword and ignore error
227 | | ... | Dictionaries Should Be Equal
228 | | ... | ${setup_vpp_pids} | ${teardown_vpp_pids}
229 | | Run Keyword And Return If | '${rc}'=='FAIL' | Log | ${err_msg}
230 | | ... | console=yes | level=WARN
231
232 | Func Test Setup
233 | | [Documentation] | Common test setup for functional tests.
234 | | ...
235 | | Setup all DUTs before test
236 | | Save VPP PIDs
237 | | Setup all TGs before traffic script
238 | | Update All Interface Data On All Nodes | ${nodes}
239 | | Reset VAT History On All DUTs | ${nodes}
240
241 | Func Test Teardown
242 | | [Documentation] | Common test teardown for functional tests.
243 | | ...
244 | | Show Packet Trace on All DUTs | ${nodes}
245 | | Show VAT History On All DUTs | ${nodes}
246 | | Vpp Show Errors On All DUTs | ${nodes}
247 | | Check VPP PID in Teardown