From 2ed0a4e85f710c24aae778634e9d48920d004f09 Mon Sep 17 00:00:00 2001 From: kubi Date: Fri, 15 Jan 2016 19:40:28 +0800 Subject: fix some bug in ipv6 to make it run in ci JIRA:YARDSTICK-187 Change-Id: Ia15d17afdef145f7b230a8a4d25a61eed5cdfd76 Signed-off-by: kubi --- .../benchmark/scenarios/networking/test_ping6.py | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'tests/unit/benchmark/scenarios/networking') diff --git a/tests/unit/benchmark/scenarios/networking/test_ping6.py b/tests/unit/benchmark/scenarios/networking/test_ping6.py index 662b85c30..b600e4103 100644 --- a/tests/unit/benchmark/scenarios/networking/test_ping6.py +++ b/tests/unit/benchmark/scenarios/networking/test_ping6.py @@ -21,18 +21,23 @@ class PingTestCase(unittest.TestCase): def setUp(self): self.ctx = { - 'host': { + 'nodes':{ + 'host1': { 'ip': '172.16.0.137', 'user': 'cirros', 'key_filename': "mykey.key", 'password': "root" - }, + }, + } } @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') - def test_pktgen_successful_setup(self, mock_ssh): - - p = ping6.Ping6({}, self.ctx) + def test_ping_successful_setup(self, mock_ssh): + args = { + 'options': {'host': 'host1','packetsize': 200}, + 'sla': {'max_rtt': 50} + } + p = ping6.Ping6(args, self.ctx) mock_ssh.SSH().execute.return_value = (0, '0', '') p.setup() @@ -40,12 +45,15 @@ class PingTestCase(unittest.TestCase): @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_successful_no_sla(self, mock_ssh): + args = { + 'options': {'host': 'host1','packetsize': 200}, + } result = {} - p = ping6.Ping6({}, self.ctx) + p = ping6.Ping6(args, self.ctx) p.client = mock_ssh.SSH() - mock_ssh.SSH().execute.return_value = (0, '100', '') + mock_ssh.SSH().execute.side_effect = [(0, 'host1', ''),(0, 100, '')] p.run(result) self.assertEqual(result, {'rtt': 100.0}) @@ -53,13 +61,14 @@ class PingTestCase(unittest.TestCase): def test_ping_successful_sla(self, mock_ssh): args = { + 'options': {'host': 'host1','packetsize': 200}, 'sla': {'max_rtt': 150} - } + } result = {} p = ping6.Ping6(args, self.ctx) p.client = mock_ssh.SSH() - mock_ssh.SSH().execute.return_value = (0, '100', '') + mock_ssh.SSH().execute.side_effect = [(0, 'host1', ''),(0, 100, '')] p.run(result) self.assertEqual(result, {'rtt': 100.0}) @@ -67,28 +76,28 @@ class PingTestCase(unittest.TestCase): def test_ping_unsuccessful_sla(self, mock_ssh): args = { - 'options': {'packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200}, 'sla': {'max_rtt': 50} } result = {} p = ping6.Ping6(args, self.ctx) p.client = mock_ssh.SSH() - mock_ssh.SSH().execute.return_value = (0, '100', '') + mock_ssh.SSH().execute.side_effect = [(0, 'host1', ''),(0, 100, '')] self.assertRaises(AssertionError, p.run, result) @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_unsuccessful_script_error(self, mock_ssh): args = { - 'options': {'packetsize': 200}, - 'sla': {'max_rtt': 50} + 'options': {'host': 'host1','packetsize': 200}, + 'sla': {'max_rtt': 150} } result = {} p = ping6.Ping6(args, self.ctx) p.client = mock_ssh.SSH() - mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR') + mock_ssh.SSH().execute.side_effect = [(0, 'host1', ''),(1, '', 'FOOBAR')] self.assertRaises(RuntimeError, p.run, result) -- cgit 1.2.3-korg