EPIC: Test isolation

オープン
#2,392 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@josecelano がすでに取り組んでいます。

2026年9月30日 から。

評価

この issue はまだ評価されていません。

説明

EPIC Testing

Goal

Every automated test is independent of every other test and of other test runs in the same environment (one host, one Docker daemon). Each test owns the resources it uses: network ports, container images and names, filesystem paths, and process-global state. A test result then depends only on the code under test.

The purpose is a robust test suite without flaky tests. Faster CI through parallel runs is a side benefit, not the goal. Isolation also improves the code: a component that works with an OS-assigned port must report the address it bound (observability), and a component that accepts injected paths and names instead of globals is easier to test (testability).

Why

  • Flaky runs. The full nextest suite fails intermittently with AddrInUse because fixtures release a selected port before using it or claim fixed ports inside the ephemeral range (reproduced locally; also seen in the #2298 container build).
  • Colliding E2E runs. The E2E runner publishes fixed host ports, so a second run on the same Docker host fails.
  • Wrong results without a failure. CI tags each run's image with a fixed name, so two runs on one Docker host can test each other's image and still pass.
  • Unknown shared resources. #2386 did not audit container names, networks, or /tmp paths; process-global state has no inventory.

Already isolated: #1419 (main-app integration suites use port 0 and temporary workspaces), #2132 (native-process fixture discovers its port from the startup log), and the qBittorrent E2E runner (random Compose project names, Docker-assigned host ports).

Subissues

Linked as GitHub sub-issues, in delivery order:

  1. Eliminate parallel test port allocation races (bug)
  2. Audit shared test resources (task)
  3. Use dynamic host ports in the E2E runner (task)
  4. Use a unique tracker image tag per CI run (task)
  5. #1419 - Allow multiple integration tests at the main app level (existing; blocked on #1488)

Isolation rules

  1. A test owns every resource it uses and releases it on success, failure, and drop paths.
  2. Prefer OS-assigned ports (port 0) and read the bound address back from the service.
  3. Never select a port by binding and releasing it before the service under test binds it.
  4. Give per-run names to shared-namespace resources: image tags, containers, networks, Compose projects, and paths.
  5. Do not change process-global state from a test that shares its process with other tests.
  6. When a test contract needs a fixed resource, document why; fixed ports must be outside the ephemeral range.

Out of scope

Production default ports; the shared Cargo target directory between runner instances (a speed concern); runner instances and self-hosted runner setup; cooperative shutdown (#1488).

Related EPIC: #1840 (PR workflow performance). Related, not parent: isolation enables running several jobs per self-hosted server, but this EPIC is driven by robustness.

The full specification is added to docs/issues/open/ by a spec-only pull request.

主要言語
Rust
スター
532
フォーク
56
平均マージ
11時間 20分
マージ済み PR(30日)
282

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

torrust/torrust-tracker のほかの issue

torrust/torrust-tracker の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。