Increase rounding digits in IXIA RFC2544 45/60045/3
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Fri, 20 Jul 2018 10:26:49 +0000 (11:26 +0100)
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Fri, 20 Jul 2018 14:12:56 +0000 (14:12 +0000)
Increase rounding digits in IXIA RFC2544 for:
  - Drop percentage: 6 digits
  - Rate: 5 digits, both for fps and % line rate.

JIRA: YARDSTICK-1338

Change-Id: Iae6e49dd3d15035452f28976af0b16222fa8e23c
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
yardstick/network_services/traffic_profile/ixia_rfc2544.py
yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py

index 7d54ec4..49bac27 100644 (file)
@@ -25,6 +25,8 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
 
     UPLINK = 'uplink'
     DOWNLINK = 'downlink'
+    DROP_PERCENT_ROUND = 6
+    RATE_ROUND = 5
 
     def __init__(self, yaml_data):
         super(IXIARFC2544Profile, self).__init__(yaml_data)
@@ -114,7 +116,8 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
             self.max_rate = self.rate
             self.min_rate = 0.0
         else:
-            self.rate = round(float(self.max_rate + self.min_rate) / 2.0, 2)
+            self.rate = round(float(self.max_rate + self.min_rate) / 2.0,
+                              self.RATE_ROUND)
 
         traffic = self._get_ixia_traffic_profile(self.full_profile, mac)
         self._ixia_traffic_generate(traffic, ixia_obj)
@@ -139,7 +142,8 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
 
         try:
             drop_percent = round(
-                (packet_drop / float(out_packets_sum)) * 100, 2)
+                (packet_drop / float(out_packets_sum)) * 100,
+                self.DROP_PERCENT_ROUND)
         except ZeroDivisionError:
             LOG.info('No traffic is flowing')
 
index 3bb8b91..4ea19a1 100644 (file)
@@ -554,7 +554,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
         self.assertTrue(completed)
         self.assertEqual(23.0, samples['TxThroughput'])
         self.assertEqual(21.0, samples['RxThroughput'])
-        self.assertEqual(0.1, samples['DropPercentage'])
+        self.assertEqual(0.099651, samples['DropPercentage'])
 
     def test_get_drop_percentage_over_drop_percentage(self):
         samples = {'iface_name_1':
@@ -571,7 +571,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
         self.assertFalse(completed)
         self.assertEqual(23.0, samples['TxThroughput'])
         self.assertEqual(21.0, samples['RxThroughput'])
-        self.assertEqual(0.1, samples['DropPercentage'])
+        self.assertEqual(0.099651, samples['DropPercentage'])
         self.assertEqual(rfc2544_profile.rate, rfc2544_profile.max_rate)
 
     def test_get_drop_percentage_under_drop_percentage(self):
@@ -589,7 +589,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
         self.assertFalse(completed)
         self.assertEqual(23.0, samples['TxThroughput'])
         self.assertEqual(21.0, samples['RxThroughput'])
-        self.assertEqual(0.1, samples['DropPercentage'])
+        self.assertEqual(0.099651, samples['DropPercentage'])
         self.assertEqual(rfc2544_profile.rate, rfc2544_profile.min_rate)
 
     @mock.patch.object(ixia_rfc2544.LOG, 'info')
@@ -625,5 +625,5 @@ class TestIXIARFC2544Profile(unittest.TestCase):
         self.assertTrue(completed)
         self.assertEqual(23.0, samples['TxThroughput'])
         self.assertEqual(21.0, samples['RxThroughput'])
-        self.assertEqual(0.1, samples['DropPercentage'])
+        self.assertEqual(0.099651, samples['DropPercentage'])
         self.assertEqual(33.45, rfc2544_profile.rate)