From faa67b38e238e2753093d3c289bbaaaa9f8b92dd Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 8 Mar 2021 19:11:43 +0100 Subject: [PATCH] Try to display service logs when hitting 50x errors --- lib/tests.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/tests.sh b/lib/tests.sh index 6ff8017..26dd34d 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -246,6 +246,13 @@ Page extract:\n$page_extract" > $TEST_CONTEXT/curl_result [[ $curl_error -eq 0 ]] \ && log_debug "$(cat $TEST_CONTEXT/curl_result)" \ || log_warning "$(cat $TEST_CONTEXT/curl_result)" + + # If we had a 50x error, try to display service info and logs to help debugging + if [[ $curl_error -ne 0 ]] && echo "5" | grep -q "${http_code:0:1}" + then + LXC_EXEC "systemctl | grep '$app.*service'" + LXC_EXEC "for SERVICE in $(systemctl | grep "$app.*service" | awk '{print $1}'); do journalctl --no-pager --no-hostname -n 30 -u $SERVICE; done" + fi done # Detect the issue alias_traversal, https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md