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

omit_data_loss config variable #4001

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions avocado_vt/plugins/vt.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ def configure(self, parser):
help=help_msg,
)

help_msg = (
"Omits the `OSError [Errno 9] Bad file descriptor` caused by "
"avocado.utils.process utility during clean up. This can be used "
"when this error would cause false positive failures of a test."
)
add_option(
Copy link
Contributor

Choose a reason for hiding this comment

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

if introduce new option in avocado run (here --vt-omit-data-loss), it will bring additional efforts to update our CI to enable that. I wonder whether we can introduce one gating_variable e.g omit_data_loss in avocado_vt/conf.d/vt.conf, if omit_data_loss is set true, it enable it implicitly .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this PR, you can enable it with config option as well by setting vt.omit_data_loss to true. see https://github.com/avocado-framework/avocado-vt/pull/4001/files#diff-64c70a40c0700575186086930678d178f26a5b3fbe71dfe9d1ebd20d4d5e7752R135

But I am not sure if we should enable this implicitly, because it can hide real failures by skipping error messages. AFAIK this issue is related only to your CI and I think we shouldn't affect others by this.

vt_compat_group_common,
dest="vt.omit_data_loss",
arg="--vt-omit-data-loss",
action="store_true",
default=False,
help=help_msg,
)

def run(self, config):
"""
Run test modules or simple tests.
Expand Down
13 changes: 13 additions & 0 deletions avocado_vt/plugins/vt_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ def initialize(self):
help_msg=help_msg,
)

help_msg = (
"Omits the `OSError [Errno 9] Bad file descriptor` caused by "
"avocado.utils.process utility during clean up. This can be used "
"when this error would cause false positive failures of a test."
)
settings.register_option(
section,
key="omit_data_loss",
key_type=bool,
default=False,
help_msg=help_msg,
)

# [vt.setup] section
section = "vt.setup"

Expand Down
64 changes: 37 additions & 27 deletions avocado_vt/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,34 @@ def setUp(self):
os.remove(libvirtd_log)
else:
# tar the libvirtd log and archive
self.log.info("archiving libvirtd debug logs")
from virttest import utils_package

if utils_package.package_install("tar"):
if os.path.isfile(libvirtd_log):
archive = os.path.join(
os.path.dirname(libvirtd_log), "libvirtd.tar.gz"
)
cmd = "tar -zcf %s -P %s" % (
shlex.quote(archive),
shlex.quote(libvirtd_log),
)
if process.system(cmd) == 0:
os.remove(libvirtd_log)
try:
self.log.info("archiving libvirtd debug logs")
from virttest import utils_package

if utils_package.package_install("tar"):
if os.path.isfile(libvirtd_log):
archive = os.path.join(
os.path.dirname(libvirtd_log), "libvirtd.tar.gz"
)
cmd = "tar -zcf %s -P %s" % (
shlex.quote(archive),
shlex.quote(libvirtd_log),
)
if process.system(cmd) == 0:
os.remove(libvirtd_log)
else:
self.log.error(
"Unable to find log file: %s", libvirtd_log
)
else:
self.log.error(
"Unable to find log file: %s", libvirtd_log
"Unable to find tar to compress libvirtd " "logs"
)
else:
self.log.error(
"Unable to find tar to compress libvirtd " "logs"
)
except OSError as e:
if not self._config.get("vt.omit_data_loss"):
raise e
elif e.errno != 9:
raise e

if env_lang:
os.environ["LANG"] = env_lang
Expand Down Expand Up @@ -307,14 +313,18 @@ def _runTest(self):
params["test_passed"] = str(test_passed)
env_process.postprocess(self, params, env)
except: # nopep8 Old-style exceptions are not inherited from Exception()

stacktrace.log_exc_info(sys.exc_info(), "avocado.test")
if test_passed:
raise
self.log.error(
"Exception raised during " "postprocessing: %s",
sys.exc_info()[1],
)
if not (
self._config.get("vt.omit_data_loss")
and "[Errno 9] Bad file descriptor"
in str(sys.exc_info()[1])
):
stacktrace.log_exc_info(sys.exc_info(), "avocado.test")
if test_passed:
raise
self.log.error(
"Exception raised during " "postprocessing: %s",
sys.exc_info()[1],
)
finally:
if (
self._safe_env_save(env)
Expand Down
Loading