summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/storage/test_fio.py
diff options
context:
space:
mode:
authorhoujingwen <houjingwen@huawei.com>2015-10-08 09:31:36 +0000
committerhoujingwen <houjingwen@huawei.com>2015-10-13 12:22:51 +0800
commitc7a3775d447e29850463893495c08328960cd3d5 (patch)
tree376bfc60d1ae8f8cead7596d651799a4c8344077 /tests/unit/benchmark/scenarios/storage/test_fio.py
parent89ee821fd10b1de5cd6d319347627ca540ac57c0 (diff)
Fio scenario support sla
JIRA: YARDSTICK-34 Change-Id: I782ba5845f8bd54a19bad078fe7be546400f7524 Signed-off-by: houjingwen <houjingwen@huawei.com>
Diffstat (limited to 'tests/unit/benchmark/scenarios/storage/test_fio.py')
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_fio.py170
1 files changed, 157 insertions, 13 deletions
diff --git a/tests/unit/benchmark/scenarios/storage/test_fio.py b/tests/unit/benchmark/scenarios/storage/test_fio.py
index 45e8a9429..6d38e9c53 100644
--- a/tests/unit/benchmark/scenarios/storage/test_fio.py
+++ b/tests/unit/benchmark/scenarios/storage/test_fio.py
@@ -26,16 +26,21 @@ class FioTestCase(unittest.TestCase):
self.ctx = {
'host': '172.16.0.137',
'user': 'cirros',
- 'key_filename': "mykey.key"
+ 'key_filename': 'mykey.key'
+ }
+ self.sample_output = {
+ 'read': 'fio_read_sample_output.json',
+ 'write': 'fio_write_sample_output.json',
+ 'rw': 'fio_rw_sample_output.json'
}
def test_fio_successful_setup(self, mock_ssh):
p = fio.Fio(self.ctx)
options = {
- 'filename': "/home/ec2-user/data.raw",
- 'bs': "4k",
- 'rw': "rw",
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': 'rw',
'ramp_time': 10
}
args = {'options': options}
@@ -49,15 +54,134 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(self.ctx)
options = {
- 'filename': "/home/ec2-user/data.raw",
- 'bs': "4k",
- 'rw': "rw",
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': 'rw',
+ 'ramp_time': 10
+ }
+ args = {'options': options}
+ p.client = mock_ssh.SSH()
+
+ sample_output = self._read_sample_output(self.sample_output['rw'])
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+
+ result = p.run(args)
+
+ expected_result = '{"read_bw": 83888, "read_iops": 20972,' \
+ '"read_lat": 236.8, "write_bw": 84182, "write_iops": 21045,'\
+ '"write_lat": 233.55}'
+ expected_result = json.loads(expected_result)
+ self.assertEqual(result, expected_result)
+
+ def test_fio_successful_read_no_sla(self, mock_ssh):
+
+ p = fio.Fio(self.ctx)
+ options = {
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': "read",
+ 'ramp_time': 10
+ }
+ args = {'options': options}
+ p.client = mock_ssh.SSH()
+
+ sample_output = self._read_sample_output(self.sample_output['read'])
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+
+ result = p.run(args)
+
+ expected_result = '{"read_bw": 36113, "read_iops": 9028,' \
+ '"read_lat": 108.7}'
+ expected_result = json.loads(expected_result)
+ self.assertEqual(result, expected_result)
+
+ def test_fio_successful_write_no_sla(self, mock_ssh):
+
+ p = fio.Fio(self.ctx)
+ options = {
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': 'write',
'ramp_time': 10
}
args = {'options': options}
p.client = mock_ssh.SSH()
- sample_output = self._read_sample_output()
+ sample_output = self._read_sample_output(self.sample_output['write'])
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+
+ result = p.run(args)
+
+ expected_result = '{"write_bw": 35107, "write_iops": 8776,'\
+ '"write_lat": 111.74}'
+ expected_result = json.loads(expected_result)
+ self.assertEqual(result, expected_result)
+
+ def test_fio_successful_lat_sla(self, mock_ssh):
+
+ p = fio.Fio(self.ctx)
+ options = {
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': 'rw',
+ 'ramp_time': 10
+ }
+ args = {
+ 'options': options,
+ 'sla': {'write_lat': 300.1}
+ }
+
+ p.client = mock_ssh.SSH()
+
+ sample_output = self._read_sample_output(self.sample_output['rw'])
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+
+ result = p.run(args)
+
+ expected_result = '{"read_bw": 83888, "read_iops": 20972,' \
+ '"read_lat": 236.8, "write_bw": 84182, "write_iops": 21045,'\
+ '"write_lat": 233.55}'
+ expected_result = json.loads(expected_result)
+ self.assertEqual(result, expected_result)
+
+
+ def test_fio_unsuccessful_lat_sla(self, mock_ssh):
+
+ p = fio.Fio(self.ctx)
+ options = {
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': 'rw',
+ 'ramp_time': 10
+ }
+ args = {
+ 'options': options,
+ 'sla': {'write_lat': 200.1}
+ }
+
+ p.client = mock_ssh.SSH()
+
+ sample_output = self._read_sample_output(self.sample_output['rw'])
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ self.assertRaises(AssertionError, p.run, args)
+
+ def test_fio_successful_bw_iops_sla(self, mock_ssh):
+
+ p = fio.Fio(self.ctx)
+ options = {
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': 'rw',
+ 'ramp_time': 10
+ }
+ args = {
+ 'options': options,
+ 'sla': {'read_iops': 20000}
+ }
+
+ p.client = mock_ssh.SSH()
+
+ sample_output = self._read_sample_output(self.sample_output['rw'])
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
result = p.run(args)
@@ -68,13 +192,33 @@ class FioTestCase(unittest.TestCase):
expected_result = json.loads(expected_result)
self.assertEqual(result, expected_result)
+ def test_fio_unsuccessful_bw_iops_sla(self, mock_ssh):
+
+ p = fio.Fio(self.ctx)
+ options = {
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': 'rw',
+ 'ramp_time': 10
+ }
+ args = {
+ 'options': options,
+ 'sla': {'read_iops': 30000}
+ }
+
+ p.client = mock_ssh.SSH()
+
+ sample_output = self._read_sample_output(self.sample_output['rw'])
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ self.assertRaises(AssertionError, p.run, args)
+
def test_fio_unsuccessful_script_error(self, mock_ssh):
p = fio.Fio(self.ctx)
options = {
- 'filename': "/home/ec2-user/data.raw",
- 'bs': "4k",
- 'rw': "rw",
+ 'filename': '/home/ec2-user/data.raw',
+ 'bs': '4k',
+ 'rw': 'rw',
'ramp_time': 10
}
args = {'options': options}
@@ -83,9 +227,9 @@ class FioTestCase(unittest.TestCase):
mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.run, args)
- def _read_sample_output(self):
+ def _read_sample_output(self, file_name):
curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, 'fio_sample_output.json')
+ output = os.path.join(curr_path, file_name)
with open(output) as f:
sample_output = f.read()
return sample_output