Add index backend startup regression coverage and update test script paths

This commit is contained in:
Carl Niklas Rydberg 2026-02-08 00:06:46 +01:00
parent cb91cc1569
commit 81c1115db5
7 changed files with 172 additions and 7 deletions

View file

@ -347,6 +347,11 @@ add_test(NAME amduatd_graph_index_append_stress
)
set_tests_properties(amduatd_graph_index_append_stress PROPERTIES SKIP_RETURN_CODE 77)
add_test(NAME amduatd_index_two_nodes
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/scripts/test_index_two_nodes.sh
)
set_tests_properties(amduatd_index_two_nodes PROPERTIES SKIP_RETURN_CODE 77)
add_executable(amduatd_test_space_doctor
tests/test_amduatd_space_doctor.c
src/amduatd_space_doctor.c

View file

@ -29,8 +29,29 @@ if [[ "${USE_HTTP_HELPER}" -eq 1 && ! -x "${HTTP_HELPER}" ]]; then
exit 77
fi
AMDUATD_BIN="${ROOT_DIR}/build/amduatd"
ASL_BIN="${ROOT_DIR}/vendor/amduat/build/amduat-asl"
AMDUATD_BIN="${AMDUATD_BIN:-}"
if [[ -z "${AMDUATD_BIN}" ]]; then
for cand in \
"${ROOT_DIR}/build/amduatd" \
"${ROOT_DIR}/build-asan/amduatd"; do
if [[ -x "${cand}" ]]; then
AMDUATD_BIN="${cand}"
break
fi
done
fi
ASL_BIN="${ASL_BIN:-}"
if [[ -z "${ASL_BIN}" ]]; then
for cand in \
"${ROOT_DIR}/build/vendor/amduat/amduat-asl" \
"${ROOT_DIR}/vendor/amduat/build/amduat-asl"; do
if [[ -x "${cand}" ]]; then
ASL_BIN="${cand}"
break
fi
done
fi
if [[ ! -x "${AMDUATD_BIN}" || ! -x "${ASL_BIN}" ]]; then
echo "missing binaries; build amduatd and amduat-asl first" >&2

View file

@ -29,8 +29,29 @@ if [[ "${USE_HTTP_HELPER}" -eq 1 && ! -x "${HTTP_HELPER}" ]]; then
exit 77
fi
AMDUATD_BIN="${ROOT_DIR}/build/amduatd"
ASL_BIN="${ROOT_DIR}/vendor/amduat/build/amduat-asl"
AMDUATD_BIN="${AMDUATD_BIN:-}"
if [[ -z "${AMDUATD_BIN}" ]]; then
for cand in \
"${ROOT_DIR}/build/amduatd" \
"${ROOT_DIR}/build-asan/amduatd"; do
if [[ -x "${cand}" ]]; then
AMDUATD_BIN="${cand}"
break
fi
done
fi
ASL_BIN="${ASL_BIN:-}"
if [[ -z "${ASL_BIN}" ]]; then
for cand in \
"${ROOT_DIR}/build/vendor/amduat/amduat-asl" \
"${ROOT_DIR}/vendor/amduat/build/amduat-asl"; do
if [[ -x "${cand}" ]]; then
ASL_BIN="${cand}"
break
fi
done
fi
if [[ ! -x "${AMDUATD_BIN}" || ! -x "${ASL_BIN}" ]]; then
echo "missing binaries; build amduatd and amduat-asl first" >&2

View file

@ -19,7 +19,10 @@ source "${ROOT_DIR}/scripts/graph_client_helpers.sh"
graph_helpers_init "${ROOT_DIR}"
AMDUATD_BIN="${ROOT_DIR}/build/amduatd"
ASL_BIN="${ROOT_DIR}/build/vendor/amduat/amduat-asl"
if [[ ! -x "${ASL_BIN}" ]]; then
ASL_BIN="${ROOT_DIR}/vendor/amduat/build/amduat-asl"
fi
if [[ ! -x "${AMDUATD_BIN}" || ! -x "${ASL_BIN}" ]]; then
echo "missing binaries; build amduatd and amduat-asl first" >&2
exit 1

View file

@ -30,7 +30,10 @@ if [[ "${USE_HTTP_HELPER}" -eq 1 && ! -x "${HTTP_HELPER}" ]]; then
fi
AMDUATD_BIN="${ROOT_DIR}/build/amduatd"
ASL_BIN="${ROOT_DIR}/build/vendor/amduat/amduat-asl"
if [[ ! -x "${ASL_BIN}" ]]; then
ASL_BIN="${ROOT_DIR}/vendor/amduat/build/amduat-asl"
fi
if [[ ! -x "${AMDUATD_BIN}" || ! -x "${ASL_BIN}" ]]; then
echo "missing binaries; build amduatd and amduat-asl first" >&2

112
scripts/test_index_two_nodes.sh Executable file
View file

@ -0,0 +1,112 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TMPDIR="${TMPDIR:-/tmp}"
mkdir -p "${TMPDIR}"
AMDUATD_BIN="${ROOT_DIR}/build/amduatd"
ASL_BIN="${ROOT_DIR}/build/vendor/amduat/amduat-asl"
HTTP_HELPER="${ROOT_DIR}/build/amduatd_http_unix"
USE_HTTP_HELPER=0
if [[ ! -x "${AMDUATD_BIN}" || ! -x "${ASL_BIN}" ]]; then
echo "missing binaries; build amduatd and amduat-asl first" >&2
exit 1
fi
if command -v curl >/dev/null 2>&1 && curl --help 2>/dev/null | grep -q -- '--unix-socket'; then
USE_HTTP_HELPER=0
else
USE_HTTP_HELPER=1
fi
if [[ "${USE_HTTP_HELPER}" -eq 1 && ! -x "${HTTP_HELPER}" ]]; then
echo "skip: curl lacks --unix-socket and helper missing" >&2
exit 77
fi
tmp_root="$(mktemp -d -p "${TMPDIR}" amduatd-index-two-nodes-XXXXXX)"
root="${tmp_root}/root"
sock="${tmp_root}/amduatd.sock"
space_id="app1"
log_file="${tmp_root}/amduatd.log"
cleanup() {
if [[ -n "${pid:-}" ]]; then
kill "${pid}" >/dev/null 2>&1 || true
wait "${pid}" >/dev/null 2>&1 || true
fi
rm -rf "${tmp_root}"
}
trap cleanup EXIT
wait_ready() {
local i
for i in $(seq 1 100); do
if ! kill -0 "${pid}" >/dev/null 2>&1; then
[[ -f "${log_file}" ]] && cat "${log_file}" >&2
return 1
fi
if [[ ! -S "${sock}" ]]; then
sleep 0.1
continue
fi
if [[ "${USE_HTTP_HELPER}" -eq 1 ]]; then
if "${HTTP_HELPER}" --sock "${sock}" --method GET --path "/v2/readyz" >/dev/null 2>&1; then
return 0
fi
elif curl --silent --show-error --fail --unix-socket "${sock}" \
"http://localhost/v2/readyz" >/dev/null 2>&1; then
return 0
fi
sleep 0.1
done
return 1
}
post_node() {
local name="$1"
local payload="{\"name\":\"${name}\"}"
if [[ "${USE_HTTP_HELPER}" -eq 1 ]]; then
"${HTTP_HELPER}" --sock "${sock}" --method POST --path "/v2/graph/nodes" \
--header "Content-Type: application/json" \
--header "X-Amduat-Space: ${space_id}" \
--data "${payload}"
else
curl --silent --show-error --fail \
--unix-socket "${sock}" \
-H "Content-Type: application/json" \
-H "X-Amduat-Space: ${space_id}" \
-X POST --data-binary "${payload}" \
"http://localhost/v2/graph/nodes"
fi
}
mkdir -p "${root}"
"${ASL_BIN}" index init --root "${root}" --force >/dev/null
"${AMDUATD_BIN}" --root "${root}" --sock "${sock}" --store-backend index --space "${space_id}" \
>"${log_file}" 2>&1 &
pid=$!
if ! wait_ready; then
echo "daemon not ready" >&2
exit 1
fi
resp1="$(post_node doca1)"
resp2="$(post_node topica1)"
echo "${resp1}" | grep -q '"name":"doca1"' || {
echo "first node write failed: ${resp1}" >&2
[[ -f "${log_file}" ]] && cat "${log_file}" >&2
exit 1
}
echo "${resp2}" | grep -q '"name":"topica1"' || {
echo "second node write failed: ${resp2}" >&2
[[ -f "${log_file}" ]] && cat "${log_file}" >&2
exit 1
}
echo "ok: two consecutive index-backed node writes succeeded"

2
vendor/amduat vendored

@ -1 +1 @@
Subproject commit 9a2903072bd10b2bc09dd082681cc7c026bf9350
Subproject commit c7a9e2f6aa30dc67731412fc27966a168e2367db