-
Notifications
You must be signed in to change notification settings - Fork 332
Improve helm test output; and provide the means (even if disabled due to flaky tests) for parallel helm test executions. #3040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c612255
f7aef32
f76f399
7ba7c31
e29eceb
3a72191
60af457
d20aff9
bbe80de
c6e5bb9
b58116d
a7d2380
22e3357
0c68d55
174de1b
282d6e5
1f2db54
6b924d1
fd033c8
134ea29
5782691
f07bb60
3446c7b
5bd9c0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add config to allow to run helm tests for different services in parallel; improve integration test output logs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| USAGE=" | ||
| Filter out garbage from logs (but keep colors and highlight problems). | ||
|
|
||
| (Adapted from logfilter.sh by Stefan Matting) | ||
|
|
||
| To use it pipe log output from integration-test.sh into this tool. | ||
|
|
||
| Usage: logs | $0 [options] | ||
| " | ||
|
|
||
| red_color="\x1b\[;1m\x1b\[31m" | ||
| problem_markers="Failures:|FAILED|ExitFailure""\ | ||
| |\^+""\ | ||
| |FAIL""\ | ||
| |tests failed""\ | ||
| |Test suite failure""\ | ||
| |""$red_color""error:""\ | ||
| |""$red_color""\ | ||
| |Test suite .+ failed" | ||
|
|
||
| exit_usage() { | ||
| echo "$USAGE" | ||
| exit 1 | ||
| } | ||
|
|
||
| # remove debug/info logs | ||
| # often this is just noise like connection to cassandra. | ||
| excludeLogEntries() { | ||
| grep -v '^{".*Info"' | | ||
| grep -v '^{".*Debug"' | | ||
| grep -v '^20.*, D, .*socket: [0-9]\+>$' | ||
| } | ||
|
|
||
| cleanup() { | ||
| # replace backspaces with newlines | ||
| # remove "Progress" lines | ||
| # Remove blank lines | ||
| # add newline between interleaved test name and log output lines | ||
| sed 's/\x08\+/\n/g' | | ||
| sed '/^Progress [0-9]\+/d' | | ||
| sed '/^\s\+$/d' | | ||
| sed 's/:\s\+{/:\n{/g' | ||
| } | ||
|
|
||
| grepper() { | ||
| # print 10 lines before/after for context | ||
| rg "$problem_markers" --color=always -A 10 -B 10 | ||
|
||
| echo -e "\033[0m" | ||
| } | ||
|
|
||
| cleanup | excludeLogEntries | grepper | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,93 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| NAMESPACE=${NAMESPACE:-test-integration} | ||
| # set to 1 to disable running helm tests in parallel | ||
| HELM_PARALLELISM=${HELM_PARALLELISM:-1} | ||
| CLEANUP_LOCAL_FILES=${CLEANUP_LOCAL_FILES:-1} # set to 0 to keep files | ||
|
|
||
| echo "Running integration tests on wire-server" | ||
| echo "Running integration tests on wire-server with parallelism=${HELM_PARALLELISM} ..." | ||
|
|
||
| CHART=wire-server | ||
| helm test --logs -n "${NAMESPACE}" "${NAMESPACE}-${CHART}" --timeout 900s | ||
| tests=(galley cargohold gundeck federator spar brig) | ||
|
|
||
| cleanup() { | ||
| if (( CLEANUP_LOCAL_FILES > 0 )); then | ||
| for t in "${tests[@]}"; do | ||
| rm -f "stat-$t" | ||
| rm -f "logs-$t" | ||
| done | ||
| fi | ||
| } | ||
|
|
||
| summary() { | ||
| echo "===============" | ||
| echo "=== summary ===" | ||
| echo "===============" | ||
| printf '%s\n' "${tests[@]}" | parallel echo "=== tail {}: ===" ';' tail -2 logs-{} | ||
|
|
||
| for t in "${tests[@]}"; do | ||
| x=$(cat "stat-$t") | ||
| if ((x > 0)); then | ||
| echo "$t-integration FAILED ❌. pfff..." | ||
| else | ||
| echo "$t-integration passed ✅." | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # Run tests in parallel using GNU parallel (see https://www.gnu.org/software/parallel/) | ||
| # The below commands are a little convoluted, but we wish to: | ||
| # - run integration tests. If they fail, keep track of this, but still go and get logs, so we see what failed | ||
| # - run all tests. Perhaps multiple flaky tests in multiple services exist, if so, we wish to see all problems | ||
| mkdir -p ~/.parallel && touch ~/.parallel/will-cite | ||
|
||
| printf '%s\n' "${tests[@]}" | parallel echo "Running helm tests for {}..." | ||
| printf '%s\n' "${tests[@]}" | parallel -P "${HELM_PARALLELISM}" \ | ||
| helm test -n "${NAMESPACE}" "${NAMESPACE}-${CHART}" --timeout 900s --filter name="${NAMESPACE}-${CHART}-{}-integration" '> logs-{};' \ | ||
jschaul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| echo '$? > stat-{};' \ | ||
| echo "==== Done testing {}. ====" '};' \ | ||
| kubectl -n "${NAMESPACE}" logs "${NAMESPACE}-${CHART}-{}-integration" '>> logs-{};' | ||
|
|
||
| summary | ||
|
|
||
| # in case any integration test suite failed, exit this script with an error. | ||
| exit_code=0 | ||
| for t in "${tests[@]}"; do | ||
| x=$(cat "stat-$t") | ||
| if ((x > 0)); then | ||
| exit_code=1 | ||
| fi | ||
| done | ||
|
|
||
| if ((exit_code > 0)); then | ||
| echo "=======================" | ||
| echo "=== failed job logs ===" | ||
| echo "=======================" | ||
| # in case a integration test suite failed, print relevant logs | ||
| for t in "${tests[@]}"; do | ||
| x=$(cat "stat-$t") | ||
| if ((x > 0)); then | ||
| echo "=== logs for failed $t-integration ===" | ||
| cat "logs-$t" | ||
| fi | ||
| done | ||
| summary | ||
| for t in "${tests[@]}"; do | ||
| x=$(cat "stat-$t") | ||
| if ((x > 0)); then | ||
| echo "=== (relevant) logs for failed $t-integration ===" | ||
| "$DIR/integration-logs-relevant-bits.sh" < "logs-$t" | ||
| fi | ||
| done | ||
| summary | ||
| fi | ||
|
|
||
| cleanup | ||
|
|
||
| if ((exit_code > 0)); then | ||
| echo "Tests failed." | ||
| exit 1 | ||
| else | ||
| echo "All integration tests passed ✅." | ||
| fi | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to attribute to me here ;)