aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark
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
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')
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py4
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_cyclictest.py34
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_iperf3.py81
-rwxr-xr-xtests/unit/benchmark/scenarios/networking/test_netperf.py57
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_ping.py43
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen.py59
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_fio.py42
7 files changed, 173 insertions, 147 deletions
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index bf1174e27..f891b0a5f 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -110,5 +110,5 @@ class HeatContextTestCase(unittest.TestCase):
'private_ip_attr': 'private_ip'}
result = heat.HeatContext._get_server(self.mock_context, attr_name)
- self.assertEqual(result.public_ip, '127.0.0.1')
- self.assertEqual(result.private_ip, '10.0.0.1')
+ self.assertEqual(result['ip'], '127.0.0.1')
+ self.assertEqual(result['private_ip'], '10.0.0.1')
diff --git a/tests/unit/benchmark/scenarios/compute/test_cyclictest.py b/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
index 28dc4d6b3..a87b39142 100644
--- a/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
+++ b/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
@@ -23,14 +23,16 @@ class CyclictestTestCase(unittest.TestCase):
def setUp(self):
self.ctx = {
- "host": "192.168.50.28",
- "user": "root",
- "key_filename": "mykey.key"
+ "host": {
+ "ip": "192.168.50.28",
+ "user": "root",
+ "key_filename": "mykey.key"
+ }
}
def test_cyclictest_successful_setup(self, mock_ssh):
- c = cyclictest.Cyclictest(self.ctx)
+ c = cyclictest.Cyclictest({}, self.ctx)
c.setup()
mock_ssh.SSH().execute.return_value = (0, '', '')
@@ -39,7 +41,6 @@ class CyclictestTestCase(unittest.TestCase):
def test_cyclictest_successful_no_sla(self, mock_ssh):
- c = cyclictest.Cyclictest(self.ctx)
options = {
"affinity": 2,
"interval": 100,
@@ -51,6 +52,7 @@ class CyclictestTestCase(unittest.TestCase):
args = {
"options": options,
}
+ c = cyclictest.Cyclictest(args, self.ctx)
result = {}
c.server = mock_ssh.SSH()
@@ -58,13 +60,12 @@ class CyclictestTestCase(unittest.TestCase):
sample_output = '{"min": 100, "avg": 500, "max": 1000}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- c.run(args, result)
+ c.run(result)
expected_result = json.loads(sample_output)
self.assertEqual(result, expected_result)
def test_cyclictest_successful_sla(self, mock_ssh):
- c = cyclictest.Cyclictest(self.ctx)
options = {
"affinity": 2,
"interval": 100,
@@ -82,6 +83,7 @@ class CyclictestTestCase(unittest.TestCase):
"options": options,
"sla": sla
}
+ c = cyclictest.Cyclictest(args, self.ctx)
result = {}
c.server = mock_ssh.SSH()
@@ -89,58 +91,57 @@ class CyclictestTestCase(unittest.TestCase):
sample_output = '{"min": 100, "avg": 500, "max": 1000}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- c.run(args, result)
+ c.run(result)
expected_result = json.loads(sample_output)
self.assertEqual(result, expected_result)
def test_cyclictest_unsuccessful_sla_min_latency(self, mock_ssh):
- c = cyclictest.Cyclictest(self.ctx)
args = {
"options": {},
"sla": {"max_min_latency": 10}
}
+ c = cyclictest.Cyclictest(args, self.ctx)
result = {}
c.server = mock_ssh.SSH()
sample_output = '{"min": 100, "avg": 500, "max": 1000}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, c.run, args, result)
+ self.assertRaises(AssertionError, c.run, result)
def test_cyclictest_unsuccessful_sla_avg_latency(self, mock_ssh):
- c = cyclictest.Cyclictest(self.ctx)
args = {
"options": {},
"sla": {"max_avg_latency": 10}
}
+ c = cyclictest.Cyclictest(args, self.ctx)
result = {}
c.server = mock_ssh.SSH()
sample_output = '{"min": 100, "avg": 500, "max": 1000}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, c.run, args, result)
+ self.assertRaises(AssertionError, c.run, result)
def test_cyclictest_unsuccessful_sla_max_latency(self, mock_ssh):
- c = cyclictest.Cyclictest(self.ctx)
args = {
"options": {},
"sla": {"max_max_latency": 10}
}
+ c = cyclictest.Cyclictest(args, self.ctx)
result = {}
c.server = mock_ssh.SSH()
sample_output = '{"min": 100, "avg": 500, "max": 1000}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, c.run, args, result)
+ self.assertRaises(AssertionError, c.run, result)
def test_cyclictest_unsuccessful_script_error(self, mock_ssh):
- c = cyclictest.Cyclictest(self.ctx)
options = {
"affinity": 2,
"interval": 100,
@@ -158,12 +159,13 @@ class CyclictestTestCase(unittest.TestCase):
"options": options,
"sla": sla
}
+ c = cyclictest.Cyclictest(args, self.ctx)
result = {}
c.server = mock_ssh.SSH()
mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, c.run, args, result)
+ self.assertRaises(RuntimeError, c.run, result)
def main():
diff --git a/tests/unit/benchmark/scenarios/networking/test_iperf3.py b/tests/unit/benchmark/scenarios/networking/test_iperf3.py
index 2ec73ebd2..91f800b60 100644
--- a/tests/unit/benchmark/scenarios/networking/test_iperf3.py
+++ b/tests/unit/benchmark/scenarios/networking/test_iperf3.py
@@ -26,15 +26,22 @@ class IperfTestCase(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_iperf_successful_setup(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
+ p = iperf3.Iperf({}, self.ctx)
mock_ssh.SSH().execute.return_value = (0, '', '')
p.setup()
@@ -44,13 +51,13 @@ class IperfTestCase(unittest.TestCase):
def test_iperf_unsuccessful_setup(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
+ p = iperf3.Iperf({}, self.ctx)
mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.setup)
def test_iperf_successful_teardown(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
+ p = iperf3.Iperf({}, self.ctx)
mock_ssh.SSH().execute.return_value = (0, '', '')
p.host = mock_ssh.SSH()
p.target = mock_ssh.SSH()
@@ -61,26 +68,22 @@ class IperfTestCase(unittest.TestCase):
def test_iperf_successful_no_sla(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {}
args = {'options': options}
result = {}
+ p = iperf3.Iperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
sample_output = self._read_sample_output(self.output_name_tcp)
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
expected_result = json.loads(sample_output)
- p.run(args, result)
+ p.run(result)
self.assertEqual(result, expected_result)
def test_iperf_successful_sla(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {}
args = {
'options': options,
@@ -88,18 +91,18 @@ class IperfTestCase(unittest.TestCase):
}
result = {}
+ p = iperf3.Iperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
sample_output = self._read_sample_output(self.output_name_tcp)
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
expected_result = json.loads(sample_output)
- p.run(args, result)
+ p.run(result)
self.assertEqual(result, expected_result)
def test_iperf_unsuccessful_sla(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {}
args = {
'options': options,
@@ -107,16 +110,16 @@ class IperfTestCase(unittest.TestCase):
}
result = {}
+ p = iperf3.Iperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
sample_output = self._read_sample_output(self.output_name_tcp)
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, args, result)
+ self.assertRaises(AssertionError, p.run, result)
def test_iperf_successful_sla_jitter(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {"udp":"udp","bandwidth":"20m"}
args = {
'options': options,
@@ -124,18 +127,18 @@ class IperfTestCase(unittest.TestCase):
}
result = {}
+ p = iperf3.Iperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
sample_output = self._read_sample_output(self.output_name_udp)
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
expected_result = json.loads(sample_output)
- p.run(args, result)
+ p.run(result)
self.assertEqual(result, expected_result)
def test_iperf_unsuccessful_sla_jitter(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {"udp":"udp","bandwidth":"20m"}
args = {
'options': options,
@@ -143,22 +146,26 @@ class IperfTestCase(unittest.TestCase):
}
result = {}
+ p = iperf3.Iperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
sample_output = self._read_sample_output(self.output_name_udp)
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, args, result)
+ self.assertRaises(AssertionError, p.run, result)
def test_iperf_unsuccessful_script_error(self, mock_ssh):
- p = iperf3.Iperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {}
args = {'options': options}
result = {}
+ p = iperf3.Iperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = 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 _read_sample_output(self,filename):
curr_path = os.path.dirname(os.path.abspath(__file__))
diff --git a/tests/unit/benchmark/scenarios/networking/test_netperf.py b/tests/unit/benchmark/scenarios/networking/test_netperf.py
index 4bb5983c3..3f224733c 100755
--- a/tests/unit/benchmark/scenarios/networking/test_netperf.py
+++ b/tests/unit/benchmark/scenarios/networking/test_netperf.py
@@ -24,15 +24,22 @@ class NetperfTestCase(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': 'cirros',
+ 'key_filename': 'mykey.key'
+ },
+ 'target': {
+ 'ip': '172.16.0.138',
+ 'user': 'cirros',
+ 'key_filename': 'mykey.key',
+ 'ipaddr': '172.16.0.138'
+ }
}
def test_netperf_successful_setup(self, mock_ssh):
- p = netperf.Netperf(self.ctx)
+ p = netperf.Netperf({}, self.ctx)
mock_ssh.SSH().execute.return_value = (0, '', '')
p.setup()
@@ -42,26 +49,22 @@ class NetperfTestCase(unittest.TestCase):
def test_netperf_successful_no_sla(self, mock_ssh):
- p = netperf.Netperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {}
args = {'options': options}
result = {}
+ p = netperf.Netperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
sample_output = self._read_sample_output()
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
expected_result = json.loads(sample_output)
- p.run(args, result)
+ p.run(result)
self.assertEqual(result, expected_result)
def test_netperf_successful_sla(self, mock_ssh):
- p = netperf.Netperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {}
args = {
'options': options,
@@ -69,18 +72,18 @@ class NetperfTestCase(unittest.TestCase):
}
result = {}
+ p = netperf.Netperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
sample_output = self._read_sample_output()
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
expected_result = json.loads(sample_output)
- p.run(args, result)
+ p.run(result)
self.assertEqual(result, expected_result)
def test_netperf_unsuccessful_sla(self, mock_ssh):
- p = netperf.Netperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {}
args = {
'options': options,
@@ -88,22 +91,26 @@ class NetperfTestCase(unittest.TestCase):
}
result = {}
+ p = netperf.Netperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
sample_output = self._read_sample_output()
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, args, result)
+ self.assertRaises(AssertionError, p.run, result)
def test_netperf_unsuccessful_script_error(self, mock_ssh):
- p = netperf.Netperf(self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH()
-
options = {}
args = {'options': options}
result = {}
+ p = netperf.Netperf(args, self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = 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 _read_sample_output(self):
curr_path = os.path.dirname(os.path.abspath(__file__))
diff --git a/tests/unit/benchmark/scenarios/networking/test_ping.py b/tests/unit/benchmark/scenarios/networking/test_ping.py
index b2c5b9859..3a897d0f8 100644
--- a/tests/unit/benchmark/scenarios/networking/test_ping.py
+++ b/tests/unit/benchmark/scenarios/networking/test_ping.py
@@ -21,71 +21,72 @@ class PingTestCase(unittest.TestCase):
def setUp(self):
self.ctx = {
- 'host': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': "mykey.key"
+ 'host': {
+ 'ip': '172.16.0.137',
+ 'user': 'cirros',
+ 'key_filename': "mykey.key"
+ },
+ "target": {
+ "ipaddr": "10.229.17.105",
}
+ }
@mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
def test_ping_successful_no_sla(self, mock_ssh):
- p = ping.Ping(self.ctx)
-
args = {
'options': {'packetsize': 200},
- 'ipaddr': '172.16.0.138'
}
result = {}
+ p = ping.Ping(args, self.ctx)
+
mock_ssh.SSH().execute.return_value = (0, '100', '')
- p.run(args, result)
+ p.run(result)
self.assertEqual(result, {'rtt': 100.0})
@mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
def test_ping_successful_sla(self, mock_ssh):
- p = ping.Ping(self.ctx)
-
args = {
'options': {'packetsize': 200},
- 'ipaddr': '172.16.0.138',
'sla': {'max_rtt': 150}
}
result = {}
+ p = ping.Ping(args, self.ctx)
+
mock_ssh.SSH().execute.return_value = (0, '100', '')
- p.run(args, result)
+ p.run(result)
self.assertEqual(result, {'rtt': 100.0})
@mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
def test_ping_unsuccessful_sla(self, mock_ssh):
- p = ping.Ping(self.ctx)
-
args = {
'options': {'packetsize': 200},
- 'ipaddr': '172.16.0.138',
'sla': {'max_rtt': 50}
- }
+ }
result = {}
+ p = ping.Ping(args, self.ctx)
+
mock_ssh.SSH().execute.return_value = (0, '100', '')
- self.assertRaises(AssertionError, p.run, args, result)
+ self.assertRaises(AssertionError, p.run, result)
@mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
def test_ping_unsuccessful_script_error(self, mock_ssh):
- p = ping.Ping(self.ctx)
-
args = {
'options': {'packetsize': 200},
- 'ipaddr': '172.16.0.138',
'sla': {'max_rtt': 50}
- }
+ }
result = {}
+ p = ping.Ping(args, self.ctx)
+
mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, args, result)
+ self.assertRaises(RuntimeError, p.run, result)
def main():
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():
diff --git a/tests/unit/benchmark/scenarios/storage/test_fio.py b/tests/unit/benchmark/scenarios/storage/test_fio.py
index b47aed968..ac8aa0684 100644
--- a/tests/unit/benchmark/scenarios/storage/test_fio.py
+++ b/tests/unit/benchmark/scenarios/storage/test_fio.py
@@ -24,9 +24,11 @@ class FioTestCase(unittest.TestCase):
def setUp(self):
self.ctx = {
- 'host': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': 'mykey.key'
+ 'host': {
+ 'ip': '172.16.0.137',
+ 'user': 'cirros',
+ 'key_filename': 'mykey.key'
+ }
}
self.sample_output = {
'read': 'fio_read_sample_output.json',
@@ -36,7 +38,6 @@ class FioTestCase(unittest.TestCase):
def test_fio_successful_setup(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -44,6 +45,7 @@ class FioTestCase(unittest.TestCase):
'ramp_time': 10
}
args = {'options': options}
+ p = fio.Fio(args, self.ctx)
p.setup()
mock_ssh.SSH().execute.return_value = (0, '', '')
@@ -52,7 +54,6 @@ class FioTestCase(unittest.TestCase):
def test_fio_successful_no_sla(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -60,6 +61,7 @@ class FioTestCase(unittest.TestCase):
'ramp_time': 10
}
args = {'options': options}
+ p = fio.Fio(args, self.ctx)
result = {}
p.client = mock_ssh.SSH()
@@ -67,7 +69,7 @@ class FioTestCase(unittest.TestCase):
sample_output = self._read_sample_output(self.sample_output['rw'])
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- p.run(args, result)
+ p.run(result)
expected_result = '{"read_bw": 83888, "read_iops": 20972,' \
'"read_lat": 236.8, "write_bw": 84182, "write_iops": 21045,'\
@@ -77,7 +79,6 @@ class FioTestCase(unittest.TestCase):
def test_fio_successful_read_no_sla(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -85,6 +86,7 @@ class FioTestCase(unittest.TestCase):
'ramp_time': 10
}
args = {'options': options}
+ p = fio.Fio(args, self.ctx)
result = {}
p.client = mock_ssh.SSH()
@@ -92,7 +94,7 @@ class FioTestCase(unittest.TestCase):
sample_output = self._read_sample_output(self.sample_output['read'])
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- p.run(args, result)
+ p.run(result)
expected_result = '{"read_bw": 36113, "read_iops": 9028,' \
'"read_lat": 108.7}'
@@ -101,7 +103,6 @@ class FioTestCase(unittest.TestCase):
def test_fio_successful_write_no_sla(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -109,6 +110,7 @@ class FioTestCase(unittest.TestCase):
'ramp_time': 10
}
args = {'options': options}
+ p = fio.Fio(args, self.ctx)
result = {}
p.client = mock_ssh.SSH()
@@ -116,7 +118,7 @@ class FioTestCase(unittest.TestCase):
sample_output = self._read_sample_output(self.sample_output['write'])
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- p.run(args, result)
+ p.run(result)
expected_result = '{"write_bw": 35107, "write_iops": 8776,'\
'"write_lat": 111.74}'
@@ -125,7 +127,6 @@ class FioTestCase(unittest.TestCase):
def test_fio_successful_lat_sla(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -136,6 +137,7 @@ class FioTestCase(unittest.TestCase):
'options': options,
'sla': {'write_lat': 300.1}
}
+ p = fio.Fio(args, self.ctx)
result = {}
p.client = mock_ssh.SSH()
@@ -143,7 +145,7 @@ class FioTestCase(unittest.TestCase):
sample_output = self._read_sample_output(self.sample_output['rw'])
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- p.run(args, result)
+ p.run(result)
expected_result = '{"read_bw": 83888, "read_iops": 20972,' \
'"read_lat": 236.8, "write_bw": 84182, "write_iops": 21045,'\
@@ -154,7 +156,6 @@ class FioTestCase(unittest.TestCase):
def test_fio_unsuccessful_lat_sla(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -165,17 +166,17 @@ class FioTestCase(unittest.TestCase):
'options': options,
'sla': {'write_lat': 200.1}
}
+ p = fio.Fio(args, self.ctx)
result = {}
p.client = mock_ssh.SSH()
sample_output = self._read_sample_output(self.sample_output['rw'])
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, args, result)
+ self.assertRaises(AssertionError, p.run, result)
def test_fio_successful_bw_iops_sla(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -186,6 +187,7 @@ class FioTestCase(unittest.TestCase):
'options': options,
'sla': {'read_iops': 20000}
}
+ p = fio.Fio(args, self.ctx)
result = {}
p.client = mock_ssh.SSH()
@@ -193,7 +195,7 @@ class FioTestCase(unittest.TestCase):
sample_output = self._read_sample_output(self.sample_output['rw'])
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- p.run(args, result)
+ p.run(result)
expected_result = '{"read_bw": 83888, "read_iops": 20972,' \
'"read_lat": 236.8, "write_bw": 84182, "write_iops": 21045,'\
@@ -203,7 +205,6 @@ class FioTestCase(unittest.TestCase):
def test_fio_unsuccessful_bw_iops_sla(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -214,17 +215,17 @@ class FioTestCase(unittest.TestCase):
'options': options,
'sla': {'read_iops': 30000}
}
+ p = fio.Fio(args, self.ctx)
result = {}
p.client = mock_ssh.SSH()
sample_output = self._read_sample_output(self.sample_output['rw'])
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, args, result)
+ self.assertRaises(AssertionError, p.run, result)
def test_fio_unsuccessful_script_error(self, mock_ssh):
- p = fio.Fio(self.ctx)
options = {
'filename': '/home/ec2-user/data.raw',
'bs': '4k',
@@ -232,12 +233,13 @@ class FioTestCase(unittest.TestCase):
'ramp_time': 10
}
args = {'options': options}
+ p = fio.Fio(args, self.ctx)
result = {}
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 _read_sample_output(self, file_name):
curr_path = os.path.dirname(os.path.abspath(__file__))