3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
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.serviceha
17 from yardstick.benchmark.scenarios.availability import serviceha
19 @mock.patch('yardstick.benchmark.scenarios.availability.serviceha.basemonitor')
20 @mock.patch('yardstick.benchmark.scenarios.availability.serviceha.baseattacker')
21 class ServicehaTestCase(unittest.TestCase):
27 "key_filename": "/root/.ssh/id_rsa"
29 self.ctx = {"nodes": {"node1": host}}
31 "fault_type": "kill-process",
32 "process_name": "nova-api",
36 attacker_cfgs.append(attacker_cfg)
38 "monitor_cmd": "nova image-list",
42 monitor_cfgs.append(monitor_cfg)
45 "attackers": attacker_cfgs,
46 "monitors": monitor_cfgs
48 sla = {"outage_time": 5}
49 self.args = {"options": options, "sla": sla}
51 def test__serviceha_setup_run_successful(self, mock_attacker, mock_monitor):
52 p = serviceha.ServiceHA(self.args, self.ctx)
55 self.assertEqual(p.setup_done, True)
56 mock_monitor.MonitorMgr().verify_SLA.return_value = True
61 def test__serviceha_run_sla_error(self, mock_attacker, mock_monitor):
62 p = serviceha.ServiceHA(self.args, self.ctx)
65 self.assertEqual(p.setup_done, True)
68 result["outage_time"] = 10
69 mock_monitor.Monitor().get_result.return_value = result
72 self.assertRaises(AssertionError, p.run, ret)