aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/networking/test_pktgen.py
diff options
context:
space:
mode:
authorQiLiang <liangqi1@huawei.com>2015-10-21 12:29:53 +0000
committerQiLiang <liangqi1@huawei.com>2015-10-27 03:34:28 +0000
commit2e1094d4aee93180126d3ce86db3cc7df2e87bc5 (patch)
tree221e98fd325ff6fcb4fbbb3e656a3789f3a77342 /tests/unit/benchmark/scenarios/networking/test_pktgen.py
parent884926d05f435217c7dac038b3bfbd7e9d05826b (diff)
Heat context code refactor part 2
Heat context code refactor to cater for the evolution of the Yardstick framework. Refactor runner_cfg host/target info handle, as specified at https://etherpad.opnfv.org/p/yardstick_framework step 4. Get general Context info (use Context.get). Before this refactor host and target vm must have the same user name and ssh key, that is not general enough for later extension. test_case.yaml do NOT need to change. JIRA: YARDSTICK-168 Change-Id: I5cfe868f3c6f633214ef550bc9676fe1de0709db Signed-off-by: QiLiang <liangqi1@huawei.com>
Diffstat (limited to 'tests/unit/benchmark/scenarios/networking/test_pktgen.py')
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen.py59
1 files changed, 33 insertions, 26 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen.py b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
index ae4481f0e..13a4c1bd4 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
@@ -23,19 +23,25 @@ class PktgenTestCase(unittest.TestCase):
def setUp(self):
self.ctx = {
- 'host': '172.16.0.137',
- 'target': '172.16.0.138',
- 'user': 'cirros',
- 'key_filename': "mykey.key"
+ 'host': {
+ 'ip': '172.16.0.137',
+ 'user': 'root',
+ 'key_filename': 'mykey.key'
+ },
+ 'target': {
+ 'ip': '172.16.0.138',
+ 'user': 'root',
+ 'key_filename': 'mykey.key',
+ 'ipaddr': '172.16.0.138'
+ }
}
def test_pktgen_successful_setup(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60},
- 'ipaddr': '172.16.0.139'
}
+ p = pktgen.Pktgen(args, self.ctx)
p.setup()
mock_ssh.SSH().execute.return_value = (0, '', '')
@@ -45,11 +51,10 @@ class PktgenTestCase(unittest.TestCase):
def test_pktgen_successful_iptables_setup(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
- 'ipaddr': '172.16.0.139'
}
+ p = pktgen.Pktgen(args, self.ctx)
p.server = mock_ssh.SSH()
p.number_of_ports = args['options']['number_of_ports']
@@ -64,11 +69,11 @@ class PktgenTestCase(unittest.TestCase):
def test_pktgen_unsuccessful_iptables_setup(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
- 'ipaddr': '172.16.0.139'
}
+
+ p = pktgen.Pktgen(args, self.ctx)
p.server = mock_ssh.SSH()
p.number_of_ports = args['options']['number_of_ports']
@@ -77,11 +82,11 @@ class PktgenTestCase(unittest.TestCase):
def test_pktgen_successful_iptables_get_result(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
- 'ipaddr': '172.16.0.139'
}
+
+ p = pktgen.Pktgen(args, self.ctx)
p.server = mock_ssh.SSH()
p.number_of_ports = args['options']['number_of_ports']
@@ -95,11 +100,12 @@ class PktgenTestCase(unittest.TestCase):
def test_pktgen_unsuccessful_iptables_get_result(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
- 'ipaddr': '172.16.0.139'
}
+
+ p = pktgen.Pktgen(args, self.ctx)
+
p.server = mock_ssh.SSH()
p.number_of_ports = args['options']['number_of_ports']
@@ -108,13 +114,13 @@ class PktgenTestCase(unittest.TestCase):
def test_pktgen_successful_no_sla(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
- 'ipaddr': '172.16.0.139'
}
result = {}
+ p = pktgen.Pktgen(args, self.ctx)
+
p.server = mock_ssh.SSH()
p.client = mock_ssh.SSH()
@@ -126,20 +132,21 @@ class PktgenTestCase(unittest.TestCase):
"packets_sent": 149776, "flows": 110}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- p.run(args, result)
+ p.run(result)
expected_result = json.loads(sample_output)
expected_result["packets_received"] = 149300
self.assertEqual(result, expected_result)
def test_pktgen_successful_sla(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
- 'ipaddr': '172.16.0.139',
'sla': {'max_ppm': 10000}
}
result = {}
+
+ p = pktgen.Pktgen(args, self.ctx)
+
p.server = mock_ssh.SSH()
p.client = mock_ssh.SSH()
@@ -151,21 +158,21 @@ class PktgenTestCase(unittest.TestCase):
"packets_sent": 149776, "flows": 110}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- p.run(args, result)
+ p.run(result)
expected_result = json.loads(sample_output)
expected_result["packets_received"] = 149300
self.assertEqual(result, expected_result)
def test_pktgen_unsuccessful_sla(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
- 'ipaddr': '172.16.0.139',
'sla': {'max_ppm': 1000}
}
result = {}
+ p = pktgen.Pktgen(args, self.ctx)
+
p.server = mock_ssh.SSH()
p.client = mock_ssh.SSH()
@@ -176,23 +183,23 @@ class PktgenTestCase(unittest.TestCase):
sample_output = '{"packets_per_second": 9753, "errors": 0, \
"packets_sent": 149776, "flows": 110}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, args, result)
+ self.assertRaises(AssertionError, p.run, result)
def test_pktgen_unsuccessful_script_error(self, mock_ssh):
- p = pktgen.Pktgen(self.ctx)
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
- 'ipaddr': '172.16.0.139',
'sla': {'max_ppm': 1000}
}
result = {}
+ p = pktgen.Pktgen(args, self.ctx)
+
p.server = mock_ssh.SSH()
p.client = mock_ssh.SSH()
mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, args, result)
+ self.assertRaises(RuntimeError, p.run, result)
def main():