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
14 from __future__ import absolute_import
18 from yardstick.benchmark.scenarios.availability import serviceha
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 @mock.patch('yardstick.benchmark.scenarios.availability.serviceha.basemonitor')
53 'yardstick.benchmark.scenarios.availability.serviceha.baseattacker')
54 def test__serviceha_setup_run_successful(self, _,
56 p = serviceha.ServiceHA(self.args, self.ctx)
59 self.assertEqual(p.setup_done, True)
60 mock_monitor.MonitorMgr().verify_SLA.return_value = True
66 self.assertEqual(p.setup_done, True)
68 # def test__serviceha_run_sla_error(self, mock_attacker, mock_monitor):
69 # p = serviceha.ServiceHA(self.args, self.ctx)
72 # self.assertTrue(p.setup_done)
75 # result["outage_time"] = 10
76 # mock_monitor.Monitor().get_result.return_value = result
79 # self.assertRaises(AssertionError, p.run, ret)