3 ##############################################################################
4 # Copyright (c) 2017 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.storage.bonnie.Bonnie
14 from __future__ import absolute_import
20 from yardstick.benchmark.scenarios.storage import bonnie
23 class BonnieTestCase(unittest.TestCase):
30 'key_filename': "mykey.key"
36 @mock.patch('yardstick.benchmark.scenarios.storage.bonnie.ssh')
37 def test_bonnie_successful_setup(self, mock_ssh):
46 args = {"options": options}
47 b = bonnie.Bonnie(args, self.ctx)
48 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
51 self.assertIsNotNone(b.client)
52 self.assertTrue(b.setup_done, True)
54 @mock.patch('yardstick.benchmark.scenarios.storage.bonnie.ssh')
55 def test_bonnie_unsuccessful_script_error(self, mock_ssh):
63 args = {"options": options}
64 b = bonnie.Bonnie(args, self.ctx)
66 mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
67 self.assertRaises(RuntimeError, b.run, self.result)
74 if __name__ == '__main__':