3 ##############################################################################
4 # Copyright (c) 2015 Ericsson AB 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.fio.Fio
18 from yardstick.benchmark.scenarios.storage import fio
21 @mock.patch('yardstick.benchmark.scenarios.storage.fio.ssh')
22 class FioTestCase(unittest.TestCase):
26 'host': '172.16.0.137',
28 'key_filename': "mykey.key"
31 def test_fio_successful_setup(self, mock_ssh):
35 'filename': "/home/ec2-user/data.raw",
40 args = {'options': options}
43 mock_ssh.SSH().execute.return_value = (0, '', '')
44 self.assertIsNotNone(p.client)
45 self.assertEqual(p.setup_done, True)
47 def test_fio_successful_no_sla(self, mock_ssh):
51 'filename': "/home/ec2-user/data.raw",
56 args = {'options': options}
57 p.client = mock_ssh.SSH()
59 sample_output = '{"read_bw": "N/A", "write_lat": "407.08usec", \
60 "read_iops": "N/A", "write_bw": "9507KB/s", \
61 "write_iops": "2376", "read_lat": "N/A"}'
62 mock_ssh.SSH().execute.return_value = (0, sample_output, '')
65 expected_result = json.loads(sample_output)
66 self.assertEqual(result, expected_result)
68 def test_fio_unsuccessful_script_error(self, mock_ssh):
72 'filename': "/home/ec2-user/data.raw",
77 args = {'options': options}
78 p.client = mock_ssh.SSH()
80 mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
81 self.assertRaises(RuntimeError, p.run, args)
87 if __name__ == '__main__':