diff --git a/tests/integration_tests/util.py b/tests/integration_tests/util.py index 8121c7600ec..2c4ca381f65 100644 --- a/tests/integration_tests/util.py +++ b/tests/integration_tests/util.py @@ -538,10 +538,20 @@ def get_console_log(client: "IntegrationInstance"): console_log = client.instance.console_log() except NotImplementedError: pytest.skip("NotImplementedError when requesting console log") + except RuntimeError as e: + if "open : no such file or directory" in str(e): + if hasattr(client, "lxc_log"): + return client.lxc_log + raise e if console_log is None: pytest.skip("Console log has not been setup") if console_log.lower().startswith("no console output"): pytest.fail("no console output") + if PLATFORM in ("lxd_vm", "lxd_container"): + # Preserve non empty console log on lxc platforms because + # lxc console --show-log can only be called once and the log is flushed + # Mulitple calls to --show-log error on "no such file or directory" + client.lxc_log = console_log return console_log