Skip to content

Improve CI pipeline stability - #3740

Merged
a-TODO-rov merged 3 commits into
redis:mainfrom
atakavci:ali/improveTestStability
May 15, 2026
Merged

a-TODO-rov merged 3 commits into
redis:mainfrom
atakavci:ali/improveTestStability

Conversation

@atakavci

@atakavci atakavci commented May 7, 2026 •

Copy link
Copy Markdown
Collaborator

Removes flakiness from a set of integration tests that were failing non-deterministically in CI. Test-only changes.

PipeliningIntegrationTests, ReactiveConnectionIntegrationTests, CodecFailureIntegrationTests

@BeforeEach ran connection.async().flushall() fire-and-forget, so a test body could start against a keyspace that wasn't yet flushed. Switched to the sync form.

CommandListenerIntegrationTests

Listener callbacks fire on the Netty I/O thread after the sync caller has already been unblocked by command.complete(...), so the eager hasSize(...) assertions ran before the lists were populated. Replaced with Wait.untilEquals(...) polling.

AdvancedClusterClientIntegrationTests.randomKey, AdvancedClusterReactiveIntegrationTests.randomKey

RANDOMKEY is dispatched to a randomly-picked partition, but the test only seeded two nodes — so a pick on an unseeded node returned null and failed the assertion. Now seeds every master partition with a slot-targeted key and asserts the result is in the seeded set.

CodecFailureIntegrationTests.testCommandsWithCustomCodecRuntimeException

reconnects[0] == 1 was brittle because the EventBus is JVM-singleton (cross-connection contamination), ConnectionWatchdog publishes one event per retry (retry inflation), and event delivery is async (race with the assertion). Now filters events by the connection's epId (resolved via Delegating.unwrap() to the underlying Endpoint), polls with Wait.untilTrue(>= 1), and disposes the subscription on completion.

RediSearchAdvancedConceptsIntegrationTests.testNoStemmingOption

The first search against a freshly-populated index could race RediSearch's keyspace-notification indexer and observe count == 0. Wrapped each first-search-after-fresh-index in a Wait.untilTrue/untilEquals poll on the same predicate; subsequent searches keep their direct assertions.


Note

Low Risk
Test-only changes that reduce timing-related flakiness by switching to synchronous setup and adding polling around async/eventual-consistency behaviors; low product risk but could mask real regressions if timeouts are too lenient.

Overview
Improves integration test stability by removing race conditions and eventual-consistency assumptions.

Several tests now use synchronous FLUSHALL in @BeforeEach to ensure a clean keyspace before assertions, and CommandListenerIntegrationTests replaces immediate event-count assertions with Wait.untilEquals(...) polling to account for listener callbacks running asynchronously.

Cluster randomkey() tests now seed every master partition with a slot-targeted key and assert the returned key is from the seeded set, avoiding null results from randomly chosen empty partitions. Codec failure tests filter ReconnectAttemptEvents by the connection endpoint id, poll for reconnect delivery, and dispose the event subscription to avoid cross-test/event-bus contamination. RediSearch stemming tests poll initial queries to absorb indexer lag after writes.

Reviewed by Cursor Bugbot for commit b84803d. Bugbot is set up for automated code reviews on this repo. Configure here.

@atakavci
atakavci requested review from a-TODO-rov, Copilot and tishun May 7, 2026 08:11
@atakavci atakavci self-assigned this May 7, 2026
@atakavci atakavci added the type: techdebt Things that can be improved or refactored label May 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves CI stability by removing several sources of test flakiness in Lettuce integration tests, primarily by ensuring database flushes complete before tests run, and by waiting/polling for asynchronous side effects (listeners, RediSearch indexing, cluster routing) before asserting.

Changes:

  • Replace fire-and-forget flushall() calls with synchronous flushes in test setup to ensure a clean keyspace.
  • Make async listener/indexing assertions deterministic by polling with Wait.until…().waitOrTimeout().
  • Stabilize cluster RANDOMKEY tests by seeding keys across all master partitions instead of only two nodes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/test/java/io/lettuce/core/search/RediSearchAdvancedConceptsIntegrationTests.java Poll initial RediSearch queries to tolerate brief indexing lag.
src/test/java/io/lettuce/core/ReactiveConnectionIntegrationTests.java Use synchronous flushall() in setup to avoid race with test bodies.
src/test/java/io/lettuce/core/protocol/CodecFailureIntegrationTests.java Make reconnect-event assertion resilient by filtering events per connection and polling.
src/test/java/io/lettuce/core/PipeliningIntegrationTests.java Use synchronous flushall() in setup to avoid race with test bodies.
src/test/java/io/lettuce/core/CommandListenerIntegrationTests.java Replace eager list-size assertions with polling to wait for listener callbacks.
src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java Seed all master partitions and assert randomkey() returns a seeded key.
src/test/java/io/lettuce/core/cluster/AdvancedClusterClientIntegrationTests.java Seed all master partitions and assert randomkey() returns a seeded key.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit b84803d. Configure here.

@a-TODO-rov

Copy link
Copy Markdown
Collaborator

LGTM. will be merging it.

@a-TODO-rov
a-TODO-rov merged commit d7f83cf into redis:main May 15, 2026
34 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: techdebt Things that can be improved or refactored

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址