e2e: schedule defers before creation
This ensures that the cleanup of clusters also happens when the
creation of one of the clusters fails, as otherwise manual removal
is required before the tests can be run again.
@@ -45,13 +45,13 @@ if ! kubectl version > /dev/null 2>&1; then
echo '>>> Creating Kind Kubernetes cluster(s)'
KIND_CONFIG_PREFIX="${HOME}/.kube/kind-config-${KIND_CLUSTER_PREFIX}"
- seq 1 "${E2E_KIND_CLUSTER_NUM}" | time parallel -- env KUBECONFIG="${KIND_CONFIG_PREFIX}-{}" kind create cluster --name "${KIND_CLUSTER_PREFIX}-{}" --wait 5m
for I in $(seq 1 "${E2E_KIND_CLUSTER_NUM}"); do
defer kind --name "${KIND_CLUSTER_PREFIX}-${I}" delete cluster > /dev/null 2>&1 || true
defer rm -rf "${KIND_CONFIG_PREFIX}-${I}"
# Wire tests with the right cluster based on their BATS_JOB_SLOT env variable
eval export "KUBECONFIG_SLOT_${I}=${KIND_CONFIG_PREFIX}-${I}"
done
+ seq 1 "${E2E_KIND_CLUSTER_NUM}" | time parallel -- env KUBECONFIG="${KIND_CONFIG_PREFIX}-{}" kind create cluster --name "${KIND_CLUSTER_PREFIX}-{}" --wait 5m
echo '>>> Loading images into the Kind cluster(s)'
seq 1 "${E2E_KIND_CLUSTER_NUM}" | time parallel -- kind --name "${KIND_CLUSTER_PREFIX}-{}" load docker-image 'docker.io/fluxcd/flux:latest'
