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
14 from __future__ import absolute_import
18 from yardstick.benchmark.scenarios.availability.scenario_general import \
23 'yardstick.benchmark.scenarios.availability.scenario_general.Director')
24 class ScenarioGeneralTestCase(unittest.TestCase):
28 'type': "general_scenario",
31 'fault_type': "general-attacker",
32 'key': "kill-process"}],
34 'monitor_type': "general-monitor",
35 'key': "service-status"}],
38 'actionKey': "kill-process",
39 'actionType': "attacker",
42 'actionKey': "service-status",
43 'actionType': "monitor",
48 def test_scenario_general_all_successful(self, mock_director):
49 ins = ScenarioGeneral(self.scenario_cfg, None)
54 def test_scenario_general_exception(self, mock_director):
55 ins = ScenarioGeneral(self.scenario_cfg, None)
56 mock_obj = mock.Mock()
57 mock_obj.createActionPlayer.side_effect = KeyError('Wrong')
58 ins.director = mock_obj
62 def test_scenario_general_case_fail(self, mock_director):
63 ins = ScenarioGeneral(self.scenario_cfg, None)
64 mock_obj = mock.Mock()
65 mock_obj.verify.return_value = False
66 ins.director = mock_obj