diff options
-rw-r--r-- | tests/unit/benchmark/scenarios/networking/test_ping.py | 14 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping.py | 17 |
2 files changed, 21 insertions, 10 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_ping.py b/tests/unit/benchmark/scenarios/networking/test_ping.py index 600974510..8d35b8490 100644 --- a/tests/unit/benchmark/scenarios/networking/test_ping.py +++ b/tests/unit/benchmark/scenarios/networking/test_ping.py @@ -36,6 +36,7 @@ class PingTestCase(unittest.TestCase): args = { 'options': {'packetsize': 200}, + 'target': 'ares.demo' } result = {} @@ -43,14 +44,15 @@ class PingTestCase(unittest.TestCase): mock_ssh.SSH().execute.return_value = (0, '100', '') p.run(result) - self.assertEqual(result, {'rtt': {'10.229.17.105': 100.0}}) + self.assertEqual(result, {'rtt': {'ares': 100.0}}) @mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh') def test_ping_successful_sla(self, mock_ssh): args = { 'options': {'packetsize': 200}, - 'sla': {'max_rtt': 150} + 'sla': {'max_rtt': 150}, + 'target': 'ares.demo' } result = {} @@ -58,14 +60,15 @@ class PingTestCase(unittest.TestCase): mock_ssh.SSH().execute.return_value = (0, '100', '') p.run(result) - self.assertEqual(result, {'rtt': {'10.229.17.105': 100.0}}) + self.assertEqual(result, {'rtt': {'ares': 100.0}}) @mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh') def test_ping_unsuccessful_sla(self, mock_ssh): args = { 'options': {'packetsize': 200}, - 'sla': {'max_rtt': 50} + 'sla': {'max_rtt': 50}, + 'target': 'ares.demo' } result = {} @@ -79,7 +82,8 @@ class PingTestCase(unittest.TestCase): args = { 'options': {'packetsize': 200}, - 'sla': {'max_rtt': 50} + 'sla': {'max_rtt': 50}, + 'target': 'ares.demo' } result = {} diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py index 08755a08b..54c192294 100644 --- a/yardstick/benchmark/scenarios/networking/ping.py +++ b/yardstick/benchmark/scenarios/networking/ping.py @@ -69,7 +69,12 @@ class Ping(base.Scenario): result["rtt"] = {} rtt_result = result["rtt"] - for dest in dest_list: + for pos, dest in enumerate(dest_list): + if 'targets' in self.scenario_cfg: + target_vm = self.scenario_cfg['targets'][pos] + else: + target_vm = self.scenario_cfg['target'] + LOG.debug("ping '%s' '%s'", options, dest) exit_status, stdout, stderr = self.connection.execute( "/bin/sh -s {0} {1}".format(dest, options), @@ -79,13 +84,15 @@ class Ping(base.Scenario): raise RuntimeError(stderr) if stdout: - rtt_result[dest] = float(stdout) + target_vm_name = target_vm.split('.')[0] + rtt_result[target_vm_name] = float(stdout) if "sla" in self.scenario_cfg: sla_max_rtt = int(self.scenario_cfg["sla"]["max_rtt"]) - assert rtt_result[dest] <= sla_max_rtt, "rtt %f > sla:\ - max_rtt(%f); " % (rtt_result[dest], sla_max_rtt) + assert rtt_result[target_vm_name] <= sla_max_rtt,\ + "rtt %f > sla: max_rtt(%f); " % \ + (rtt_result[target_vm_name], sla_max_rtt) else: - LOG.error("ping '%s' '%s' timeout", options, dest) + LOG.error("ping '%s' '%s' timeout", options, target_vm) def _test(): # pragma: no cover |