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.common import utils
21 from yardstick.benchmark.scenarios.storage import bonnie
24 class BonnieTestCase(unittest.TestCase):
31 'key_filename': "mykey.key"
37 @mock.patch('yardstick.benchmark.scenarios.storage.bonnie.ssh')
38 def test_bonnie_successful_setup(self, mock_ssh):
47 args = {"options": options}
48 b = bonnie.Bonnie(args, self.ctx)
49 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
52 self.assertIsNotNone(b.client)
53 self.assertTrue(b.setup_done, True)
55 @mock.patch('yardstick.benchmark.scenarios.storage.bonnie.ssh')
56 def test_bonnie_unsuccessful_script_error(self, mock_ssh):
64 args = {"options": options}
65 b = bonnie.Bonnie(args, self.ctx)
67 mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
68 self.assertRaises(RuntimeError, b.run, self.result)
73 if __name__ == '__main__':