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 <cheimes@redhat.com>
Reviewed-By: Francisco Trivino <ftrivino@redhat.com>
This commit is contained in:
Christian Heimes 2018-12-10 12:51:29 +01:00
parent a9f34c7605
commit 18f610caea

View File

@ -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):