Skip to content

Increasing test coverage for PubSub.#4076

Open
petyaslavova wants to merge 3 commits into
masterfrom
ps_add_pubsub_e2e_tests
Open

Increasing test coverage for PubSub.#4076
petyaslavova wants to merge 3 commits into
masterfrom
ps_add_pubsub_e2e_tests

Conversation

@petyaslavova

@petyaslavova petyaslavova commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Adding tests in the following areas:

  • integration tests
  • scenario tests

Note

Medium Risk
Touches redis/asyncio cluster 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. ClusterPubSub adds _ensure_cluster_initialized() and calls it from ssubscribe, sunsubscribe, and execute_command so 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, duplicate ssubscribe, 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 new test_scenario/test_pubsub.py runs 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.

@petyaslavova petyaslavova added the maintenance Maintenance (CI, Releases, etc) label May 21, 2026
@jit-ci

jit-ci Bot commented May 21, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

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),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5fe864d. Configure here.

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

Labels

maintenance Maintenance (CI, Releases, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant