chg: [tests] search for errors in logs

pull/9432/head
Christophe Vandeplas 2023-12-01 10:17:36 +01:00
parent aac06b2831
commit cb07b6177b
3 changed files with 19 additions and 0 deletions

View File

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

View File

@ -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
tests/logs_tests.sh Normal file
View File

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