5 # Test log_compression and log_store_compressed. Uses null ioengine.
6 # Previous bugs have caused output in per I/O log files to be missing
9 # Expected result: 8000 log entries, offset starting at 0 and increasing by bs
10 # Buggy result: Log entries out of order (usually without log_store_compressed)
11 # and/or missing log entries (usually with log_store_compressed)
14 # python log_compression.py [-f fio-executable]
17 # python t/log_compression.py
18 # python t/log_compression.py -f ./fio
25 # With log_compression=10K
26 # With log_store_compressed=1 and log_compression=10K
36 """Parse command-line arguments."""
37 parser = argparse.ArgumentParser()
38 parser.add_argument('-f', '--fio',
39 help='path to fio executable (e.g., ./fio)')
40 return parser.parse_args()
43 def run_fio(fio,log_store_compressed):
51 '--write_bw_log=test',
54 '--log_compression=10K',
56 if log_store_compressed:
57 fio_args.append('--log_store_compressed=1')
59 subprocess.check_output([fio] + fio_args)
61 if log_store_compressed:
63 '--inflate-log=test_bw.log.fz'
65 with open('test_bw.from_fz.log','wt') as f:
66 subprocess.check_call([fio]+fio_inflate_args,stdout=f)
68 def check_log_file(log_store_compressed):
69 filename = 'test_bw.from_fz.log' if log_store_compressed else 'test_bw.log'
70 with open(filename,'rt') as f:
72 log_lines = [x for x in file_data.split('\n') if len(x.strip())!=0]
73 log_ios = len(log_lines)
75 filesize = 1000*1024*1024
79 print('wrong number of ios ({}) in log; should be {}'.format(log_ios,ios))
83 for line_number,line in enumerate(log_lines):
84 log_offset = int(line.split(',')[4])
85 if log_offset != expected_offset:
86 print('wrong offset ({}) for io number {} in log; should be {}'.format(
87 log_offset, line_number, expected_offset))
93 """Entry point for this script."""
98 fio_path = os.path.join(os.path.dirname(__file__), '../fio')
99 if not os.path.exists(fio_path):
101 print("fio path is", fio_path)
105 for log_store_compressed in [False, True]:
106 run_fio(fio_path, log_store_compressed)
107 passed = check_log_file(log_store_compressed)
108 print('Test with log_store_compressed={} {}'.format(log_store_compressed,
109 'PASSED' if passed else 'FAILED'))
115 print('{} tests passed, {} failed'.format(passed_count, failed_count))
117 sys.exit(failed_count)
119 if __name__ == '__main__':