k3s/scripts/sonobuoy-e2e-tests

84 lines
1.7 KiB
Plaintext
Raw Normal View History

2019-04-29 20:54:51 +00:00
#!/bin/bash
set -e -x
cd $(dirname $0)/..
2019-05-02 19:04:45 +00:00
if [ -z "$K3S_IMAGE" ]; then
2019-11-12 23:36:04 +00:00
. ./scripts/version.sh
2019-05-02 19:04:45 +00:00
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-rancher}
IMAGE_NAME=${IMAGE_NAME:-k3s}
export K3S_IMAGE=${REPO}/${IMAGE_NAME}:${TAG}
fi
2019-04-29 20:54:51 +00:00
OUTPUT=$(pwd)/dist/artifacts
mkdir -p ${OUTPUT}
pids=()
output=()
2019-10-25 05:30:40 +00:00
show-logs() {
for pid in "${pids[@]}"; do
logdir=$(pwd)/logs/${pid}
if [ ! -d $logdir ]; then
continue
fi
echo
echo "#- Begin: logs for sonobuoy run pid ${pid}"
2019-11-11 22:18:16 +00:00
for log in $(pwd)/logs/${pid}/*.log; do
2019-10-25 05:30:40 +00:00
if [ -f ${log} ]; then
echo
2019-11-11 22:18:16 +00:00
echo "#- Tail: ${log}"
tail -10 ${log}
echo "#- Done: ${log}"
2019-10-25 05:30:40 +00:00
echo
fi
done
echo "#- Finish: logs for sonobuoy run pid ${pid}"
echo
done
}
2019-10-14 21:27:39 +00:00
cleanup() {
exit_status=$?
set +e
trap - EXIT INT
kill ${pids[@]} 2>/dev/null
wait
set +x
echo -n "Tests "
if [ "${exit_status}" -eq "0" ]; then
echo "passed"
else
echo "failed"
2019-10-25 05:30:40 +00:00
show-logs
2019-10-14 21:27:39 +00:00
fi
exit ${exit_status}
}
trap cleanup EXIT INT
2019-11-11 22:18:16 +00:00
# ---
2019-04-29 20:54:51 +00:00
run-sonobuoy() {
output+=(${log_output})
2019-11-11 22:18:16 +00:00
E2E_LOG_OUTPUT=${log_output} \
./scripts/sonobuoy ${@} \
> >(stdbuf -oL sed "s/^/[${label}] /") 2>&1 &
2019-04-29 20:54:51 +00:00
pids+=($!)
}
2019-11-11 22:18:16 +00:00
log_output=${OUTPUT}/e2e-STATUS-${ARCH}-parallel.log label=PARALLEL \
2019-04-29 20:54:51 +00:00
run-sonobuoy --e2e-focus='\[Conformance\]' --e2e-skip='\[Serial\]' --e2e-parallel=y
2019-07-04 15:07:26 +00:00
sleep 60
2019-11-11 22:18:16 +00:00
log_output=${OUTPUT}/e2e-STATUS-${ARCH}-serial.log label=SERIAL \
2019-07-04 15:07:26 +00:00
run-sonobuoy --e2e-focus='\[Serial\].*\[Conformance\]'
2019-10-14 21:27:39 +00:00
exit_code=0
2019-07-01 15:29:57 +00:00
for pid in "${pids[@]}"; do
2019-10-14 21:27:39 +00:00
wait $pid || exit_code=$?
2019-07-01 15:29:57 +00:00
done
2019-10-14 21:27:39 +00:00
exit ${exit_code}