4 ## Copyright (c) 2020 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
11 ## http://www.apache.org/licenses/LICENSE-2.0
13 ## Unless required by applicable law or agreed to in writing, software
14 ## distributed under the License is distributed on an "AS IS" BASIS,
15 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 ## See the License for the specific language governing permissions and
17 ## limitations under the License.
23 from rapid_log import RapidLog
24 from rapid_test import RapidTest
25 from statistics import mean
27 class ImpairTest(RapidTest):
29 Class to manage the impair testing
31 def __init__(self, test_param, lat_percentile, runtime, testname,
32 environment_file, gen_machine, sut_machine):
33 super().__init__(test_param, runtime, testname, environment_file)
34 self.gen_machine = gen_machine
35 self.sut_machine = sut_machine
36 self.test['lat_percentile'] = lat_percentile
39 result_details = {'Details': 'Nothing'}
40 imix = self.test['imix']
42 flow_number = self.test['flowsize']
44 self.gen_machine.set_udp_packet_size(imix)
45 flow_number = self.gen_machine.set_flows(flow_number)
46 self.gen_machine.start_latency_cores()
47 RapidLog.info("+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+")
48 RapidLog.info("| Generator is sending UDP ({:>5} flow) packets ({:>5} bytes) to SUT via GW dropping and delaying packets. SUT sends packets back. Use ctrl-c to stop the test |".format(flow_number,size))
49 RapidLog.info("+--------+------------------+-------------+-------------+-------------+------------------------+----------+----------+----------+-----------+-----------+-----------+-----------+-------+----+")
50 RapidLog.info('| Test | Speed requested | Gen by core | Sent by NIC | Fwrd by SUT | Rec. by core | Avg. Lat.|{:.0f} Pcentil| Max. Lat.| Sent | Received | Lost | Total Lost|L.Ratio|Time|'.format(self.test['lat_percentile']*100))
51 RapidLog.info("+--------+------------------+-------------+-------------+-------------+------------------------+----------+----------+----------+-----------+-----------+-----------+-----------+-------+----+")
53 speed = self.test['startspeed']
54 self.gen_machine.set_generator_speed(speed)
57 print('Measurement ongoing at speed: ' + str(round(speed,2)) + '% ',end='\r')
60 # Get statistics now that the generation is stable and NO ARP messages any more
61 pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg, lat_perc, lat_perc_max, lat_max, abs_tx, abs_rx, abs_dropped, abs_tx_fail, drop_rate, lat_min, lat_used, r, actual_duration, _,bucket_size, buckets = self.run_iteration(float(self.test['runtime']),flow_number,size,speed)
62 # Drop rate is expressed in percentage. lat_used is a ratio (0 to 1). The sum of these 2 should be 100%.
63 # If the sum is lower than 95, it means that more than 5% of the latency measurements where dropped for accuracy reasons.
64 if (drop_rate + lat_used * 100) < 95:
65 lat_warning = bcolors.WARNING + ' Latency accuracy issue?: {:>3.0f}%'.format(lat_used*100) + bcolors.ENDC
68 RapidLog.info(self.report_result(attempts,size,speed,pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,lat_perc,lat_perc_max,lat_max,abs_tx,abs_rx,abs_dropped,actual_duration))
69 result_details = {'test': self.test['test'],
70 'environment_file': self.test['environment_file'],
73 'RequestedSpeed': RapidTest.get_pps(speed,size),
74 'CoreGenerated': pps_req_tx,
76 'FwdBySUT': pps_sut_tx,
78 'AvgLatency': lat_avg,
79 'PCTLatency': lat_perc,
80 'MaxLatency': lat_max,
81 'PacketsLost': abs_dropped,
82 'DropRate': drop_rate,
83 'bucket_size': bucket_size,
85 result_details = self.post_data('rapid_impairtest', result_details)
86 self.gen_machine.stop_latency_cores()
87 return (True, result_details)