Skip to content

Commit

Permalink
t/jobs/t0034: add test for the log_issue_time option
Browse files Browse the repository at this point in the history
Add a test to check the newly added option 'log_issue_time'. Generate
log files using the option and check that lines in the log files have
the format described in the "Log File Format" section in HOWTO.rst.

This test case has the logic same as t0033 except the log file names and
matching patterns. Factor out the logic to the new class
FioJobFileTest_LogFileFormat.

Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vincent Fu <[email protected]>
  • Loading branch information
kawasaki authored and vincentkfu committed Sep 4, 2024
1 parent 8b0018e commit 20d0ba8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 10 deletions.
27 changes: 27 additions & 0 deletions t/jobs/t0034.fio
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[global]
rw=read
filename=t0034file
size=8k
time_based
runtime=2s
ioengine=libaio
iodepth=1

[job1]
write_lat_log=log
log_offset=1
log_issue_time=1

[job2]
write_lat_log=log
log_offset=1
log_issue_time=1
log_avg_msec=100
log_window_value=both

[job3]
write_lat_log=log
write_bw_log=log
write_iops_log=log
log_offset=1
log_issue_time=1
51 changes: 41 additions & 10 deletions t/run-fio-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,30 +554,51 @@ def check_result(self):
if self.json_data['jobs'][1]['read']['io_kbytes'] != 8:
self.passed = False

class FioJobFileTest_t0033(FioJobFileTest):
class FioJobFileTest_LogFileFormat(FioJobFileTest):
"""Test log file format"""
def setup(self, *args, **kws):
super().setup(*args, **kws)
self.patterns = {}

def check_result(self):
super().check_result()

if not self.passed:
return

patterns = {
'log_bw.1.log': '\\d+, \\d+, \\d+, \\d+, 0x[\\da-f]+\\n',
'log_clat.2.log': '\\d+, \\d+, \\d+, \\d+, 0, \\d+\\n',
'log_iops.3.log': '\\d+, \\d+, \\d+, \\d+, \\d+, 0x[\\da-f]+\\n',
'log_iops.4.log': '\\d+, \\d+, \\d+, \\d+, 0, 0, \\d+\\n',
}

for logfile in patterns.keys():
for logfile in self.patterns.keys():
file_path = os.path.join(self.paths['test_dir'], logfile)
with open(file_path, "r") as f:
line = f.readline()
if not re.match(patterns[logfile], line):
if not re.match(self.patterns[logfile], line):
self.passed = False
self.failure_reason = "wrong log file format: " + logfile
return

class FioJobFileTest_t0033(FioJobFileTest_LogFileFormat):
"""Test log file format"""
def setup(self, *args, **kws):
super().setup(*args, **kws)
self.patterns = {
'log_bw.1.log': '\\d+, \\d+, \\d+, \\d+, 0x[\\da-f]+\\n',
'log_clat.2.log': '\\d+, \\d+, \\d+, \\d+, 0, \\d+\\n',
'log_iops.3.log': '\\d+, \\d+, \\d+, \\d+, \\d+, 0x[\\da-f]+\\n',
'log_iops.4.log': '\\d+, \\d+, \\d+, \\d+, 0, 0, \\d+\\n',
}

class FioJobFileTest_t0034(FioJobFileTest_LogFileFormat):
"""Test log file format"""
def setup(self, *args, **kws):
super().setup(*args, **kws)
self.patterns = {
'log_clat.1.log': '\\d+, \\d+, \\d+, \\d+, \\d+, \\d+, \\d+\\n',
'log_slat.1.log': '\\d+, \\d+, \\d+, \\d+, \\d+, \\d+, \\d+\\n',
'log_lat.1.log': '\\d+, \\d+, \\d+, \\d+, \\d+, \\d+, 0\\n',
'log_clat.2.log': '\\d+, \\d+, \\d+, \\d+, 0, 0, \\d+, 0\\n',
'log_bw.3.log': '\\d+, \\d+, \\d+, \\d+, \\d+, \\d+, 0\\n',
'log_iops.3.log': '\\d+, \\d+, \\d+, \\d+, \\d+, \\d+, 0\\n',
}

class FioJobFileTest_iops_rate(FioJobFileTest):
"""Test consists of fio test job t0011
Confirm that job0 iops == 1000
Expand Down Expand Up @@ -913,6 +934,16 @@ def check_result(self):
'pre_success': SUCCESS_DEFAULT,
'requirements': [Requirements.linux, Requirements.libaio],
},
{
'test_id': 34,
'test_class': FioJobFileTest_t0034,
'job': 't0034.fio',
'success': SUCCESS_DEFAULT,
'pre_job': None,
'pre_success': None,
'pre_success': SUCCESS_DEFAULT,
'requirements': [Requirements.linux, Requirements.libaio],
},
{
'test_id': 1000,
'test_class': FioExeTest,
Expand Down

0 comments on commit 20d0ba8

Please sign in to comment.