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