Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run blockdev report commands after _make_loopbacked_devices() #218

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# isort: STDLIB
import argparse
import itertools
import logging
import os
import subprocess
import tempfile
Expand Down Expand Up @@ -61,6 +62,13 @@ def _run_command(num_devices, command):
:param list command: the command to be run
"""
devices = _make_loopbacked_devices(num_devices)
for device in devices:
for option in ["--getss", "--getpbsz", "--getiomin", "--getioopt"]:
diagcmd = ["blockdev", option, device]
with subprocess.Popen(diagcmd, stdout=subprocess.PIPE) as proc:
blockdevoutput = proc.stdout.readline().strip().decode("utf-8")
logging.debug("output of %s: %s", diagcmd, blockdevoutput)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use f-strings here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried before, but it failed linting with this:

test_harness.py:70:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!


command = command + list(itertools.chain(*[["--disk", dev] for dev in devices]))
subprocess.run(command, check=True)

Expand Down Expand Up @@ -108,6 +116,13 @@ def _gen_parser():
"clean up resources, such as temporary directories."
)
)
parser.add_argument(
"--log-level",
help="Log level",
action="store",
choices=["debug", "info", "warning", "error", "critical"],
default="info",
)

subparsers = parser.add_subparsers(title="subcommand")

Expand Down Expand Up @@ -149,6 +164,8 @@ def main():

namespace, unittest_args = parser.parse_known_args()

logging.basicConfig(level=namespace.log_level.upper())

namespace.func(namespace, unittest_args)


Expand Down