diff options
| author | Mark Goddard <mark@stackhpc.com> | 2019-09-20 11:24:51 +0100 |
|---|---|---|
| committer | Mark Goddard <mark@stackhpc.com> | 2019-09-20 15:36:50 +0000 |
| commit | bfd8ee19780a6718fbaedae42fc2cf1c87eb7495 (patch) | |
| tree | 92562bba042cbbf71973f00ea7466ce3909d1a14 /tests/check-logs.sh | |
| parent | ec8437205e6beee082ff1871a04df76e91851ba2 (diff) | |
| download | kolla-ansible-bfd8ee19780a6718fbaedae42fc2cf1c87eb7495.tar.gz kolla-ansible-bfd8ee19780a6718fbaedae42fc2cf1c87eb7495.zip | |
CI: Fix check-logs.sh
This script has a few issues:
* It catches false positives, due to log levels in config options.
* It doesn't fail on CRITICAL logs, due to variable reset issue.
This change fixes these.
Change-Id: I50c859eb2991e498eeb64bca45daf1e6f237761f
Diffstat (limited to 'tests/check-logs.sh')
| -rwxr-xr-x | tests/check-logs.sh | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/check-logs.sh b/tests/check-logs.sh index 614a5ed00..179a7f6f3 100755 --- a/tests/check-logs.sh +++ b/tests/check-logs.sh @@ -3,24 +3,32 @@ # Check for CRITICAL, ERROR or WARNING messages in log files. set -o errexit +set -o pipefail # Enable unbuffered output for Ansible in Jenkins. export PYTHONUNBUFFERED=1 +function check_file_for_level { + # $1: file + # $2: log level + # Filter out false positives from logged config options. + sudo egrep " $2 " $1 | egrep -v "(logging_exception_prefix|rate_limit_except_level)" +} + +any_critical=0 for level in CRITICAL ERROR WARNING; do all_file=/tmp/logs/kolla/all-${level}.log any_matched=0 - any_critical=0 echo "Checking for $level log messages" for f in $(sudo find /var/log/kolla/ -type f); do - if sudo egrep "^.* .* .* $level" $f >/dev/null; then + if check_file_for_level $f $level >/dev/null; then any_matched=1 if [[ $level = CRITICAL ]]; then any_critical=1 fi echo $f >> $all_file - sudo egrep "^.* .* .* $level" $f >> $all_file + check_file_for_level $f $level >> $all_file echo >> $all_file fi done |
