summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/benchmark/core/test_task.py28
-rw-r--r--tests/unit/benchmark/runner/__init__.py0
-rw-r--r--tests/unit/benchmark/runner/test_base.py45
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_attacker_process.py4
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_basemonitor.py10
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_command.py6
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_general.py6
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_multi.py4
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_process.py4
9 files changed, 90 insertions, 17 deletions
diff --git a/tests/unit/benchmark/core/test_task.py b/tests/unit/benchmark/core/test_task.py
index cd7ffdebb..8034392f4 100644
--- a/tests/unit/benchmark/core/test_task.py
+++ b/tests/unit/benchmark/core/test_task.py
@@ -64,6 +64,7 @@ class TaskTestCase(unittest.TestCase):
t = task.Task()
runner = mock.Mock()
runner.join.return_value = 0
+ runner.get_output.return_value = {}
mock_base_runner.Runner.get.return_value = runner
t._run([scenario], False, "yardstick.out")
self.assertTrue(runner.run.called)
@@ -155,6 +156,33 @@ class TaskTestCase(unittest.TestCase):
self.assertEqual(task_args_fnames[0], None)
self.assertEqual(task_args_fnames[1], None)
+ def test_parse_options(self):
+ options = {
+ 'openstack': {
+ 'EXTERNAL_NETWORK': '$network'
+ },
+ 'ndoes': ['node1', '$node'],
+ 'host': '$host'
+ }
+
+ t = task.Task()
+ t.outputs = {
+ 'network': 'ext-net',
+ 'node': 'node2',
+ 'host': 'server.yardstick'
+ }
+
+ idle_result = {
+ 'openstack': {
+ 'EXTERNAL_NETWORK': 'ext-net'
+ },
+ 'ndoes': ['node1', 'node2'],
+ 'host': 'server.yardstick'
+ }
+
+ actual_result = t._parse_options(options)
+ self.assertEqual(idle_result, actual_result)
+
def test_change_server_name_host_str(self):
scenario = {'host': 'demo'}
suffix = '-8'
diff --git a/tests/unit/benchmark/runner/__init__.py b/tests/unit/benchmark/runner/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/unit/benchmark/runner/__init__.py
diff --git a/tests/unit/benchmark/runner/test_base.py b/tests/unit/benchmark/runner/test_base.py
new file mode 100644
index 000000000..7880fe5a5
--- /dev/null
+++ b/tests/unit/benchmark/runner/test_base.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import unittest
+import multiprocessing
+import time
+
+from yardstick.benchmark.runners.iteration import IterationRunner
+
+
+class RunnerTestCase(unittest.TestCase):
+
+ def test_get_output(self):
+ queue = multiprocessing.Queue()
+ runner = IterationRunner({}, queue)
+ runner.output_queue.put({'case': 'opnfv_yardstick_tc002'})
+ runner.output_queue.put({'criteria': 'PASS'})
+
+ idle_result = {
+ 'case': 'opnfv_yardstick_tc002',
+ 'criteria': 'PASS'
+ }
+
+ time.sleep(1)
+ actual_result = runner.get_output()
+ self.assertEqual(idle_result, actual_result)
+
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_process.py b/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
index eec512a58..0a8e8322a 100644
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
+++ b/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
@@ -41,7 +41,7 @@ class AttackerServiceTestCase(unittest.TestCase):
cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
ins = cls(self.attacker_cfg, self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "10", '')
ins.setup()
ins.inject_fault()
ins.recover()
@@ -51,5 +51,5 @@ class AttackerServiceTestCase(unittest.TestCase):
cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
ins = cls(self.attacker_cfg, self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "error check", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, None, '')
ins.setup()
diff --git a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py b/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
index 7030c7849..3b7e07376 100644
--- a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
+++ b/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
@@ -34,7 +34,7 @@ class MonitorMgrTestCase(unittest.TestCase):
self.monitor_configs.append(config)
def test__MonitorMgr_setup_successful(self, mock_monitor):
- instance = basemonitor.MonitorMgr()
+ instance = basemonitor.MonitorMgr({"nova-api": 10})
instance.init_monitors(self.monitor_configs, None)
instance.start_monitors()
instance.wait_monitors()
@@ -42,7 +42,7 @@ class MonitorMgrTestCase(unittest.TestCase):
ret = instance.verify_SLA()
def test_MonitorMgr_getitem(self, mock_monitor):
- monitorMgr = basemonitor.MonitorMgr()
+ monitorMgr = basemonitor.MonitorMgr({"nova-api": 10})
monitorMgr.init_monitors(self.monitor_configs, None)
monitorIns = monitorMgr['service-status']
@@ -67,12 +67,12 @@ class BaseMonitorTestCase(unittest.TestCase):
}
def test__basemonitor_start_wait_successful(self):
- ins = basemonitor.BaseMonitor(self.monitor_cfg, None)
+ ins = basemonitor.BaseMonitor(self.monitor_cfg, None, {"nova-api": 10})
ins.start_monitor()
ins.wait_monitor()
def test__basemonitor_all_successful(self):
- ins = self.MonitorSimple(self.monitor_cfg, None)
+ ins = self.MonitorSimple(self.monitor_cfg, None, {"nova-api": 10})
ins.setup()
ins.run()
ins.verify_SLA()
@@ -81,7 +81,7 @@ class BaseMonitorTestCase(unittest.TestCase):
'yardstick.benchmark.scenarios.availability.monitor.basemonitor'
'.multiprocessing')
def test__basemonitor_func_false(self, mock_multiprocess):
- ins = self.MonitorSimple(self.monitor_cfg, None)
+ ins = self.MonitorSimple(self.monitor_cfg, None, {"nova-api": 10})
ins.setup()
mock_multiprocess.Event().is_set.return_value = False
ins.run()
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py b/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
index c179bbfaf..2ed4be731 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
+++ b/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
@@ -59,7 +59,7 @@ class MonitorOpenstackCmdTestCase(unittest.TestCase):
def test__monitor_command_monitor_func_successful(self, mock_subprocess):
- instance = monitor_command.MonitorOpenstackCmd(self.config, None)
+ instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10})
instance.setup()
mock_subprocess.check_output.return_value = (0, 'unittest')
ret = instance.monitor_func()
@@ -69,7 +69,7 @@ class MonitorOpenstackCmdTestCase(unittest.TestCase):
def test__monitor_command_monitor_func_failure(self, mock_subprocess):
mock_subprocess.check_output.return_value = (1, 'unittest')
- instance = monitor_command.MonitorOpenstackCmd(self.config, None)
+ instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10})
instance.setup()
mock_subprocess.check_output.side_effect = RuntimeError
ret = instance.monitor_func()
@@ -85,7 +85,7 @@ class MonitorOpenstackCmdTestCase(unittest.TestCase):
self.config["host"] = "node1"
instance = monitor_command.MonitorOpenstackCmd(
- self.config, self.context)
+ self.config, self.context, {"nova-api": 10})
instance.setup()
mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
ret = instance.monitor_func()
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
index 169b630bf..c14f073ec 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
+++ b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
@@ -50,7 +50,7 @@ class GeneralMonitorServiceTestCase(unittest.TestCase):
}
def test__monitor_general_all_successful(self, mock_open, mock_ssh):
- ins = monitor_general.GeneralMonitor(self.monitor_cfg, self.context)
+ ins = monitor_general.GeneralMonitor(self.monitor_cfg, self.context, {"nova-api": 10})
ins.setup()
mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
@@ -61,7 +61,7 @@ class GeneralMonitorServiceTestCase(unittest.TestCase):
def test__monitor_general_all_successful_noparam(self, mock_open,
mock_ssh):
ins = monitor_general.GeneralMonitor(
- self.monitor_cfg_noparam, self.context)
+ self.monitor_cfg_noparam, self.context, {"nova-api": 10})
ins.setup()
mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
@@ -71,7 +71,7 @@ class GeneralMonitorServiceTestCase(unittest.TestCase):
def test__monitor_general_failure(self, mock_open, mock_ssh):
ins = monitor_general.GeneralMonitor(
- self.monitor_cfg_noparam, self.context)
+ self.monitor_cfg_noparam, self.context, {"nova-api": 10})
ins.setup()
mock_ssh.SSH.from_node().execute.return_value = (1, "error", 'error')
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py b/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
index 5719f286a..f8d12bd29 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
+++ b/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
@@ -42,7 +42,7 @@ class MultiMonitorServiceTestCase(unittest.TestCase):
}
def test__monitor_multi_all_successful(self, mock_open, mock_ssh):
- ins = monitor_multi.MultiMonitor(self.monitor_cfg, self.context)
+ ins = monitor_multi.MultiMonitor(self.monitor_cfg, self.context, {"nova-api": 10})
mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
@@ -51,7 +51,7 @@ class MultiMonitorServiceTestCase(unittest.TestCase):
ins.verify_SLA()
def test__monitor_multi_all_fail(self, mock_open, mock_ssh):
- ins = monitor_multi.MultiMonitor(self.monitor_cfg, self.context)
+ ins = monitor_multi.MultiMonitor(self.monitor_cfg, self.context, {"nova-api": 10})
mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_process.py b/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
index 8c267e413..41ce5445e 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
+++ b/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
@@ -40,7 +40,7 @@ class MonitorProcessTestCase(unittest.TestCase):
def test__monitor_process_all_successful(self, mock_ssh):
- ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context)
+ ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context, {"nova-api": 10})
mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
ins.setup()
@@ -50,7 +50,7 @@ class MonitorProcessTestCase(unittest.TestCase):
def test__monitor_process_down_failuer(self, mock_ssh):
- ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context)
+ ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context, {"nova-api": 10})
mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
ins.setup()