Skip to content

Fix failing sort command test caused by data interference through shared key - #3724

Merged
tishun merged 2 commits into
redis:mainfrom
atakavci:ali/sortTestsFix
Apr 16, 2026
Merged

tishun merged 2 commits into
redis:mainfrom
atakavci:ali/sortTestsFix

Conversation

@atakavci

@atakavci atakavci commented Apr 16, 2026 •

Copy link
Copy Markdown
Collaborator

Sort commands test (SortCommandIntegrationTests.sortGet in particular) consistently fails on the pipeline, while there is no issue with local runs and debug sessions.

Error:  Tests run: 12, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.060 s <<< FAILURE! -- in io.lettuce.core.commands.SortCommandIntegrationTests
Error:  io.lettuce.core.commands.SortCommandIntegrationTests.sortGet -- Time elapsed: 0.005 s <<< FAILURE!
org.opentest4j.AssertionFailedError: 

expected: ["foo", "bar"]
 but was: ["bar"]
	at sun.reflect.GeneratedConstructorAccessor108.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at io.lettuce.core.commands.SortCommandIntegrationTests.sortGet(SortCommandIntegrationTests.java:112)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at java.util.ArrayList.forEach(ArrayList.java:1259)

Turns out it always fails due to missing first item in the relevant list, issued in the test, which suggests the test data is affected by some other test/component in the env.

    @Test
    void sortGet() {
        redis.rpush(key, "1", "2");
        redis.set("obj_1", "foo");
        redis.set("obj_2", "bar");
        assertThat(redis.sort(key, get("obj_*"))).isEqualTo(list("foo", "bar"));
    }

To avoid this, replacing the exsiting common key(from base class) with a distinct one looks like the quick fix.

For the long term, all async operations that changes data as part of test requirements should be tracked and either awaited to ensure completion before assertions, or rolled back after the test to leave the shared state clean for subsequent tests.


Note

Low Risk
Test-only change that only affects key naming; no production code or behavior is modified.

Overview
Fixes flaky SortCommandIntegrationTests by switching the test data key from the shared TestSupport.key constant to a dedicated per-test class key ("sort-command-key"), reducing the chance of interference from other tests running in the same Redis instance.

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

@tishun
tishun merged commit 181a51d into redis:main Apr 16, 2026
18 of 21 checks passed
@tishun tishun mentioned this pull request Apr 16, 2026
4 tasks done
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.

2 participants

⌂ 换网址