Keep `figment::Jail` tests from changing the environment other tests see
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with the full specification in docs/issues/open/, then inspect the Jail tests under packages/configuration/src and audit finding G1 in src/bootstrap/config.rs. Reproduce whether non-Jail tests observe changed PATH, TMPDIR, or current directory, then agree on the isolation design with the maintainer. Done means the tests are isolated, the G1/G2 audit entries are accurate, and the reproduction no longer shows interference.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Parent EPIC: #2392
Goal
No test of the torrust-tracker-configuration lib test binary sees an environment or a current directory that another test changed. Today the tests that use figment::Jail change both for the whole process while they run, and the tests that do not use Jail run at the same time, against rule 5 of the EPIC (no process-global changes from a test that shares its process with other tests).
Background
The shared-resource audit (#2394) recorded this resource as finding G2 and classified it as isolated, because Jail serializes on its own global lock and restores the state. #2907 found that the classification is wrong.
What figment::Jail (figment 0.10.19) does:
Jail::expect_withtakes a private global lock, creates a temporary directory and makes it the current directory of the process.jail.clear_env()removes every environment variable of the process,TMPDIRandPATHincluded.jail.set_env()sets one.- When the jail is dropped it restores the variables and the current directory.
The lock serializes only the tests that use Jail. The environment and the current directory belong to the process, and cargo test runs the tests of one binary on several threads. A test of the same binary that does not use Jail and reads the environment or resolves a relative path while a jail is active sees the jail's state.
Jail is used only in packages/configuration/src: 51 Jail::expect_with calls, 18 clear_env() calls and 14 set_env() calls. The same binary has 159 tests; 107 of them run outside a jail.
What #2907 observed: in a run of the whole package with a fresh TMPDIR, only one of the two test_config_<uuid>.toml files was there. The other most likely went to /tmp, because TMPDIR was unset when the test read it; #2907 inferred this from the code.
A second concern: since the 2024 edition, which this workspace uses, Rust marks std::env::set_var and std::env::remove_var as unsafe, because changing the environment while another thread reads it is not safe on every platform. The jail does both while other test threads run.
Approach
- Reproduce the interference with a probe test that does not use
Jailand readsPATHandTMPDIRwhile the jail tests run. - Isolate the tests with the design the maintainer chooses. Candidates: the non-
Jailtests that read the environment move into a jail; theJailtests move to their own test binary; the loading code takes its environment from a provider that tests replace (a production change, out of scope unless widened). - Recheck audit finding G1 (
src/bootstrap/config.rs,std::env::set_varin tests) with the same question. - Correct the G2 row (and G1, if the recheck changes it) of the audit inventory.
Out of scope: how production code loads the configuration, replacing figment, and the work of #2907, #2924 and #2925.
Tasks
- Reproduce and recheck G1.
- Decide the design with the maintainer.
- Isolate the tests.
- Correct the audit inventory.
- Recheck with the same reproduction.
The full specification is added to docs/issues/open/ by a spec-only pull request.
- Lingua principale
- Rust
- Stelle
- 532
- Fork
- 56
- Merge medio
- 11h 20m
- PR unite (30g)
- 282
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di torrust/torrust-tracker
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
torrust/torrust-tracker#3080 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
torrust/torrust-tracker#3069 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
torrust/torrust-tracker#3058 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
torrust/torrust-tracker#2978 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
torrust/torrust-tracker#2332 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di torrust/torrust-tracker
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
difficulty: easy docs help wanted tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
-
bug help wanted ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
userFRM/egui-charts#4386 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
eliasstravik/herdr-projects#1605 · 1 commento ·