From 79458688d1b621a36fd27c200732fafae76809fc Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 25 Jan 2023 11:02:52 +0100 Subject: [PATCH] Check unexpected exceptions in Patroni logs after behave (#2538) and make behave fail if there are anything unexpected found. In addition to that fix globing rule when uploading artifacts with logs. --- .github/workflows/tests.yaml | 2 +- features/environment.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a68e3b2f..fd0d826a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -144,7 +144,7 @@ jobs: name: behave-${{ matrix.os }}-${{ matrix.dcs }}-${{ matrix.python-version }}-logs path: | features/output/*_failed/*postgres?.* - features/output/* + features/output/*.log if-no-files-found: error retention-days: 5 - name: Generate coverage xml report diff --git a/features/environment.py b/features/environment.py index 2a2f0017..0c1e2c1f 100644 --- a/features/environment.py +++ b/features/environment.py @@ -1,5 +1,6 @@ import abc import datetime +import glob import os import json import psutil @@ -1110,8 +1111,20 @@ def after_feature(context, feature): if os.path.exists(data): shutil.rmtree(data) context.dcs_ctl.cleanup_service_tree() - if feature.status == 'failed': + + found = False + logs = glob.glob(context.pctl.output_dir + '/patroni_*.log') + for log in logs: + with open(log) as f: + for line in f: + if 'please report it as a BUG' in line: + print(':'.join([log, line.rstrip()])) + found = True + + if feature.status == 'failed' or found: shutil.copytree(context.pctl.output_dir, context.pctl.output_dir + '_failed') + if found: + raise Exception('Unexpected errors in Patroni log files') def before_scenario(context, scenario):