1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 from __future__ import absolute_import
16 from yardstick.benchmark.scenarios.storage import bonnie
19 class BonnieTestCase(unittest.TestCase):
26 'key_filename': "mykey.key"
32 @mock.patch('yardstick.benchmark.scenarios.storage.bonnie.ssh')
33 def test_bonnie_successful_setup(self, mock_ssh):
42 args = {"options": options}
43 b = bonnie.Bonnie(args, self.ctx)
44 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
47 self.assertIsNotNone(b.client)
48 self.assertTrue(b.setup_done, True)
50 @mock.patch('yardstick.benchmark.scenarios.storage.bonnie.ssh')
51 def test_bonnie_unsuccessful_script_error(self, mock_ssh):
59 args = {"options": options}
60 b = bonnie.Bonnie(args, self.ctx)
62 mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
63 self.assertRaises(RuntimeError, b.run, self.result)