Repository navigation
Fail tests whose memtier runs get NOAUTH on a password-protected env - #863
Conversation
memtier counts error replies as completed requests and exits 0, so in the "TCP Plaintext with auth" CI cell a test whose memtier command line forgets --authenticate still passes while every request is answered -NOAUTH. Dropping the auth from test_sigpipe_immunity's command line, for example, passes with 79897 NOAUTH replies recorded by the server. When the env has a password, include.py now wraps each RLTest function test that takes an env. Before the test it reads errorstat_NOAUTH from INFO errorstats on every server of the env (each shard's master and its replicas), and after the test, even one that failed, it asserts that no count grew, naming the server and how many requests it answered NOAUTH. Checking the servers catches every client: Benchmark runs, hand-built Popen command lines and redis-py. RLTest has no per-test hook for function tests, so the guard wraps the target that RLTest's loader resolves before each test; include.py is imported while RLTest discovers the test files, before any test runs and before the --parallelism workers fork. It compares against the counts taken before the test rather than running CONFIG RESETSTAT, so the commandstats that tests assert on are left alone. A server that restarted during the test counts from zero, and one the env's password cannot reach is skipped. Tests that are unauthenticated on purpose opt out with @allow_noauth(reason). Only test_cli_fuzz_phase1's two #426 item 3 tests need it: they send memcache_text and memcache_binary to Redis on purpose, and memcache cannot AUTH. The other memcache-protocol runs against Redis are rejected before they connect, and the wrong-credential and fake-server tests do not talk to the env's servers. The password is now read one way, with env_password(env) (the RLTest node's "password"). test_retry_on_error and test_prometheus_redaction restore requirepass from it, and test_progress_interval, test_cluster_ask_asking and test_cli_validation_count_flags no longer append a second --authenticate that add_required_env_arguments() already adds. The replica clients that get_cluster_replica_connections() builds now carry that password too. Without it, on a password-protected env with replicas, every replica command was answered NOAUTH and swallowed, so test_read_preference_resp3 read 0 calls and failed. The replica shutdown in test_read_preference_resp3 and test_read_preference_failover also swallowed a NOAUTH reply to SHUTDOWN NOSAVE and still marked the replica dead, so RLTest never stopped it and a redis-server leaked after every such run. The new shutdown_nosave() reports success only once the server stops answering, and only then is the replica marked dead. test_harness_auth.py adds a table test of memtier_auth_args()'s skip rules (-a, --authenticate, userinfo in the last --uri, memcache in the last --protocol, no password) and tests of the guard against a fake env. Fixes #842 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. Reading errorstats on the server side instead of grepping memtier's stderr seems like the right call, since it also catches hand-built Popen lines and redis-py clients. The replica
The guard logic itself looks solid to me: the restart-to-zero handling, the check still running when the test fails, and failing instead of passing when no server can be read. The validation in the description covers the cases I'd want covered. Mostly I'd want the silent-disable question answered before this merges. (would file this as a comment, not a formal block) |
Follow-up to the NOAUTH guard (#842), from review. The guard passed without checking anything when it could read no server of the env before the test, for example after RLTest drift or a password mismatch. It now fails the test, listing each server and its error. A server that stops during the test, such as a replica a test shuts down on purpose, is still not a failure, but the guard now prints that it was not checked. It asserts only when a count grew. In VERBOSE CI logs every passing test used to print a "✅ (OK): 0 == 0 ... answered 0 request(s) -NOAUTH" line. The guard's connections and shutdown_nosave() now use bounded_client(): no redis-py retries and a 5 s socket timeout. A stopped server used to cost about 4.5 s of retry backoff per guard read, and a successful shutdown about 8 s. Both now return at once, a hung server can no longer block the guard, and redis-py no longer resends SHUTDOWN after the connection closes. Tests whose first parameter takes the env are wrapped even if they have more parameters, which is how RLTest decides to pass the env. test_harness_auth.py gains: - a check that RLTest's loader really wraps the tests it resolves (it fails if _install_noauth_guard() does nothing); - fake-connection tests of shutdown_nosave(): a NOAUTH or other error reply to SHUTDOWN, or a server that keeps answering PING, is not a stop; a closed connection followed by a refused PING is; - rows for no readable server, a server stopped mid-test, a restart back to 0 with no new NOAUTH, a passing test printing nothing, and a test with a defaulted second parameter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bounded_client only changed the pool's settings for new connections. The replica clients shutdown_nosave gets from the read-preference tests have already been used, and their pooled connections kept redis-py's default retry, so a refused SHUTDOWN still took about 4 s and a successful one about 8 s, and redis-py could resend the SHUTDOWN. Use the pool's set_retry, which also reaches its existing connections, and drop them so the next command reconnects with the socket timeout. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without pool.set_retry, a connection the client already opened keeps redis-py's 10 retries, and test_harness_auth.py did not notice. The new case puts such a connection in the pool and checks its retries are 0. Also correct the comment: open connections keep the socket timeout they were made with; only the retries reach them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7f1658c. Configure here.
_read_noauth caught every exception, so an RLTest API change, such as a getSlaveConnection that takes no index, would have left that server unchecked without a word. Catch only redis-py and socket errors, for a server that is down or refuses us, and let anything else fail the test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ds from RLTest bounded_client() and its test use Retry.get_retries() and ConnectionPool.set_retry(), which redis>=3.0.0 did not promise. Next to the RLTest pin, name the loader and replica APIs the guard relies on and the tests that fail if a pin move changes them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, answering the three points:
The TLS v1.2 cell on 56382cc lost its runner ("The hosted runner lost communication with the server") after 405 PASS and 0 FAIL. The new head reruns it. |
Instead of wrapping RLTest.loader.TestFunction.initialize, register the check as a test hook. add_test_hook() is new in the RLTest fork commit pinned here (RedisLabsModules/RLTest#262, on top of #253). The hook gets the test function, so @allow_noauth still opts a test out. test_guard_is_installed_in_rltest now runs a test through RLTest's hook runner and expects the guard to fail it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Following up on the RLTest hook suggestion: 3e00990 does it. RedisLabsModules/RLTest#262 adds |
73c10b7 keeps one copy of a test hook that a test file adds again each time RLTest re-imports it. memtier registers its hook from include.py, which is imported once, so it was not affected; this keeps the pin on the reviewed version of RedisLabsModules/RLTest#262. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
880af13 moves the RLTest pin to fork commit 73c10b7. Reviewers found that RLTest#262 only skipped a hook added a second time when it was the same function object, so a hook added at the top of a test file was added again each time RLTest re-imported the file. The hook now counts as the same when it has the same module and name, and a new flow test checks, through the runner, that it runs once per test. memtier wasn't affected, since |
…ctions 09176c8 matches a re-added test hook by module and name only when it is a top-level function, so distinct lambdas or closures are not merged. memtier's hook is a top-level function in include.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review summary for 47da15e. All 7 lenses approve (semantics, output, tests, lifecycle, interactions, maintainability, build). CI ran 15,875 tests with 0 failed. Every RLTest job installed Answering the updated review:
|

Fixes #842.
Problem
The "Single Endpoint: TCP Plaintext with auth" CI cell sets
REDIS_PASSWORD, but a test that forgets to authenticate memtier still passes there. memtier counts-NOAUTHerror replies as completed operations and exits 0. For example, dropping auth fromtest_sigpipe_immunity's command line on master still passes, while the server records 79,897 NOAUTH replies.Change
NOAUTH guard (
tests/include.py):errorstat_NOAUTHon every server of the env: each shard's master and each replica. The counts are read before the test, and the test fails if any count grew, even if the test itself already failed. The message names the server and how many requests it answered-NOAUTH.CONFIG RESETSTAT: comparing against the starting counts leaves the commandstats that tests assert on unchanged.include.pyregisters the check withRLTest.add_test_hook(), which runs it around every function test that takes the env. The hook is new in the pinned RLTest fork commit and proposed upstream as Add add_test_hook() to run a hook around each function test RedisLabsModules/RLTest#262. The pin also keeps Fixed build for tls v1.3 on openssl v1.0.2. Added CI check #253's cluster-aware replicas.@allow_noauth(reason), with a required reason. Only the twotest_cli_fuzz_phase1tests that send memcache to Redis on purpose use it, because memcache cannot AUTH.One password reader: a new
env_password(env)feedsmemtier_auth_args(), the password restores intest_retry_on_errorandtest_prometheus_redaction, the skip intest_cli_fuzz_phase1, and the replica clients.test_progress_intervalandtest_cluster_ask_askingno longer pass--authenticatetwice, andtest_cli_validation_count_flagsdrops its own copy, becauseadd_required_env_arguments()already adds it.Replica helpers. The guard surfaced these on its own:
get_cluster_replica_connections()created replica clients without the password. WithOSS_CLUSTER_REPLICAS=1and a password, every replica command got NOAUTH, and that error was swallowed, sotest_read_preference_resp3.pyfailed 4 assertions._stop_one_replica()intest_read_preference_resp3.pyandtest_read_preference_failover.pytreated anyConnectionErrorfromSHUTDOWN NOSAVEas success. NOAUTH is a subclass of that error, so the replica was marked dead in RLTest while still running, and a redis-server leaked after every password run. A newshutdown_nosave()reports success only once the server stops answering.Table test:
tests/test_harness_auth.pyhas 21 rows ofmemtier_auth_args()skip rules and tests of the guard against a fake env.Validation
test_sigpipe_immunity, master passes and this PR fails with "shard 1 master answered 77040 request(s) -NOAUTH".memtier_auth_args()returning nothing, the issue's 148-test file set has 23 failures on master and 90 with the guard, including all 27test_prometheustests.test_cli_validation_read_preference.pyis left out because it hard-codes-p 6379): withREDIS_PASSWORDonly the memcache-text test failed, and it is now opted out; without a password there were 0 failures. On the final head,test_harness_auth.py(with and without a password), 8 files standalone with a password (84/84, 3 by-design skips) andtest_reconnections.pyover a Unix socket with a password (32/32) pass.test_read_preference_resp3.pyandtest_read_preference_failover.pyunderOSS_CLUSTER_REPLICAS=1 SHARDS=3, with and without a password, give 5 passes and 1 by-design skip, with no leaked redis-server.Follow-up after review:
test_harness_auth.pyruns a test through RLTest's hook runner and checks that the guard fails it.shutdown_nosave()'s connections have redis-py retries off, including connections the client already has open, and a 5 s socket timeout (connections already open keep the one they were made with, which is redis-py's default of 5 s). A refused or successful SHUTDOWN on a replica client the test has already used now returns at once instead of after 4–8 s of retry backoff, and redis-py no longer resends it. The 3-shard replica failover file with a password takes 78 s instead of 132 s.shutdown_nosave(), a restarted server, and a test with extra parameters.Limits
add_test_hook()(RLTest#262) and the indexedgetSlaveConnection()(RLTest#253).test_requirements.txtsays so next to the pin, and two harness tests fail if a pin move drops either.CONFIG RESETSTATduring a test clears errorstats and hides NOAUTH replies before it.--test,test_benchmark_logging.pyhas no guard because it doesn't importinclude.py; it talks to no server. In the full suite the guard is always installed.Test-only change; no memtier code is touched.
🤖 Generated with Claude Code
Note
Low Risk
Changes are confined to the RLTest harness and dependencies; production memtier code is untouched, with moderate complexity in the global test hook and RLTest pin.
Overview
Fixes #842: on password-protected CI, memtier can exit 0 while every request gets
-NOAUTH, so tests that omit auth still pass.NOAUTH guard registers an RLTest hook that snapshots
errorstat_NOAUTHon every shard master and replica before each test and fails if any count rises. Tests can opt out with@allow_noauth(reason)(used for intentional unauthenticated memcache-to-Redis cases).env_password(env)centralizes readingREDIS_PASSWORD/--oss_password; several suites drop duplicate manual--authenticatewiring and rely onadd_required_env_arguments()/memtier_auth_args()instead.Related harness fixes exposed while enabling the guard: cluster replica redis-py clients now authenticate;
shutdown_nosave()only reports success after the server stops answering (avoids treating NOAUTHSHUTDOWNas a killed replica and leaking processes);bounded_client()disables redis-py retries for guard/shutdown paths. Newtest_harness_auth.pytable-tests auth args and guard behavior.test_requirements.txtbumps redis-py ≥6.0 and the RLTest pin foradd_test_hook(and existing cluster-replica support).Test-only; no memtier binary changes.
Reviewed by Cursor Bugbot for commit 47da15e. Bugbot is set up for automated code reviews on this repo. Configure here.