Add continue/fail option for enable traces
[csit.git] / resources / libraries / robot / performance / performance_utils.robot
1 # Copyright (c) 2019 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 | Collections
16 | Library | resources.libraries.python.topology.Topology
17 | Library | resources.libraries.python.NodePath
18 | Library | resources.libraries.python.DpdkUtil
19 | Library | resources.libraries.python.InterfaceUtil
20 | Library | resources.libraries.python.KubernetesUtils
21 | Library | resources.libraries.python.VhostUser
22 | Library | resources.libraries.python.TrafficGenerator
23 | Library | resources.libraries.python.TrafficGenerator.OptimizedSearch
24 | Library | resources.libraries.python.TrafficGenerator.TGDropRateSearchImpl
25 | Library | resources.libraries.python.Trace
26 | Resource | resources/libraries/robot/shared/default.robot
27 | Resource | resources/libraries/robot/shared/interfaces.robot
28 | Resource | resources/libraries/robot/shared/counters.robot
29 | Resource | resources/libraries/robot/shared/container.robot
30 | Resource | resources/libraries/robot/shared/memif.robot
31 | Resource | resources/libraries/robot/l2/l2_bridge_domain.robot
32 | Resource | resources/libraries/robot/l2/l2_xconnect.robot
33 | Resource | resources/libraries/robot/ip/ip4.robot
34 | Resource | resources/libraries/robot/ip/ip6.robot
35 | Resource | resources/libraries/robot/l2/tagging.robot
36 | Documentation | Performance suite keywords - utilities to find and verify NDR
37 | ... | and PDR.
38
39 *** Keywords ***
40 | Find NDR and PDR intervals using optimized search
41 | | [Documentation]
42 | | ... | Find boundaries for RFC2544 compatible NDR and PDR values
43 | | ... | using an optimized search algorithm.
44 | | ... | Display results as formatted test message.
45 | | ... | Fail if a resulting lower bound has too high loss fraction.
46 | | ... | Input rates are understood as uni-directional,
47 | | ... | reported result contains bi-directional rates.
48 | | ... | Currently, the min_rate value is hardcoded to match test teardowns.
49 | | ...
50 | | ... | TODO: Should the trial duration of the additional
51 | | ... | measurements be configurable?
52 | | ...
53 | | ... | Some inputs are read from variables to streamline suites.
54 | | ...
55 | | ... | *Test (or broader scope) variables read:*
56 | | ... | - traffic_profile - Name of module defining traffc for measurements.
57 | | ... | Type: string
58 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
59 | | ... | - max_rate - Calculated unidirectional maximal transmit rate [pps].
60 | | ... | Type: float
61 | | ...
62 | | ... | *Arguments:*
63 | | ... | - packet_loss_ratio - Accepted loss during search. Type: float
64 | | ... | - final_relative_width - Maximal width multiple of upper. Type: float
65 | | ... | - final_trial_duration - Duration of final trials [s]. Type: float
66 | | ... | - initial_trial_duration - Duration of initial trials [s]. Type: float
67 | | ... | - intermediate phases - Number of intermediate phases [1]. Type: int
68 | | ... | - timeout - Fail if search duration is longer [s]. Type: float
69 | | ... | - doublings - How many doublings to do when expanding [1]. Type: int
70 | | ...
71 | | ... | *Example:*
72 | | ...
73 | | ... | \| Find NDR and PDR intervals using optimized search \| \${0.005}
74 | | ... | \| \${0.005} \| \${30.0} \| \${1.0} \| \${2} \| ${600.0} \| ${2} \|
75 | | ...
76 | | [Arguments] | ${packet_loss_ratio}=${0.005}
77 | | ... | ${final_relative_width}=${0.005} | ${final_trial_duration}=${30.0}
78 | | ... | ${initial_trial_duration}=${1.0}
79 | | ... | ${number_of_intermediate_phases}=${2} | ${timeout}=${720.0}
80 | | ... | ${doublings}=${2}
81 | | ...
82 | | ${result} = | Perform optimized ndrpdr search | ${frame_size}
83 | | ... | ${traffic_profile} | ${20000} | ${max_rate*2}
84 | | ... | ${packet_loss_ratio} | ${final_relative_width}
85 | | ... | ${final_trial_duration} | ${initial_trial_duration}
86 | | ... | ${number_of_intermediate_phases} | timeout=${timeout}
87 | | ... | doublings=${doublings}
88 | | Display result of NDRPDR search | ${result} | ${frame_size}
89 | | Check NDRPDR interval validity | ${result.pdr_interval}
90 | | ... | ${packet_loss_ratio}
91 | | Check NDRPDR interval validity | ${result.ndr_interval}
92 | | Perform additional measurements based on NDRPDR result
93 | | ... | ${result} | ${frame_size} | ${traffic_profile}
94
95 | Find critical load using PLRsearch
96 | | [Documentation]
97 | | ... | Find boundaries for troughput (of given target loss ratio)
98 | | ... | using PLRsearch algorithm.
99 | | ... | Display results as formatted test message.
100 | | ... | Fail if computed lower bound is below minimal rate.
101 | | ... | Input rates are understood as uni-directional,
102 | | ... | reported result contains bi-directional rates.
103 | | ... | Currently, the min_rate value is hardcoded to match test teardowns.
104 | | ... | Some inputs are read from variables to streamline suites.
105 | | ...
106 | | ... | *Test (or broader scope) variables read:*
107 | | ... | - traffic_profile - Name of module defining traffc for measurements.
108 | | ... | Type: string
109 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
110 | | ... | - max_rate - Calculated unidirectional maximal transmit rate [pps].
111 | | ... | Type: float
112 | | ...
113 | | ... | *Arguments:*
114 | | ... | - packet_loss_ratio - Accepted loss during search. Type: float
115 | | ... | - timeout - Stop when search duration is longer [s]. Type: float
116 | | ...
117 | | ... | *Example:*
118 | | ...
119 | | ... | \| Find critical load using PLR search \| \${1e-7} \| \${120} \|
120 | | ...
121 | | [Arguments] | ${packet_loss_ratio}=${1e-7} | ${timeout}=${7200.0}
122 | | ...
123 | | ${min_rate} = | Set Variable | ${20000}
124 | | ${average} | ${stdev} = | Perform soak search | ${frame_size}
125 | | ... | ${traffic_profile} | ${min_rate} | ${max_rate*2}
126 | | ... | ${packet_loss_ratio} | timeout=${timeout}
127 | | ${lower} | ${upper} = | Display result of soak search
128 | | ... | ${average} | ${stdev} | ${frame_size}
129 | | Should Not Be True | ${lower} < ${min_rate}
130 | | ... | Lower bound ${lower} is below bidirectional minimum ${min_rate}.
131
132 | Display single bound
133 | | [Documentation]
134 | | ... | Display one bound of NDR+PDR search,
135 | | ... | in packet per seconds (total and per stream)
136 | | ... | and Gbps total bandwidth with untagged packet.
137 | | ... | Througput is calculated as:
138 | | ... | Measured rate per stream * Total number of streams
139 | | ... | Bandwidth is calculated as:
140 | | ... | (Throughput * (L2 Frame Size + IPG) * 8) / Max bitrate of NIC
141 | | ... | The given result should contain latency data as well.
142 | | ...
143 | | ... | *Arguments:*
144 | | ... | - text - Flavor text describing which bound is this. Type: string
145 | | ... | - rate_total - Total (not per stream) measured Tr [pps]. Type: float
146 | | ... | - frame_size - L2 Frame Size [B]. Type: integer
147 | | ... | - latency - Latency data to display if non-empty. Type: string
148 | | ...
149 | | ... | *Example:*
150 | | ...
151 | | ... | \| Display single bound \| NDR lower bound \| \${12345.67} \
152 | | ... | \| \${64} \| show_latency=\${EMPTY} \|
153 | | ...
154 | | [Arguments] | ${text} | ${rate_total} | ${frame_size} | ${latency}=${EMPTY}
155 | | ...
156 | | ${bandwidth_total} = | Evaluate | ${rate_total} * (${frame_size}+20)*8 / 1e9
157 | | Set Test Message | ${\n}${text}: ${rate_total} pps, | append=yes
158 | | Set Test Message | ${bandwidth_total} Gbps (untagged) | append=yes
159 | | Return From Keyword If | not """${latency}"""
160 | | Set Test Message | ${\n}LATENCY usec [min/avg/max] per stream: ${latency}
161 | | ... | append=yes
162
163 | Display result of NDRPDR search
164 | | [Documentation]
165 | | ... | Display result of NDR+PDR search, both quantities, both bounds,
166 | | ... | in packet per seconds (total and per stream)
167 | | ... | and Gbps total bandwidth with untagged packet.
168 | | ... | Througput is calculated as:
169 | | ... | Measured rate per stream * Total number of streams
170 | | ... | Bandwidth is calculated as:
171 | | ... | (Throughput * (L2 Frame Size + IPG) * 8) / Max bitrate of NIC
172 | | ... | The given result should contain latency data as well.
173 | | ...
174 | | ... | *Arguments:*
175 | | ... | - result - Measured result data per stream [pps]. Type: NdrPdrResult
176 | | ... | - frame_size - L2 Frame Size [B]. Type: integer
177 | | ...
178 | | ... | *Example:*
179 | | ...
180 | | ... | \| Display result of NDRPDR search \| \${result} \| \${64} \|
181 | | ...
182 | | [Arguments] | ${result} | ${frame_size}
183 | | ...
184 | | ${frame_size} = | Get Average Frame Size | ${frame_size}
185 | | Display single bound | NDR_LOWER
186 | | ... | ${result.ndr_interval.measured_low.transmit_rate} | ${frame_size}
187 | | ... | ${result.ndr_interval.measured_low.latency}
188 | | Display single bound | NDR_UPPER
189 | | ... | ${result.ndr_interval.measured_high.transmit_rate} | ${frame_size}
190 | | Display single bound | PDR_LOWER
191 | | ... | ${result.pdr_interval.measured_low.transmit_rate} | ${frame_size}
192 | | ... | ${result.pdr_interval.measured_low.latency}
193 | | Display single bound | PDR_UPPER
194 | | ... | ${result.pdr_interval.measured_high.transmit_rate} | ${frame_size}
195
196 | Display result of soak search
197 | | [Documentation]
198 | | ... | Display result of soak search, avg+-stdev, as upper/lower bounds,
199 | | ... | in packet per seconds (total and per stream)
200 | | ... | and Gbps total bandwidth with untagged packet.
201 | | ... | Througput is calculated as:
202 | | ... | Measured rate per stream * Total number of streams
203 | | ... | Bandwidth is calculated as:
204 | | ... | (Throughput * (L2 Frame Size + IPG) * 8) / Max bitrate of NIC
205 | | ... | TODO: Do we want to report some latency data,
206 | | ... | even if not measured at the reported bounds?.
207 | | ...
208 | | ... | *Arguments:*
209 | | ... | - avg - Estimated average critical load [pps]. Type: float
210 | | ... | - stdev - Standard deviation of critical load [pps]. Type: float
211 | | ... | - frame_size - L2 Frame Size [B]. Type: integer
212 | | ...
213 | | ... | *Returns:*
214 | | ... | - Lower and upper bound of critical load [pps]. Type: 2-tuple of float
215 | | ...
216 | | ... | *Example:*
217 | | ...
218 | | ... | \| Display result of soak search \| \${100000} \| \${100} \| \${64} \|
219 | | ...
220 | | [Arguments] | ${avg} | ${stdev} | ${frame_size}
221 | | ...
222 | | ${frame_size} = | Get Average Frame Size | ${frame_size}
223 | | ${avg} = | Convert To Number | ${avg}
224 | | ${stdev} = | Convert To Number | ${stdev}
225 | | ${lower} = | Evaluate | ${avg} - ${stdev}
226 | | ${upper} = | Evaluate | ${avg} + ${stdev}
227 | | Display single bound | PLRsearch lower bound: | ${lower} | ${frame_size}
228 | | Display single bound | PLRsearch upper bound: | ${upper} | ${frame_size}
229 | | Return From Keyword | ${lower} | ${upper}
230
231 | Check NDRPDR interval validity
232 | | [Documentation]
233 | | ... | Extract loss ratio of lower bound of the interval.
234 | | ... | Fail if it does not reach the allowed value.
235 | | ...
236 | | ... | *Arguments:*
237 | | ... | - interval - Measured interval. Type: ReceiveRateInterval
238 | | ... | - packet_loss_ratio - Accepted loss (0.0 for NDR). Type: float
239 | | ...
240 | | ... | *Example:*
241 | | ...
242 | | ... | \| Check NDRPDR interval validity \| \${result.pdr_interval} \
243 | | ... | \| \${0.005} \|
244 | | ...
245 | | [Arguments] | ${interval} | ${packet_loss_ratio}=${0.0}
246 | | ...
247 | | ${lower_bound} = | Set Variable | ${interval.measured_low}
248 | | ${lower_bound_lf} = | Set Variable | ${lower_bound.loss_fraction}
249 | | Return From Keyword If | ${lower_bound_lf} <= ${packet_loss_ratio}
250 | | ${message}= | Catenate | SEPARATOR=${SPACE}
251 | | ... | Minimal rate loss fraction ${lower_bound_lf}
252 | | ... | does not reach target ${packet_loss_ratio}.
253 | | ${message_zero} = | Set Variable | Zero packets forwarded!
254 | | ${message_other} = | Set Variable | ${lower_bound.loss_count} packets lost.
255 | | ${message} = | Set Variable If | ${lower_bound_lf} >= 1.0
256 | | ... | ${message}${\n}${message_zero} | ${message}${\n}${message_other}
257 | | Fail | ${message}
258
259 | Perform additional measurements based on NDRPDR result
260 | | [Documentation]
261 | | ... | Perform any additional measurements which are not directly needed
262 | | ... | for determining NDR nor PDR, but which are needed for gathering
263 | | ... | additional data for debug purposes.
264 | | ... | Currently, just "Traffic should pass with no loss" is called.
265 | | ... | TODO: Move latency measurements from optimized search here.
266 | | ...
267 | | ... | *Arguments:*
268 | | ... | - result - Measured result data per stream [pps]. Type: NdrPdrResult
269 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
270 | | ... | - traffic_profile - Topology profile. Type: string
271 | | ...
272 | | ... | *Example:*
273 | | ... | \| Perform additional measurements based on NDRPDR result \
274 | | ... | \| \${result} \| ${64} \| 3-node-IPv4 \|
275 | | ...
276 | | [Arguments] | ${result} | ${framesize} | ${traffic_profile}
277 | | ...
278 | | ${duration}= | Set Variable | 2.0
279 | | ${rate_per_stream}= | Evaluate
280 | | ... | ${result.ndr_interval.measured_low.target_tr} / 2.0
281 | | Traffic should pass with no loss | ${duration} | ${rate_per_stream}pps
282 | | ... | ${framesize} | ${traffic_profile} | fail_on_loss=${False}
283
284 | Traffic should pass with no loss
285 | | [Documentation]
286 | | ... | Send traffic at specified rate. No packet loss is accepted at loss
287 | | ... | evaluation.
288 | | ...
289 | | ... | *Arguments:*
290 | | ... | - duration - Duration of traffic run [s]. Type: integer
291 | | ... | - rate - Rate for sending packets. Type: string
292 | | ... | - frame_size - L2 Frame Size [B] or IMIX_v4_1. Type: integer/string
293 | | ... | - traffic_profile - Name of module defining traffc for measurements.
294 | | ... | Type: string
295 | | ... | - fail_on_loss - If True, the keyword fails if loss occurred.
296 | | ... | Type: boolean
297 | | ...
298 | | ... | *Example:*
299 | | ...
300 | | ... | \| Traffic should pass with no loss \| 10 \| 4.0mpps \| 64 \
301 | | ... | \| 3-node-IPv4 \|
302 | | ...
303 | | [Arguments] | ${duration} | ${rate} | ${frame_size} | ${traffic_profile}
304 | | ... | ${fail_on_loss}=${True}
305 | | ...
306 | | Send traffic at specified rate | ${duration} | ${rate} | ${frame_size}
307 | | ... | ${traffic_profile}
308 | | Run Keyword If | ${fail_on_loss} | No traffic loss occurred
309
310 | Traffic should pass with maximum rate
311 | | [Documentation]
312 | | ... | Send traffic at maximum rate.
313 | | ...
314 | | ... | Some inputs are read from variables to streamline suites.
315 | | ...
316 | | ... | *Test (or broader scope) variables read:*
317 | | ... | - traffic_profile - Name of module defining traffc for measurements.
318 | | ... | Type: string
319 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
320 | | ... | - max_rate - Calculated unidirectional maximal transmit rate [pps].
321 | | ... | Type: float
322 | | ...
323 | | ... | *Arguments:*
324 | | ... | - subsamples - How many trials in this measurement. Type: int
325 | | ... | - trial_duration - Duration of single trial [s]. Type: float
326 | | ... | - fail_no_traffic - Whether to fail on zero receive count. Type: boolean
327 | | ... | - unidirection - False if traffic is bidirectional. Type: boolean
328 | | ... | - tx_port - TX port of TG, default 0. Type: integer
329 | | ... | - rx_port - RX port of TG, default 1. Type: integer
330 | | ...
331 | | ... | *Example:*
332 | | ...
333 | | ... | \| Traffic should pass with maximum rate \| ${1} \| ${10.0} \|
334 | | ... | \| ${False} \| ${False} \| ${0} \| ${1} \|
335 | | ...
336 | | [Arguments] | ${trial_duration}=${perf_trial_duration}
337 | | ... | ${fail_no_traffic}=${True} | ${subsamples}=${perf_trial_multiplicity}
338 | | ... | ${unidirection}=${False} | ${tx_port}=${0} | ${rx_port}=${1}
339 | | ...
340 | | ${results} = | Send traffic at specified rate | ${trial_duration}
341 | | ... | ${max_rate}pps | ${frame_size} | ${traffic_profile} | ${subsamples}
342 | | ... | ${unidirection} | ${tx_port} | ${rx_port}
343 | | Set Test Message | ${\n}Maximum Receive Rate trial results
344 | | Set Test Message | in packets per second: ${results}
345 | | ... | append=yes
346 | | # TODO: Should we also report the percentage relative to transmit rate,
347 | | # so that people looking at console can decide how close to 100% it is?
348 | | Run Keyword If | ${fail_no_traffic} | Fail if no traffic forwarded
349
350 | Send traffic at specified rate
351 | | [Documentation]
352 | | ... | Send traffic at specified rate.
353 | | ... | Return list of measured receive rates.
354 | | ... | The rate argument should be TRex friendly, so it should include "pps".
355 | | ...
356 | | ... | *Arguments:*
357 | | ... | - trial_duration - Duration of single trial [s]. Type: float
358 | | ... | - rate - Rate for sending packets. Type: string
359 | | ... | - frame_size - L2 Frame Size [B]. Type: integer/string
360 | | ... | - traffic_profile - Name of module defining traffc for measurements.
361 | | ... | Type: string
362 | | ... | - subsamples - How many trials in this measurement. Type: int
363 | | ... | - unidirection - False if traffic is bidirectional. Type: boolean
364 | | ... | - tx_port - TX port of TG, default 0. Type: integer
365 | | ... | - rx_port - RX port of TG, default 1. Type: integer
366 | | ...
367 | | ... | *Example:*
368 | | ...
369 | | ... | \| Send traffic at specified rate \| ${1.0} \| 4.0mpps \| 64 \
370 | | ... | \| 3-node-IPv4 \| ${10} \| ${False} \| ${0} | ${1} \|
371 | | ...
372 | | [Arguments] | ${trial_duration} | ${rate} | ${frame_size}
373 | | ... | ${traffic_profile} | ${subsamples}=${1} | ${unidirection}=${False}
374 | | ... | ${tx_port}=${0} | ${rx_port}=${1}
375 | | ...
376 | | Clear and show runtime counters with running traffic | ${trial_duration}
377 | | ... | ${rate} | ${frame_size} | ${traffic_profile}
378 | | ... | ${unidirection} | ${tx_port} | ${rx_port}
379 | | Run Keyword If | ${dut_stats}==${True} | Clear all counters on all DUTs
380 | | Run Keyword If | ${dut_stats}==${True} and ${pkt_trace}==${True}
381 | | ... | VPP Enable Traces On All DUTs | ${nodes} | fail_on_error=${False}
382 | | Run Keyword If | ${dut_stats}==${True}
383 | | ... | VPP enable elog traces on all DUTs | ${nodes}
384 | | ${results} = | Create List
385 | | :FOR | ${i} | IN RANGE | ${subsamples}
386 | | | # The following line is skipping some default arguments,
387 | | | # that is why subsequent arguments have to be named.
388 | | | Send traffic on tg | ${trial_duration} | ${rate} | ${frame_size}
389 | | | ... | ${traffic_profile} | warmup_time=${0} | unidirection=${unidirection}
390 | | | ... | tx_port=${tx_port} | rx_port=${rx_port}
391 | | | ${rx} = | Get Received
392 | | | ${rr} = | Evaluate | ${rx} / ${trial_duration}
393 | | | Append To List | ${results} | ${rr}
394 | | Run Keyword If | ${dut_stats}==${True} | Show event logger on all DUTs
395 | | ... | ${nodes}
396 | | Run Keyword If | ${dut_stats}==${True} | Show statistics on all DUTs
397 | | ... | ${nodes}
398 | | Run Keyword If | ${dut_stats}==${True} and ${pkt_trace}==${True}
399 | | ... | Show Packet Trace On All Duts | ${nodes} | maximum=${100}
400 | | Return From Keyword | ${results}
401
402 | Clear and show runtime counters with running traffic
403 | | [Documentation]
404 | | ... | Start traffic at specified rate then clear runtime counters on all
405 | | ... | DUTs. Wait for specified amount of time and capture runtime counters
406 | | ... | on all DUTs. Finally stop traffic
407 | | ...
408 | | ... | *Arguments:*
409 | | ... | - duration - Duration of traffic run [s]. Type: integer
410 | | ... | - rate - Rate for sending packets. Type: string
411 | | ... | - frame_size - L2 Frame Size [B] or IMIX_v4_1. Type: integer/string
412 | | ... | - traffic_profile - Name of module defining traffc for measurements.
413 | | ... | Type: string
414 | | ... | - unidirection - False if traffic is bidirectional. Type: boolean
415 | | ... | - tx_port - TX port of TG, default 0. Type: integer
416 | | ... | - rx_port - RX port of TG, default 1. Type: integer
417 | | ...
418 | | ... | *Example:*
419 | | ...
420 | | ... | \| Clear and show runtime counters with running traffic \| 10 \
421 | | ... | \| 4.0mpps \| 64 \| 3-node-IPv4 \| ${False} \| ${0} | ${1} \|
422 | | ...
423 | | [Arguments] | ${duration} | ${rate} | ${frame_size} | ${traffic_profile}
424 | | ... | ${unidirection}=${False} | ${tx_port}=${0} | ${rx_port}=${1}
425 | | ...
426 | | # Duration of -1 means we will stop traffic manually.
427 | | Send traffic on tg | ${-1} | ${rate} | ${frame_size} | ${traffic_profile}
428 | | ... | warmup_time=${0} | async_call=${True} | latency=${False}
429 | | ... | unidirection=${unidirection} | tx_port=${tx_port} | rx_port=${rx_port}
430 | | Run Keyword If | ${dut_stats}==${True}
431 | | ... | Clear runtime counters on all DUTs | ${nodes}
432 | | Sleep | ${duration}
433 | | Run Keyword If | ${dut_stats}==${True}
434 | | ... | Show runtime counters on all DUTs | ${nodes}
435 | | Stop traffic on tg