Replace the fixed listener-start sleep in the tracker-core TestEnv
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- testing-qa
Research direction
Start in packages/tracker-core/tests/common/test_env.rs at TestEnv::run_jobs, noting where each listener calls event_bus.receiver() relative to the spawn, then read packages/events/src/broadcaster.rs to confirm the broadcast channel buffers for subscribers. Decide whether subscription alone means ready (remove the sleep with a comment explaining why) or whether a bounded readiness signal is needed, and write the spec first per the repo workflow. Done when the sleep is gone and repeated runs of a listener-dependent test (and the whole integration binary) pass.
Written by the indexing model from the issue text.
Description
Problem
TestEnv::run_jobs in packages/tracker-core/tests/common/test_env.rs spawns the tracker-core integration-test event listeners (swarm statistics, in-memory statistics and, with persistence, persistent completed statistics) and then sleeps a fixed 100 ms:
// Give the event listeners some time to start
// todo: they should notify when they are ready
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
A fixed sleep is a timing guess. It adds 100 ms to every started TestEnv (some tests start two to simulate a restart), and on a loaded host it either is not needed or is not enough. #2953 was a race of the same kind in this test environment: a wait that assumed the background task had finished. It failed once in the maintainer's merge-script pre-push run.
What to find out first
Each listener gets its receiver from event_bus.receiver() synchronously in run_jobs, before the task is spawned, and the bus is a tokio::sync::broadcast channel (packages/events/src/broadcaster.rs). If subscribing is all a listener needs to "be ready", events sent after run_jobs returns are already buffered for it, and the sleep can be removed. If something else must happen first, TestEnv needs a readiness signal (for example the listener reports when it has started) instead of the sleep.
Done when
- The fixed sleep in
run_jobsis gone: either it is removed with a recorded reason why the listeners are ready whenrun_jobsreturns, or it is replaced by an explicit readiness signal with a bounded wait. - The tracker-core integration test binary still passes on repeated runs (for example 300 runs of a listener-dependent test and 100 runs of the whole binary, as in #2953).
- No production behavior changes unless the investigation shows a readiness signal is needed in the listener API; if so, the spec says so.
Found while working on #2953 (PRs #2954, #2964, #2970). The spec comes first, per the repository's spec-first workflow.
- Dominant language
- Rust
- Stars
- 532
- Forks
- 56
- Avg merge
- 11h 20m
- Merged PRs (30d)
- 282
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from torrust/torrust-tracker
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
torrust/torrust-tracker#3080 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
torrust/torrust-tracker#3069 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
torrust/torrust-tracker#3058 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
torrust/torrust-tracker#2978 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
torrust/torrust-tracker#2332 ·
Maintainers usually reply within 1 day
All issues in torrust/torrust-tracker
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
difficulty: easy docs help wanted tooling
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
-
bug help wanted ui
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
userFRM/egui-charts#4386 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
eliasstravik/herdr-projects#1605 · 1 comment ·