3 ##############################################################################
4 # Copyright (c) 2016 Huan Li and others
5 # lihuansse@tongji.edu.cn
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Unittest for yardstick.benchmark.scenarios.availability.scenario_general
17 from yardstick.benchmark.scenarios.availability.scenario_general import ScenarioGeneral
20 @mock.patch('yardstick.benchmark.scenarios.availability.scenario_general.Director')
21 class ScenarioGeneralTestCase(unittest.TestCase):
25 'type': "general_scenario",
28 'fault_type': "general-attacker",
29 'key': "kill-process"}],
31 'monitor_type': "general-monitor",
32 'key': "service_status"}],
35 'actionKey': "kill-process",
36 'actionType': "attacker",
39 'actionKey': "service_status",
40 'actionType': "monitor",
45 def test_scenario_general_all_successful(self, mock_director):
46 ins = ScenarioGeneral(self.scenario_cfg, None)
51 def test_scenario_general_exception(self, mock_director):
52 ins = ScenarioGeneral(self.scenario_cfg, None)
53 mock_obj = mock.Mock()
54 mock_obj.createActionPlayer.side_effect = KeyError('Wrong')
55 ins.director = mock_obj
59 def test_scenario_general_case_fail(self, mock_director):
60 ins = ScenarioGeneral(self.scenario_cfg, None)
61 mock_obj = mock.Mock()
62 mock_obj.verify.return_value = False
63 ins.director = mock_obj