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