aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
diff options
context:
space:
mode:
authorEmma Foley <emma.l.foley@intel.com>2017-11-29 22:56:21 +0000
committerEmma Foley <emma.l.foley@intel.com>2018-02-12 16:57:56 +0000
commitba4e9e6e47bd10ecc803bab920178ea973c2fa86 (patch)
tree54576c199cabe8ccc29d04eedfe0e4f88b2bd598 /yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
parentbabe3cc2882e19c6dafdbf41d502d7ba5560635a (diff)
Move tests: unit/benchmark
* Fix pylint errors * Add TODOs Some errors are ignored locally, as they were a symptom of other problems. These issues have been flagged with a TODO, and should be fixed later. Change-Id: I30eb4b0aafe0575d0cddbc946108291f21a98ed8 Jira: YARDSTICK-837 Signed-off-by: Emma Foley <emma.l.foley@intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py')
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
new file mode 100644
index 000000000..45840d569
--- /dev/null
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
@@ -0,0 +1,67 @@
+##############################################################################
+# Copyright (c) 2016 Huan Li and others
+# lihuansse@tongji.edu.cn
+# 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
+##############################################################################
+
+import mock
+import unittest
+
+from yardstick.benchmark.scenarios.availability import scenario_general
+
+class ScenarioGeneralTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.scenario_cfg = {
+ 'type': "general_scenario",
+ 'options': {
+ 'attackers': [{
+ 'fault_type': "general-attacker",
+ 'key': "kill-process"}],
+ 'monitors': [{
+ 'monitor_type': "general-monitor",
+ 'key': "service-status"}],
+ 'steps': [
+ {
+ 'actionKey': "kill-process",
+ 'actionType': "attacker",
+ 'index': 1},
+ {
+ 'actionKey': "service-status",
+ 'actionType': "monitor",
+ 'index': 2}]
+ }
+ }
+ self.instance = scenario_general.ScenarioGeneral(self.scenario_cfg, None)
+
+ self._mock_director = mock.patch.object(scenario_general, 'Director')
+ self.mock_director = self._mock_director.start()
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_director.stop()
+
+ def test_scenario_general_all_successful(self):
+ self.instance.setup()
+ self.instance.run({})
+ self.instance.teardown()
+
+ def test_scenario_general_exception(self):
+ mock_obj = mock.Mock()
+ mock_obj.createActionPlayer.side_effect = KeyError('Wrong')
+ self.instance.director = mock_obj
+ self.instance.director.data = {}
+ self.instance.run({})
+ self.instance.teardown()
+
+ def test_scenario_general_case_fail(self):
+ mock_obj = mock.Mock()
+ mock_obj.verify.return_value = False
+ self.instance.director = mock_obj
+ self.instance.director.data = {}
+ self.instance.run({})
+ self.instance.pass_flag = True
+ self.instance.teardown()