20 lines
1.4 KiB
Bash
Executable file
20 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# P8-REVIEW, axis 2: PD-23 says the login journal "grows without retention and is cleaned only by
|
|
# the cascade when an account is deleted". This probe shows the retention sweep is BUILT and RUNS.
|
|
#
|
|
# Carriers in the tree:
|
|
# internal/pgstore/identity.go:72 DeleteOldLoginEvents (delete from login_events where at < $1)
|
|
# cmd/tmplatformd/main.go:257 const loginJournalRetention = 180 * 24 * time.Hour
|
|
# cmd/tmplatformd/main.go:260-279 sweepLogins: ticker every 15 minutes, started at main.go:121/145
|
|
# landed by commit 9b23e8c (the P7 landing) — git log -S'DeleteOldLoginEvents' -- platform/
|
|
#
|
|
# Usage: pd23-retention-probe.sh (needs a dev daemon running against $PGDATABASE)
|
|
# Expect: the row disappears within one 15-minute tick and the daemon logs `"login sweep" events=1`.
|
|
set -u
|
|
PSQL="${PSQL:-$HOME/.local/pgsql/bin/psql}"
|
|
: "${PGDATABASE:?set PGDATABASE to the database of the dev daemon}"
|
|
$PSQL -X -c "insert into login_events (user_id, provider, outcome, ip_prefix, client, at)
|
|
values (null,'dev','denied','203.0.113.0/24','p8-review-probe', now() - interval '200 days')
|
|
returning id, at"
|
|
echo "over-retention rows now: $($PSQL -tAX -c "select count(*) from login_events where at < now() - interval '180 days'")"
|
|
echo "wait for the next 15-minute tick of sweepLogins, then re-run the count and grep the daemon log for 'login sweep'."
|