1 ##############################################################################
2 # Copyright (c) 2016 Huan Li and others
3 # lihuansse@tongji.edu.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
13 from yardstick.benchmark.scenarios.availability import scenario_general
15 class ScenarioGeneralTestCase(unittest.TestCase):
19 'type': "general_scenario",
22 'fault_type': "general-attacker",
23 'key': "kill-process"}],
25 'monitor_type': "general-monitor",
26 'key': "service-status"}],
29 'actionKey': "kill-process",
30 'actionType': "attacker",
33 'actionKey': "service-status",
34 'actionType': "monitor",
38 self.instance = scenario_general.ScenarioGeneral(self.scenario_cfg, None)
40 self._mock_director = mock.patch.object(scenario_general, 'Director')
41 self.mock_director = self._mock_director.start()
42 self.addCleanup(self._stop_mock)
45 self._mock_director.stop()
47 def test_scenario_general_all_successful(self):
50 self.instance.teardown()
52 def test_scenario_general_exception(self):
53 mock_obj = mock.Mock()
54 mock_obj.createActionPlayer.side_effect = KeyError('Wrong')
55 self.instance.director = mock_obj
56 self.instance.director.data = {}
58 self.instance.teardown()
60 def test_scenario_general_case_fail(self):
61 mock_obj = mock.Mock()
62 mock_obj.verify.return_value = False
63 self.instance.director = mock_obj
64 self.instance.director.data = {}
66 self.instance.pass_flag = True
67 self.instance.teardown()