Skip to content

Keep MONITOR reproducibility tests on the configured Redis endpoint - #543

Merged
fcostaoliveira merged 3 commits into
masterfrom
fix/monitor-test-port
Sep 21, 2026
Merged

fcostaoliveira merged 3 commits into
masterfrom
fix/monitor-test-port

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

The MONITOR random reproducibility test configures the selected Redis endpoint on a temporary dictionary, discards it, and builds its benchmark from a fresh copy. On nondefault test ports memtier consequently connects to port 6379. TLS runs can fail against the wrong service, while plaintext runs can falsely pass by comparing two empty counter dictionaries from the intended Redis.

Pass the same configuration through the endpoint helper and RunConfig, require its port to equal the fixture port before launch (except Unix sockets), and require each run to record its full configured command budget before comparing counts.

Validation: on a dedicated password-protected nondefault port, a port guard rejects the original test's attempt to use 6379 before any connection. The fixed test passes on plaintext and TLS; both runs record identical nonempty counts [21, 25, 22, 13, 19], totaling 100. Independent review approved the routing and stronger oracle. No production code changes.

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🤖 Automated first-pass review — a human maintainer's review is still required before merge.

Thanks for this — went through it, the diagnosis looks right and I only have comments on the guard.

Traced it: add_required_env_arguments sets config['redis_process_port'] on the dict it's handed (tests/include.py:62), and RunConfig falls back to 6379 when that key is absent (tests/mb.py:18), so the shallow .copy() really did drop the port on the floor while silently keeping explicit_connect_args (nested dict, shared). And grepping the suite, this was the only add_required_env_arguments(..., .copy()) / RunConfig(..., .copy()) site, so nothing else is carrying the same bug.

On the port guard — I think the if wrapper is redundant. Now that the helper mutates the shared config_dict two lines above, the condition can only be true if someone re-adds a .copy(), which I assume is exactly the invariant you want pinned; but then the if is re-testing precisely what the env.assertEqual on the next line already asserts. Wouldn't a plain unconditional env.assertEqual(...) under if not env.isUnixSocket(): be the smaller diff and read more obviously as a pin?

Related: I may be wrong, but isn't the return {} worse than just falling through? If both runs take that path they each return {}, and the final env.assertEqual(counts_run1, counts_run2) then compares two empty dicts and passes — the same vacuous comparison this PR is removing. The earlier assertEqual still fails the test, so it's not a real hole, but it reintroduces the shape one line down. And since sum(counts.values()) == expected_requests already catches both the wrong-host case (nothing listening on 6379 → memtier_ok false) and the falsely-passing case (reads from the intended Redis come back empty → sum 0 ≠ 100), does the early return buy anything the sum assertion doesn't?

The count assertion itself is the strong part here and I'd keep it as-is — that's the assertion that actually would have failed on the old code, which is the bar PR#364 already met in this repo with a test that pins the invariant rather than a prose claim of manual testing. Worth noting the PR body's validation story ("a port guard rejects the original test's attempt to use 6379 before any connection") describes the guard firing against the pre-fix code; as committed it can't fire, so the standing regression pin is the count assertion, not the guard.

Nitpicking: the guard's message ("must reach RunConfig explicitly") reads like it's about RunConfig, but it fires before RunConfig is constructed — "must survive the helper" or similar would be closer to what it's checking.

Test-only and no production change, so nothing here blocks; I'd just collapse the guard before this merges.

(would file this as a comment, not a formal block)

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Addressed in f201790. The test now requires an explicit redis_process_port in the shared configuration before constructing RunConfig (except Unix sockets), so discarding the helper's mutation fails even on CI's default 6379. Removed the shallow copies and redundant nonempty assertion; expected command count comes from the configured request budget.

Verified the guard by injecting the original discarded-mutation behavior with fixture metadata ports 6379 and 48379: both fail before Benchmark.from_json is called. The corrected test also passes against a password-protected nondefault Redis endpoint over plaintext and TLS, recording all 100 commands in both runs.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

The guard now checks equality with the fixture's actual port and still stops before launching on mismatch. RLTest assertions accumulate failures rather than aborting immediately, so the early return is intentional: it prevents a failing guard from contacting an unrelated service. Both missing and wrong explicit ports were injected at fixture metadata 6379 and 48379; all four cases fail before benchmark construction.

I kept the repair local rather than removing RunConfig's existing default for all callers, which would change the contract used by unrelated CLI/configuration tests. The suite search found this discarded-copy bug only here. The shared configuration matches the surrounding fixtures; the PR description now describes that final implementation.

@fcostaoliveira
fcostaoliveira merged commit 830ddbe into master Sep 21, 2026
125 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant