From: Vincent Fu Date: Wed, 7 Jun 2023 21:21:50 +0000 (+0000) Subject: t/fiotestlib: add ability to ingest iops logs X-Git-Tag: fio-3.36~89 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=885e170af6501530f884e3be40fe413095d39fb1;p=fio.git t/fiotestlib: add ability to ingest iops logs Enhance the FioJobCmdTest class with the ability to read in an IOPS log if one was generated during the course of the test run. This reads in only the first IOPS log written as a result of --write_iops_log. Signed-off-by: Vincent Fu --- diff --git a/t/fiotestlib.py b/t/fiotestlib.py index 69f630a0..0fe17b74 100755 --- a/t/fiotestlib.py +++ b/t/fiotestlib.py @@ -279,17 +279,17 @@ class FioJobCmdTest(FioExeTest): self.basename = basename if basename else os.path.basename(fio_path) self.fio_opts = fio_opts self.json_data = None + self.iops_log_lines = None super().__init__(fio_path, success, testnum, artifact_root) - filename_stub = f"{self.basename}{self.testnum:03d}" - self.filenames['cmd'] = os.path.join(self.paths['test_dir'], f"{filename_stub}.command") - self.filenames['stdout'] = os.path.join(self.paths['test_dir'], f"{filename_stub}.stdout") - self.filenames['stderr'] = os.path.join(self.paths['test_dir'], f"{filename_stub}.stderr") - self.filenames['output'] = os.path.abspath(os.path.join(self.paths['test_dir'], - f"{filename_stub}.output")) - self.filenames['exitcode'] = os.path.join(self.paths['test_dir'], - f"{filename_stub}.exitcode") + filename_stub = os.path.join(self.paths['test_dir'], f"{self.basename}{self.testnum:03d}") + self.filenames['cmd'] = f"{filename_stub}.command" + self.filenames['stdout'] = f"{filename_stub}.stdout" + self.filenames['stderr'] = f"{filename_stub}.stderr" + self.filenames['output'] = os.path.abspath(f"{filename_stub}.output") + self.filenames['exitcode'] = f"{filename_stub}.exitcode" + self.filenames['iopslog'] = os.path.abspath(f"{filename_stub}") def run(self): super().run() @@ -300,6 +300,16 @@ class FioJobCmdTest(FioExeTest): print('Unable to decode JSON data') self.passed = False + if any('--write_iops_log=' in param for param in self.parameters): + self.get_iops_log() + + def get_iops_log(self): + """Read IOPS log from the first job.""" + + log_filename = self.filenames['iopslog'] + "_iops.1.log" + with open(log_filename, 'r', encoding=locale.getpreferredencoding()) as iops_file: + self.iops_log_lines = iops_file.read() + def get_json(self): """Convert fio JSON output into a python JSON object"""