test: per-directory coverage + E2E cleanup hardening (Days 5-6)#1123
test: per-directory coverage + E2E cleanup hardening (Days 5-6)#1123
Conversation
|
Reducing
With a 5-minute window, a test whose deploy takes >5 min (container builds have a 900s/15-min timeout, and regular deploys routinely go past 5 min) can have its active credential provider deleted by another test file's A few options, pick whichever fits best:
|
|
In afterAll(async () => {
if (projectPath && hasAws) {
await teardownE2EProject(projectPath, agentName, cfg.modelProvider);
}
if (testDir) await rm(testDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 1000 });
}, 600000);Previously Options:
|
|
The PR-changed-line gate silently ignores new/changed In const coveredSet = coveredLinesByFile[file];
if (!coveredSet) continue;
Meanwhile the git-diff in the same script explicitly includes `git diff ${baseSha}...${headSha} --unified=0 --diff-filter=AM -- 'src/**/*.ts' 'src/**/*.tsx'`So a PR that adds a brand-new Options:
|
|
Addressed — reverted the default to 30 min and added an opt-in |
|
Addressed — wrapped the |
|
Addressed — extended |
Coverage Report
File CoverageNo changed files found. |
Test Coverage ReportOverall
Per-Directory Line Coverage
PR Changed Lines100.0% (0/0) — threshold 50% — PASS |
Day 5: Coverage gate - Add scripts/check-coverage.mjs with ratchet thresholds per source directory (schema 78%, operations 52%, lib 82%, aws 40%, tui/hooks 14%, tui/components 68%, commands 46%). Target thresholds documented in the report, ratchet set ~5% below current to prevent regression. - Also check PR changed-line coverage (>=50%) and post a report comment. - Switch davelosert/vitest-coverage-report-action to file-coverage-mode: changes so PR comments highlight uncovered new lines. Day 6: E2E cleanup - teardownE2EProject() now retries deploy up to 3x and throws on failure instead of swallowing silently. The remove step logs but does not retry. - Tag CDK stacks with Environment=e2e-test / CreatedAt / CreatedBy when AGENTCORE_E2E_TEST=1 is set. The CLI's e2e helper sets this env var; user projects are unaffected. - Shrink cleanupStaleCredentialProviders() window from 30min -> 5min to catch orphans faster. - byo-custom-jwt.test.ts Cognito cleanup now retries 3x with 5s delay instead of swallowing errors on first try. - Add docs/test-resource-sweeper-spec.md for the infra team to implement a scheduled sweeper (CFN stacks, credential providers, log groups, ECR).
1. cleanupStaleCredentialProviders default restored to 30 min, now configurable via E2E_STALE_CRED_MAX_AGE_MS env var. 5 min was too aggressive given container builds >5 min. 2. afterAll blocks that call teardownE2EProject now wrap in try/finally so testDir cleanup always runs even when teardown throws. Updated createE2ESuite + 5 standalone suites (ab-test-*, archive-lifecycle, config-bundle-eval-rec, evals-lifecycle). 3. vitest coverage include adds src/**/*.tsx so TUI React files are gated. Also exclude *.test.tsx from the coverage set. Adjusted src/cli/commands/ ratchet from 46% to 34% to reflect the new denominator (was 3424 lines, now 4553 with .tsx included). 4. check-coverage.mjs no longer silently skips changed files missing from coverage-final.json — counts them as 0% covered instead.
ff38b62 to
9c0156f
Compare
Summary
Two days of test infrastructure work bundled together since they're orthogonal but small.
Day 5 — Per-directory coverage thresholds
scripts/check-coverage.mjsenforces per-directory line coverage thresholds (ratchet values ~5% below current coverage; target values documented inline)davelosert/vitest-coverage-report-actiontofile-coverage-mode: changesso PR comments highlight uncovered new linesDay 6 — E2E cleanup hardening + sweeper spec
teardownE2EProject()retries deploy up to 3× (15s backoff) and throws on failure instead of swallowing silently. Stops silent AWS resource leaks.Environment=e2e-test/CreatedAt/CreatedBywhenAGENTCORE_E2E_TEST=1is set (opt-in, user projects unaffected)cleanupStaleCredentialProviderswindow shrunk from 30min → 5min — catches orphans fasterbyo-custom-jwt.test.tsretries 3× with 5s delay instead of swallowing errorsdocs/test-resource-sweeper-spec.mdfor the infra team to implement a scheduled sweeperTest plan
node scripts/check-coverage.mjspasses against current coverage locally