Skip to content

Commit 0022d68

Browse files
committed
Print logs after failed installs
Because `ct install` calls `helm test` without `--logs`, always pass `--skip-clean-up`, and get the logs and cleanup manually after a failure.
1 parent 4f75b60 commit 0022d68

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

test.sh

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function join_by {
1818
# default to randomly generated namespace, same as chart-testing would do, but we need to load secrets into the same namespace
1919
NAMESPACE=trino-$(LC_ALL=C tr -dc 'a-z0-9' </dev/urandom | head -c 6 || true)
2020
HELM_EXTRA_SET_ARGS=
21-
CT_ARGS=(--charts=charts/trino)
21+
CT_ARGS=(--charts=charts/trino --skip-clean-up)
2222
CLEANUP_NAMESPACE=true
2323
TEST_NAMES=("${!testCases[@]}")
2424

@@ -47,7 +47,6 @@ while getopts ":a:n:t:sh:" OPTKEY; do
4747
IFS=, read -ra TEST_NAMES <<<"$OPTARG"
4848
;;
4949
s)
50-
CT_ARGS+=(--skip-clean-up)
5150
CLEANUP_NAMESPACE=false
5251
;;
5352
h)
@@ -65,7 +64,7 @@ shift $((OPTIND - 1))
6564
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
6665
cd "${SCRIPT_DIR}" || exit 2
6766

68-
echo "Generating a self-signed TLS certificate"
67+
echo 1>&2 "Generating a self-signed TLS certificate"
6968
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
7069
-subj "/O=Trino Software Foundation" \
7170
-addext "subjectAltName=DNS:localhost,DNS:*.$NAMESPACE,DNS:*.$NAMESPACE.svc,DNS:*.$NAMESPACE.svc.cluster.local,IP:127.0.0.1" \
@@ -76,14 +75,29 @@ kubectl -n "$NAMESPACE" create secret tls certificates --cert=cert.crt --key=cer
7675

7776
CT_ARGS+=(--namespace "$NAMESPACE")
7877

78+
result=0
7979
for test_name in "${TEST_NAMES[@]}"; do
80-
echo ""
81-
echo "🧪 Running test $test_name"
82-
echo ""
83-
time ct install "${CT_ARGS[@]}" --helm-extra-set-args "$HELM_EXTRA_SET_ARGS ${testCases[$test_name]}"
84-
echo "Test $test_name completed"
80+
echo 1>&2 ""
81+
echo 1>&2 "🧪 Running test $test_name"
82+
echo 1>&2 ""
83+
if ! time ct install "${CT_ARGS[@]}" --helm-extra-set-args "$HELM_EXTRA_SET_ARGS ${testCases[$test_name]}"; then
84+
echo 1>&2 "❌ Test $test_name failed"
85+
echo 1>&2 "Test logs:"
86+
kubectl --namespace "$NAMESPACE" logs --tail=-1 --selector app.kubernetes.io/component=test
87+
result=1
88+
else
89+
echo 1>&2 "✅ Test $test_name completed"
90+
fi
91+
if [ "$CLEANUP_NAMESPACE" == "true" ]; then
92+
for release in $(helm --namespace "$NAMESPACE" ls --all --short); do
93+
echo 1>&2 "Cleaning up Helm release $release"
94+
helm --namespace "$NAMESPACE" delete "$release"
95+
done
96+
fi
8597
done
8698

8799
if [ "$CLEANUP_NAMESPACE" == "true" ]; then
88100
kubectl delete namespace "$NAMESPACE"
89101
fi
102+
103+
exit $result

0 commit comments

Comments
 (0)