Skip to content

Commit

Permalink
Merge pull request #24 from katlapinka/kasiat/update-fio-version
Browse files Browse the repository at this point in the history
Update fio version and make it possible to set it in config file
  • Loading branch information
katlapinka authored Nov 12, 2024
2 parents a5a05f4 + d7f9d90 commit 5d8afd3
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test_tools/fio/fio.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#
# Copyright(c) 2019-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#

import datetime
import uuid

from packaging.version import Version
import test_tools.fio.fio_param
import test_tools.fs_utils
from core.test_run import TestRun
from test_tools import fs_utils
from test_utils import os_utils
from test_utils.output import CmdException


class Fio:
def __init__(self, executor_obj=None):
self.fio_version = "fio-3.30"
self.min_fio_version = Version(TestRun.config.get("fio_version", "3.30"))
self.default_run_time = datetime.timedelta(hours=1)
self.jobs = []
self.executor = executor_obj if executor_obj is not None else TestRun.executor
Expand All @@ -26,7 +29,8 @@ def create_command(self, output_type=test_tools.fio.fio_param.FioOutput.json):
self.base_cmd_parameters = test_tools.fio.fio_param.FioParamCmd(self, self.executor)
self.global_cmd_parameters = test_tools.fio.fio_param.FioParamConfig(self, self.executor)

self.fio_file = f'fio_run_{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}_{uuid.uuid4().hex}'
self.fio_file = \
f'fio_run_{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}_{uuid.uuid4().hex}'
self.base_cmd_parameters\
.set_param('eta', 'always')\
.set_param('output-format', output_type.value)\
Expand All @@ -37,14 +41,21 @@ def create_command(self, output_type=test_tools.fio.fio_param.FioOutput.json):
return self.global_cmd_parameters

def is_installed(self):
return self.executor.run("fio --version").stdout.strip() == self.fio_version
try:
output = self.executor.run_expect_success("fio --version").stdout
except CmdException:
return False
current_version = Version(output.strip().removeprefix("fio-"))
return current_version >= self.min_fio_version

def install(self):
fio_url = f"http://brick.kernel.dk/snaps/{self.fio_version}.tar.bz2"
fio_url = f"http://brick.kernel.dk/snaps/fio-{self.min_fio_version}.tar.bz2"
fio_package = os_utils.download_file(fio_url)
fs_utils.uncompress_archive(fio_package)
TestRun.executor.run_expect_success(f"cd {fio_package.parent_dir}/{self.fio_version}"
f" && ./configure && make -j && make install")
TestRun.executor.run_expect_success(
f"cd {fio_package.parent_dir}/fio-{self.min_fio_version}"
f" && ./configure && make -j && make install"
)

def calculate_timeout(self):
if "time_based" not in self.global_cmd_parameters.command_flags:
Expand Down

0 comments on commit 5d8afd3

Please sign in to comment.