Skip to content

Commit

Permalink
chg: [tests] search for errors in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Dec 1, 2023
1 parent aac06b2 commit cb07b61
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,15 @@ jobs:

- name: Logs
if: ${{ always() }}
# update logs_test.sh when adding more logsources here
run: |
tail -n +1 `pwd`/app/tmp/logs/*
tail -n +1 /var/log/apache2/*.log
sudo -u $USER app/Console/cake Log export /tmp/logs.json.gz --without-changes
zcat /tmp/logs.json.gz
- name: Errors in Logs
if: ${{ always() }}
run: |
./logs_tests.sh
5 changes: 5 additions & 0 deletions tests/logs_fail_regexes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file contains regexes applied to logs, one line per regex
# Whenever the regex matches, the Logs job will fail and report the error.
class="cake-error"
Error: [ParseError]
Error: [PDOException]
8 changes: 8 additions & 0 deletions tests/logs_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
ERROR_MESSAGE="Errors found in logs !"
# exit 0 of grep = match found, so we need to exit 1 on this use-case.
grep -HE -f logs_fail_regexes.txt `pwd`/app/tmp/logs/* && echo $ERROR_MESSAGE && exit 1
grep -HE -f logs_fail_regexes.txt /var/log/apache2/*.log && echo $ERROR_MESSAGE && exit 1
zgrep -HE -f logs_fail_regexes.txt /tmp/logs.json.gz && echo $ERROR_MESSAGE && exit 1
# exit cleanly because grep found nothing, and did exit 1.
exit 0

0 comments on commit cb07b61

Please sign in to comment.