diff options
Diffstat (limited to 'yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py')
-rw-r--r-- | yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py index b8fbc6344..febcfe5da 100644 --- a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py +++ b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py @@ -141,25 +141,25 @@ class TestRFC2544Profile(base.BaseUnitTestCase): port_pg_id, True) mock_stl_profile.assert_called_once_with(['stream1']) - def test__create_imix_data_mode_DIB(self): + def test__create_imix_data_mode_DIP(self): rfc2544_profile = rfc2544.RFC2544Profile(self.TRAFFIC_PROFILE) data = {'64B': 50, '128B': 50} self.assertEqual( {'64': 50.0, '128': 50.0}, rfc2544_profile._create_imix_data( - data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) + data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) data = {'64B': 1, '128b': 3} self.assertEqual( {'64': 25.0, '128': 75.0}, rfc2544_profile._create_imix_data( - data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) + data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) data = {} self.assertEqual( {}, rfc2544_profile._create_imix_data( - data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) + data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) - def test__create_imix_data_mode_DIP(self): + def test__create_imix_data_mode_DIB(self): rfc2544_profile = rfc2544.RFC2544Profile(self.TRAFFIC_PROFILE) data = {'64B': 25, '128B': 25, '512B': 25, '1518B': 25} byte_total = 64 * 25 + 128 * 25 + 512 * 25 + 1518 * 25 @@ -169,17 +169,17 @@ class TestRFC2544Profile(base.BaseUnitTestCase): '512': 512 * 25.0 * 100 / byte_total, '1518': 1518 * 25.0 * 100/ byte_total}, rfc2544_profile._create_imix_data( - data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) + data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) data = {} self.assertEqual( {}, rfc2544_profile._create_imix_data( - data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) + data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) data = {'64B': 100} self.assertEqual( {'64': 100.0}, rfc2544_profile._create_imix_data( - data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) + data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) def test__create_vm(self): packet = {'outer_l2': 'l2_definition'} @@ -248,41 +248,55 @@ class TestRFC2544Profile(base.BaseUnitTestCase): mock.call(percentage=float(25 * 35) / 100), mock.call(percentage=float(75 * 35) / 100)], any_order=True) - def test_get_drop_percentage(self): + @mock.patch.object(rfc2544.RFC2544Profile, '_get_framesize') + def test_get_drop_percentage(self, mock_get_framesize): rfc2544_profile = rfc2544.RFC2544Profile(self.TRAFFIC_PROFILE) + rfc2544_profile.iteration = 1 + mock_get_framesize.return_value = '64B' + samples = [ - {'xe1': {'tx_throughput_fps': 110, - 'rx_throughput_fps': 101, - 'out_packets': 2100, + {'xe1': {'out_packets': 2100, 'in_packets': 2010, + 'out_bytes': 134400, + 'in_bytes': 128640, 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 1)}, - 'xe2': {'tx_throughput_fps': 210, - 'rx_throughput_fps': 201, - 'out_packets': 4100, + 'xe2': {'out_packets': 4100, 'in_packets': 4010, + 'out_bytes': 262400, + 'in_bytes': 256640, 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 1)}}, - {'xe1': {'tx_throughput_fps': 156, - 'rx_throughput_fps': 108, - 'out_packets': 2110, + {'xe1': {'out_packets': 2110, 'in_packets': 2040, + 'out_bytes': 135040, + 'in_bytes': 130560, 'latency': 'Latency1', 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 31)}, - 'xe2': {'tx_throughput_fps': 253, - 'rx_throughput_fps': 215, - 'out_packets': 4150, + 'xe2': {'out_packets': 4150, 'in_packets': 4010, + 'out_bytes': 265600, + 'in_bytes': 256640, 'latency': 'Latency2', 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 31)}} ] completed, output = rfc2544_profile.get_drop_percentage( - samples, 0, 0, False) - expected = {'DropPercentage': 50.0, - 'Latency': {'xe1': 'Latency1', 'xe2': 'Latency2'}, + samples, 0, 0, False, 0.1) + expected = {'xe1': {'OutPackets': 10, + 'InPackets': 30, + 'OutBytes': 640, + 'InBytes': 1920}, + 'xe2': {'OutPackets': 50, + 'InPackets': 0, + 'OutBytes': 3200, + 'InBytes': 0}, + 'DropPercentage': 50.0, 'RxThroughput': 1000000.0, 'TxThroughput': 2000000.0, - 'CurrentDropPercentage': 50.0, + 'RxThroughputBps': 64000000.0, + 'TxThroughputBps': 128000000.0, 'Rate': 100.0, - 'Throughput': 1000000.0} + 'Iteration': 1, + 'PktSize': '64B', + 'Status': 'Failure'} self.assertEqual(expected, output) self.assertFalse(completed) |