2026-07-17 18:30:34 +09:00
#!/usr/bin/env bash
set -euo pipefail
ROOT = " $( cd " $( dirname " $0 " ) /../.. " && pwd ) "
source " $ROOT /tests/kind/lib.sh "
2026-07-18 00:54:47 +09:00
assert_matrix( ) {
local expected = " $1 "
shift
local actual
actual = " $( expand_fixture_matrix " $@ " ) "
if [ [ " $actual " != " $expected " ] ] ; then
printf 'unexpected matrix for %s\nexpected:\n%s\nactual:\n%s\n' \
" $* " " $expected " " $actual " >& 2
return 1
fi
}
assert_matrix $'001\t-\t-\t-' durable
assert_matrix $'001\tredis\t-\t-\n002\tdragonfly\t-\t-' coordination
assert_matrix $'001\t-\tkeycloak\tgarage\n002\t-\tkeycloak\tversitygw\n003\t-\tzitadel\tgarage\n004\t-\tzitadel\tversitygw' oidc target
assert_matrix $'001\tredis\tkeycloak\tgarage\n002\tredis\tkeycloak\tversitygw\n003\tredis\tzitadel\tgarage\n004\tredis\tzitadel\tversitygw\n005\tdragonfly\tkeycloak\tgarage\n006\tdragonfly\tkeycloak\tversitygw\n007\tdragonfly\tzitadel\tgarage\n008\tdragonfly\tzitadel\tversitygw' all
if expand_fixture_matrix redis >/dev/null 2>& 1; then
printf 'individual provider selector was accepted\n' >& 2
exit 1
fi
select_fixture_families target durable target
if [ [ " ${ FIXTURE_FAMILIES [*] } " != "durable target" ] ] ; then
printf 'families were not normalized: %s\n' " ${ FIXTURE_FAMILIES [*] } " >& 2
exit 1
fi
2026-07-17 18:30:34 +09:00
if kube get namespaces >/dev/null 2>& 1; then
printf 'kube helper unexpectedly reached a cluster without fixture setup\n' >& 2
exit 1
fi
2026-07-18 00:54:47 +09:00
kube( ) {
return 1
}
select_fixture_families durable
if write_lane_profile 001 - - - >/dev/null 2>& 1; then
printf 'lane provisioning failure was ignored\n' >& 2
exit 1
fi
select_fixture_families base
if write_lane_profile 001 - - - >/dev/null 2>& 1; then
printf 'ConfigMap provisioning failure was ignored\n' >& 2
exit 1
fi
source " $ROOT /tests/kind/lib.sh "
kube_calls = 0
kube( ) {
kube_calls = $(( kube_calls + 1 ))
case " $kube_calls " in
1) return 1 ; ;
2) return 0 ; ;
3) return 1 ; ;
*) return 0 ; ;
esac
}
if reset_lane_target_store garage nuthatch-lane-001 >/dev/null 2>& 1; then
printf 'target-store emptying failure was ignored\n' >& 2
exit 1
fi
source " $ROOT /tests/kind/lib.sh "
write_lane_profile( ) {
printf 'nuthatch-fixture-lane-001\n'
}
render_lane_job( ) {
return 0
}
run_job_manifest( ) {
return 42
}
cleanup_called = false
cleanup_lane_resources( ) {
cleanup_called = true
}
cleanup_lane_state( ) {
cleanup_called = true
}
if run_job_matrix fixture-consumer /dev/null nuthatch-test:local durable; then
printf 'Job failure was ignored\n' >& 2
exit 1
fi
if [ [ " $cleanup_called " = true ] ] ; then
printf 'failed lane was not retained for inspection\n' >& 2
exit 1
fi
source " $ROOT /tests/kind/lib.sh "
kube( ) {
return 1
}
if run_job_manifest fixture-consumer /dev/null >/dev/null 2>& 1; then
printf 'Job cleanup failure was ignored\n' >& 2
exit 1
fi
if cleanup_lane_resources fixture-consumer nuthatch-fixture-lane-001 >/dev/null 2>& 1; then
printf 'lane resource cleanup failure was ignored\n' >& 2
exit 1
fi
source " $ROOT /tests/kind/lib.sh "
select_fixture_families all
cleanup_calls = ( )
cleanup_lane_durable_store( ) {
cleanup_calls += ( durable)
return 1
}
cleanup_lane_coordination_store( ) {
cleanup_calls += ( coordination)
}
cleanup_lane_target_store( ) {
cleanup_calls += ( target)
}
if cleanup_lane_state 001 redis keycloak garage >/dev/null 2>& 1; then
printf 'partial lane cleanup failure was ignored\n' >& 2
exit 1
fi
if [ [ " ${ cleanup_calls [*] } " != "durable coordination target" ] ] ; then
printf 'lane cleanup stopped early: %s\n' " ${ cleanup_calls [*] } " >& 2
exit 1
fi
if ! declare -F load_local_image >/dev/null; then
printf 'local application image loading is unavailable\n' >& 2
exit 1
fi
source " $ROOT /tests/kind/lib.sh "
configure_provider( ) {
return 0
}
delete_cluster( ) {
return 1
}
runtime_cleanup_called = false
remove_runtime_namespace( ) {
runtime_cleanup_called = true
}
if destroy_fixture >/dev/null 2>& 1; then
printf 'fixture teardown failure was ignored\n' >& 2
exit 1
fi
if [ [ " $runtime_cleanup_called " != true ] ] ; then
printf 'fixture teardown stopped before runtime cleanup\n' >& 2
exit 1
fi
2026-07-17 18:30:34 +09:00
FIXTURE_LOCK_DIR = " $RUNTIME /lock-test "
FIXTURE_LOCK_PATH = " $FIXTURE_LOCK_DIR /nuthatch-testbed-kind.lock "
acquire_fixture_lock
if XDG_RUNTIME_DIR = " $FIXTURE_LOCK_DIR " bash -c \
'source "$1"; acquire_fixture_lock' _ " $ROOT /tests/kind/lib.sh " 9>& -; then
printf 'singleton fixture lock admitted a second worktree process\n' >& 2
exit 1
fi
exec 9>& -
2026-07-18 00:54:47 +09:00
printf 'fixture family matrix tests passed\n'