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