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.attacker.attacker_process
17 from yardstick.benchmark.scenarios.availability.attacker import baseattacker
19 @mock.patch('yardstick.benchmark.scenarios.availability.attacker.attacker_process.ssh')
20 class AttackerServiceTestCase(unittest.TestCase):
26 "key_filename": "/root/.ssh/id_rsa"
28 self.context = {"node1": host}
30 'fault_type': 'kill-process',
31 'process_name': 'nova-api',
35 def test__attacker_service_all_successful(self, mock_ssh):
37 cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
38 ins = cls(self.attacker_cfg, self.context)
40 mock_ssh.SSH().execute.return_value = (0, "running", '')
45 def test__attacker_service_check_failuer(self, mock_ssh):
47 cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
48 ins = cls(self.attacker_cfg, self.context)
50 mock_ssh.SSH().execute.return_value = (0, "error check", '')