On the single self-hosted runner CI jobs run sequentially, so booting OpenZaak once beats once-per-job. Replace the integration + notifications + compose-smoke jobs with one verify-stack job that brings the full stack up once and runs, as clearly-named steps: health (make verify-up, the DoD smoke) → ACL ↔ OpenZaak (verify-acl) → OpenZaak → NRC delivery (verify-nrc) → teardown (always) + log dump on failure. The check logic moves into stack-agnostic runners (run-acl-integration.sh, run-notification-check.sh) that operate on whatever stack is already up, reaching services by container IP. The local single-concern wrappers (make integration oz-only, make verify-notifications oz+nrc) keep working by delegating to the same runners, so nothing is duplicated. make ci now runs the consolidated 'verify' stage. Verified locally: make verify boots the full stack once, ACL integration passes and the NRC notification is delivered, then tears down. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
73 lines
3.3 KiB
Bash
Executable File
73 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Verify the OpenZaak → NRC notification path against an ALREADY-RUNNING oz+nrc stack
|
|
# (the standalone stack via `make verify-notifications`, or the full compose stack in
|
|
# the CI `verify-stack` job). Seeds a published BIG zaaktype (idempotent), registers
|
|
# an abonnement to a webhook sink, creates a zaak, and asserts the sink receives the
|
|
# `zaken`/`create` notification. All in-network, reaching services by container IP
|
|
# (single-label hosts aren't URL-valid; the runner can't reach published ports).
|
|
#
|
|
# Does NOT manage the stack lifecycle (the caller owns bring-up + teardown), but it
|
|
# cleans up the throwaway sink/driver it creates. Plain docker primitives only.
|
|
# See ADR-0007.
|
|
set -euo pipefail
|
|
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SINK_AUTH="Bearer notification-sink-token"
|
|
|
|
cleanup() { docker rm -f rr-nsink rr-nverify >/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)"
|
|
[ -n "$oz" ] && [ -n "$nrc" ] || { echo "ERROR: OpenZaak and/or NRC 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")"
|
|
echo ">> network=$net openzaak=$oz_ip nrc=$nrc_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 ">> starting the webhook sink"
|
|
docker rm -f rr-nsink >/dev/null 2>&1 || true
|
|
sink="$(docker create --network "$net" --name rr-nsink -e "EXPECTED_AUTH=$SINK_AUTH" \
|
|
python:3-slim python /sink.py)"
|
|
docker cp "$here/notification-sink.py" "$sink:/sink.py" >/dev/null
|
|
docker start "$sink" >/dev/null
|
|
sleep 1
|
|
sink_ip="$(ip rr-nsink)"
|
|
echo ">> sink at $sink_ip:9000"
|
|
|
|
echo ">> registering abonnement + creating a zaak"
|
|
docker rm -f rr-nverify >/dev/null 2>&1 || true
|
|
drv="$(docker create --network "$net" --name rr-nverify \
|
|
-e "OZ_BASE=http://$oz_ip:8000" -e "NRC_BASE=http://$nrc_ip:8000" \
|
|
-e "SINK_CALLBACK=http://$sink_ip:9000/" -e "SINK_AUTH=$SINK_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-nverify 2>/dev/null | sed -n 's/^ZAAK_CREATED //p' | head -1)"
|
|
docker rm -f rr-nverify >/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 ">> waiting for the notification to reach the sink"
|
|
for _ in $(seq 1 30); do
|
|
if docker logs rr-nsink 2>&1 | grep -q "$zaak_uuid"; then
|
|
echo "OK — NRC delivered the zaken notification for zaak $zaak_uuid to the sink"
|
|
docker logs rr-nsink 2>&1 | grep "$zaak_uuid" | tail -1 | cut -c1-300
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "FAIL — the sink never received a notification for zaak $zaak_uuid" >&2
|
|
echo "--- sink log ---" >&2; docker logs rr-nsink 2>&1 | tail -8 >&2
|
|
exit 1
|