Skip to content

test(tracker): [#1419] stop the integration fixture with the final production shutdown API - #2971

Merged
josecelano merged 7 commits into
torrust:developfrom
josecelano-bot:1419-align-fixture-with-final-shutdown-api
Nov 20, 2026
Merged

josecelano merged 7 commits into
torrust:developfrom
josecelano-bot:1419-align-fixture-with-final-shutdown-api

Conversation

@josecelano-bot

Copy link
Copy Markdown
Contributor

Summary

Completes task R8 and acceptance criterion AC8a of issue 1419 (sub-issue order 5 of EPIC 2392, Test isolation). The main-app integration fixture now stops the tracker with the final production shutdown API that EPIC 1488 delivered, and it checks the result. The plan and the maintainer's decisions D1 to D5 were merged with pull request 2961.

Related to #1419

The issue stays open: R9 (the closure review and the move of the specification to docs/issues/closed/) follows in its own pull request after this one merges.

What changed

tests/common/workspace.rs (TrackerApplicationFixture):

  • shutdown() and restart() call app::begin_shutdown instead of JobManager::cancel() (D1), wait with the configured [application.shutdown] deadline instead of a fixed 10 seconds (D2), and panic when a component did not stop gracefully, naming the components (D3). One private helper, stop_gracefully, holds the sequence.
  • Drop calls app::begin_shutdown (D5). It still cannot await or check outcomes.
  • New method spawn_component, which adds one extra component to the running application through the public JobManager::reserve and JobManager::spawn.

New target lifecycle-fixture-shutdown-assertion (tests/lifecycle/fixture_shutdown_assertion.rs, one [[test]] entry in the root Cargo.toml) (D4): it adds a component that never stops to a tracker with a 3-second shutdown deadline and requires that shutdown() panics naming it within 6 seconds. The bound makes the test fail if the fixture ignores the configured deadline.

No production code changes. No existing suite changes its call site.

Documentation: tests/AGENTS.md, the module documentation of tests/scaffold.rs, and the status line of completion-plan.md describe the new sequence. ISSUE.md records the prose-first review of the new test, the evidence E1 to E5, AC8a as met and R8 as done.

Carried over from pull request 2961

That pull request was merged while the fixes of its last review round (findings F10 and F11 of review 5981075592) were being pushed, so they are the first three commits here: the wording of the D5 line, the bound on the elapsed time in the plan (F10, which the new test implements), and round 4 of the review audit docs/pr-reviews/pr-2961-review/PR-REVIEW.md.

Validation

Toolchain: rustc 1.100.0, cargo 1.100.0, dev profile, Linux x86_64; the pre-commit gate also uses the nightly Rust toolchain for its formatting step.

  • The ten fixture-based targets pass in one cargo test invocation; each test finished in 0.11 to 2.05 seconds, so no component consumed the 25-second deadline.
  • cargo test --test metrics-port-zero -- --nocapture and -- --test-threads=1 pass (1.04 and 1.05 seconds).
  • cargo test --test lifecycle-fixture-shutdown-assertion passes in 3.03 seconds; the panic names health_check_api and hung_component.
  • Two temporary mutations of the fixture, not included in this pull request, show that the new test can fail: with a fixed 10-second wait it failed after 6.03 seconds, and with the outcome assertion removed it failed because nothing panicked.
  • The pre-commit gate passed (cargo machete, linter all, documentation tests).

🤖 Generated with Claude Code

josecelano-bot and others added 7 commits November 19, 2026 18:47
…uite so it proves the configured deadline

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…inal production shutdown API

The fixture called JobManager::cancel() itself, waited with its own fixed
10 seconds and discarded the component outcomes. It now calls
app::begin_shutdown in shutdown(), restart() and Drop, waits with the
configured [application.shutdown] deadline, and panics when a component did
not stop gracefully, naming the components.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… when a component does not stop

A new target, lifecycle-fixture-shutdown-assertion, adds a component that
never stops through a new fixture method and requires that shutdown()
panics naming it within a bound that only the configured deadline can meet.
The spec records the prose-first Arrange-Act-Assert review of the test.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@josecelano

Copy link
Copy Markdown
Member

ACK f2cabbf

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the production-aligned shutdown fixture changes.

No open issues 🎉

What changed in this PR

Aligns the main-application integration fixture with the final production shutdown API, completing R8 and AC8a of issue #1419. Production code remains unchanged; the issue’s closure review remains a separate follow-up.

Changes:

  • Uses production shutdown initiation, the configured deadline, and graceful-outcome assertions for fixture shutdown and restart.
  • Adds a negative integration test requiring a panic naming a hung component within six seconds.
  • Updates fixture documentation, records validation evidence, and carries forward the final review fixes from PR #2961.
File Description
tests/​scaffold.rs Documents production-aligned shutdown and failure assertions.
tests/​lifecycle/​fixture_shutdown_assertion.rs Tests hung-component reporting and the configured shutdown deadline.
tests/​common/​workspace.rs Centralizes graceful shutdown and adds component injection for tests.
tests/​AGENTS.md Updates fixture lifecycle guidance and the test inventory.
docs/​pr-reviews/​pr-2961-review/​PR-REVIEW.md Records the final review round and its resolutions.
docs/​issues/​open/​1419-allow-multiple-integration-tests-at-main-app-level/​ISSUE.md Marks R8 and AC8a complete and records test evidence.
docs/​issues/​open/​1419-allow-multiple-integration-tests-at-main-app-level/​completion-plan.md Labels the earlier plan as historical and links the current shutdown work.
Cargo.toml Registers the new shutdown-assertion integration test target.

Review effort: Balanced

@josecelano
josecelano merged commit 0b24de5 into torrust:develop Nov 20, 2026
22 checks passed
@da2ce7

da2ce7 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Post-merge note: this pull request requested a review from this account and was closed without one at its final head. A post-merge review will not be done: All 116 executable lines it added are tests, benchmarks or test support with no production behaviour, and 116 of them are still present.

This branch was previously deployed

1 inactive deployment
coverage — f2cabbfc Deployed Nov 19, 2026 by josecelano-bot via Generate Coverage Report #3362
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.

4 participants