Add v2 end-to-end smoke test script
This commit is contained in:
parent
522720da6a
commit
c10e7e04e6
|
|
@ -58,6 +58,12 @@ Run integration coverage (requires running `amduatd` + `jq`):
|
|||
./tests/integration_v2.sh
|
||||
```
|
||||
|
||||
Run a fast end-to-end smoke (startup + ingest + sync + retrieve + tombstone):
|
||||
|
||||
```sh
|
||||
./scripts/smoke_v2.sh
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- This scaffold assumes local Unix-socket access to `amduatd`.
|
||||
|
|
|
|||
95
scripts/smoke_v2.sh
Executable file
95
scripts/smoke_v2.sh
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
# Use an isolated cursor file so smoke runs do not mutate normal sync state.
|
||||
export CURSOR_FILE="${ROOT_DIR}/.cursor.smoke.$$"
|
||||
# shellcheck source=/dev/null
|
||||
source "${ROOT_DIR}/src/app_v2.sh"
|
||||
|
||||
require_jq() {
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo "smoke_v2.sh: jq is required" >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo "smoke_v2.sh: FAIL: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
step() {
|
||||
echo "== $1 =="
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -f "${CURSOR_FILE}" >/dev/null 2>&1 || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
require_jq
|
||||
app_init
|
||||
|
||||
run_id="$(date +%s)"
|
||||
idempotency_key="smoke-seed-${run_id}"
|
||||
doc_name="smoke-doc-${run_id}"
|
||||
topic_name="smoke-topic-${run_id}"
|
||||
goal_pred="ms.within_domain"
|
||||
|
||||
step "startup"
|
||||
startup_out="$(app_startup_checks)" || fail "startup checks failed"
|
||||
printf '%s' "${startup_out}" | grep -q '"ok":true' || fail "readyz did not report ok=true"
|
||||
|
||||
step "ingest"
|
||||
payload="$(cat <<JSON
|
||||
{
|
||||
"idempotency_key":"${idempotency_key}",
|
||||
"mode":"continue_on_error",
|
||||
"nodes":[{"name":"${doc_name}"},{"name":"${topic_name}"}],
|
||||
"edges":[
|
||||
{
|
||||
"subject":"${doc_name}",
|
||||
"predicate":"${goal_pred}",
|
||||
"object":"${topic_name}",
|
||||
"provenance":{
|
||||
"source_uri":"urn:smoke:seed",
|
||||
"extractor":"smoke-v2",
|
||||
"observed_at":1,
|
||||
"ingested_at":2,
|
||||
"trace_id":"smoke-trace-${run_id}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
)"
|
||||
ingest_out="$(app_ingest_batch "${payload}")" || fail "batch ingest call failed"
|
||||
printf '%s' "${ingest_out}" | grep -q '"results"' || fail "batch ingest missing results"
|
||||
|
||||
step "sync"
|
||||
sync_out="$(app_sync_once)" || fail "sync-once failed"
|
||||
printf '%s' "${sync_out}" | grep -q '"events"' || fail "sync response missing events"
|
||||
[[ -s "${CURSOR_FILE}" ]] || fail "cursor file was not persisted"
|
||||
|
||||
step "retrieve"
|
||||
retrieve_out="$(app_retrieve_with_fallback "${doc_name}" "${goal_pred}")" || fail "retrieve call failed"
|
||||
printf '%s' "${retrieve_out}" | grep -q '"edges"' || fail "retrieve response missing edges"
|
||||
|
||||
amduat_api_call GET "/v2/graph/subgraph?roots[]=${doc_name}&max_depth=2&dir=outgoing&limit_nodes=200&limit_edges=400&max_result_bytes=1048576" || fail "subgraph call failed"
|
||||
subgraph_out="${AMDUAT_LAST_BODY}"
|
||||
edge_ref="$(printf '%s' "${subgraph_out}" | jq -r '.edges[0].edge_ref // empty')"
|
||||
[[ -n "${edge_ref}" ]] || fail "could not resolve edge_ref from subgraph"
|
||||
|
||||
step "tombstone"
|
||||
app_tombstone_edge "${edge_ref}" >/dev/null || fail "tombstone call failed"
|
||||
post_retrieve="$(app_retrieve_with_fallback "${doc_name}" "${goal_pred}")" || fail "post-tombstone retrieve failed"
|
||||
post_edges_count="$(printf '%s' "${post_retrieve}" | jq '.edges | length')"
|
||||
[[ "${post_edges_count}" == "0" ]] || fail "tombstoned edge still visible in default retrieval"
|
||||
|
||||
amduat_api_call GET "/v2/graph/subgraph?roots[]=${doc_name}&max_depth=2&dir=outgoing&limit_nodes=200&limit_edges=400&include_tombstoned=true&max_result_bytes=1048576" || fail "include_tombstoned subgraph failed"
|
||||
visible_out="${AMDUAT_LAST_BODY}"
|
||||
visible_has_edge="$(printf '%s' "${visible_out}" | jq --arg edge_ref "${edge_ref}" '[.edges[] | select(.edge_ref == $edge_ref)] | length')"
|
||||
[[ "${visible_has_edge}" != "0" ]] || fail "tombstoned edge not visible with include_tombstoned=true"
|
||||
|
||||
echo "smoke_v2.sh: PASS"
|
||||
Loading…
Reference in a new issue