Skip to content

Commit

Permalink
Print logs after failed installs
Browse files Browse the repository at this point in the history
Because `ct install` calls `helm test` without `--logs`, always pass
`--skip-clean-up`, and get the logs and cleanup manually after a
failure.
  • Loading branch information
nineinchnick committed May 30, 2024
1 parent 3932c8f commit c910a07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions charts/trino/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
test: connection
{{- if .Values.commonLabels }}
{{- tpl (toYaml .Values.commonLabels) . | nindent 4 }}
{{- end }}
Expand Down
10 changes: 7 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function join_by {
# default to randomly generated namespace, same as chart-testing would do, but we need to load secrets into the same namespace
NAMESPACE=trino-$(LC_ALL=C tr -dc 'a-z0-9' </dev/urandom | head -c 6 || true)
HELM_EXTRA_SET_ARGS=
CT_ARGS=(--charts=charts/trino)
CT_ARGS=(--charts=charts/trino --skip-clean-up)
CLEANUP_NAMESPACE=true
TEST_NAMES=("${!testCases[@]}")

Expand Down Expand Up @@ -47,7 +47,6 @@ while getopts ":a:n:t:sh:" OPTKEY; do
IFS=, read -ra TEST_NAMES <<<"$OPTARG"
;;
s)
CT_ARGS+=(--skip-clean-up)
CLEANUP_NAMESPACE=false
;;
h)
Expand Down Expand Up @@ -80,7 +79,12 @@ for test_name in "${TEST_NAMES[@]}"; do
echo ""
echo "🧪 Running test $test_name"
echo ""
time ct install "${CT_ARGS[@]}" --helm-extra-set-args "$HELM_EXTRA_SET_ARGS ${testCases[$test_name]}"
if ! time ct install "${CT_ARGS[@]}" --helm-extra-set-args "$HELM_EXTRA_SET_ARGS ${testCases[$test_name]}"; then
kubectl logs -l test=connection
fi
if [ "$CLEANUP_NAMESPACE" == "true" ]; then
helm ls --all --short | xargs -L1 --no-run-if-empty helm delete
fi
echo "Test $test_name completed"
done

Expand Down

0 comments on commit c910a07

Please sign in to comment.