feat(infra): Objecten publishes register events to NRC (closes #152) #154
@@ -4,7 +4,7 @@
|
|||||||
Registers an abonnement on the `objecten` kanaal pointing at the webhook sink, then writes a
|
Registers an abonnement on the `objecten` kanaal pointing at the webhook sink, then writes a
|
||||||
RegisterRecord object exactly as the ACL's ObjectenGateway does (S-19a). The caller
|
RegisterRecord object exactly as the ACL's ObjectenGateway does (S-19a). The caller
|
||||||
(run-objecten-notifications-check.sh) watches the sink for the delivery — this only sets it up,
|
(run-objecten-notifications-check.sh) watches the sink for the delivery — this only sets it up,
|
||||||
and prints `REFERENCE <value>` for the caller to grep on.
|
and prints `OBJECT_URL <url>` for the caller to grep on.
|
||||||
|
|
||||||
Delivery exercises the whole chain: Objecten → its celery worker → NRC → nrc-beat → the callback.
|
Delivery exercises the whole chain: Objecten → its celery worker → NRC → nrc-beat → the callback.
|
||||||
Anything missing (broker, worker, kanaal, notifications config) shows up as a non-delivery.
|
Anything missing (broker, worker, kanaal, notifications config) shows up as a non-delivery.
|
||||||
@@ -111,7 +111,9 @@ def main():
|
|||||||
},
|
},
|
||||||
}, crs=True)
|
}, crs=True)
|
||||||
print(f">> wrote RegisterRecord {created['url']}")
|
print(f">> wrote RegisterRecord {created['url']}")
|
||||||
print(f"REFERENCE {reference}")
|
# An NRC notification carries no record data — only hoofdObject/resourceUrl — so the object
|
||||||
|
# URL, not the reference in its data, is what the caller can correlate the delivery on.
|
||||||
|
print(f"OBJECT_URL {created['url']}")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,22 +58,24 @@ drv="$(docker create --network "$net" --name rr-overify \
|
|||||||
python:3-slim python /driver.py)"
|
python:3-slim python /driver.py)"
|
||||||
docker cp "$here/objecten-notifications-check.py" "$drv:/driver.py" >/dev/null
|
docker cp "$here/objecten-notifications-check.py" "$drv:/driver.py" >/dev/null
|
||||||
docker start -a "$drv"
|
docker start -a "$drv"
|
||||||
reference="$(docker logs rr-overify 2>/dev/null | sed -n 's/^REFERENCE //p' | head -1)"
|
object_url="$(docker logs rr-overify 2>/dev/null | sed -n 's/^OBJECT_URL //p' | head -1)"
|
||||||
docker rm -f rr-overify >/dev/null
|
docker rm -f rr-overify >/dev/null
|
||||||
[ -n "$reference" ] || { echo "FAIL — the driver did not write a RegisterRecord" >&2; exit 1; }
|
[ -n "$object_url" ] || { echo "FAIL — the driver did not write a RegisterRecord" >&2; exit 1; }
|
||||||
echo ">> wrote reference $reference"
|
echo ">> wrote $object_url"
|
||||||
|
|
||||||
|
# Correlate on the object URL: a notification carries hoofdObject/resourceUrl, never the record
|
||||||
|
# data, so the reference inside the record is not in the delivered message.
|
||||||
echo ">> waiting for the notification to reach the sink"
|
echo ">> waiting for the notification to reach the sink"
|
||||||
for _ in $(seq 1 "${NOTIFICATION_TRIES:-40}"); do
|
for _ in $(seq 1 "${NOTIFICATION_TRIES:-40}"); do
|
||||||
if docker logs rr-osink 2>&1 | grep -q "$reference"; then
|
if docker logs rr-osink 2>&1 | grep -qF "$object_url"; then
|
||||||
echo "OK — Objecten published to NRC and the abonnement delivered it:"
|
echo "OK — Objecten published to NRC and the abonnement delivered it:"
|
||||||
docker logs rr-osink 2>&1 | grep "$reference" | tail -1 | cut -c1-500
|
docker logs rr-osink 2>&1 | grep -F "$object_url" | tail -1 | cut -c1-500
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "FAIL — no 'objecten' notification for $reference reached the sink." >&2
|
echo "FAIL — no 'objecten' notification for $object_url reached the sink." >&2
|
||||||
echo " Objecten accepted the write, so the gap is downstream: the celery broker/worker," >&2
|
echo " Objecten accepted the write, so the gap is downstream: the celery broker/worker," >&2
|
||||||
echo " the kanaal registration, or Objecten's notifications_config." >&2
|
echo " the kanaal registration, or Objecten's notifications_config." >&2
|
||||||
echo "--- sink log ---" >&2; docker logs rr-osink 2>&1 | tail -8 >&2
|
echo "--- sink log ---" >&2; docker logs rr-osink 2>&1 | tail -8 >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user