Skip to content

Commit

Permalink
Make e2e tests more reliable
Browse files Browse the repository at this point in the history
`kubectl run --attach` proved to be rather unreliable. It often was not
able to attach to the newly created pod. There were various different
error messages.

By running the pod, waiting and then printing the logs, it improved the
reliability by a lot. Where it previously failed ever so often, I was
not able to have it fail once with the new function so far.

Signed-off-by: Simon Beck <simon.beck@vshn.ch>
  • Loading branch information
Kidswiss committed Mar 19, 2024
1 parent cd6ceb5 commit 60feb80
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions e2e/lib/k8up.bash
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ clear_pv_data() {
mkdir -p ./debug/data/pvc-subject
}

# We're not using `kubectl run --attach` here, to get the output of the pod.
# It's very unreliable unfortunately. So running the pod, waiting and getting the
# log output is a lot less prone for race conditions.
restic() {
kubectl run "restic-$(timestamp)" \
--attach \
podname="restic-$(timestamp)"
kubectl run "$podname" \
--restart Never \
--namespace "${DETIK_CLIENT_NAMESPACE-"k8up-system"}" \
--image "${E2E_IMAGE}" \
Expand All @@ -68,7 +71,9 @@ restic() {
--no-cache \
--repo "s3:http://minio.minio.svc.cluster.local:9000/backup" \
"${@}" \
--json
--json > /dev/null
kubectl wait --for jsonpath='{.status.phase}'=Succeeded pod "$podname" -n "${DETIK_CLIENT_NAMESPACE-"k8up-system"}" --timeout=2m > /dev/null
kubectl -n "${DETIK_CLIENT_NAMESPACE-"k8up-system"}" logs "$podname"
}

replace_in_file() {
Expand Down

0 comments on commit 60feb80

Please sign in to comment.