NF density tests with dtc=0.5 and dtcr=2
[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
93 | Find critical load using PLRsearch
94 | | [Documentation]
95 | | ... | Find boundaries for troughput (of given target loss ratio)
96 | | ... | using PLRsearch algorithm.
97 | | ... | Display results as formatted test message.
98 | | ... | Fail if computed lower bound is below minimal rate.
99 | | ... | Input rates are understood as uni-directional,
100 | | ... | reported result contains bi-directional rates.
101 | | ... | Currently, the min_rate value is hardcoded to match test teardowns.
102 | | ... | Some inputs are read from variables to streamline suites.
103 | | ...
104 | | ... | *Test (or broader scope) variables read:*
105 | | ... | - traffic_profile - Name of module defining traffc for measurements.
106 | | ... | 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 | Traffic should pass with no loss
258 | | [Documentation]
259 | | ... | Send traffic at specified rate. No packet loss is accepted at loss
260 | | ... | evaluation.
261 | | ...
262 | | ... | *Arguments:*
263 | | ... | - duration - Duration of traffic run [s]. Type: integer
264 | | ... | - rate - Rate for sending packets. Type: string
265 | | ... | - frame_size - L2 Frame Size [B] or IMIX_v4_1. Type: integer/string
266 | | ... | - traffic_profile - Name of module defining traffc for measurements.
267 | | ... | Type: string
268 | | ... | - fail_on_loss - If True, the keyword fails if loss occurred.
269 | | ... | Type: boolean
270 | | ...
271 | | ... | *Example:*
272 | | ...
273 | | ... | \| Traffic should pass with no loss \| 10 \| 4.0mpps \| 64 \
274 | | ... | \| 3-node-IPv4 \|
275 | | ...
276 | | [Arguments] | ${duration} | ${rate} | ${frame_size} | ${traffic_profile}
277 | | ... | ${fail_on_loss}=${True}
278 | | ...
279 | | Send traffic at specified rate | ${duration} | ${rate} | ${frame_size}
280 | | ... | ${traffic_profile}
281 | | Run Keyword If | ${fail_on_loss} | No traffic loss occurred
282
283 | Traffic should pass with maximum rate
284 | | [Documentation]
285 | | ... | Send traffic at maximum rate.
286 | | ...
287 | | ... | Some inputs are read from variables to streamline suites.
288 | | ...
289 | | ... | *Test (or broader scope) variables read:*
290 | | ... | - traffic_profile - Name of module defining traffc for measurements.
291 | | ... | Type: string
292 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
293 | | ... | - max_rate - Calculated unidirectional maximal transmit rate [pps].
294 | | ... | Type: float
295 | | ...
296 | | ... | *Arguments:*
297 | | ... | - subsamples - How many trials in this measurement. Type: int
298 | | ... | - trial_duration - Duration of single trial [s]. Type: float
299 | | ... | - fail_no_traffic - Whether to fail on zero receive count. Type: boolean
300 | | ... | - unidirection - False if traffic is bidirectional. Type: boolean
301 | | ... | - tx_port - TX port of TG, default 0. Type: integer
302 | | ... | - rx_port - RX port of TG, default 1. Type: integer
303 | | ...
304 | | ... | *Example:*
305 | | ...
306 | | ... | \| Traffic should pass with maximum rate \| ${1} \| ${10.0} \|
307 | | ... | \| ${False} \| ${False} \| ${0} \| ${1} \|
308 | | ...
309 | | [Arguments] | ${trial_duration}=${perf_trial_duration}
310 | | ... | ${fail_no_traffic}=${True} | ${subsamples}=${perf_trial_multiplicity}
311 | | ... | ${unidirection}=${False} | ${tx_port}=${0} | ${rx_port}=${1}
312 | | ...
313 | | ${results} = | Send traffic at specified rate | ${trial_duration}
314 | | ... | ${max_rate}pps | ${frame_size} | ${traffic_profile} | ${subsamples}
315 | | ... | ${unidirection} | ${tx_port} | ${rx_port}
316 | | Set Test Message | ${\n}Maximum Receive Rate trial results
317 | | Set Test Message | in packets per second: ${results}
318 | | ... | append=yes
319 | | # TODO: Should we also report the percentage relative to transmit rate,
320 | | # so that people looking at console can decide how close to 100% it is?
321 | | Run Keyword If | ${fail_no_traffic} | Fail if no traffic forwarded
322
323 | Send traffic at specified rate
324 | | [Documentation]
325 | | ... | Send traffic at specified rate.
326 | | ... | Return list of measured receive rates.
327 | | ... | The rate argument should be TRex friendly, so it should include "pps".
328 | | ...
329 | | ... | *Arguments:*
330 | | ... | - trial_duration - Duration of single trial [s]. Type: float
331 | | ... | - rate - Rate for sending packets. Type: string
332 | | ... | - frame_size - L2 Frame Size [B]. Type: integer/string
333 | | ... | - traffic_profile - Name of module defining traffc for measurements.
334 | | ... | Type: string
335 | | ... | - subsamples - How many trials in this measurement. Type: int
336 | | ... | - unidirection - False if traffic is bidirectional. Type: boolean
337 | | ... | - tx_port - TX port of TG, default 0. Type: integer
338 | | ... | - rx_port - RX port of TG, default 1. Type: integer
339 | | ...
340 | | ... | *Example:*
341 | | ...
342 | | ... | \| Send traffic at specified rate \| ${1.0} \| 4.0mpps \| 64 \
343 | | ... | \| 3-node-IPv4 \| ${10} \| ${False} \| ${0} | ${1} \|
344 | | ...
345 | | [Arguments] | ${trial_duration} | ${rate} | ${frame_size}
346 | | ... | ${traffic_profile} | ${subsamples}=${1} | ${unidirection}=${False}
347 | | ... | ${tx_port}=${0} | ${rx_port}=${1}
348 | | ...
349 | | Clear and show runtime counters with running traffic | ${trial_duration}
350 | | ... | ${rate} | ${frame_size} | ${traffic_profile}
351 | | ... | ${unidirection} | ${tx_port} | ${rx_port}
352 | | Run Keyword If | ${dut_stats}==${True} | Clear all counters on all DUTs
353 | | Run Keyword If | ${dut_stats}==${True} and ${pkt_trace}==${True}
354 | | ... | VPP Enable Traces On All DUTs | ${nodes}
355 | | Run Keyword If | ${dut_stats}==${True}
356 | | ... | VPP enable elog traces on all DUTs | ${nodes}
357 | | ${results} = | Create List
358 | | :FOR | ${i} | IN RANGE | ${subsamples}
359 | | | # The following line is skipping some default arguments,
360 | | | # that is why subsequent arguments have to be named.
361 | | | Send traffic on tg | ${trial_duration} | ${rate} | ${frame_size}
362 | | | ... | ${traffic_profile} | warmup_time=${0} | unidirection=${unidirection}
363 | | | ... | tx_port=${tx_port} | rx_port=${rx_port}
364 | | | ${rx} = | Get Received
365 | | | ${rr} = | Evaluate | ${rx} / ${trial_duration}
366 | | | Append To List | ${results} | ${rr}
367 | | Run Keyword If | ${dut_stats}==${True} | Show event logger on all DUTs
368 | | ... | ${nodes}
369 | | Run Keyword If | ${dut_stats}==${True} | Show statistics on all DUTs
370 | | ... | ${nodes}
371 | | Run Keyword If | ${dut_stats}==${True} and ${pkt_trace}==${True}
372 | | ... | Show Packet Trace On All Duts | ${nodes} | maximum=${100}
373 | | Return From Keyword | ${results}
374
375 | Clear and show runtime counters with running traffic
376 | | [Documentation]
377 | | ... | Start traffic at specified rate then clear runtime counters on all
378 | | ... | DUTs. Wait for specified amount of time and capture runtime counters
379 | | ... | on all DUTs. Finally stop traffic
380 | | ...
381 | | ... | *Arguments:*
382 | | ... | - duration - Duration of traffic run [s]. Type: integer
383 | | ... | - rate - Rate for sending packets. Type: string
384 | | ... | - frame_size - L2 Frame Size [B] or IMIX_v4_1. Type: integer/string
385 | | ... | - traffic_profile - Name of module defining traffc for measurements.
386 | | ... | Type: string
387 | | ... | - unidirection - False if traffic is bidirectional. Type: boolean
388 | | ... | - tx_port - TX port of TG, default 0. Type: integer
389 | | ... | - rx_port - RX port of TG, default 1. Type: integer
390 | | ...
391 | | ... | *Example:*
392 | | ...
393 | | ... | \| Clear and show runtime counters with running traffic \| 10 \
394 | | ... | \| 4.0mpps \| 64 \| 3-node-IPv4 \| ${False} \| ${0} | ${1} \|
395 | | ...
396 | | [Arguments] | ${duration} | ${rate} | ${frame_size} | ${traffic_profile}
397 | | ... | ${unidirection}=${False} | ${tx_port}=${0} | ${rx_port}=${1}
398 | | ...
399 | | # Duration of -1 means we will stop traffic manually.
400 | | Send traffic on tg | ${-1} | ${rate} | ${frame_size} | ${traffic_profile}
401 | | ... | warmup_time=${0} | async_call=${True} | latency=${False}
402 | | ... | unidirection=${unidirection} | tx_port=${tx_port} | rx_port=${rx_port}
403 | | Run Keyword If | ${dut_stats}==${True}
404 | | ... | Clear runtime counters on all DUTs | ${nodes}
405 | | Sleep | ${duration}
406 | | Run Keyword If | ${dut_stats}==${True}
407 | | ... | Show runtime counters on all DUTs | ${nodes}
408 | | Stop traffic on tg