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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
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
21 | ${extended_debug}= | ${EXTENDED_DEBUG}
26 | | ... | If Get Use Latency returns true, return false.
27 | | ... | Otherwise return value of \${disable_latency} variable,
28 | | ... | or \${False} if not defined.
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.
37 | | ... | \| \${disable_latency} = \| Get Disable Latency \|
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}
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.
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.
57 | | ... | \| \${max_rate} = \| Get Max Rate \|
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.
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.
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.
78 | | ... | \| \${min_rate} = \| Get Min Rate \|
80 | | Return From Keyword | ${9001.0}
82 | Get Mrr Trial Duration
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.
89 | | ... | The return value controls the duration of main trial measurement
90 | | ... | for MRR type tests.
91 | | ... | Return type: float.
95 | | ... | \| \${mrr_trial_duration} = \| Get Mrr Trial Duration \|
97 | | Return From Keyword | ${PERF_TRIAL_DURATION}
99 | Get Mrr Trial Multiplicity
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.
106 | | ... | The return value controls the number of main trial measurement
107 | | ... | for (B)MRR type tests.
108 | | ... | Return type: integer.
112 | | ... | \| \${mrr_trial_multiplicity} = \| Get Mrr Trial Multiplicity \|
114 | | Return From Keyword | ${PERF_TRIAL_MULTIPLICITY}
116 | Get Packet Loss Ratio
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.
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.
130 | | ... | \| \${packet_loss_ratio} = \| Get Packet Loss Ratio \|
132 | | Return From Keyword | ${0.005}
134 | Get Packets Per Transaction Aggregated
136 | | ... | Return value of \${packets_per_transaction_aggregated};
137 | | ... | if not defined, assume traffic is symmetric and compute
138 | | ... | from unidirectional values.
140 | | ... | The return value is used when reporting PPS values from TPS found
141 | | ... | by some search (e.g. NDRPDR).
142 | | ... | Return type: integer.
146 | | ... | \| \${ppta} = \| Get Packets Per Transaction Aggregated \|
148 | | ${ppta} = | Get Variable Value | \${packets_per_transaction_aggregated}
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}
158 | Get Packets Per Transaction And Direction
160 | | ... | Return value of \${packets_per_transaction_and_direction},
161 | | ... | or ${1} if not defined.
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.
169 | | ... | \| \${pptad} = \| Get Packets Per Transaction And Direction \|
171 | | ${pptad} = | Get Variable Value | \${packets_per_transaction_and_direction}
173 | | Return From Keyword | ${pptad}
175 | Get Ramp Up Duration
177 | | ... | Return value of \${ramp_up_duration},
178 | | ... | or ${0.0} if not defined.
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.
187 | | ... | \| \${ramp_up_duration} = \| Get Ramp Up Duration \|
189 | | ${ramp_up_duration} = | Get Variable Value | \${ramp_up_duration} | ${0.0}
190 | | Return From Keyword | ${ramp_up_duration}
194 | | ... | Return value of \${ramp_up_rate},
195 | | ... | if not defined return \${max_rate}.
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.
205 | | ... | \| \${ramp_up_rate} = \| Get Ramp Up Rate \|
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
211 | Get Rate For Teardown
213 | | ... | Return value of \${rate_for_teardown},
214 | | ... | if not defined (or zero) return the min rate.
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.
225 | | ... | \| \${rate_for_teardown} = \| Get Rate For Teardown \|
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
233 | | ... | Return value of \${resetter} variable,
234 | | ... | or \${None} if not defined.
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.
242 | | ... | \| \${resetter} = \| Get Resetter \|
244 | | ${resetter} = | Get Variable Value | \${resetter} | ${None}
245 | | Return From Keyword | ${resetter}
247 | Get Runtime Duration
249 | | ... | Return value of \${runtime_duration} variable,
250 | | ... | if not defined return ${1.0}.
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.
259 | | ... | \| \${runtime_duration} = \| Get Runtime Duration \|
261 | | ${runtime_duration} = | Get Variable Value | \${runtime_duration} | ${1.0}
262 | | Return From Keyword | ${runtime_duration}
266 | | ... | Return value of \${runtime_rate} variable,
267 | | ... | if not defined return the max rate.
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.
276 | | ... | \| \${runtime_rate} = \| Get Runtime Rate \|
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
282 | Get Traffic Directions
284 | | ... | Return value of \${traffic_directions},
285 | | ... | or ${2} if not defined.
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.
294 | | ... | \| \${traffic_directions} = \| Get Traffic Directions \|
296 | | ${traffic_directions} = | Get Variable Value | \${traffic_directions} | ${2}
297 | | Return From Keyword | ${traffic_directions}
299 | Get Transaction Duration
301 | | ... | Return value of \${transaction_duration} variable,
302 | | ... | or \${0.0} if not defined.
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.
313 | | ... | \| \${transaction_duration} = \| Get Transaction Duration \|
315 | | ${transaction_duration} = | Get Variable Value | \${transaction_duration}
317 | | Return From Keyword | ${transaction_duration}
319 | Get Transaction Scale
321 | | ... | Return value of \${transaction_scale} variable,
322 | | ... | or \${0} if not defined.
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.
332 | | ... | \| \${transaction_scale} = \| Get Transaction Scale \|
334 | | ${transaction_scale} = | Get Variable Value | \${transaction_scale} | ${0}
335 | | Return From Keyword | ${transaction_scale}
337 | Get Transaction Type
339 | | ... | Return value of \${transaction_type} variable,
340 | | ... | or "packet" if not defined.
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.
351 | | ... | \| \${transaction_type} = \| Get Transaction Type \|
353 | | ${transaction_type} = | Get Variable Value | \${transaction_type} | packet
354 | | Return From Keyword | ${transaction_type}
358 | | ... | Return value of \${use_latency} variable,
359 | | ... | if not defined return the value from Constants.
361 | | ... | The return value controls whether latency streams are active
362 | | ... | during the main search.
363 | | ... | Return type: bool.
367 | | ... | \| \${use_latency} = \| Get Use Latency \|
369 | | ${use_latency} = | Get Variable Value | ${use_latency} | ${PERF_USE_LATENCY}
370 | | Return From Keyword | ${use_latency}
374 | | ... | For jumbo frames detection, the maximal packet size is relevant,
375 | | ... | encapsulation overhead (if any) has effect.
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.
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
388 | | ... | *Test variables set:*
389 | | ... | - jumbo - Jumbo boolean, true if jumbo packet support has to be
390 | | ... | enabled. Type: boolean
394 | | ... | \| Set Jumbo \|
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}
403 | Set Max Rate And Jumbo
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.
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.
422 | | ... | If this keyword detects the test is interested in (unidirectional)
423 | | ... | transactons per second maximal rate (tps), that is returned (not pps).
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
430 | | ... | - packets_per_transaction_and_direction - Pps-tps conversion.
431 | | ... | Optional, default 1.
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
444 | | ... | \| Set Max Rate And Jumbo \|
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}
463 | Set Numeric Frame Sizes
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.
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.
479 | | ... | *Test variables read:*
480 | | ... | - frame_size - Framesize. Type: integer or string
481 | | ... | - overhead - Overhead in bytes; default value: ${0}. Type: integer
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
489 | | ... | \| Set Numeric Frame Sizes \|
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}
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}
501 | | ... | Convert To Number | ${frame_size}
502 | | ${max_frame_size} = | Evaluate | $bare_max_frame_size + $max_overhead
503 | | Set Test Variable | ${max_frame_size}
505 | Set Rates For Policer
507 | | ... | Policer tests need these values,
508 | | ... | currently computed from \${avg_frame_size}.
509 | | ... | TODO: Verify the units match and computation is correct.
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.
515 | | ... | *Test variables set:*
516 | | ... | - eb - Excess burst rate for policer. Type: float
517 | | ... | - cb - Committed burst rate for policer. Type: float
521 | | ... | \| Set Rates For Policer \|
523 | | Set Test Variable | \${eb} | ${avg_frame_size}
524 | | Set Test Variable | \${cb} | ${avg_frame_size}