Align suite/test teardown/setup
[csit.git] / resources / libraries / robot / honeycomb / honeycomb.robot
1 # Copyright (c) 2017 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.honeycomb.HoneycombSetup
16 | Library | resources.libraries.python.honeycomb.HoneycombUtil
17 | Library | resources.libraries.python.honeycomb.HcPersistence
18 | Library | resources.libraries.python.DUTSetup
19 | Library | resources.libraries.python.InterfaceUtil
20 | Resource | resources/libraries/robot/shared/default.robot
21
22 *** Keywords ***
23 | Configure Honeycomb service on DUTs
24 | | [Documentation] | *Setup environment for honeycomb testing.*
25 | | ...
26 | | ... | _Setup steps:_
27 | | ... | - 1. Login to each honeycomb node using ssh
28 | | ... | - 2. Startup honeycomb service
29 | | ... | - 3. Monitor service startup using HTTP GET request loop
30 | | ... | Expected sequence of HTTP replies:
31 | | ... | connection refused -> 404 -> 401 -> 503 or 500 -> 200 (pass)
32 | | ... | - 4. Configure honeycomb nodes using HTTP PUT request
33 | | ...
34 | | ... | _Arguments:_
35 | | ... | - duts - list of nodes to setup Honeycomb on
36 | | ...
37 | | ... | _Used global constants and variables:_
38 | | ... | - RESOURCES_TPL_HC - path to honeycomb templates directory
39 | | ... | - HTTPCodes - HTTP protocol status codes
40 | | ...
41 | | [Arguments] | @{duts}
42 | | Start honeycomb on DUTs | @{duts}
43 | | :FOR | ${dut} | IN | @{duts}
44 | | | Check honeycomb startup state | @{duts}
45 | | | Sleep | 5s | Make sure all modules are loaded and ready.
46
47 | Stop Honeycomb service on DUTs
48 | | [Documentation] | *Cleanup environment after honeycomb testing.*
49 | | ...
50 | | ... | _Teardown steps:_
51 | | ... | - 1. Login to each honeycomb node using ssh
52 | | ... | - 2. Stop honeycomb service
53 | | ... | - 3. Monitor service shutdown using HTTP GET request loop
54 | | ... | Expected sequence of HTTP replies:
55 | | ... | 200 -> 404 -> connection refused (pass)
56 | | ...
57 | | ... | _Arguments:_
58 | | ... | - duts - list of nodes to stop Honeycomb on
59 | | ...
60 | | ... | _Used global constants and variables:_
61 | | ... | - RESOURCES_TPL_HC - path to honeycomb templates directory
62 | | ... | - HTTPCodes - HTTP protocol status codes
63 | | ...
64 | | [Arguments] | @{duts}
65 | | Stop honeycomb on DUTs | @{duts}
66 | | :FOR | ${dut} | IN | @{duts}
67 | | | Wait until keyword succeeds | 60sec | 15sec
68 | | | ... | Check honeycomb shutdown state | @{duts}
69
70 | Clear persisted Honeycomb configuration
71 | | [Documentation] | *Delete saved configuration.*
72 | | ...
73 | | ... | *Arguments:*
74 | | ... | - duts - one or more nodes to clear persistence on. Type: dictionary
75 | | ...
76 | | ... | *Example:*
77 | | ...
78 | | ... | \| Clear persisted Honeycomb configuration \| ${nodes['DUT1']} \|
79 | | ...
80 | | [Arguments] | @{duts}
81 | | Clear persisted Honeycomb config | @{duts}
82
83 | Restart Honeycomb and VPP and clear persisted configuration
84 | | [Documentation] | Restarts Honeycomb and VPP with default configuration.
85 | | ...
86 | | ... | *Arguments:*
87 | | ... | - node - information about a DUT node. Type: dictionary
88 | | ...
89 | | ... | *Example:*
90 | | ...
91 | | ... | \| Restart Honeycomb and VPP and clear persisted configuration \
92 | | ... | \| ${nodes['DUT1']} \|
93 | | ...
94 | | [Arguments] | ${node}
95 | | Stop Honeycomb service on DUTs | ${node}
96 | | Clear persisted Honeycomb configuration | ${node}
97 | | Restart Vpp Service | ${node}
98 | | Verify Vpp | ${node}
99 | | VPP Enable Traces On DUT | ${node}
100 | | Configure Honeycomb service on DUTs | ${node}
101
102 | Restart Honeycomb and VPP
103 | | [Documentation] | Stops the Honeycomb service and verifies it is stopped.
104 | | ... | Then restarts VPP, starts Honeycomb again and verifies it is running.
105 | | ...
106 | | ... | *Arguments:*
107 | | ... | - node - information about a DUT node. Type: dictionary
108 | | ...
109 | | ... | *Example:*
110 | | ...
111 | | ... | \| Restart Honeycomb and VPP \| ${nodes['DUT1']} \|
112 | | ...
113 | | [Arguments] | ${node}
114 | | Stop Honeycomb service on DUTs | ${node}
115 | | Restart Vpp Service | ${node}
116 | | Verify Vpp | ${node}
117 | | VPP Enable Traces On DUT | ${node}
118 | | Configure Honeycomb service on DUTs | ${node}
119
120 | Restart Honeycomb and VPP in performance test
121 | | [Documentation] | Stops Honeycomb and VPP and verifies HC is stopped.
122 | | ... | Then restarts VPP, starts Honeycomb again and verifies it is running.
123 | | ...
124 | | ... | *Arguments:*
125 | | ... | - node - information about a DUT node. Type: dictionary
126 | | ...
127 | | ... | *Example:*
128 | | ...
129 | | ... | \| Restart Honeycomb and VPP \| ${nodes['DUT1']} \|
130 | | ...
131 | | [Arguments] | ${node}
132 | | Stop Honeycomb service on DUTs | ${node}
133 | | Restart Vpp Service | ${node}
134 | | Verify Vpp | ${node}
135 | | VPP Enable Traces On DUT | ${node}
136 | | Configure Honeycomb service on DUTs | ${node}
137 | | Check honeycomb startup state | ${node} | timeout=120
138
139 | Archive Honeycomb logs
140 | | [Documentation] | Copies log files from Honeycomb node\
141 | | ... | to test executor.
142 | | ...
143 | | ... | *Arguments:*
144 | | ... | - node - information about a DUT node. Type: dictionary
145 | | ... | - perf - Running on performance testbed? Yes/no Type: boolean
146 | | ...
147 | | ... | *Example:*
148 | | ...
149 | | ... | \| Archive Honeycomb logs \| ${nudes['DUT1']} \|
150 | | ...
151 | | [Arguments] | ${node} | ${perf}=${False}
152 | | Archive Honeycomb log | ${node} | ${perf}
153 | | Archive ODL log | ${node}
154
155 | Configure ODL Client Service On DUT
156 | | [Documentation] | Configure and start ODL client, then repeatedly check if
157 | | ... | it is running.
158 | | ...
159 | | ... | *Arguments:*
160 | | ... | - node - information about a DUT node. Type: dictionary
161 | | ... | - odl_name - Name of ODL client version. Type: string
162 | | ...
163 | | ... | *Example:*
164 | | ...
165 | | ... | \| Configure ODL Client Service on DUT \| ${nodes['DUT1']} \
166 | | ... | \| carbon-SR1 \|
167 | | ...
168 | | [Arguments] | ${node} | ${odl_name}
169 | | Copy ODL Client | ${node} | ${odl_name} | /mnt/common | /tmp
170 | | Setup ODL Client | ${node} | /tmp
171 | | Wait until keyword succeeds | 3min | 30sec
172 | | ... | Install ODL Features | ${node} | /tmp
173 | | Wait until keyword succeeds | 4min | 15sec
174 | | ... | Mount Honeycomb on ODL | ${node}
175 | | Wait until keyword succeeds | 2min | 15sec
176 | | ... | Check ODL startup state | ${node}
177 | | Check honeycomb startup state | ${node} | timeout=120
178
179 | Configure Honeycomb for functional testing
180 | | [Documentation] | Configure Honeycomb with parameters for functional
181 | | ... | testing, then start Honeycomb and repeatedly check startup status.
182 | | ...
183 | | ... | *Arguments:*
184 | | ... | - node - information about a DUT node. Type: dictionary
185 | | ...
186 | | ... | *Example:*
187 | | ...
188 | | ... | \| Configure Honeycomb for functional testing \| ${nodes['DUT1']} \|
189 | | ...
190 | | [Arguments] | ${node}
191 | | Configure Restconf binding address | ${node}
192 | | Configure Log Level | ${node} | TRACE
193 | | Configure Persistence | ${node} | disable
194 | | Configure jVPP timeout | ${node} | ${10}
195 | | Generate Honeycomb startup configuration for ODL test | ${node}
196 | | Clear Persisted Honeycomb Configuration | ${node}
197 | | Configure Honeycomb service on DUTs | ${node}
198
199 | Configure ODL Client for functional testing
200 | | [Documentation] | Read external variable HC_ODL. Depending on its
201 | | ... | value either: do nothing, or setup ODL client for testing and
202 | | ... | create a global variable that modifies Restconf requests to use ODL.
203 | | ...
204 | | ... | *Arguments:*
205 | | ... | - node - information about a DUT node. Type: dictionary
206 | | ...
207 | | ... | *Example:*
208 | | ...
209 | | ... | \| Configure ODL Client for functional testing \| ${nodes['DUT1']} \|
210 | | ...
211 | | [Arguments] | ${node}
212 | | ${use_odl_client}= | Get Variable Value | ${HC_ODL}
213 | | Run Keyword If | '${use_odl_client}' != '${NONE}'
214 | | ... | Run Keywords
215 | | ... | Set Global Variable | ${use_odl_client} | AND
216 | | ... | Configure ODL Client Service On DUT | ${node} | ${use_odl_client}
217 | | ... | ELSE | Log | Variable HC_ODL is not present. Not using ODL.
218 | | ... | level=INFO
219
220 | Set Up Honeycomb Functional Test Suite
221 | | [Documentation] | Generic test suite setup for Honeycomb functional tests.
222 | | ... | Restarts VPP, then enables Honeycomb and optionally ODL, based
223 | | ... | on external variable.
224 | | ...
225 | | ... | *Arguments:*
226 | | ... | - node - information about a DUT node. Type: dictionary
227 | | ...
228 | | ... | *Example:*
229 | | ...
230 | | ... | \| Set Up Honeycomb Functional Test Suite \| ${nodes['DUT1']} \|
231 | | ...
232 | | [Arguments] | ${node}
233 | | Restart Vpp Service | ${node}
234 | | Verify Vpp | ${node}
235 | | VPP Enable Traces On DUT | ${node}
236 | | All TGs Set Interface Default Driver | ${nodes}
237 | | Configure Honeycomb for functional testing | ${node}
238 | | Configure ODL Client for functional testing | ${node}
239
240 | Tear Down Honeycomb Functional Test Suite
241 | | [Documentation] | Generic test suite teardown for Honeycomb functional
242 | | ... | tests. Stops ODL client (if used), then stops Honeycomb and verifies
243 | | ... | that they are both stopped.
244 | | ...
245 | | ... | *Arguments:*
246 | | ... | - node - information about a DUT node. Type: dictionary
247 | | ...
248 | | ... | *Example:*
249 | | ...
250 | | ... | \| Tear Down Honeycomb Functional Test Suite \| ${nodes['DUT1']} \|
251 | | ...
252 | | [Arguments] | ${node}
253 | | Append suite to Honeycomb log file | ${node}
254 | | ${use_odl_client}= | Get Variable Value | ${HC_ODL}
255 | | Run Keyword If | '${use_odl_client}' != '${NONE}'
256 | | ... | Run Keywords
257 | | ... | Append suite to ODL log file | ${node} | ${use_odl_client} | AND
258 | | ... | Stop ODL Client | ${node} | /tmp | AND
259 | | ... | Wait until keyword succeeds | 3min | 15sec
260 | | ... | Check ODL shutdown state | ${node} | AND
261 | | ... | Set Global Variable | ${use_odl_client} | ${NONE}
262 | | Stop Honeycomb service on DUTs | ${node}
263 | | Clear Honeycomb Log | ${node}
264 | | Stop VPP Service on DUT | ${node}
265
266 | Enable Honeycomb Feature
267 | | [Documentation] | Enable the specified feature in Honeycomb configuration.
268 | | ... | Requires a restart of Honeycomb to take effect.
269 | | ...
270 | | ... | *Arguments:*
271 | | ... | - node - information about a DUT node. Type: dictionary
272 | | ...
273 | | ... | *Example:*
274 | | ...
275 | | ... | \| Enable Honeycomb Feature \| ${nodes['DUT1']} \| NSH \|
276 | | ...
277 | | [arguments] | ${node} | ${feature}
278 | | Manage Honeycomb Features | ${node} | ${feature}
279
280 | Disable Honeycomb Feature
281 | | [Documentation] | Disable the specified feature in Honeycomb configuration.
282 | | ... | Requires a restart of Honeycomb to take effect.
283 | | ...
284 | | ... | *Arguments:*
285 | | ... | - node - information about a DUT node. Type: dictionary
286 | | ...
287 | | ... | *Example:*
288 | | ...
289 | | ... | \| Disable Honeycomb Feature \| ${nodes['DUT1']} \| NSH \|
290 | | ...
291 | | [arguments] | ${node} | ${feature}
292 | | Manage Honeycomb Features | ${node} | ${feature} | disable=${True}
293
294 | Honeycomb Performance Suite Setup Generic
295 | | [Documentation] | Generic test suite setup for Honeycomb performance tests.
296 | | ... | Performs multiple attempts to start Honeycomb+VPP stack.
297 | | ...
298 | | ... | *Arguments:*
299 | | ... | - node - information about a DUT node. Type: dictionary
300 | | ...
301 | | ... | *Example:*
302 | | ...
303 | | ... | \| Honeycomb Performance Suite Setup Generic \| ${nodes['DUT1']} \|
304 | | ...
305 | | [Arguments] | ${node}
306 | | Wait until keyword succeeds | 8min | 2min
307 | | ... | Restart Honeycomb and VPP in Performance test | ${node}
308
309 | Honeycomb Performance Suite Teardown Generic
310 | | [Documentation] | Generic test suite teardown for Honeycomb performance
311 | | ... | tests. Logs CPU usage before stopping Honeycomb.
312 | | ...
313 | | ... | *Arguments:*
314 | | ... | - node - information about a DUT node. Type: dictionary
315 | | ...
316 | | ... | *Example:*
317 | | ...
318 | | ... | \| Honeycomb Performance Suite Teardown Generic \| ${nodes['DUT1']} \|
319 | | ...
320 | | [Arguments] | ${node}
321 | | Log Honeycomb and VPP process distribution on cores | ${node}
322 | | Append suite to Honeycomb log file | ${node}
323 | | Stop Honeycomb service on DUTs | ${node}
324 | | Clear Honeycomb Log | ${node}
325 | | Stop VPP Service on DUT | ${node}
326
327 | Append suite to Honeycomb log file
328 | | [Documentation] | Add the contents of honeycomb.log for the current suite\
329 | | ... | to the full log which will be archived.
330 | | ...
331 | | ... | *Arguments:*
332 | | ... | - node - information about a DUT node. Type: dictionary
333 | | ...
334 | | ... | *Example:*
335 | | ...
336 | | ... | \| Append suite to Honeycomb log file \| ${nodes['DUT1']} \|
337 | | ...
338 | | [Arguments] | ${node}
339 | | Append Honeycomb log | ${node} | ${SUITE_NAME}
340
341 | Append suite to ODL log file
342 | | [Documentation] | Add the contents of ODL karaf.log for the current suite\
343 | | ... | to the full log which will be archived.
344 | | ...
345 | | ... | *Arguments:*
346 | | ... | - node - information about a DUT node. Type: dictionary
347 | | ... | - odl_name - name of ODL client version. Type: string
348 | | ...
349 | | ... | *Example:*
350 | | ...
351 | | ... | \| Append suite to ODL karaf log file \| ${nodes['DUT1']} \
352 | | ... | \| Oxygen \|
353 | | ...
354 | | [Arguments] | ${node} | ${odl_name}
355 | | Append ODL log | ${node} | ${odl_name} | ${SUITE_NAME}
356
357 | Generate Honeycomb startup configuration for ODL test
358 | | [Documentation] | Create HC startup configuration and apply to config
359 | | ... | file on DUT. Requires Honeycomb restart to take effect.
360 | | ...
361 | | ... | *Arguments:*
362 | | ... | - node - Honeycomb node. Type: dictionary
363 | | ...
364 | | ... | *Example:*
365 | | ...
366 | | ... | \| Generate Honeycomb startup configuration for ODL test \
367 | | ... | \| ${nodes[DUT1]} \|
368 | | ...
369 | | [Arguments] | ${node}
370 | | Import Library | resources.libraries.python.honeycomb.HoneycombSetup.HoneycombStartupConfig
371 | | ... | WITH NAME | HC_config
372 | | Run Keyword | HC_config.Set SSH Security provider
373 | | Run Keyword | HC_config.Set Memory Size | ${32}
374 | | Run Keyword | HC_config.Set Metaspace Size | ${32}
375 | | Run Keyword | HC_config.Apply config | ${node}