Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Laing <[email protected]>
  • Loading branch information
markylaing committed Oct 24, 2024
1 parent 86d9a32 commit 4b56433
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ jobs:
strategy:
fail-fast: false
matrix:
suite: ["cluster", "standalone"]
backend: ["dir", "btrfs", "lvm", "zfs", "ceph", "random"]
suite: ["standalone"]
backend: ["dir"]

steps:
- name: Checkout
Expand Down
35 changes: 35 additions & 0 deletions test/deps/panic-checker
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3

import sys
import re

# Looks for a panic by grepping for stacktraces in a log file.
# If a panic is found, it exits with code 1 and prints the stacktrace plus the last log message.
# Only the first panic is returned.
# If no panics are found it exits with code 0
with open(sys.argv[1]) as file:
output = ""
lastline = ""
for line in file:
if output == "" and not re.search("^goroutine\s+\d+\s+\[running]:", line):
# Output empty and no regex match so nothing found yet.
lastline = line
continue

if lastline != "":
# Got a regex match on this line, start the output with the last line and set it empty.
output = lastline + line
lastline = ""
continue

if re.search("(INFO|DEBUG|TRACE|WARNING|ERROR)", line):
# Print the stack trace and exit when we encounter the next standard log message
sys.stdout.write(output)
exit(1)
else:
# While we don't have standard log messages, append the output (the stacktrace).
output += line

exit(0)


10 changes: 10 additions & 0 deletions test/includes/lxd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ wipe() {
rm -Rf "${1}"
}

panic_checker() {
local test_dir daemon_dir
test_dir="${1}"

sleep 1
while read -r daemon_dir; do
deps/panic-checker "${daemon_dir}/lxd.log"
done < "${test_dir}/daemons"
}

# Kill and cleanup LXD instances and related resources
cleanup_lxds() {
local test_dir daemon_dir
Expand Down
4 changes: 4 additions & 0 deletions test/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ run_test() {
TEST_CURRENT=${1}
TEST_CURRENT_DESCRIPTION=${2:-${1}}
TEST_UNMET_REQUIREMENT=""
cwd="$(pwd)"

echo "==> TEST BEGIN: ${TEST_CURRENT_DESCRIPTION}"
START_TIME=$(date +%s)
Expand Down Expand Up @@ -211,6 +212,9 @@ run_test() {
fi

END_TIME=$(date +%s)
cd "${cwd}"

panic_checker "${TEST_DIR}"

echo "==> TEST DONE: ${TEST_CURRENT_DESCRIPTION} ($((END_TIME-START_TIME))s)"
}
Expand Down

0 comments on commit 4b56433

Please sign in to comment.