aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-08-24 21:30:52 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-24 21:30:52 +0000
commitffecd5b84eecdb74d7534b801c1359251c34b34e (patch)
tree983692e783bc14699440740b9a39671ff8b50520
parentaa357e44fcd77cbc6b6c7444c06602d474d65ea4 (diff)
parent8bc2681e8c5ff635f71bf4244c58402c96ca0259 (diff)
Merge "add ppm into result of pktgen to make result clear"
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen.py10
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen.py13
2 files changed, 12 insertions, 11 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen.py b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
index 32ba255b2..0ca31d484 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
@@ -132,7 +132,7 @@ class PktgenTestCase(unittest.TestCase):
p._iptables_get_result = mock_iptables_result
sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "packetsize": 60, "flows": 110}'
+ "packets_sent": 149776, "packetsize": 60, "flows": 110, "ppm": 3179}'
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -159,7 +159,7 @@ class PktgenTestCase(unittest.TestCase):
p._iptables_get_result = mock_iptables_result
sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "packetsize": 60, "flows": 110}'
+ "packets_sent": 149776, "packetsize": 60, "flows": 110, "ppm": 3179}'
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -648,7 +648,7 @@ class PktgenTestCase(unittest.TestCase):
p._iptables_get_result = mock_iptables_result
sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149300, "flows": 110}'
+ "packets_sent": 149300, "flows": 110, "ppm": 0}'
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -693,7 +693,7 @@ class PktgenTestCase(unittest.TestCase):
p._iptables_get_result = mock_iptables_result
sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149300, "flows": 110}'
+ "packets_sent": 149300, "flows": 110, "ppm": 0}'
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -730,7 +730,7 @@ class PktgenTestCase(unittest.TestCase):
p._iptables_get_result = mock_iptables_result
sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149300, "flows": 110}'
+ "packets_sent": 149300, "flows": 110, "ppm": 0}'
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
diff --git a/yardstick/benchmark/scenarios/networking/pktgen.py b/yardstick/benchmark/scenarios/networking/pktgen.py
index 1e0a5fcbb..a9e7aa6a3 100644
--- a/yardstick/benchmark/scenarios/networking/pktgen.py
+++ b/yardstick/benchmark/scenarios/networking/pktgen.py
@@ -11,6 +11,7 @@ from __future__ import print_function
import os
import logging
+import math
import pkg_resources
from oslo_serialization import jsonutils
@@ -357,15 +358,15 @@ class Pktgen(base.Scenario):
result.update(jsonutils.loads(stdout))
- result['packets_received'] = self._iptables_get_result()
+ received = result['packets_received'] = self._iptables_get_result()
+ sent = result['packets_sent']
result['packetsize'] = packetsize
+ # compatible with python3 /
+ ppm = math.ceil(1000000.0 * (sent - received) / sent)
+
+ result['ppm'] = ppm
if "sla" in self.scenario_cfg:
- sent = result['packets_sent']
- received = result['packets_received']
- ppm = 1000000 * (sent - received) / sent
- # if ppm is 1, then 11 out of 10 million is no pass
- ppm += (sent - received) % sent > 0
LOG.debug("Lost packets %d - Lost ppm %d", (sent - received), ppm)
sla_max_ppm = int(self.scenario_cfg["sla"]["max_ppm"])
assert ppm <= sla_max_ppm, "ppm %d > sla_max_ppm %d; " \