Split kind tests into component-owned probes
This commit is contained in:
parent
b3c0f6d58a
commit
691ad92e30
1 changed files with 4269 additions and 3108 deletions
100
tests/kind/fixture/core.sh
Normal file
100
tests/kind/fixture/core.sh
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
||||
TESTBED="$ROOT/tests/kind"
|
||||
RUNTIME="$TESTBED/.runtime"
|
||||
BIN="$RUNTIME/bin"
|
||||
KUBECONFIG_PATH="$RUNTIME/kubeconfig"
|
||||
FIXTURE_LOCK_DIR="${XDG_RUNTIME_DIR:-/tmp/nuthatch-$(id -u)}"
|
||||
FIXTURE_LOCK_PATH="$FIXTURE_LOCK_DIR/nuthatch-testbed-kind.lock"
|
||||
CONTEXT=kind-nuthatch-testbed
|
||||
CLUSTER=nuthatch-testbed
|
||||
NERDCTL_NAMESPACE=nuthatch-testbed
|
||||
FIXTURE_NAMESPACE=nuthatch-testbed
|
||||
FIXTURE_MODULES="$TESTBED/fixture"
|
||||
|
||||
set -a
|
||||
source "$TESTBED/versions.env"
|
||||
set +a
|
||||
|
||||
user_kubeconfig_digest() {
|
||||
local config_value="${KUBECONFIG:-${HOME:?}/.kube/config}"
|
||||
local path
|
||||
local paths
|
||||
IFS=: read -r -a paths <<< "$config_value"
|
||||
{
|
||||
for path in "${paths[@]}"; do
|
||||
if [[ -f "$path" ]]; then
|
||||
sha256sum "$path"
|
||||
else
|
||||
printf 'missing %s\n' "$path"
|
||||
fi
|
||||
done
|
||||
} | sha256sum | cut -d' ' -f1
|
||||
}
|
||||
|
||||
acquire_fixture_lock() {
|
||||
mkdir -p "$RUNTIME" "$FIXTURE_LOCK_DIR"
|
||||
exec 9>"$FIXTURE_LOCK_PATH"
|
||||
if ! flock --nonblock 9; then
|
||||
printf 'kind test fixture is already in use\n' >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
kube() {
|
||||
"$BIN/kubectl" \
|
||||
--kubeconfig "$KUBECONFIG_PATH" \
|
||||
--context "$CONTEXT" \
|
||||
"$@"
|
||||
}
|
||||
|
||||
wait_for_job() {
|
||||
local job="$1"
|
||||
local deadline=$((SECONDS + 300))
|
||||
local complete
|
||||
local failed
|
||||
while ((SECONDS < deadline)); do
|
||||
complete="$(kube --namespace "$FIXTURE_NAMESPACE" get "job/$job" --output jsonpath='{.status.conditions[?(@.type=="Complete")].status}')"
|
||||
if [[ "$complete" = True ]]; then
|
||||
kube --namespace "$FIXTURE_NAMESPACE" logs "job/$job" --all-containers
|
||||
return
|
||||
fi
|
||||
failed="$(kube --namespace "$FIXTURE_NAMESPACE" get "job/$job" --output jsonpath='{.status.conditions[?(@.type=="Failed")].status}')"
|
||||
if [[ "$failed" = True ]]; then
|
||||
kube --namespace "$FIXTURE_NAMESPACE" logs "job/$job" --all-containers >&2 || true
|
||||
return 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
printf 'job/%s did not complete within 300 seconds\n' "$job" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
source "$FIXTURE_MODULES/runtime.sh"
|
||||
source "$FIXTURE_MODULES/matrix.sh"
|
||||
source "$FIXTURE_MODULES/durable.sh"
|
||||
source "$FIXTURE_MODULES/coordination.sh"
|
||||
source "$FIXTURE_MODULES/target.sh"
|
||||
source "$FIXTURE_MODULES/oidc.sh"
|
||||
source "$FIXTURE_MODULES/dependencies.sh"
|
||||
source "$FIXTURE_MODULES/profile.sh"
|
||||
source "$FIXTURE_MODULES/lifecycle.sh"
|
||||
|
||||
destroy_fixture() {
|
||||
local status=0
|
||||
configure_provider || return
|
||||
delete_cluster || status=1
|
||||
remove_runtime_namespace || status=1
|
||||
rm -rf "$RUNTIME/image-archives" || status=1
|
||||
rm -f \
|
||||
"$KUBECONFIG_PATH" \
|
||||
"$RUNTIME/dependencies.yaml" \
|
||||
"$RUNTIME/probe.yaml" \
|
||||
"$RUNTIME/fixture.env" \
|
||||
"$RUNTIME"/nuthatch-fixture-lane-*.env \
|
||||
"$RUNTIME"/nuthatch-fixture-lane-*.env.oidc-secret \
|
||||
"$RUNTIME"/*-app-*.yaml || status=1
|
||||
return "$status"
|
||||
}
|
||||
Loading…
Reference in a new issue