aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py
diff options
context:
space:
mode:
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.py100
1 files changed, 68 insertions, 32 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 2e0331e8e..b8fbc6344 100644
--- a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py
+++ b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py
@@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import mock
+import datetime
+import mock
from trex_stl_lib import api as Pkt
from trex_stl_lib import trex_stl_client
from trex_stl_lib import trex_stl_packet_builder_scapy
from trex_stl_lib import trex_stl_streams
+from yardstick.common import constants
from yardstick.network_services.traffic_profile import rfc2544
from yardstick.tests.unit import base
@@ -102,10 +104,10 @@ class TestRFC2544Profile(base.BaseUnitTestCase):
mock_create_profile:
rfc2544_profile.execute_traffic(traffic_generator=mock_generator)
mock_create_profile.assert_has_calls([
- mock.call('profile1', rfc2544_profile.rate, mock.ANY),
- mock.call('profile1', rfc2544_profile.rate, mock.ANY),
- mock.call('profile2', rfc2544_profile.rate, mock.ANY),
- mock.call('profile2', rfc2544_profile.rate, mock.ANY)])
+ mock.call('profile1', rfc2544_profile.rate, mock.ANY, False),
+ mock.call('profile1', rfc2544_profile.rate, mock.ANY, False),
+ mock.call('profile2', rfc2544_profile.rate, mock.ANY, False),
+ mock.call('profile2', rfc2544_profile.rate, mock.ANY, False)])
mock_generator.client.add_streams.assert_has_calls([
mock.call(mock.ANY, ports=[10]),
mock.call(mock.ANY, ports=[20]),
@@ -129,25 +131,55 @@ class TestRFC2544Profile(base.BaseUnitTestCase):
mock_create_streams:
mock_create_imix.return_value = 'imix_data'
mock_create_streams.return_value = ['stream1']
- rfc2544_profile._create_profile(profile_data, rate, port_pg_id)
+ rfc2544_profile._create_profile(profile_data, rate, port_pg_id,
+ True)
mock_create_imix.assert_called_once_with('imix_info')
mock_create_vm.assert_called_once_with(
{'outer_l2': {'framesize': 'imix_info'}})
mock_create_streams.assert_called_once_with('imix_data', 100,
- port_pg_id)
+ port_pg_id, True)
mock_stl_profile.assert_called_once_with(['stream1'])
- def test__create_imix_data(self):
+ def test__create_imix_data_mode_DIB(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))
+ self.assertEqual(
+ {'64': 50.0, '128': 50.0},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_BYTES))
data = {'64B': 1, '128b': 3}
- self.assertEqual({'64': 25.0, '128': 75.0},
- rfc2544_profile._create_imix_data(data))
+ self.assertEqual(
+ {'64': 25.0, '128': 75.0},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_BYTES))
+ data = {}
+ self.assertEqual(
+ {},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_BYTES))
+
+ def test__create_imix_data_mode_DIP(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
+ self.assertEqual(
+ {'64': 64 * 25.0 * 100 / byte_total,
+ '128': 128 * 25.0 * 100 / byte_total,
+ '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 = {}
- self.assertEqual({}, rfc2544_profile._create_imix_data(data))
+ self.assertEqual(
+ {},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_PACKETS))
+ data = {'64B': 100}
+ self.assertEqual(
+ {'64': 100.0},
+ rfc2544_profile._create_imix_data(
+ data, weight_mode=constants.DISTRIBUTION_IN_PACKETS))
def test__create_vm(self):
packet = {'outer_l2': 'l2_definition'}
@@ -208,7 +240,7 @@ class TestRFC2544Profile(base.BaseUnitTestCase):
rfc2544_profile = rfc2544.RFC2544Profile(self.TRAFFIC_PROFILE)
with mock.patch.object(rfc2544_profile, '_create_single_packet'):
output = rfc2544_profile._create_streams(imix_data, rate,
- port_pg_id)
+ port_pg_id, True)
self.assertEqual(['stream1', 'stream2'], output)
mock_latency.assert_has_calls([
mock.call(pg_id=1), mock.call(pg_id=2)])
@@ -219,34 +251,38 @@ class TestRFC2544Profile(base.BaseUnitTestCase):
def test_get_drop_percentage(self):
rfc2544_profile = rfc2544.RFC2544Profile(self.TRAFFIC_PROFILE)
samples = [
- {'xe1': {'tx_throughput_fps': 100,
+ {'xe1': {'tx_throughput_fps': 110,
'rx_throughput_fps': 101,
- 'out_packets': 2000,
- 'in_packets': 2010},
- 'xe2': {'tx_throughput_fps': 200,
+ 'out_packets': 2100,
+ 'in_packets': 2010,
+ 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 1)},
+ 'xe2': {'tx_throughput_fps': 210,
'rx_throughput_fps': 201,
- 'out_packets': 4000,
- 'in_packets': 4010}},
- {'xe1': {'tx_throughput_fps': 106,
+ 'out_packets': 4100,
+ 'in_packets': 4010,
+ 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 1)}},
+ {'xe1': {'tx_throughput_fps': 156,
'rx_throughput_fps': 108,
- 'out_packets': 2031,
+ 'out_packets': 2110,
'in_packets': 2040,
- 'latency': 'Latency1'},
- 'xe2': {'tx_throughput_fps': 203,
+ 'latency': 'Latency1',
+ 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 31)},
+ 'xe2': {'tx_throughput_fps': 253,
'rx_throughput_fps': 215,
- 'out_packets': 4025,
- 'in_packets': 4040,
- 'latency': 'Latency2'}}
+ 'out_packets': 4150,
+ 'in_packets': 4010,
+ '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': 0.3963,
+ expected = {'DropPercentage': 50.0,
'Latency': {'xe1': 'Latency1', 'xe2': 'Latency2'},
- 'RxThroughput': 312.5,
- 'TxThroughput': 304.5,
- 'CurrentDropPercentage': 0.3963,
+ 'RxThroughput': 1000000.0,
+ 'TxThroughput': 2000000.0,
+ 'CurrentDropPercentage': 50.0,
'Rate': 100.0,
- 'Throughput': 312.5}
+ 'Throughput': 1000000.0}
self.assertEqual(expected, output)
self.assertFalse(completed)