From 102b603cf5ea3627381a84822890ad2d7879aeba Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 31 Aug 2018 10:43:26 +0100 Subject: TRex IMIX data must return percentage value Function "_create_imix_data" must return the weight in percentage, not in absolute value. JIRA: YARDSTICK-1406 Change-Id: I3bc409bab17ae5778a6783f4319699009a5437fa Signed-off-by: Rodolfo Alonso Hernandez --- yardstick/network_services/traffic_profile/rfc2544.py | 2 +- .../unit/network_services/traffic_profile/test_rfc2544.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/yardstick/network_services/traffic_profile/rfc2544.py b/yardstick/network_services/traffic_profile/rfc2544.py index 4b339c2ed..e33c437c9 100644 --- a/yardstick/network_services/traffic_profile/rfc2544.py +++ b/yardstick/network_services/traffic_profile/rfc2544.py @@ -197,7 +197,7 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): byte_total = sum([int(size) * weight for size, weight in imix_dip.items()]) - return {size: (int(size) * weight) / byte_total + return {size: (int(size) * weight * 100) / byte_total for size, weight in imix_dip.items()} def _create_vm(self, packet_definition): 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 4c546d7ef..b8fbc6344 100644 --- a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py +++ b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py @@ -164,8 +164,10 @@ class TestRFC2544Profile(base.BaseUnitTestCase): 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 / byte_total, '128': 128 * 25.0 / byte_total, - '512': 512 * 25.0 / byte_total, '1518': 1518 * 25.0 / byte_total}, + {'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 = {} @@ -173,6 +175,11 @@ class TestRFC2544Profile(base.BaseUnitTestCase): {}, 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'} -- cgit 1.2.3-korg