aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/compute
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/compute
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/compute')
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_cyclictest.py34
1 files changed, 18 insertions, 16 deletions
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():