From 59be5aee7dcecf547e49df3861f9f98adcddb46f Mon Sep 17 00:00:00 2001 From: Carl Niklas Rydberg Date: Sun, 8 Feb 2026 00:06:46 +0100 Subject: [PATCH] Add index backend startup regression coverage and update test script paths (cherry picked from commit 81c1115db54ee7d2d4c20fc0c88e4f614f74b999) --- CMakeLists.txt | 5 ++ scripts/test_fed_ingest.sh | 25 ++++++- scripts/test_fed_smoke.sh | 25 ++++++- scripts/test_graph_contract.sh | 5 +- scripts/test_graph_queries.sh | 5 +- scripts/test_index_two_nodes.sh | 112 ++++++++++++++++++++++++++++++++ vendor/amduat | 2 +- 7 files changed, 172 insertions(+), 7 deletions(-) create mode 100755 scripts/test_index_two_nodes.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index ea8b9e8..2ad3c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/scripts/test_fed_ingest.sh b/scripts/test_fed_ingest.sh index f2f7fa7..ce8eaef 100644 --- a/scripts/test_fed_ingest.sh +++ b/scripts/test_fed_ingest.sh @@ -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 diff --git a/scripts/test_fed_smoke.sh b/scripts/test_fed_smoke.sh index 5fd251b..e5d1a84 100644 --- a/scripts/test_fed_smoke.sh +++ b/scripts/test_fed_smoke.sh @@ -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 diff --git a/scripts/test_graph_contract.sh b/scripts/test_graph_contract.sh index c881a67..2eed777 100755 --- a/scripts/test_graph_contract.sh +++ b/scripts/test_graph_contract.sh @@ -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}/vendor/amduat/build/amduat-asl" +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 diff --git a/scripts/test_graph_queries.sh b/scripts/test_graph_queries.sh index 13d56c8..dda0cdd 100755 --- a/scripts/test_graph_queries.sh +++ b/scripts/test_graph_queries.sh @@ -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}/vendor/amduat/build/amduat-asl" +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 diff --git a/scripts/test_index_two_nodes.sh b/scripts/test_index_two_nodes.sh new file mode 100755 index 0000000..6379849 --- /dev/null +++ b/scripts/test_index_two_nodes.sh @@ -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" diff --git a/vendor/amduat b/vendor/amduat index 9a29030..c7a9e2f 160000 --- a/vendor/amduat +++ b/vendor/amduat @@ -1 +1 @@ -Subproject commit 9a2903072bd10b2bc09dd082681cc7c026bf9350 +Subproject commit c7a9e2f6aa30dc67731412fc27966a168e2367db