4a6d3853639cd446db629eeca44ba01718a437a7
[csit.git] / resources / libraries / robot / performance / performance_vars.robot
1 # Copyright (c) 2021 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 | Documentation | Performance suite keywords - Handling of various values
16 | ... | to allow autodetection, computation and overriding by suite variables.
17 | Library | Collections
18 | Variables | ${CURDIR}/../../python/Constants.py
19
20 *** Variables ***
21 | ${extended_debug}= | ${EXTENDED_DEBUG}
22
23 *** Keywords ***
24 | Get Disable Latency
25 | | [Documentation]
26 | | ... | If Get Use Latency returns true, return false.
27 | | ... | Otherwise return value of \${disable_latency} variable,
28 | | ... | or \${False} if not defined.
29 | |
30 | | ... | The return value controls whether latency trials in NDRPDR tests
31 | | ... | are executed. For example, ASTF tests do not support latency
32 | | ... | measurements yet, so executing the trials just wastes time.
33 | | ... | Return type: bool.
34 | |
35 | | ... | *Example:*
36 | |
37 | | ... | \| \${disable_latency} = \| Get Disable Latency \|
38 | |
39 | | ${use_latency} = | Get Use Latency
40 | | Return From Keyword If | ${use_latency} | ${False}
41 | | ${disable_latency} = | Get Variable Value | \${disable_latency} | ${False}
42 | | Return From Keyword | ${disable_latency}
43
44 | Get Max Rate
45 | | [Documentation]
46 | | ... | Return value of \${max_rate} variable,
47 | | ... | fail if it is not defined.
48 | | ... | Call this just before calling a Python keyword,
49 | | ... | as those have restricted access to Robot variables.
50 | |
51 | | ... | The return value controls the maximal unidirectional packet rate.
52 | | ... | The value is also usable for minimal TPS value for ASTF tests.
53 | | ... | Return type: float.
54 | |
55 | | ... | *Example:*
56 | |
57 | | ... | \| \${max_rate} = \| Get Max Rate \|
58 | |
59 | | ${max_rate} = | Get Variable Value | \${max_rate} | ${0.0}
60 | | Return From Keyword If | ${max_rate} | ${max_rate}
61 | | Fail | \${max_rate} is not defined. Call Set Max Rate And Jumbo keyword.
62
63 | Get Min Rate
64 | | [Documentation]
65 | | ... | Return a hardcoded value. This is an abstraction, useful in case
66 | | ... | we start allowing various other overrides or computations.
67 | | ... | Call this just before calling a Python keyword,
68 | | ... | as those have restricted access to Robot variables.
69 | |
70 | | ... | The return value controls the minimal unidirectional packet rate.
71 | | ... | The value is also usable for minimal TPS value for ASTF tests.
72 | | ... | The current value is the smallest one permitted
73 | | ... | by STL profiles with latency streams.
74 | | ... | Return type: float.
75 | |
76 | | ... | *Example:*
77 | |
78 | | ... | \| \${min_rate} = \| Get Min Rate \|
79 | |
80 | | Return From Keyword | ${9001.0}
81
82 | Get Mrr Trial Duration
83 | | [Documentation]
84 | | ... | Return value from Constants. This is an abstraction, useful in case
85 | | ... | we start allowing various other overrides or computations.
86 | | ... | Call this just before calling a Python keyword,
87 | | ... | as those have restricted access to Robot variables.
88 | |
89 | | ... | The return value controls the duration of main trial measurement
90 | | ... | for MRR type tests.
91 | | ... | Return type: float.
92 | |
93 | | ... | *Example:*
94 | |
95 | | ... | \| \${mrr_trial_duration} = \| Get Mrr Trial Duration \|
96 | |
97 | | Return From Keyword | ${PERF_TRIAL_DURATION}
98
99 | Get Mrr Trial Multiplicity
100 | | [Documentation]
101 | | ... | Return value from Constants. This is an abstraction, useful in case
102 | | ... | we start allowing various other overrides or computations.
103 | | ... | Call this just before calling a Python keyword,
104 | | ... | as those have restricted access to Robot variables.
105 | |
106 | | ... | The return value controls the number of main trial measurement
107 | | ... | for (B)MRR type tests.
108 | | ... | Return type: integer.
109 | |
110 | | ... | *Example:*
111 | |
112 | | ... | \| \${mrr_trial_multiplicity} = \| Get Mrr Trial Multiplicity \|
113 | |
114 | | Return From Keyword | ${PERF_TRIAL_MULTIPLICITY}
115
116 | Get Packet Loss Ratio
117 | | [Documentation]
118 | | ... | Return a hardcoded value. This is an abstraction, useful in case
119 | | ... | we start allowing various other overrides or computations.
120 | | ... | Call this just before calling a Python keyword,
121 | | ... | as those have restricted access to Robot variables.
122 | |
123 | | ... | The return value controls the default packet loss ration for PDR
124 | | ... | in NDRPDR tests. Some other usages of MLRsearch (e.g. reconf tests)
125 | | ... | may use a different value.
126 | | ... | Return type: float.
127 | |
128 | | ... | *Example:*
129 | |
130 | | ... | \| \${packet_loss_ratio} = \| Get Packet Loss Ratio \|
131 | |
132 | | Return From Keyword | ${0.005}
133
134 | Get Packets Per Transaction Aggregated
135 | | [Documentation]
136 | | ... | Return value of \${packets_per_transaction_aggregated};
137 | | ... | if not defined, assume traffic is symmetric and compute
138 | | ... | from unidirectional values.
139 | |
140 | | ... | The return value is used when reporting PPS values from TPS found
141 | | ... | by some search (e.g. NDRPDR).
142 | | ... | Return type: integer.
143 | |
144 | | ... | *Example:*
145 | |
146 | | ... | \| \${ppta} = \| Get Packets Per Transaction Aggregated \|
147 | |
148 | | ${ppta} = | Get Variable Value | \${packets_per_transaction_aggregated}
149 | | ... | ${0}
150 | | Return From Keyword If | "${ppta}" != "0" | ${ppta}
151 | | # TODO: Insert TCP computation from packet size here.
152 | | ${pptad} = | Get Packets Per Transaction And Direction
153 | | ${traffic_directions} = | Get Traffic Directions
154 | | # We do not support ASTF profiles with multiple transactions, yet.
155 | | ${ppta} = | Evaluate | ${pptad} * ${traffic_directions}
156 | | Return From Keyword | ${ppta}
157
158 | Get Packets Per Transaction And Direction
159 | | [Documentation]
160 | | ... | Return value of \${packets_per_transaction_and_direction},
161 | | ... | or ${1} if not defined.
162 | |
163 | | ... | The return value is used when computing max rate (TPS),
164 | | ... | so for asymmetric transaction use the more numerous direction.
165 | | ... | Return type: integer.
166 | |
167 | | ... | *Example:*
168 | |
169 | | ... | \| \${pptad} = \| Get Packets Per Transaction And Direction \|
170 | |
171 | | ${pptad} = | Get Variable Value | \${packets_per_transaction_and_direction}
172 | | ... | ${1}
173 | | Return From Keyword | ${pptad}
174
175 | Get Ramp Up Duration
176 | | [Documentation]
177 | | ... | Return value of \${ramp_up_duration},
178 | | ... | or ${0.0} if not defined.
179 | |
180 | | ... | The return value determines the required duration of ramp-up phase.
181 | | ... | Typically used to prepare a specific state on DUT.
182 | | ... | If the value is zero, ramp-up phase is skipped.
183 | | ... | Return type: float.
184 | |
185 | | ... | *Example:*
186 | |
187 | | ... | \| \${ramp_up_duration} = \| Get Ramp Up Duration \|
188 | |
189 | | ${ramp_up_duration} = | Get Variable Value | \${ramp_up_duration} | ${0.0}
190 | | Return From Keyword | ${ramp_up_duration}
191
192 | Get Ramp Up Rate
193 | | [Documentation]
194 | | ... | Return value of \${ramp_up_rate},
195 | | ... | if not defined return \${max_rate}.
196 | |
197 | | ... | The return value determines the rate for ramp-up phase.
198 | | ... | Typically used to limit the rate when max rate
199 | | ... | would lose packets in the ramp up phase, thus not setting
200 | | ... | the DUT state correctly.
201 | | ... | Return type: float.
202 | |
203 | | ... | *Example:*
204 | |
205 | | ... | \| \${ramp_up_rate} = \| Get Ramp Up Rate \|
206 | |
207 | | ${ramp_up_rate} = | Get Variable Value | \${ramp_up_rate} | ${0.0}
208 | | Return From Keyword If | ${ramp_up_rate} | ${ramp_up_rate}
209 | | Run Keyword And Return | Get Max Rate
210
211 | Get Rate For Teardown
212 | | [Documentation]
213 | | ... | Return value of \${rate_for_teardown},
214 | | ... | if not defined (or zero) return the min rate.
215 | |
216 | | ... | The return value determines the rate for teardown trial,
217 | | ... | that is executed if a perf test fails.
218 | | ... | The \${rate_for_teardown} is usually not defined in suite,
219 | | ... | but search keywords set it in places where failure can occur,
220 | | ... | so the trial is done at the rate interesting for the failure.
221 | | ... | Return type: float.
222 | |
223 | | ... | *Example:*
224 | |
225 | | ... | \| \${rate_for_teardown} = \| Get Rate For Teardown \|
226 | |
227 | | ${rate_for_teardown} = | Get Variable Value | \${rate_for_teardown} | ${0.0}
228 | | Return From Keyword If | ${rate_for_teardown} | ${rate_for_teardown}
229 | | Run Keyword And Return | Get Min Rate
230
231 | Get Resetter
232 | | [Documentation]
233 | | ... | Return value of \${resetter} variable,
234 | | ... | or \${None} if not defined.
235 | |
236 | | ... | If not \${None}, the returned value is callable.
237 | | ... | Its use is to reset DUT to initial conditions,
238 | | ... | for example to remove NAT sessions created in the previous trial.
239 | |
240 | | ... | *Example:*
241 | |
242 | | ... | \| \${resetter} = \| Get Resetter \|
243 | |
244 | | ${resetter} = | Get Variable Value | \${resetter} | ${None}
245 | | Return From Keyword | ${resetter}
246
247 | Get Runtime Duration
248 | | [Documentation]
249 | | ... | Return value of \${runtime_duration} variable,
250 | | ... | if not defined return ${1.0}.
251 | |
252 | | ... | The return value controls the duration of runtime trial,
253 | | ... | which also acts as a warmup. Usually one second is enough,
254 | | ... | but some suites need longer time to set up state on DUT.
255 | | ... | Return type: float.
256 | |
257 | | ... | *Example:*
258 | |
259 | | ... | \| \${runtime_duration} = \| Get Runtime Duration \|
260 | |
261 | | ${runtime_duration} = | Get Variable Value | \${runtime_duration} | ${1.0}
262 | | Return From Keyword | ${runtime_duration}
263
264 | Get Runtime Rate
265 | | [Documentation]
266 | | ... | Return value of \${runtime_rate} variable,
267 | | ... | if not defined return the max rate.
268 | |
269 | | ... | The return value controls the rate (TPS unidir) of runtime trial,
270 | | ... | which also acts as a warmup. No plans to ever use a different rate,
271 | | ... | but keywords look better if access to such values is uniform.
272 | | ... | Return type: float.
273 | |
274 | | ... | *Example:*
275 | |
276 | | ... | \| \${runtime_rate} = \| Get Runtime Rate \|
277 | |
278 | | ${runtime_rate} = | Get Variable Value | \${runtime_rate} | ${0.0}
279 | | Return From Keyword If | ${runtime_rate} | ${runtime_rate}
280 | | Run Keyword And Return | Get Max Rate
281
282 | Get Traffic Directions
283 | | [Documentation]
284 | | ... | Return value of \${traffic_directions},
285 | | ... | or ${2} if not defined.
286 | |
287 | | ... | The return value used when parsing for measurement results.
288 | | ... | This needs to be known already in profile driver,
289 | | ... | as bidirectional parsing may fail on unidirectional traffic.
290 | | ... | Return type: integer.
291 | |
292 | | ... | *Example:*
293 | |
294 | | ... | \| \${traffic_directions} = \| Get Traffic Directions \|
295 | |
296 | | ${traffic_directions} = | Get Variable Value | \${traffic_directions} | ${2}
297 | | Return From Keyword | ${traffic_directions}
298
299 | Get Transaction Duration
300 | | [Documentation]
301 | | ... | Return value of \${transaction_duration} variable,
302 | | ... | or \${0.0} if not defined.
303 | |
304 | | ... | The return value is the expected duration of single (ASTF) transaction
305 | | ... | if it is not negligible for overall trial duration computation.
306 | | ... | Most tests use very short transactions (without explicit delays),
307 | | ... | so the zero default works (and suite saves one line
308 | | ... | of Variables table).
309 | | ... | Return type: float.
310 | |
311 | | ... | *Example:*
312 | |
313 | | ... | \| \${transaction_duration} = \| Get Transaction Duration \|
314 | |
315 | | ${transaction_duration} = | Get Variable Value | \${transaction_duration}
316 | | ... | ${0.0}
317 | | Return From Keyword | ${transaction_duration}
318
319 | Get Transaction Scale
320 | | [Documentation]
321 | | ... | Return value of \${transaction_scale} variable,
322 | | ... | or \${0} if not defined.
323 | |
324 | | ... | Zero return value means the number of transactions is not limited,
325 | | ... | which is true for most STL TRex profiles (transaction is a packet).
326 | | ... | Nonzero return value means the number of transactions is fixed,
327 | | ... | for example in stateful NAT scale tests.
328 | | ... | Return type: integer.
329 | |
330 | | ... | *Example:*
331 | |
332 | | ... | \| \${transaction_scale} = \| Get Transaction Scale \|
333 | |
334 | | ${transaction_scale} = | Get Variable Value | \${transaction_scale} | ${0}
335 | | Return From Keyword | ${transaction_scale}
336
337 | Get Transaction Type
338 | | [Documentation]
339 | | ... | Return value of \${transaction_type} variable,
340 | | ... | or "packet" if not defined.
341 | |
342 | | ... | The return value describes the type of transaction
343 | | ... | the test is executed. For example "packet" means a transaction
344 | | ... | is just a single packet. For more sophisticated transactions,
345 | | ... | the logic to determine the number of passed transactions
346 | | ... | is different from merely counting the packets received from DUT.
347 | | ... | Return type: string.
348 | |
349 | | ... | *Example:*
350 | |
351 | | ... | \| \${transaction_type} = \| Get Transaction Type \|
352 | |
353 | | ${transaction_type} = | Get Variable Value | \${transaction_type} | packet
354 | | Return From Keyword | ${transaction_type}
355
356 | Get Use Latency
357 | | [Documentation]
358 | | ... | Return value of \${use_latency} variable,
359 | | ... | if not defined return the value from Constants.
360 | |
361 | | ... | The return value controls whether latency streams are active
362 | | ... | during the main search.
363 | | ... | Return type: bool.
364 | |
365 | | ... | *Example:*
366 | |
367 | | ... | \| \${use_latency} = \| Get Use Latency \|
368 | |
369 | | ${use_latency} = | Get Variable Value | ${use_latency} | ${PERF_USE_LATENCY}
370 | | Return From Keyword | ${use_latency}
371
372 | Set Jumbo
373 | | [Documentation]
374 | | ... | For jumbo frames detection, the maximal packet size is relevant,
375 | | ... | encapsulation overhead (if any) has effect.
376 | |
377 | | ... | This keyword computes jumbo boolean (some suites need that for
378 | | ... | configuration decisions).
379 | | ... | To streamline suite autogeneration, both input and output values
380 | | ... | are communicated as test (or broader scope) variables,
381 | | ... | instead of explicit arguments and return values.
382 | |
383 | | ... | *Test (or broader scope) variables read:*
384 | | ... | - overhead - Overhead in bytes; default value: 0. Type: integer
385 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: integer or
386 | | ... | string
387 | |
388 | | ... | *Test variables set:*
389 | | ... | - jumbo - Jumbo boolean, true if jumbo packet support has to be
390 | | ... | enabled. Type: boolean
391 | |
392 | | ... | *Example:*
393 | |
394 | | ... | \| Set Jumbo \|
395 | |
396 | | # Already called by Set Max Rate And Jumbo, but some suites (e.g. device)
397 | | # are calling this directly.
398 | | Set Numeric Frame Sizes
399 | | ${jumbo} = | Set Variable If | ${max_frame_size} < 1522
400 | | ... | ${False} | ${True}
401 | | Set Test Variable | \${jumbo}
402
403 | Set Max Rate And Jumbo
404 | | [Documentation]
405 | | ... | Input framesize can be either integer in case of a single packet
406 | | ... | in stream, or IMIX string defining mix of packets.
407 | | ... | For jumbo frames detection, the maximal packet size is relevant.
408 | | ... | For maximal transmit rate, the average packet size is relevant.
409 | | ... | In both cases, encapsulation overhead (if any) has effect.
410 | | ... | The maximal rate is computed from NIC name.
411 | | ... | The implementation works by mapping from exact
412 | | ... | whitelisted NIC names.
413 | | ... | The mapping is hardcoded in nic_limits.yaml
414 | | ... | TODO: Make the mapping from NIC names case insensistive.
415 | |
416 | | ... | This keyword computes maximal unidirectional transmit rate
417 | | ... | and jumbo boolean (some suites need that for configuration decisions).
418 | | ... | To streamline suite autogeneration, both input and output values
419 | | ... | are communicated as test (or broader scope) variables,
420 | | ... | instead of explicit arguments and return values.
421 | |
422 | | ... | If this keyword detects the test is interested in (unidirectional)
423 | | ... | transactons per second maximal rate (tps), that is returned (not pps).
424 | |
425 | | ... | *Test (or broader scope) variables read:*
426 | | ... | - nic_name - Name of bottleneck NIC. Type: string
427 | | ... | - overhead - Overhead in bytes; default value: 0. Type: integer
428 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: integer or
429 | | ... | string
430 | | ... | - packets_per_transaction_and_direction - Pps-tps conversion.
431 | | ... | Optional, default 1.
432 | |
433 | | ... | *Test variables set:*
434 | | ... | - max_rate - Calculated unidirectional maximal transmit rate [pps].
435 | | ... | This never exceeds bandwidth on TG-DUT nor DUT-DUT links.
436 | | ... | Type: float
437 | | ... | - jumbo - Jumbo boolean, true if jumbo packet support has to be
438 | | ... | enabled. Type: boolean
439 | | ... | avg_frame_size - Average frame size including overhead. Type: float
440 | | ... | max_frame_size - Maximal frame size including overhead. Type: float
441 | |
442 | | ... | *Example:*
443 | |
444 | | ... | \| Set Max Rate And Jumbo \|
445 | |
446 | | # TODO: Re-check overhead values in suites with both traffics encapsulated.
447 | | # TODO: Improve layered setup to detect encap/decap and update overhead.
448 | | ${pps_limit} = | Get From Dictionary
449 | | ... | ${NIC_NAME_TO_PPS_LIMIT} | ${nic_name}
450 | | ${bps_limit} = | Get From Dictionary
451 | | ... | ${NIC_NAME_TO_BPS_LIMIT} | ${nic_name}
452 | | Set Numeric Frame Sizes
453 | | # We need to add 20B (Ethernet preamble and inter-frame gap)
454 | | # to avg_frame_size
455 | | ${rate} = | Evaluate | ${bps_limit} / ((${avg_frame_size} + 20.0) * 8)
456 | | ${max_rate} = | Set Variable If | ${rate} > ${pps_limit}
457 | | ... | ${pps_limit} | ${rate}
458 | | ${pptad} = | Get Packets Per Transaction And Direction
459 | | ${max_rate} = | Evaluate | ${max_rate} / ${pptad}
460 | | Set Test Variable | \${max_rate}
461 | | Set Jumbo
462
463 | Set Numeric Frame Sizes
464 | | [Documentation]
465 | | ... | Framesize can be either integer in case of a single packet
466 | | ... | in stream, or set of packets in case of IMIX type or simmilar.
467 | | ... | For jumbo decisions, we need a numeric size of the biggest packet.
468 | | ... | For max rate decisions, we need a numeric average packet size.
469 | | ... | This keyword computes both and sets them as test variables.
470 | |
471 | | ... | Each suite sets a value named \${overhead},
472 | | ... | which describes by how many bytes the frames on DUT-DUT link
473 | | ... | are larger (due to encapsulation) than those
474 | | ... | on the primary TG-DUT link. But for some suites that value
475 | | ... | can be negaive (if TG-DUT is encapsulated more heavily).
476 | | ... | For calculations in this keyword, we need largest sizes
477 | | ... | across links, so zero is used if \${overhead} is negative.
478 | |
479 | | ... | *Test variables read:*
480 | | ... | - frame_size - Framesize. Type: integer or string
481 | | ... | - overhead - Overhead in bytes; default value: ${0}. Type: integer
482 | |
483 | | ... | *Test variables set*
484 | | ... | avg_frame_size - Average frame size including overhead. Type: float
485 | | ... | max_frame_size - Maximal frame size including overhead. Type: float
486 | |
487 | | ... | *Example:*
488 | |
489 | | ... | \| Set Numeric Frame Sizes \|
490 | |
491 | | ${max_overhead} = | Set Variable If | ${overhead} >= 0 | ${overhead} | ${0}
492 | | ${bare_avg_frame_size} = | Run Keyword If | '${frame_size}' == 'IMIX_v4_1'
493 | | ... | Set Variable | ${353.83333}
494 | | ... | ELSE
495 | | ... | Convert To Number | ${frame_size}
496 | | ${avg_frame_size} = | Evaluate | $bare_avg_frame_size + $max_overhead
497 | | Set Test Variable | \${avg_frame_size}
498 | | ${bare_max_frame_size} = | Run Keyword If | '${frame_size}' == 'IMIX_v4_1'
499 | | ... | Set Variable | ${1518}
500 | | ... | ELSE
501 | | ... | Convert To Number | ${frame_size}
502 | | ${max_frame_size} = | Evaluate | $bare_max_frame_size + $max_overhead
503 | | Set Test Variable | ${max_frame_size}
504
505 | Set Rates For Policer
506 | | [Documentation]
507 | | ... | Policer tests need these values,
508 | | ... | currently computed from \${avg_frame_size}.
509 | | ... | TODO: Verify the units match and computation is correct.
510 | |
511 | | ... | *Test (or broader scope) variables read:*
512 | | ... | - avg_frame_size - Average L2 Frame Size [B]. Type: float
513 | | ... | Set by Set Max Rate And Jumbo keyword.
514 | |
515 | | ... | *Test variables set:*
516 | | ... | - eb - Excess burst rate for policer. Type: float
517 | | ... | - cb - Committed burst rate for policer. Type: float
518 | |
519 | | ... | *Example:*
520 | |
521 | | ... | \| Set Rates For Policer \|
522 | |
523 | | Set Test Variable | \${eb} | ${avg_frame_size}
524 | | Set Test Variable | \${cb} | ${avg_frame_size}