Skip to content

test(backups): make idle-expiry admission checks deterministic - #431

Merged
RentnerKev merged 2 commits into
mainfrom
rentner/test-main-smoke-stability-426
Nov 12, 2026
Merged

RentnerKev merged 2 commits into
mainfrom
rentner/test-main-smoke-stability-426

Conversation

@RentnerKev

@RentnerKev RentnerKev commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

The root backup-download idle-expiry regression used a 150 ms real timer and a wall-clock sleep, also applying that small idle allowance to the subsequent snapshot preparation. The final-main smoke retry returned HTTP 503 for that second request. Pass an optional scheduler through the existing timeout factory and drive the actual idle callback after a real snapshot is prepared, so filesystem scheduling cannot decide this admission assertion.

The test still verifies stream cancellation, admission release before the error is observed, immediate second-request HTTP 200, final cancellation and complete timer cleanup. Existing production callers retain the same real timers, limits and cleanup ordering.

Related issue

Refs #426: follow-up required by final-main validation after #427/#428/#429. The parent remains open until its full main verification passes.

Type of change

  • CI / tooling
  • Refactoring

Testing

  • Isolated Linux/root download and timeout tests: 12 passed, 67 assertions; no network or database.
  • Full application and script typechecks: 2,423 and 820 files passed.
  • Scoped standard/type-aware Oxlint and diff whitespace checks passed.
  • Independent focused review found no actionable issue.

The exact reason for the earlier 503 is not established by the redacted CI output; this change removes the test's short wall-clock coupling. The separate first-attempt ACME fixture Docker-start failure remains unclassified. The complete runtime smoke must execute successfully for this PR and on the resulting main; no assertion or production timeout was relaxed.

Checklist

  • Relevant behavior tested with actual owned snapshot files and stream cleanup.
  • Test updated without sleeps, polling retries or disabled assertions.
  • No secrets, production data, dependencies, documentation files or screenshots added.
  • Related issue linked.

Breaking changes

None; the new optional scheduler defaults to the existing implementation.

Summary by CodeRabbit

  • Bug Fixes
    • Backup downloads that expire after inactivity now release their admission slot, allowing a subsequent download to proceed without waiting for the expired download to finish.
    • When an idle download expires, its timer is canceled and removed. This prevents stale timers from affecting later downloads and helps ensure download capacity is available for the next request.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

createBackupDownload accepts an optional scheduler and passes it to the timeout factory. The idle-expiration test uses a controlled scheduler to verify cancellation, timer removal, admission-slot release, and subsequent download admission.

Changes: Backup download timeout scheduling

Layer / File(s) Summary
Forward scheduler and test idle expiration
docker/production/backups/download.ts, web/src/tests/tooling/docker/production/backup-download.test.ts
createBackupDownload forwards the optional scheduler to the timeout factory. The test fixture passes the scheduler through, and the idle-expiration test checks cancellation, timer removal, admission-slot release, and a subsequent download.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related issues

Possibly related PRs

  • RentnerProxy/platform#413: It changes cleanup and admission-release behavior in the same backup-download path, which this PR's idle-expiration test also checks.
Merge Risk: Minimal · up to 8f4cd

This change makes a backup-download timeout test deterministic. Production callers keep the same real timers and behavior. No actionable merge risk remains.

Security architecture risk: Minimal · up to 8f4cd

The new scheduler parameter is optional and is not supplied by the production caller or controlled by HTTP requests. Existing timeout defaults and cleanup ordering remain intact. The revised test exercises idle cancellation and immediate admission reuse without relying on a wall-clock sleep.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected production download route gains no new scheduler authority or backup-selection scope. It still passes the request and path identifier to a factory configured with default timers and shared admission; each handler instance retains its single-active-snapshot guard.

Trust Boundaries and Controls

  • observed — Scheduler selection occurs during trusted factory construction, not request parsing. The production route derives only a backup identifier from the URL and rejects download requests containing a query string; it does not forward request data into scheduler configuration.

Resilience and Maintainability Implications

  • observed — The lifecycle retains containment against repeated cleanup and timer callbacks: release callers share a promise, cleared timeouts ignore subsequent expiry or progress, and normal completion, read failure, abort, and cancellation converge on cleanup. The controlled scheduler removes timer registrations through its cancellation callbacks.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the backup-download idle-expiry admission test is made deterministic. It is a test-only change, and the title says so with the test(backups) prefix. The title is speci…
Description check Passed The description follows the template. It has Summary, Related issue, Type of change, Testing, Checklist, Breaking changes, and Screenshots content. The Summary explains the change and the reason for i…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the backup-download idle-expiry admission test is made deterministic. It is a test-only change, and the title says so with the test(backups) prefix. The title is specific and short, and it matches the PR objectives and the test file changes.

Full details: Description check

Explanation

The description follows the template. It has Summary, Related issue, Type of change, Testing, Checklist, Breaking changes, and Screenshots content. The Summary explains the change and the reason for it. The related issue is linked as Refs #426 with a reason why it is not a full closing link. The type is marked as CI / tooling and Refactoring. Testing lists commands and results. The checklist is filled in. Breaking changes is answered as None. The Screenshots section is omitted, which is acceptable because the template says to write None only when UI changed and no UI is involved. The description also records open items, including the unclassified ACME Docker-start failure and the pending full runtime smoke.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fd6da9c and 8f4cddb.

Files selected for processing: 2

  • docker/production/backups/download.ts
  • web/src/tests/tooling/docker/production/backup-download.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@RentnerKev

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Full review finished.

@RentnerKev
RentnerKev merged commit 53454af into main Nov 12, 2026
64 checks passed
@RentnerKev
RentnerKev deleted the rentner/test-main-smoke-stability-426 branch November 12, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant