2 # SPDX-License-Identifier: GPL-2.0-only
4 # Copyright (c) 2019 Western Digital Corporation or its affiliates.
9 # Automate running of fio tests
12 # python3 run-fio-tests.py [-r fio-root] [-f fio-path] [-a artifact-root]
13 # [--skip # # #...] [--run-only # # #...]
17 # # git clone git://git.kernel.dk/fio.git
20 # # python3 t/run-fio-tests.py
24 # - Python 3.5 (subprocess.run)
25 # - Linux (libaio ioengine, zbd tests, etc)
26 # - The artifact directory must be on a file system that accepts 512-byte IO
27 # (t0002, t0003, t0004).
28 # - The artifact directory needs to be on an SSD. Otherwise tests that carry
29 # out file-based IO will trigger a timeout (t0006).
31 # - SciPy (steadystate_tests.py)
32 # - libzbc (zbd tests)
33 # - root privileges (zbd test)
34 # - kernel 4.19 or later for zoned null block devices (zbd tests)
35 # - CUnit support (unittests)
40 # TODO run multiple tests simultaneously
41 # TODO Add sgunmap tests (requires SAS SSD)
54 import multiprocessing
55 from pathlib import Path
58 class FioTest(object):
59 """Base for all fio tests."""
61 def __init__(self, exe_path, parameters, success):
62 self.exe_path = exe_path
63 self.parameters = parameters
64 self.success = success
66 self.artifact_root = None
70 self.failure_reason = ''
71 self.command_file = None
72 self.stdout_file = None
73 self.stderr_file = None
74 self.exitcode_file = None
76 def setup(self, artifact_root, testnum):
77 """Setup instance variables for test."""
79 self.artifact_root = artifact_root
80 self.testnum = testnum
81 self.test_dir = os.path.join(artifact_root, "{:04d}".format(testnum))
82 if not os.path.exists(self.test_dir):
83 os.mkdir(self.test_dir)
85 self.command_file = os.path.join(
87 "{0}.command".format(os.path.basename(self.exe_path)))
88 self.stdout_file = os.path.join(
90 "{0}.stdout".format(os.path.basename(self.exe_path)))
91 self.stderr_file = os.path.join(
93 "{0}.stderr".format(os.path.basename(self.exe_path)))
94 self.exitcode_file = os.path.join(
96 "{0}.exitcode".format(os.path.basename(self.exe_path)))
101 raise NotImplementedError()
103 def check_result(self):
104 """Check test results."""
106 raise NotImplementedError()
109 class FioExeTest(FioTest):
110 """Test consists of an executable binary or script"""
112 def __init__(self, exe_path, parameters, success):
113 """Construct a FioExeTest which is a FioTest consisting of an
114 executable binary or script.
116 exe_path: location of executable binary or script
117 parameters: list of parameters for executable
118 success: Definition of test success
121 FioTest.__init__(self, exe_path, parameters, success)
124 """Execute the binary or script described by this instance."""
126 command = [self.exe_path] + self.parameters
127 command_file = open(self.command_file, "w+")
128 command_file.write("%s\n" % command)
131 stdout_file = open(self.stdout_file, "w+")
132 stderr_file = open(self.stderr_file, "w+")
133 exitcode_file = open(self.exitcode_file, "w+")
136 # Avoid using subprocess.run() here because when a timeout occurs,
137 # fio will be stopped with SIGKILL. This does not give fio a
138 # chance to clean up and means that child processes may continue
139 # running and submitting IO.
140 proc = subprocess.Popen(command,
144 universal_newlines=True)
145 proc.communicate(timeout=self.success['timeout'])
146 exitcode_file.write('{0}\n'.format(proc.returncode))
147 logging.debug("Test %d: return code: %d", self.testnum, proc.returncode)
148 self.output['proc'] = proc
149 except subprocess.TimeoutExpired:
153 self.output['failure'] = 'timeout'
159 self.output['failure'] = 'exception'
160 self.output['exc_info'] = sys.exc_info()
164 exitcode_file.close()
166 def check_result(self):
167 """Check results of test run."""
169 if 'proc' not in self.output:
170 if self.output['failure'] == 'timeout':
171 self.failure_reason = "{0} timeout,".format(self.failure_reason)
173 assert self.output['failure'] == 'exception'
174 self.failure_reason = '{0} exception: {1}, {2}'.format(
175 self.failure_reason, self.output['exc_info'][0],
176 self.output['exc_info'][1])
181 if 'zero_return' in self.success:
182 if self.success['zero_return']:
183 if self.output['proc'].returncode != 0:
185 self.failure_reason = "{0} non-zero return code,".format(self.failure_reason)
187 if self.output['proc'].returncode == 0:
188 self.failure_reason = "{0} zero return code,".format(self.failure_reason)
191 stderr_size = os.path.getsize(self.stderr_file)
192 if 'stderr_empty' in self.success:
193 if self.success['stderr_empty']:
195 self.failure_reason = "{0} stderr not empty,".format(self.failure_reason)
199 self.failure_reason = "{0} stderr empty,".format(self.failure_reason)
203 class FioJobTest(FioExeTest):
204 """Test consists of a fio job"""
206 def __init__(self, fio_path, fio_job, success, fio_pre_job=None,
207 fio_pre_success=None, output_format="normal"):
208 """Construct a FioJobTest which is a FioExeTest consisting of a
209 single fio job file with an optional setup step.
211 fio_path: location of fio executable
212 fio_job: location of fio job file
213 success: Definition of test success
214 fio_pre_job: fio job for preconditioning
215 fio_pre_success: Definition of test success for fio precon job
216 output_format: normal (default), json, jsonplus, or terse
219 self.fio_job = fio_job
220 self.fio_pre_job = fio_pre_job
221 self.fio_pre_success = fio_pre_success if fio_pre_success else success
222 self.output_format = output_format
223 self.precon_failed = False
224 self.json_data = None
225 self.fio_output = "{0}.output".format(os.path.basename(self.fio_job))
228 "--output-format={0}".format(self.output_format),
229 "--output={0}".format(self.fio_output),
232 FioExeTest.__init__(self, fio_path, self.fio_args, success)
234 def setup(self, artifact_root, testnum):
235 """Setup instance variables for fio job test."""
237 super(FioJobTest, self).setup(artifact_root, testnum)
239 self.command_file = os.path.join(
241 "{0}.command".format(os.path.basename(self.fio_job)))
242 self.stdout_file = os.path.join(
244 "{0}.stdout".format(os.path.basename(self.fio_job)))
245 self.stderr_file = os.path.join(
247 "{0}.stderr".format(os.path.basename(self.fio_job)))
248 self.exitcode_file = os.path.join(
250 "{0}.exitcode".format(os.path.basename(self.fio_job)))
252 def run_pre_job(self):
253 """Run fio job precondition step."""
255 precon = FioJobTest(self.exe_path, self.fio_pre_job,
256 self.fio_pre_success,
257 output_format=self.output_format)
258 precon.setup(self.artifact_root, self.testnum)
260 precon.check_result()
261 self.precon_failed = not precon.passed
262 self.failure_reason = precon.failure_reason
265 """Run fio job test."""
270 if not self.precon_failed:
271 super(FioJobTest, self).run()
273 logging.debug("Test %d: precondition step failed", self.testnum)
276 def get_file(cls, filename):
277 """Safely read a file."""
282 with open(filename, "r") as output_file:
283 file_data = output_file.read()
287 return file_data, success
289 def check_result(self):
290 """Check fio job results."""
292 if self.precon_failed:
294 self.failure_reason = "{0} precondition step failed,".format(self.failure_reason)
297 super(FioJobTest, self).check_result()
302 if 'json' not in self.output_format:
305 file_data, success = self.get_file(os.path.join(self.test_dir, self.fio_output))
307 self.failure_reason = "{0} unable to open output file,".format(self.failure_reason)
312 # Sometimes fio informational messages are included at the top of the
313 # JSON output, especially under Windows. Try to decode output as JSON
314 # data, skipping everything until the first {
316 lines = file_data.splitlines()
317 file_data = '\n'.join(lines[lines.index("{"):])
319 self.json_data = json.loads(file_data)
320 except json.JSONDecodeError:
321 self.failure_reason = "{0} unable to decode JSON data,".format(self.failure_reason)
325 class FioJobTest_t0005(FioJobTest):
326 """Test consists of fio test job t0005
327 Confirm that read['io_kbytes'] == write['io_kbytes'] == 102400"""
329 def check_result(self):
330 super(FioJobTest_t0005, self).check_result()
335 if self.json_data['jobs'][0]['read']['io_kbytes'] != 102400:
336 self.failure_reason = "{0} bytes read mismatch,".format(self.failure_reason)
338 if self.json_data['jobs'][0]['write']['io_kbytes'] != 102400:
339 self.failure_reason = "{0} bytes written mismatch,".format(self.failure_reason)
343 class FioJobTest_t0006(FioJobTest):
344 """Test consists of fio test job t0006
345 Confirm that read['io_kbytes'] ~ 2*write['io_kbytes']"""
347 def check_result(self):
348 super(FioJobTest_t0006, self).check_result()
353 ratio = self.json_data['jobs'][0]['read']['io_kbytes'] \
354 / self.json_data['jobs'][0]['write']['io_kbytes']
355 logging.debug("Test %d: ratio: %f", self.testnum, ratio)
356 if ratio < 1.99 or ratio > 2.01:
357 self.failure_reason = "{0} read/write ratio mismatch,".format(self.failure_reason)
361 class FioJobTest_t0007(FioJobTest):
362 """Test consists of fio test job t0007
363 Confirm that read['io_kbytes'] = 87040"""
365 def check_result(self):
366 super(FioJobTest_t0007, self).check_result()
371 if self.json_data['jobs'][0]['read']['io_kbytes'] != 87040:
372 self.failure_reason = "{0} bytes read mismatch,".format(self.failure_reason)
376 class FioJobTest_t0008(FioJobTest):
377 """Test consists of fio test job t0008
378 Confirm that read['io_kbytes'] = 32768 and that
379 write['io_kbytes'] ~ 16568
381 I did runs with fio-ae2fafc8 and saw write['io_kbytes'] values of
382 16585, 16588. With two runs of fio-3.16 I obtained 16568"""
384 def check_result(self):
385 super(FioJobTest_t0008, self).check_result()
390 ratio = self.json_data['jobs'][0]['write']['io_kbytes'] / 16568
391 logging.debug("Test %d: ratio: %f", self.testnum, ratio)
393 if ratio < 0.99 or ratio > 1.01:
394 self.failure_reason = "{0} bytes written mismatch,".format(self.failure_reason)
396 if self.json_data['jobs'][0]['read']['io_kbytes'] != 32768:
397 self.failure_reason = "{0} bytes read mismatch,".format(self.failure_reason)
401 class FioJobTest_t0009(FioJobTest):
402 """Test consists of fio test job t0009
403 Confirm that runtime >= 60s"""
405 def check_result(self):
406 super(FioJobTest_t0009, self).check_result()
411 logging.debug('Test %d: elapsed: %d', self.testnum, self.json_data['jobs'][0]['elapsed'])
413 if self.json_data['jobs'][0]['elapsed'] < 60:
414 self.failure_reason = "{0} elapsed time mismatch,".format(self.failure_reason)
418 class FioJobTest_t0012(FioJobTest):
419 """Test consists of fio test job t0012
420 Confirm ratios of job iops are 1:5:10
421 job1,job2,job3 respectively"""
423 def check_result(self):
424 super(FioJobTest_t0012, self).check_result()
431 file_data, success = self.get_file(os.path.join(self.test_dir, "{0}_iops.{1}.log".format(os.path.basename(self.fio_job), i)))
434 self.failure_reason = "{0} unable to open output file,".format(self.failure_reason)
438 iops_files.append(file_data.splitlines())
440 # there are 9 samples for job1 and job2, 4 samples for job3
445 iops1 = iops1 + float(iops_files[0][i].split(',')[1])
446 iops2 = iops2 + float(iops_files[1][i].split(',')[1])
447 iops3 = iops3 + float(iops_files[2][i].split(',')[1])
452 "sample {0}: job1 iops={1} job2 iops={2} job3 iops={3} job3/job2={4:.3f} job3/job1={5:.3f}".format(
453 i, iops1, iops2, iops3, ratio1, ratio2
457 # test job1 and job2 succeeded to recalibrate
458 if ratio1 < 1 or ratio1 > 3 or ratio2 < 7 or ratio2 > 13:
459 self.failure_reason = "{0} iops ratio mismatch iops1={1} iops2={2} iops3={3} expected r1~2 r2~10 got r1={4:.3f} r2={5:.3f},".format(
460 self.failure_reason, iops1, iops2, iops3, ratio1, ratio2
466 class FioJobTest_t0014(FioJobTest):
467 """Test consists of fio test job t0014
468 Confirm that job1_iops / job2_iops ~ 1:2 for entire duration
469 and that job1_iops / job3_iops ~ 1:3 for first half of duration.
471 The test is about making sure the flow feature can
472 re-calibrate the activity dynamically"""
474 def check_result(self):
475 super(FioJobTest_t0014, self).check_result()
482 file_data, success = self.get_file(os.path.join(self.test_dir, "{0}_iops.{1}.log".format(os.path.basename(self.fio_job), i)))
485 self.failure_reason = "{0} unable to open output file,".format(self.failure_reason)
489 iops_files.append(file_data.splitlines())
491 # there are 9 samples for job1 and job2, 4 samples for job3
497 iops3 = iops3 + float(iops_files[2][i].split(',')[1])
499 ratio1 = iops1 / iops2
500 ratio2 = iops1 / iops3
503 if ratio1 < 0.43 or ratio1 > 0.57 or ratio2 < 0.21 or ratio2 > 0.45:
504 self.failure_reason = "{0} iops ratio mismatch iops1={1} iops2={2} iops3={3}\
505 expected r1~0.5 r2~0.33 got r1={4:.3f} r2={5:.3f},".format(
506 self.failure_reason, iops1, iops2, iops3, ratio1, ratio2
510 iops1 = iops1 + float(iops_files[0][i].split(',')[1])
511 iops2 = iops2 + float(iops_files[1][i].split(',')[1])
516 "sample {0}: job1 iops={1} job2 iops={2} job3 iops={3} job1/job2={4:.3f} job1/job3={5:.3f}".format(
517 i, iops1, iops2, iops3, ratio1, ratio2
521 # test job1 and job2 succeeded to recalibrate
522 if ratio1 < 0.43 or ratio1 > 0.57:
523 self.failure_reason = "{0} iops ratio mismatch iops1={1} iops2={2} expected ratio~0.5 got ratio={3:.3f},".format(
524 self.failure_reason, iops1, iops2, ratio1
530 class FioJobTest_t0015(FioJobTest):
531 """Test consists of fio test jobs t0015 and t0016
532 Confirm that mean(slat) + mean(clat) = mean(tlat)"""
534 def check_result(self):
535 super(FioJobTest_t0015, self).check_result()
540 slat = self.json_data['jobs'][0]['read']['slat_ns']['mean']
541 clat = self.json_data['jobs'][0]['read']['clat_ns']['mean']
542 tlat = self.json_data['jobs'][0]['read']['lat_ns']['mean']
543 logging.debug('Test %d: slat %f, clat %f, tlat %f', self.testnum, slat, clat, tlat)
545 if abs(slat + clat - tlat) > 1:
546 self.failure_reason = "{0} slat {1} + clat {2} = {3} != tlat {4},".format(
547 self.failure_reason, slat, clat, slat+clat, tlat)
551 class FioJobTest_t0019(FioJobTest):
552 """Test consists of fio test job t0019
553 Confirm that all offsets were touched sequentially"""
555 def check_result(self):
556 super(FioJobTest_t0019, self).check_result()
558 bw_log_filename = os.path.join(self.test_dir, "test_bw.log")
559 file_data, success = self.get_file(bw_log_filename)
560 log_lines = file_data.split('\n')
563 for line in log_lines:
564 if len(line.strip()) == 0:
566 cur = int(line.split(',')[4])
567 if cur - prev != 4096:
569 self.failure_reason = "offsets {0}, {1} not sequential".format(prev, cur)
575 self.failure_reason = "unexpected last offset {0}".format(cur)
578 class FioJobTest_t0020(FioJobTest):
579 """Test consists of fio test jobs t0020 and t0021
580 Confirm that almost all offsets were touched non-sequentially"""
582 def check_result(self):
583 super(FioJobTest_t0020, self).check_result()
585 bw_log_filename = os.path.join(self.test_dir, "test_bw.log")
586 file_data, success = self.get_file(bw_log_filename)
587 log_lines = file_data.split('\n')
592 prev = int(log_lines[0].split(',')[4])
593 for line in log_lines[1:]:
594 offsets.add(prev/4096)
595 if len(line.strip()) == 0:
597 cur = int(line.split(',')[4])
598 if cur - prev == 4096:
602 # 10 is an arbitrary threshold
605 self.failure_reason = "too many ({0}) consecutive offsets".format(seq_count)
607 if len(offsets) != 256:
609 self.failure_reason += " number of offsets is {0} instead of 256".format(len(offsets))
614 self.failure_reason += " missing offset {0}".format(i*4096)
617 class FioJobTest_t0022(FioJobTest):
618 """Test consists of fio test job t0022"""
620 def check_result(self):
621 super(FioJobTest_t0022, self).check_result()
623 bw_log_filename = os.path.join(self.test_dir, "test_bw.log")
624 file_data, success = self.get_file(bw_log_filename)
625 log_lines = file_data.split('\n')
632 prev = int(log_lines[0].split(',')[4])
633 for line in log_lines[1:]:
635 if len(line.strip()) == 0:
637 cur = int(line.split(',')[4])
642 # 10 is an arbitrary threshold
645 self.failure_reason = "too many ({0}) consecutive offsets".format(seq_count)
647 if len(offsets) == filesize/bs:
649 self.failure_reason += " no duplicate offsets found with norandommap=1".format(len(offsets))
652 class FioJobTest_t0023(FioJobTest):
653 """Test consists of fio test job t0023"""
655 def check_trimwrite(self, filename):
656 """Make sure that trims are followed by writes of the same size at the same offset."""
658 bw_log_filename = os.path.join(self.test_dir, filename)
659 file_data, success = self.get_file(bw_log_filename)
660 log_lines = file_data.split('\n')
663 for line in log_lines:
664 if len(line.strip()) == 0:
666 vals = line.split(',')
669 offset = int(vals[4])
673 self.failure_reason += " {0}: write not preceeded by trim: {1}".format(bw_log_filename, line)
678 self.failure_reason += " {0}: trim not preceeded by write: {1}".format(bw_log_filename, line)
683 self.failure_reason += " {0}: block size does not match: {1}".format(bw_log_filename, line)
685 if prev_offset != offset:
687 self.failure_reason += " {0}: offset does not match: {1}".format(bw_log_filename, line)
694 def check_result(self):
695 super(FioJobTest_t0023, self).check_result()
697 self.check_trimwrite("basic_bw.log")
698 self.check_trimwrite("bs_bw.log")
699 self.check_trimwrite("bsrange_bw.log")
700 self.check_trimwrite("bssplit_bw.log")
701 self.check_trimwrite("basic_no_rm_bw.log")
702 self.check_trimwrite("bs_no_rm_bw.log")
703 self.check_trimwrite("bsrange_no_rm_bw.log")
704 self.check_trimwrite("bssplit_no_rm_bw.log")
706 # TODO make sure all offsets were touched
709 class FioJobTest_iops_rate(FioJobTest):
710 """Test consists of fio test job t0009
711 Confirm that job0 iops == 1000
712 and that job1_iops / job0_iops ~ 8
713 With two runs of fio-3.16 I observed a ratio of 8.3"""
715 def check_result(self):
716 super(FioJobTest_iops_rate, self).check_result()
721 iops1 = self.json_data['jobs'][0]['read']['iops']
722 logging.debug("Test %d: iops1: %f", self.testnum, iops1)
723 iops2 = self.json_data['jobs'][1]['read']['iops']
724 logging.debug("Test %d: iops2: %f", self.testnum, iops2)
725 ratio = iops2 / iops1
726 logging.debug("Test %d: ratio: %f", self.testnum, ratio)
728 if iops1 < 950 or iops1 > 1050:
729 self.failure_reason = "{0} iops value mismatch,".format(self.failure_reason)
732 if ratio < 6 or ratio > 10:
733 self.failure_reason = "{0} iops ratio mismatch,".format(self.failure_reason)
737 class Requirements(object):
738 """Requirements consists of multiple run environment characteristics.
739 These are to determine if a particular test can be run"""
752 def __init__(self, fio_root):
753 Requirements._not_macos = platform.system() != "Darwin"
754 Requirements._not_windows = platform.system() != "Windows"
755 Requirements._linux = platform.system() == "Linux"
757 if Requirements._linux:
758 config_file = os.path.join(fio_root, "config-host.h")
759 contents, success = FioJobTest.get_file(config_file)
761 print("Unable to open {0} to check requirements".format(config_file))
762 Requirements._zbd = True
764 Requirements._zbd = "CONFIG_HAS_BLKZONED" in contents
765 Requirements._libaio = "CONFIG_LIBAIO" in contents
767 contents, success = FioJobTest.get_file("/proc/kallsyms")
769 print("Unable to open '/proc/kallsyms' to probe for io_uring support")
771 Requirements._io_uring = "io_uring_setup" in contents
773 Requirements._root = (os.geteuid() == 0)
774 if Requirements._zbd and Requirements._root:
776 subprocess.run(["modprobe", "null_blk"],
777 stdout=subprocess.PIPE,
778 stderr=subprocess.PIPE)
779 if os.path.exists("/sys/module/null_blk/parameters/zoned"):
780 Requirements._zoned_nullb = True
784 if platform.system() == "Windows":
785 utest_exe = "unittest.exe"
787 utest_exe = "unittest"
788 unittest_path = os.path.join(fio_root, "unittests", utest_exe)
789 Requirements._unittests = os.path.exists(unittest_path)
791 Requirements._cpucount4 = multiprocessing.cpu_count() >= 4
793 req_list = [Requirements.linux,
795 Requirements.io_uring,
798 Requirements.zoned_nullb,
799 Requirements.not_macos,
800 Requirements.not_windows,
801 Requirements.unittests,
802 Requirements.cpucount4]
805 logging.debug("Requirements: Requirement '%s' met? %s", desc, value)
809 """Are we running on Linux?"""
810 return Requirements._linux, "Linux required"
814 """Is libaio available?"""
815 return Requirements._libaio, "libaio required"
819 """Is io_uring available?"""
820 return Requirements._io_uring, "io_uring required"
824 """Is ZBD support available?"""
825 return Requirements._zbd, "Zoned block device support required"
829 """Are we running as root?"""
830 return Requirements._root, "root required"
833 def zoned_nullb(cls):
834 """Are zoned null block devices available?"""
835 return Requirements._zoned_nullb, "Zoned null block device support required"
839 """Are we running on a platform other than macOS?"""
840 return Requirements._not_macos, "platform other than macOS required"
843 def not_windows(cls):
844 """Are we running on a platform other than Windws?"""
845 return Requirements._not_windows, "platform other than Windows required"
849 """Were unittests built?"""
850 return Requirements._unittests, "Unittests support required"
854 """Do we have at least 4 CPUs?"""
855 return Requirements._cpucount4, "4+ CPUs required"
860 'stderr_empty': True,
864 'zero_return': False,
865 'stderr_empty': False,
870 'stderr_empty': False,
876 'test_class': FioJobTest,
877 'job': 't0001-52c58027.fio',
878 'success': SUCCESS_DEFAULT,
885 'test_class': FioJobTest,
886 'job': 't0002-13af05ae-post.fio',
887 'success': SUCCESS_DEFAULT,
888 'pre_job': 't0002-13af05ae-pre.fio',
890 'requirements': [Requirements.linux, Requirements.libaio],
894 'test_class': FioJobTest,
895 'job': 't0003-0ae2c6e1-post.fio',
896 'success': SUCCESS_NONZERO,
897 'pre_job': 't0003-0ae2c6e1-pre.fio',
898 'pre_success': SUCCESS_DEFAULT,
899 'requirements': [Requirements.linux, Requirements.libaio],
903 'test_class': FioJobTest,
904 'job': 't0004-8a99fdf6.fio',
905 'success': SUCCESS_DEFAULT,
908 'requirements': [Requirements.linux, Requirements.libaio],
912 'test_class': FioJobTest_t0005,
913 'job': 't0005-f7078f7b.fio',
914 'success': SUCCESS_DEFAULT,
917 'output_format': 'json',
918 'requirements': [Requirements.not_windows],
922 'test_class': FioJobTest_t0006,
923 'job': 't0006-82af2a7c.fio',
924 'success': SUCCESS_DEFAULT,
927 'output_format': 'json',
928 'requirements': [Requirements.linux, Requirements.libaio],
932 'test_class': FioJobTest_t0007,
933 'job': 't0007-37cf9e3c.fio',
934 'success': SUCCESS_DEFAULT,
937 'output_format': 'json',
942 'test_class': FioJobTest_t0008,
943 'job': 't0008-ae2fafc8.fio',
944 'success': SUCCESS_DEFAULT,
947 'output_format': 'json',
952 'test_class': FioJobTest_t0009,
953 'job': 't0009-f8b0bd10.fio',
954 'success': SUCCESS_DEFAULT,
957 'output_format': 'json',
958 'requirements': [Requirements.not_macos,
959 Requirements.cpucount4],
960 # mac os does not support CPU affinity
964 'test_class': FioJobTest,
965 'job': 't0010-b7aae4ba.fio',
966 'success': SUCCESS_DEFAULT,
973 'test_class': FioJobTest_iops_rate,
974 'job': 't0011-5d2788d5.fio',
975 'success': SUCCESS_DEFAULT,
978 'output_format': 'json',
983 'test_class': FioJobTest_t0012,
985 'success': SUCCESS_DEFAULT,
988 'output_format': 'json',
993 'test_class': FioJobTest,
995 'success': SUCCESS_DEFAULT,
998 'output_format': 'json',
1003 'test_class': FioJobTest_t0014,
1005 'success': SUCCESS_DEFAULT,
1007 'pre_success': None,
1008 'output_format': 'json',
1013 'test_class': FioJobTest_t0015,
1014 'job': 't0015-e78980ff.fio',
1015 'success': SUCCESS_DEFAULT,
1017 'pre_success': None,
1018 'output_format': 'json',
1019 'requirements': [Requirements.linux, Requirements.libaio],
1023 'test_class': FioJobTest_t0015,
1024 'job': 't0016-d54ae22.fio',
1025 'success': SUCCESS_DEFAULT,
1027 'pre_success': None,
1028 'output_format': 'json',
1033 'test_class': FioJobTest_t0015,
1035 'success': SUCCESS_DEFAULT,
1037 'pre_success': None,
1038 'output_format': 'json',
1039 'requirements': [Requirements.not_windows],
1043 'test_class': FioJobTest,
1045 'success': SUCCESS_DEFAULT,
1047 'pre_success': None,
1048 'requirements': [Requirements.linux, Requirements.io_uring],
1052 'test_class': FioJobTest_t0019,
1054 'success': SUCCESS_DEFAULT,
1056 'pre_success': None,
1061 'test_class': FioJobTest_t0020,
1063 'success': SUCCESS_DEFAULT,
1065 'pre_success': None,
1070 'test_class': FioJobTest_t0020,
1072 'success': SUCCESS_DEFAULT,
1074 'pre_success': None,
1079 'test_class': FioJobTest_t0022,
1081 'success': SUCCESS_DEFAULT,
1083 'pre_success': None,
1088 'test_class': FioJobTest_t0023,
1090 'success': SUCCESS_DEFAULT,
1092 'pre_success': None,
1097 'test_class': FioExeTest,
1100 'success': SUCCESS_DEFAULT,
1105 'test_class': FioExeTest,
1108 'success': SUCCESS_DEFAULT,
1113 'test_class': FioExeTest,
1114 'exe': 't/lfsr-test',
1115 'parameters': ['0xFFFFFF', '0', '0', 'verify'],
1116 'success': SUCCESS_STDERR,
1121 'test_class': FioExeTest,
1122 'exe': 't/readonly.py',
1123 'parameters': ['-f', '{fio_path}'],
1124 'success': SUCCESS_DEFAULT,
1129 'test_class': FioExeTest,
1130 'exe': 't/steadystate_tests.py',
1131 'parameters': ['{fio_path}'],
1132 'success': SUCCESS_DEFAULT,
1137 'test_class': FioExeTest,
1140 'success': SUCCESS_STDERR,
1145 'test_class': FioExeTest,
1146 'exe': 't/strided.py',
1147 'parameters': ['{fio_path}'],
1148 'success': SUCCESS_DEFAULT,
1153 'test_class': FioExeTest,
1154 'exe': 't/zbd/run-tests-against-nullb',
1155 'parameters': ['-s', '1'],
1156 'success': SUCCESS_DEFAULT,
1157 'requirements': [Requirements.linux, Requirements.zbd,
1162 'test_class': FioExeTest,
1163 'exe': 't/zbd/run-tests-against-nullb',
1164 'parameters': ['-s', '2'],
1165 'success': SUCCESS_DEFAULT,
1166 'requirements': [Requirements.linux, Requirements.zbd,
1167 Requirements.root, Requirements.zoned_nullb],
1171 'test_class': FioExeTest,
1172 'exe': 'unittests/unittest',
1174 'success': SUCCESS_DEFAULT,
1175 'requirements': [Requirements.unittests],
1179 'test_class': FioExeTest,
1180 'exe': 't/latency_percentiles.py',
1181 'parameters': ['-f', '{fio_path}'],
1182 'success': SUCCESS_DEFAULT,
1187 'test_class': FioExeTest,
1188 'exe': 't/jsonplus2csv_test.py',
1189 'parameters': ['-f', '{fio_path}'],
1190 'success': SUCCESS_DEFAULT,
1195 'test_class': FioExeTest,
1196 'exe': 't/log_compression.py',
1197 'parameters': ['-f', '{fio_path}'],
1198 'success': SUCCESS_DEFAULT,
1205 """Parse command-line arguments."""
1207 parser = argparse.ArgumentParser()
1208 parser.add_argument('-r', '--fio-root',
1209 help='fio root path')
1210 parser.add_argument('-f', '--fio',
1211 help='path to fio executable (e.g., ./fio)')
1212 parser.add_argument('-a', '--artifact-root',
1213 help='artifact root directory')
1214 parser.add_argument('-s', '--skip', nargs='+', type=int,
1215 help='list of test(s) to skip')
1216 parser.add_argument('-o', '--run-only', nargs='+', type=int,
1217 help='list of test(s) to run, skipping all others')
1218 parser.add_argument('-d', '--debug', action='store_true',
1219 help='provide debug output')
1220 parser.add_argument('-k', '--skip-req', action='store_true',
1221 help='skip requirements checking')
1222 parser.add_argument('-p', '--pass-through', action='append',
1223 help='pass-through an argument to an executable test')
1224 args = parser.parse_args()
1234 logging.basicConfig(level=logging.DEBUG)
1236 logging.basicConfig(level=logging.INFO)
1239 if args.pass_through:
1240 for arg in args.pass_through:
1242 print("Invalid --pass-through argument '%s'" % arg)
1243 print("Syntax for --pass-through is TESTNUMBER:ARGUMENT")
1245 split = arg.split(":", 1)
1246 pass_through[int(split[0])] = split[1]
1247 logging.debug("Pass-through arguments: %s", pass_through)
1250 fio_root = args.fio_root
1252 fio_root = str(Path(__file__).absolute().parent.parent)
1253 print("fio root is %s" % fio_root)
1258 if platform.system() == "Windows":
1262 fio_path = os.path.join(fio_root, fio_exe)
1263 print("fio path is %s" % fio_path)
1264 if not shutil.which(fio_path):
1265 print("Warning: fio executable not found")
1267 artifact_root = args.artifact_root if args.artifact_root else \
1268 "fio-test-{0}".format(time.strftime("%Y%m%d-%H%M%S"))
1269 os.mkdir(artifact_root)
1270 print("Artifact directory is %s" % artifact_root)
1272 if not args.skip_req:
1273 req = Requirements(fio_root)
1279 for config in TEST_LIST:
1280 if (args.skip and config['test_id'] in args.skip) or \
1281 (args.run_only and config['test_id'] not in args.run_only):
1282 skipped = skipped + 1
1283 print("Test {0} SKIPPED (User request)".format(config['test_id']))
1286 if issubclass(config['test_class'], FioJobTest):
1287 if config['pre_job']:
1288 fio_pre_job = os.path.join(fio_root, 't', 'jobs',
1292 if config['pre_success']:
1293 fio_pre_success = config['pre_success']
1295 fio_pre_success = None
1296 if 'output_format' in config:
1297 output_format = config['output_format']
1299 output_format = 'normal'
1300 test = config['test_class'](
1302 os.path.join(fio_root, 't', 'jobs', config['job']),
1304 fio_pre_job=fio_pre_job,
1305 fio_pre_success=fio_pre_success,
1306 output_format=output_format)
1307 desc = config['job']
1308 elif issubclass(config['test_class'], FioExeTest):
1309 exe_path = os.path.join(fio_root, config['exe'])
1310 if config['parameters']:
1311 parameters = [p.format(fio_path=fio_path) for p in config['parameters']]
1314 if Path(exe_path).suffix == '.py' and platform.system() == "Windows":
1315 parameters.insert(0, exe_path)
1316 exe_path = "python.exe"
1317 if config['test_id'] in pass_through:
1318 parameters += pass_through[config['test_id']].split()
1319 test = config['test_class'](exe_path, parameters,
1321 desc = config['exe']
1323 print("Test {0} FAILED: unable to process test config".format(config['test_id']))
1327 if not args.skip_req:
1329 for req in config['requirements']:
1330 reqs_met, reason = req()
1331 logging.debug("Test %d: Requirement '%s' met? %s", config['test_id'], reason,
1336 print("Test {0} SKIPPED ({1}) {2}".format(config['test_id'], reason, desc))
1337 skipped = skipped + 1
1341 test.setup(artifact_root, config['test_id'])
1344 except KeyboardInterrupt:
1346 except Exception as e:
1348 test.failure_reason += str(e)
1349 logging.debug("Test %d exception:\n%s\n", config['test_id'], traceback.format_exc())
1354 result = "FAILED: {0}".format(test.failure_reason)
1356 contents, _ = FioJobTest.get_file(test.stderr_file)
1357 logging.debug("Test %d: stderr:\n%s", config['test_id'], contents)
1358 contents, _ = FioJobTest.get_file(test.stdout_file)
1359 logging.debug("Test %d: stdout:\n%s", config['test_id'], contents)
1360 print("Test {0} {1} {2}".format(config['test_id'], result, desc))
1362 print("{0} test(s) passed, {1} failed, {2} skipped".format(passed, failed, skipped))
1367 if __name__ == '__main__':