Part of the whole-repo test-suite audit (2026-09-30). Cuts 330 lines of copy-paste and 144 seconds of wall clock.
What to build
Every auto_discover integration test bootstrapping its harness through the existing helper, and waiting on a poller instead of a fixed sleep.
Findings
- 18 hand-rolled ~30-line bootstraps.
tests/auto_discover/recovery.rs inlines the consul + dummy0 + natmap + cat > /tmp/discovery.yaml + auto-discover block ten times (rg -c "cat > /tmp/discovery.yaml" tests/auto_discover/recovery.rs returns 10; consul agent -dev appears seven times). tests/auto_discover/forwarding.rs inlines the consul + natmap pair seven times, and startup_race.rs:17-49 inlines the whole thing once. new_format_setup_with_defaults_ext at tests/auto_discover/mod.rs:114 and new_format_setup at :110 already emit exactly that block, and 32 tests use them. There is no tests/common/ because mod.rs already is it; the copy-paste bypasses it.
- 160 fixed sleeps, 308 seconds of unconditional wait, across the
tests/ tree. 36 of them are sleep 4 waiting for a Docker event to reach Consul. wait_for_consul_service at mod.rs:166 polls for exactly that condition and is used by only three tests. tests/natmap_docker.rs adds 39 copies of for i in $(seq 1 20); do [ -S /tmp/ns ] && break; sleep 0.2; done; extract one wait_for_socket helper.
- A shutdown-flush race.
tests/natmap_docker.rs:287,309 send kill -INT $DAEMON_PID and then poll [ -S /tmp/ns ], but the socket already exists, so the loop breaks on its first iteration and the flush assertion races the shutdown. Poll kill -0 $DAEMON_PID instead.
- A duplicate test.
tests/auto_discover/recovery.rs:411 remove_all_services_clean_slate and :266 remove_service_from_config_stale_deregistered are the same test: both kill the daemon, write services: {}, run sync, and assert the service is gone. Merge into one.
Acceptance criteria
Blocked by
None (can start immediately).
Note: run the auto_discover integration suite deliberately, not as a side effect.
Part of the whole-repo test-suite audit (2026-09-30). Cuts 330 lines of copy-paste and 144 seconds of wall clock.
What to build
Every auto_discover integration test bootstrapping its harness through the existing helper, and waiting on a poller instead of a fixed sleep.
Findings
tests/auto_discover/recovery.rsinlines the consul + dummy0 + natmap +cat > /tmp/discovery.yaml+ auto-discover block ten times (rg -c "cat > /tmp/discovery.yaml" tests/auto_discover/recovery.rsreturns 10;consul agent -devappears seven times).tests/auto_discover/forwarding.rsinlines the consul + natmap pair seven times, andstartup_race.rs:17-49inlines the whole thing once.new_format_setup_with_defaults_extattests/auto_discover/mod.rs:114andnew_format_setupat:110already emit exactly that block, and 32 tests use them. There is notests/common/becausemod.rsalready is it; the copy-paste bypasses it.tests/tree. 36 of them aresleep 4waiting for a Docker event to reach Consul.wait_for_consul_serviceatmod.rs:166polls for exactly that condition and is used by only three tests.tests/natmap_docker.rsadds 39 copies offor i in $(seq 1 20); do [ -S /tmp/ns ] && break; sleep 0.2; done; extract onewait_for_sockethelper.tests/natmap_docker.rs:287,309sendkill -INT $DAEMON_PIDand then poll[ -S /tmp/ns ], but the socket already exists, so the loop breaks on its first iteration and the flush assertion races the shutdown. Pollkill -0 $DAEMON_PIDinstead.tests/auto_discover/recovery.rs:411 remove_all_services_clean_slateand:266 remove_service_from_config_stale_deregisteredare the same test: both kill the daemon, writeservices: {}, runsync, and assert the service is gone. Merge into one.Acceptance criteria
tests/auto_discover/writes a discovery config inlinerg -c "sleep 4" tests/finds no unconditional four-second wait for a Consul service.cargo/config.toml; do not rely on that for correctness.cargo test -p lab-ops --test auto_discoverpassesBlocked by
None (can start immediately).
Note: run the auto_discover integration suite deliberately, not as a side effect.