Increasing test coverage for PubSub.#4076
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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 5fe864d. Configure here.
| def make_pubsub_db_config(base_config, test_name): | ||
| db_config = copy.deepcopy(base_config) | ||
| db_config["shards_count"] = PUBSUB_TEST_SHARDS_COUNT | ||
| return db_config |
There was a problem hiding this comment.
Unused parameter in database config factory function
Low Severity
make_pubsub_db_config accepts a test_name parameter (called with request.node.name from the fixture) but never uses it. This looks like it was intended to make the database name unique per test (e.g., incorporating the test name into db_config["name"]), but that logic was never implemented. All tests end up sharing the same database name from the base config, which works for sequential execution but could cause issues if tests ever run in parallel.
Reviewed by Cursor Bugbot for commit 5fe864d. Configure here.
| return request.config.getoption("--cluster-endpoint-name") or os.getenv( | ||
| "REDIS_PUBSUB_ENDPOINT_NAME", | ||
| os.getenv("REDIS_CLUSTER_ENDPOINT_NAME", DEFAULT_PUBSUB_ENDPOINT_NAME), | ||
| ) |
There was a problem hiding this comment.
Fixture overrides pubsub env var with cluster option
Low Severity
The pubsub_endpoint_name fixture reads --cluster-endpoint-name as its first choice, which means the dedicated REDIS_PUBSUB_ENDPOINT_NAME env var is silently ignored whenever that CLI option is set. This appears to be a copy-paste from cluster_endpoint_name. Users who configure separate cluster and pubsub endpoints via env vars will find the pubsub setting overridden when --cluster-endpoint-name is also provided.
Reviewed by Cursor Bugbot for commit 5fe864d. Configure here.


Adding tests in the following areas:
Note
Medium Risk
Touches
redis/asynciocluster Pub/Sub command routing by forcing lazy cluster initialization before resolving shard slots, which could affect connection/setup timing in production. Most of the PR is new test coverage, but it exercises real cluster-fault scenarios that may be flaky or environment-sensitive.Overview
Async cluster Pub/Sub now guarantees lazy initialization before sharded operations.
ClusterPubSubadds_ensure_cluster_initialized()and calls it fromssubscribe,sunsubscribe, andexecute_commandso shard-slot resolution doesn’t run against an uninitialized slots cache.Pub/Sub test coverage is significantly expanded. New/updated tests cover RESP2 subscriber-mode command rejection, server-side cleanup on
close/aclose, sharded Pub/Sub delivery semantics (multiple subscribers, duplicatessubscribe,sunsubscribe), and connection lifecycle behavior in cluster.New scenario-test utilities and Pub/Sub recovery scenarios are added. Shared cluster/key helpers are extracted into
common_scenario_helpers.py, scenario config gains a dedicated Pub/Sub endpoint fixture, fault-injector action types are extended, and a newtest_scenario/test_pubsub.pyruns sharded Pub/Sub through migrations and injected infra failures (sync + asyncio) while asserting post-recovery delivery ratios.Reviewed by Cursor Bugbot for commit 71b3da3. Bugbot is set up for automated code reviews on this repo. Configure here.