fix(load-test): tear down the app-side data a load run leaves behind - #1247
Merged
Merged
Conversation
teardown.sh removed only the Cognito user and the quota override. Everything the application writes once a load-test user signs in and chats - the users row, sessions-metadata (sessions, C# cost rows, TSUM#, ...), user-cost-summary, the system-cost-rollup ACTIVE# markers and their activeUsers/uniqueUsers counters, quota events, uploads and artifacts with their S3 objects, and AgentCore Memory long-term records - stayed behind. Production still counts 620 @load.invalid users, 310 of them in September's active-user figures. Teardown now inventories that data per sub, prints it as the plan, and deletes it with the users row last. New rails: every manifest user_id must be a well-formed sub, and each sub's users row must carry the load-test email (<username>@<domain>) before anything is deleted; one mismatch refuses the whole run. Rollup population counters are decremented atomically with each marker delete (idempotent on re-run); cost totals are kept, since they were real Bedrock spend, and the plan prints the amount kept per period. --orphans (dry run unless --apply) finds load-test users whose manifest is gone and whose Cognito account no longer exists, and removes their app data through the same checks. Per-user phases run as a bounded job pool (--jobs, default 8). Verified against dev only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er sub A filtered list-users per candidate ran at ~26 subs a minute against the production pool, making the Cognito check alone take ~25 minutes for 620 orphans. One unfiltered paginated listing gives the same exact answer in a few dozen calls; an empty listing is refused rather than read as all-orphaned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
scripts/load-test/teardown.shdeleted the Cognito user and the quota override, but nothing the application writes once a load-test user signs in and chats. Production (checked 2026-09-22) still has 620@load.invalidrows in<prefix>-usersfrom the 2026-09-10/11 runs, 310 of them with Septemberuser-cost-summaryrows. The admin dashboards count them as real users: 1,829 this month, of which 1,519 are real.What changed
teardown.sh --manifestnow also deletes per-user app data, keyed on the manifest'suser_id(sub). Everything is read first and printed as the plan. The plan also shows the load-test spend that stays in the rollups. A newapp-data.shholds the inventory and delete code.users(read first, deleted last),sessions-metadata(allUSER#<sub>rows:S#,C#,D#,F#,TSUM#,APPCARD#,UIRES#,LEASE#),user-cost-summary,system-cost-rollupACTIVE#markers,quota-events, overrides viaUserOverrideIndex,user-file-uploads+user-files/<sub>/andcompaction-offload/<sub>/,user-artifacts+<sub>/objects, AgentCore Memory long-term recordsbff-sessions(TTL + logout),user-settings/ tool and skill preferences (explicitPUTonly),api-keys,oauth-user-tokens, memory spaces, shares, assistants, fine-tuning, announcement acks, audit logNew safety rails, on top of the existing ones (the
loadtest-prefix check across the whole manifest, overrides deleted before users, fail loudly and keep the manifest, re-runnable):user_idin the manifest must be a well-formed sub, checked across the whole file before anything is deleted. An empty sub would otherwise makeuser-files/<sub>/a prefix covering every user.<prefix>-usersrow must carry<username>@${LOAD_TEST_EMAIL_DOMAIN}before any of its app data is touched. One mismatch refuses the whole run.system-cost-rollupdecision. The population counters are corrected and the cost totals are kept:ACTIVE#marker is deleted in the sameTransactWriteItemsthat decrements theactiveUsers/uniqueUserscounter it once incremented. The dashboard's "active users" readsROLLUP#MONTHLY.activeUsersdirectly, nothing in the codebase recomputes it, and the table has no TTL.totalCostand the token/request totals are kept. That was real Bedrock spend, and removing it would put the rollups out of step with Cost Explorer and thePLATFORM#rows. The plan prints the spend kept per period, and the README explains the gap.--orphanshandles runs whose manifest is already gone:--applyis given.@load.invalidusers throughEmailDomainIndex, requires aloadtest-…@load.invalidemail, and skips any sub that still has a Cognito account. Each remaining user then goes through the same owner check, inventory and delete as a manifest entry.--limit Nprocesses a batch at a time.Per-user work runs as a bounded job pool (
--jobs, default 8). The 5-user dry run took 47s serially and 21s with the pool. At the default, the README estimates roughly 15–30 minutes per 600 users.Testing (dev only,
dev-ai/dev-boisestateai-v2)The repo has no shell-test pattern, so testing was against dev, in a GNU userland (bash 5.2, aws-cli 2.34).
totalCostwas unchanged. Then two users were turned into orphans (Cognito deleted, app data kept) and cleared with--limit 1followed by a second pass.loadtest-usernameBatchWriteItemfailure on sessions-metadata gave exit 1 with the manifest and users row kept. A plain re-run then deleted only what was left.wait -nneeds 4.3.Side effect in dev: the 2026-09-03 run was never torn down. Six of its users were used as test subjects and are now fully removed. The other 44 are still in dev's Cognito, with expired overrides still in the quota table.
🤖 Generated with Claude Code