From 18f610caeadf6fd80c31f951cb7971cec82e4fa1 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 10 Dec 2018 12:51:29 +0100 Subject: [PATCH] Always collect test logs mh.install() is the default multi host installer. Most integration test classes use it to install master, replicas, and clients. In case of a failed installation, the test collector step is skipped. Guard log collection with a try/finally block so logs are always collected. Also collect journald output for mh.install() steps. The journal output was missing from installation logs and were only available in each test step. Signed-off-by: Christian Heimes Reviewed-By: Francisco Trivino --- ipatests/pytest_ipa/integration/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ipatests/pytest_ipa/integration/__init__.py b/ipatests/pytest_ipa/integration/__init__.py index 7c1eb2232..f7b1857c1 100644 --- a/ipatests/pytest_ipa/integration/__init__.py +++ b/ipatests/pytest_ipa/integration/__init__.py @@ -253,12 +253,16 @@ def mh(request, class_integration_logs): setup_class(cls, mh) mh._pytestmh_request.addfinalizer(lambda: teardown_class(cls)) - yield mh.install() - - for host in cls.get_all_hosts(): - host.remove_log_collector(collect_log) - - collect_test_logs(request.node, class_integration_logs, request.config) + try: + yield mh.install() + finally: + hosts = list(cls.get_all_hosts()) + for host in hosts: + host.remove_log_collector(collect_log) + collect_test_logs( + request.node, class_integration_logs, request.config + ) + collect_systemd_journal(request.node, hosts, request.config) def setup_class(cls, mh):