Skip to content

auto_discover Docker suite is flaky: 44-47 of 47 across identical runs #54

Description

@FAZuH

Found while verifying PR #52. Pre-existing, not caused by the harness fix, and confirmed by re-running the identical command on the pristine tree with the change stashed.

The observation

Across repeated runs of the same command, on the same tree, with no code change, the pass count varies: 47/47, then 46/47, then 44/47, with a different random subset failing each time. The most frequently hit is registration::container_id_in_consul_meta. The failures are not always the same tests, which points at shared state or timing rather than one broken assertion.

Why it matters

The suite is the only thing covering the auto_discover Docker paths, and its green is currently luck. Any claim that it passes is worth less than it looks on a given run. This is the same class of problem as the 19 vacuous tests in #44: a suite whose green is not earned.

Likely cause, not yet confirmed

docs/dev/testing.md and AGENTS.md both assert the Docker tests are single-threaded via --test-threads=1 "enforced by .cargo/config.toml". That enforcement does not exist. .cargo/config.toml contains only rustflags; there is no test-threads setting anywhere in the repo, and the host has 4 CPUs, so cargo's default parallelism applies. The suite has therefore been running tests concurrently all along, while sharing:

  • a single Consul HTTP port, 8500, reached through the mounted Docker socket
  • one shared image tag, lab-ops-auto-discover-test:latest
  • one fixed config path, /tmp/discovery.yaml, inside every test script

Any of those is enough to make concurrent tests interfere. The fixed /tmp/discovery.yaml lives inside the per-test container, so that one is probably fine; the shared Consul port and the shared image are not obviously so.

What to build

Decide the concurrency question first, then make the suite deterministic.

Acceptance criteria

  • Ten consecutive runs of cargo test -p lab-ops --test auto_discover --all-features on an unchanged tree all report the same result
  • The concurrency setting is real, lives in the repo rather than in a user-level cargo config, and is documented
  • AGENTS.md and docs/dev/testing.md no longer claim .cargo/config.toml enforces --test-threads=1
  • Not "fixed" by adding sleeps or retries. A flaky test is worse than no test, and papering over it hides the real interference.

Blocked by

None (can start immediately).

The --all-features question in #53 applies here too: on this host it is required, or the run reports 0 tests and exits green.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions