Skip to content

test(integration): add application lifecycle fixture - #2086

Merged
josecelano merged 3 commits into
torrust:developfrom
josecelano:1419-allow-multiple-integration-tests
Aug 24, 2026
Merged

test(integration): add application lifecycle fixture#2086
josecelano merged 3 commits into
torrust:developfrom
josecelano:1419-allow-multiple-integration-tests

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

Add TrackerApplicationFixture for main-application integration suites. The fixture owns the isolated workspace, application container, and JobManager, then invokes the best shutdown sequence exposed by current production before releasing the workspace.

  • Migrate the current metrics, UDP-policy, banning, and scaffold suites from implicit _jobs drop cleanup.
  • Add focused lifecycle ordering coverage: the workspace is released only after awaited fixture shutdown.
  • Reconcile Allow multiple integration tests at the main app level #1419 documentation and record the verification evidence.

Verification

  • cargo test --test metrics-fixed-ports --test metrics-port-zero --test metrics-udp-error-enabled-port-zero --test metrics-udp-error-disabled-port-zero --test banning-udp-metrics-disabled-port-zero --test scaffold
  • cargo test --test metrics-port-zero -- --nocapture
  • cargo test --test metrics-port-zero -- --test-threads=1
  • TORRUST_GIT_HOOKS_LOG_DIR=.tmp ./contrib/dev-tools/git/hooks/pre-commit.sh --format=json

Scope and Follow-up

Partially addresses #1419; it intentionally remains open.

Current server jobs can consume JobManager::wait_for_all's per-job timeout because they do not yet react to the shared cancellation token. This change makes test lifecycle ownership explicit but does not claim cooperative server completion. Production shutdown coordination is deferred to #1488 and draft PR #1993; this PR does not introduce a competing shutdown mechanism.

Copilot AI lite review requested due to automatic review settings August 24, 2026 13:05
@josecelano josecelano self-assigned this Aug 24, 2026
@josecelano
josecelano force-pushed the 1419-allow-multiple-integration-tests branch from 4b112d7 to 02bb268 Compare August 24, 2026 13:20

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.

Pull request overview

Adds an explicit main-application integration-test lifecycle fixture (TrackerApplicationFixture) so suites own their isolated workspace + application container + JobManager, and can request/await shutdown before releasing the temporary workspace (aligning with issue #1419’s execution model and verification evidence).

Changes:

  • Introduces TrackerApplicationFixture to centralize integration-suite startup and awaited shutdown sequencing.
  • Migrates existing main-level integration suites (metrics, UDP policy, banning, scaffold) from implicit _jobs drop cleanup to explicit fixture.shutdown().await.
  • Updates test/docs guidance and issue-spec verification evidence to reflect the new lifecycle ownership model.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/common/workspace.rs Adds TrackerApplicationFixture, workspace path access, and shared shutdown grace period used by suites.
tests/common/mod.rs Re-exports TrackerApplicationFixture for suite consumption.
tests/scaffold.rs Updates the scaffold sample to use the fixture and documents explicit awaited shutdown.
tests/metrics/port_zero.rs Uses fixture and adds a focused ordering assertion that workspace cleanup occurs after awaited shutdown.
tests/metrics/fixed_ports.rs Migrates fixed-port metrics suite to fixture lifecycle.
tests/metrics/udp_error_enabled_port_zero.rs Migrates UDP error-policy (enabled) suite to fixture lifecycle.
tests/metrics/udp_error_disabled_port_zero.rs Migrates UDP error-policy (disabled) suite to fixture lifecycle.
tests/banning/udp_metrics_disabled_port_zero.rs Migrates banning suite to fixture lifecycle.
tests/AGENTS.md Updates contributor guidance to require explicit fixture shutdown and clarifies process-global constraints.
docs/issues/open/1419-allow-multiple-integration-tests-at-main-app-level/ISSUE.md Reconciles issue spec with current test structure and records verification evidence and lifecycle findings.
docs/issues/open/1419-allow-multiple-integration-tests-at-main-app-level/completion-plan.md Adds/updates decision record for lifecycle fixture approach and mandatory verification protocol.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/common/workspace.rs
Comment thread tests/common/workspace.rs Outdated
@josecelano
josecelano force-pushed the 1419-allow-multiple-integration-tests branch from 16a671c to af5ddb7 Compare August 24, 2026 15:11
@josecelano

Copy link
Copy Markdown
Member Author

ACK af5ddb7

@josecelano
josecelano merged commit 7f8fb83 into torrust:develop Aug 24, 2026
11 checks passed
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.

2 participants