aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Pshyk <serhiyx.pshyk@intel.com>2019-01-31 14:23:59 +0000
committerSerhiy Pshyk <serhiyx.pshyk@intel.com>2019-01-31 14:31:23 +0000
commit11b0b1e3cfcc4b09008c33903d4bf70eb96beba7 (patch)
treefa1efca8d7042217a27c64e9c09c86b7c647e5bc
parent79cf0db4a45b64f2663468b7ea303b9c06fb2010 (diff)
Add rate 'resolution' option for IXIA rfc2544 test
Rate resolution value is compared with the difference between the rates in two consecutive iterations. If the difference is smaller than the resolution, the test stops. JIRA: YYARDSTICK-1592 Change-Id: I3f203d33d1688734a59a8f62f31e3ad238bc63b0 Signed-off-by: Serhiy Pshyk <serhiyx.pshyk@intel.com>
-rw-r--r--yardstick/network_services/traffic_profile/ixia_rfc2544.py19
-rw-r--r--yardstick/network_services/vnf_generic/vnf/sample_vnf.py9
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py25
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py50
4 files changed, 83 insertions, 20 deletions
diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
index 35038891b..7df590fb3 100644
--- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py
+++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
@@ -167,6 +167,10 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
self.ports = [port for port in port_generator()]
+ def _get_next_rate(self):
+ rate = round(float(self.max_rate + self.min_rate)/2.0, self.RATE_ROUND)
+ return rate
+
def execute_traffic(self, traffic_generator, ixia_obj=None, mac=None):
mac = {} if mac is None else mac
first_run = self.first_run
@@ -176,17 +180,16 @@ 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,
- self.RATE_ROUND)
+ self.rate = self._get_next_rate()
traffic = self._get_ixia_traffic_profile(self.full_profile, mac)
self._ixia_traffic_generate(traffic, ixia_obj)
return first_run
def get_drop_percentage(self, samples, tol_min, tolerance, precision,
- first_run=False):
+ resolution, first_run=False):
completed = False
- drop_percent = 100
+ drop_percent = 100.0
num_ifaces = len(samples)
duration = self.config.duration
in_packets_sum = sum(
@@ -217,6 +220,14 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
else:
completed = True
+ next_rate = self._get_next_rate()
+ if abs(next_rate - self.rate) < resolution:
+ LOG.debug("rate=%s, next_rate=%s, resolution=%s", self.rate,
+ next_rate, resolution)
+ # stop test if the difference between the rate transmission
+ # in two iterations is smaller than the value of the resolution
+ completed = True
+
LOG.debug("tolerance=%s, tolerance_precision=%s drop_percent=%s "
"completed=%s", tolerance, precision, drop_percent,
completed)
diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
index 82a6eda33..6c2e940d1 100644
--- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
@@ -470,6 +470,7 @@ class Rfc2544ResourceHelper(object):
DEFAULT_CORRELATED_TRAFFIC = False
DEFAULT_LATENCY = False
DEFAULT_TOLERANCE = '0.0001 - 0.0001'
+ DEFAULT_RESOLUTION = '0.1'
def __init__(self, scenario_helper):
super(Rfc2544ResourceHelper, self).__init__()
@@ -481,6 +482,7 @@ class Rfc2544ResourceHelper(object):
self._tolerance_low = None
self._tolerance_high = None
self._tolerance_precision = None
+ self._resolution = None
@property
def rfc2544(self):
@@ -520,6 +522,13 @@ class Rfc2544ResourceHelper(object):
self._latency = self.get_rfc2544('latency', self.DEFAULT_LATENCY)
return self._latency
+ @property
+ def resolution(self):
+ if self._resolution is None:
+ self._resolution = float(self.get_rfc2544('resolution',
+ self.DEFAULT_RESOLUTION))
+ return self._resolution
+
def get_rfc2544(self, name, default=None):
return self.rfc2544.get(name, default)
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
index c2327733a..2c3140f8c 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
@@ -543,6 +543,7 @@ class IxiaResourceHelper(ClientResourceHelper):
min_tol = self.rfc_helper.tolerance_low
max_tol = self.rfc_helper.tolerance_high
precision = self.rfc_helper.tolerance_precision
+ resolution = self.rfc_helper.resolution
default = "00:00:00:00:00:00"
self._build_ports()
@@ -563,8 +564,8 @@ class IxiaResourceHelper(ClientResourceHelper):
try:
while not self._terminated.value:
- first_run = traffic_profile.execute_traffic(
- self, self.client, mac)
+ first_run = traffic_profile.execute_traffic(self, self.client,
+ mac)
self.client_started.value = 1
# pylint: disable=unnecessary-lambda
utils.wait_until_true(lambda: self.client.is_traffic_stopped(),
@@ -573,7 +574,8 @@ class IxiaResourceHelper(ClientResourceHelper):
traffic_profile.config.duration)
completed, samples = traffic_profile.get_drop_percentage(
- samples, min_tol, max_tol, precision, first_run=first_run)
+ samples, min_tol, max_tol, precision, resolution,
+ first_run=first_run)
self._queue.put(samples)
if completed:
@@ -594,6 +596,7 @@ class IxiaResourceHelper(ClientResourceHelper):
min_tol = self.rfc_helper.tolerance_low
max_tol = self.rfc_helper.tolerance_high
precision = self.rfc_helper.tolerance_precision
+ resolution = self.rfc_helper.resolution
default = "00:00:00:00:00:00"
self._build_ports()
@@ -614,6 +617,7 @@ class IxiaResourceHelper(ClientResourceHelper):
try:
completed = False
+ self.rfc_helper.iteration.value = 0
self.client_started.value = 1
while completed is False and not self._terminated.value:
LOG.info("Wait for task ...")
@@ -626,9 +630,11 @@ class IxiaResourceHelper(ClientResourceHelper):
if task != 'RUN_TRAFFIC':
continue
- LOG.info("Got %s task", task)
- first_run = traffic_profile.execute_traffic(
- self, self.client, mac)
+ self.rfc_helper.iteration.value += 1
+ LOG.info("Got %s task, start iteration %d", task,
+ self.rfc_helper.iteration.value)
+ first_run = traffic_profile.execute_traffic(self, self.client,
+ mac)
# pylint: disable=unnecessary-lambda
utils.wait_until_true(lambda: self.client.is_traffic_stopped(),
timeout=traffic_profile.config.duration * 2)
@@ -636,7 +642,8 @@ class IxiaResourceHelper(ClientResourceHelper):
traffic_profile.config.duration)
completed, samples = traffic_profile.get_drop_percentage(
- samples, min_tol, max_tol, precision, first_run=first_run)
+ samples, min_tol, max_tol, precision, resolution,
+ first_run=first_run)
self._queue.put(samples)
if completed:
@@ -653,10 +660,6 @@ class IxiaResourceHelper(ClientResourceHelper):
self.client_started.value = 0
LOG.debug("IxiaResourceHelper::run_test done")
- def collect_kpi(self):
- self.rfc_helper.iteration.value += 1
- return super(IxiaResourceHelper, self).collect_kpi()
-
class IxiaTrafficGen(SampleVNFTrafficGen):
diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
index ef16676c7..3d12dddcf 100644
--- a/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
+++ b/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
@@ -584,8 +584,9 @@ class TestIXIARFC2544Profile(unittest.TestCase):
'Store-Forward_Max_latency_ns': 28}
}
rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE)
+ rfc2544_profile._get_next_rate = mock.Mock(return_value=100.0)
completed, samples = rfc2544_profile.get_drop_percentage(
- samples, 0, 1, 4)
+ samples, 0, 1, 4, 0.1)
self.assertTrue(completed)
self.assertEqual(66.9, samples['TxThroughput'])
self.assertEqual(66.833, samples['RxThroughput'])
@@ -608,8 +609,9 @@ class TestIXIARFC2544Profile(unittest.TestCase):
}
rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE)
rfc2544_profile.rate = 1000
+ rfc2544_profile._get_next_rate = mock.Mock(return_value=50.0)
completed, samples = rfc2544_profile.get_drop_percentage(
- samples, 0, 0.05, 4)
+ samples, 0, 0.05, 4, 0.1)
self.assertFalse(completed)
self.assertEqual(66.9, samples['TxThroughput'])
self.assertEqual(66.833, samples['RxThroughput'])
@@ -630,8 +632,9 @@ class TestIXIARFC2544Profile(unittest.TestCase):
}
rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE)
rfc2544_profile.rate = 1000
+ rfc2544_profile._get_next_rate = mock.Mock(return_value=50.0)
completed, samples = rfc2544_profile.get_drop_percentage(
- samples, 0.2, 1, 4)
+ samples, 0.2, 1, 4, 0.1)
self.assertFalse(completed)
self.assertEqual(66.9, samples['TxThroughput'])
self.assertEqual(66.833, samples['RxThroughput'])
@@ -653,8 +656,9 @@ class TestIXIARFC2544Profile(unittest.TestCase):
}
rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE)
rfc2544_profile.rate = 1000
+ rfc2544_profile._get_next_rate = mock.Mock(return_value=50.0)
completed, samples = rfc2544_profile.get_drop_percentage(
- samples, 0.2, 1, 4)
+ samples, 0.2, 1, 4, 0.1)
self.assertFalse(completed)
self.assertEqual(0.0, samples['TxThroughput'])
self.assertEqual(66.833, samples['RxThroughput'])
@@ -674,14 +678,50 @@ class TestIXIARFC2544Profile(unittest.TestCase):
'Store-Forward_Max_latency_ns': 25}
}
rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE)
+ rfc2544_profile._get_next_rate = mock.Mock(return_value=50.0)
completed, samples = rfc2544_profile.get_drop_percentage(
- samples, 0, 1, 4, first_run=True)
+ samples, 0, 1, 4, 0.1, first_run=True)
self.assertTrue(completed)
self.assertEqual(66.9, samples['TxThroughput'])
self.assertEqual(66.833, samples['RxThroughput'])
self.assertEqual(0.099651, samples['DropPercentage'])
self.assertEqual(33.45, rfc2544_profile.rate)
+ def test_get_drop_percentage_resolution(self):
+ rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE)
+ rfc2544_profile._get_next_rate = mock.Mock(return_value=0.1)
+ samples = {'iface_name_1':
+ {'in_packets': 1000, 'out_packets': 1000,
+ 'Store-Forward_Avg_latency_ns': 20,
+ 'Store-Forward_Min_latency_ns': 15,
+ 'Store-Forward_Max_latency_ns': 25},
+ 'iface_name_2':
+ {'in_packets': 1005, 'out_packets': 1007,
+ 'Store-Forward_Avg_latency_ns': 20,
+ 'Store-Forward_Min_latency_ns': 15,
+ 'Store-Forward_Max_latency_ns': 25}
+ }
+ rfc2544_profile.rate = 0.19
+ completed, _ = rfc2544_profile.get_drop_percentage(
+ samples, 0, 0.05, 4, 0.1)
+ self.assertTrue(completed)
+
+ samples = {'iface_name_1':
+ {'in_packets': 1000, 'out_packets': 1000,
+ 'Store-Forward_Avg_latency_ns': 20,
+ 'Store-Forward_Min_latency_ns': 15,
+ 'Store-Forward_Max_latency_ns': 25},
+ 'iface_name_2':
+ {'in_packets': 1005, 'out_packets': 1007,
+ 'Store-Forward_Avg_latency_ns': 20,
+ 'Store-Forward_Min_latency_ns': 15,
+ 'Store-Forward_Max_latency_ns': 25}
+ }
+ rfc2544_profile.rate = 0.5
+ completed, _ = rfc2544_profile.get_drop_percentage(
+ samples, 0, 0.05, 4, 0.1)
+ self.assertFalse(completed)
+
class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase):