3 ##############################################################################
4 # Copyright (c) 2016 Juan Qiu and others
5 # juan_ qiu@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.attacker
18 from yardstick.benchmark.scenarios.availability.attacker import baseattacker
20 @mock.patch('yardstick.benchmark.scenarios.availability.attacker.'
21 'attacker_general.ssh')
22 class GeneralAttackerServiceTestCase(unittest.TestCase):
28 "key_filename": "/root/.ssh/id_rsa"
30 self.context = {"node1": host}
32 'fault_type': 'general-attacker',
33 'action_parameter':{'process_name':'nova_api'},
34 'rollback_parameter':{'process_name':'nova_api'},
39 def test__attacker_service_all_successful(self, mock_ssh):
41 cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
42 ins = cls(self.attacker_cfg, self.context)
44 mock_ssh.SSH().execute.return_value = (0, "running", '')
49 def test__attacker_service_check_failuer(self, mock_ssh):
51 cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
52 ins = cls(self.attacker_cfg, self.context)
54 mock_ssh.SSH().execute.return_value = (0, "error check", '')