#!/usr/bin/env bash # # Verify the end-to-end read-projection path (S-06) against an ALREADY-RUNNING full stack: # OpenZaak → NRC → Event Subscriber → projection → projection-api. Seeds a published BIG # zaaktype (idempotent), registers an abonnement on the `zaken` kanaal pointing at the real # Event Subscriber's /notifications callback (with the bearer it enforces), creates a zaak, # and asserts projection-api serves a row for that zaak with status INGEDIEND. # # All in-network, reaching services by container IP — single-label hosts aren't URL-valid and # the runner can't reach published ports (gitea-actions-gotchas.md §5/§6). Reuses the # notification driver to register the abonnement + create the zaak. Does NOT manage the stack # lifecycle (the caller owns bring-up + teardown). Plain docker primitives only. See ADR-0007/0008. set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" WEBHOOK_AUTH="${NOTIFICATION_WEBHOOK_TOKEN:-Bearer big-reference-notifications}" cleanup() { docker rm -f rr-pverify rr-pquery >/dev/null 2>&1 || true; } trap cleanup EXIT ip() { docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$1"; } oz="$(docker ps -q --filter 'name=[-_]openzaak[-_]' | head -1)" nrc="$(docker ps -q --filter 'name=nrc-web' | head -1)" es="$(docker ps -q --filter 'name=event-subscriber' | head -1)" proj="$(docker ps -q --filter 'name=projection-api' | head -1)" [ -n "$oz" ] && [ -n "$nrc" ] || { echo "ERROR: OpenZaak and/or NRC not running — bring the stack up first" >&2; exit 1; } [ -n "$es" ] && [ -n "$proj" ] || { echo "ERROR: event-subscriber and/or projection-api not running — bring the stack up first" >&2; exit 1; } net="$(docker inspect -f '{{range $k,$_ := .NetworkSettings.Networks}}{{$k}}{{"\n"}}{{end}}' "$oz" | head -1)" oz_ip="$(ip "$oz")"; nrc_ip="$(ip "$nrc")"; es_ip="$(ip "$es")"; proj_ip="$(ip "$proj")" echo ">> network=$net openzaak=$oz_ip nrc=$nrc_ip event-subscriber=$es_ip projection-api=$proj_ip" echo ">> seeding a published BIG zaaktype (idempotent)" sid="$(docker create --network "$net" -e "OZ_BASE=http://$oz_ip:8000" -e OZ_PUBLISH=1 \ python:3-slim python /seed.py)" docker cp "$here/openzaak/seed_catalogus.py" "$sid:/seed.py" >/dev/null docker start -a "$sid" docker rm -f "$sid" >/dev/null echo ">> registering abonnement at the Event Subscriber + creating a zaak" docker rm -f rr-pverify >/dev/null 2>&1 || true drv="$(docker create --network "$net" --name rr-pverify \ -e "OZ_BASE=http://$oz_ip:8000" -e "NRC_BASE=http://$nrc_ip:8000" \ -e "SINK_CALLBACK=http://$es_ip:8080/notifications" -e "SINK_AUTH=$WEBHOOK_AUTH" \ python:3-slim python /driver.py)" docker cp "$here/verify-notification-driver.py" "$drv:/driver.py" >/dev/null docker start -a "$drv" zaak_url="$(docker logs rr-pverify 2>/dev/null | sed -n 's/^ZAAK_CREATED //p' | head -1)" docker rm -f rr-pverify >/dev/null [ -n "$zaak_url" ] || { echo "ERROR: driver did not create a zaak" >&2; exit 1; } zaak_uuid="${zaak_url##*/}" echo ">> zaak created: $zaak_url" echo ">> polling projection-api for the projected row (status INGEDIEND)" for _ in $(seq 1 30); do body="$(docker run --rm --network "$net" curlimages/curl:latest \ -fsS "http://$proj_ip:8080/register/$zaak_uuid" 2>/dev/null || true)" if echo "$body" | grep -q '"INGEDIEND"'; then echo "OK — projection-api serves zaak $zaak_uuid with status INGEDIEND" echo "$body" | cut -c1-300 exit 0 fi sleep 2 done echo "FAIL — projection-api never served an INGEDIEND row for zaak $zaak_uuid" >&2 echo "--- event-subscriber log ---" >&2; docker logs "$es" 2>&1 | tail -10 >&2 echo "--- projection-api log ---" >&2; docker logs "$proj" 2>&1 | tail -10 >&2 exit 1