Skip to content

Conversation

@jh1231223
Copy link

Fixes #4862

Summary
I addressed flakiness in TestPubSub::test_pubsub_combined_exact_pattern_and_sharded_one_client. The test occasionally reported an off-by-one result (e.g., 767/768). The root cause was key collisions across the randomly generated channel names for Exact, Pattern, and Sharded modes. When collisions occurred, dictionary entries were overwritten, reducing the number of distinct publishes and leading to a mismatched final count.

What changed

  • Exact: "{channel}:{rand}:{i}"

  • Pattern: "{pattern}:{rand}:{i}"

  • Sharded: "{same-shard}:{i}:{rand}" (no space after the colon)

This preserves shard grouping via {same-shard} and eliminates accidental overwrites without relaxing any assertions. The expected message count remains NUM_CHANNELS * 3.

Validation

python -m pytest -c /dev/null -q \
  tests/async_tests/test_pubsub.py \
  -k "test_pubsub_combined_exact_pattern_and_sharded_one_client" \
  --count=200 -s --maxfail=1

@jh1231223 jh1231223 requested a review from a team as a code owner October 16, 2025 08:04
Signed-off-by: Jessica Hsiao <[email protected]>
@jh1231223 jh1231223 force-pushed the fix-test_pubsub_combined_exact_pattern_and_sharded_one_client branch from 4fb13a6 to b14f737 Compare October 16, 2025 08:07
@xShinnRyuu
Copy link
Collaborator

Additional ask in ticket: #4862 (comment)

jh1231223 added a commit to jh1231223/valkey-glide that referenced this pull request Oct 27, 2025
…attern_and_sharded_one_client' into fix-pubsub-deterministic-channels

Merge valkey-io#4886 into valkey-io#4880 to combine flaky Pub/Sub test fixes

Includes fixes from fix-test_pubsub_combined_exact_pattern_and_sharded_one_client
into fix-pubsub-deterministic-channels as requested in issue valkey-io#4862.
Stabilizes all related Pub/Sub tests with unique channel names and proper sync.#
@jh1231223
Copy link
Author

Merged into #4880 as requested by the maintainer in this comment.
The fixes from this PR have been fully integrated into #4880 to consolidate all related flaky test updates in a single PR.

@jh1231223 jh1231223 closed this Oct 27, 2025
@jh1231223 jh1231223 deleted the fix-test_pubsub_combined_exact_pattern_and_sharded_one_client branch October 27, 2025 06:55
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.

[Python][Flaky Test] test_pubsub_combined_exact_pattern_and_sharded_one_client

2 participants