Skip to content

Commit

Permalink
Check unexpected exceptions in Patroni logs after behave (patroni#2538)
Browse files Browse the repository at this point in the history
and make behave fail if there are anything unexpected found.

In addition to that fix globing rule when uploading artifacts with logs.
  • Loading branch information
CyberDem0n authored Jan 25, 2023
1 parent 4872ac5 commit 7945868
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion features/environment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import abc
import datetime
import glob
import os
import json
import psutil
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 7945868

Please sign in to comment.