Skip to content

test(cluster): make the pipelining tests use a real cluster client - #794

Merged
vishal-bala merged 2 commits into
mainfrom
test/cluster-pipelining-client
Nov 11, 2026
Merged

vishal-bala merged 2 commits into
mainfrom
test/cluster-pipelining-client

Conversation

@vishal-bala

@vishal-bala vishal-bala commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The requires_cluster tests in tests/integration/test_cluster_pipelining.py never exercised what they claimed, and CI doesn't run them, so nobody noticed.

  • Three SearchIndex tests passed a bare redis://localhost:7001 URL. RedisVL only builds a cluster client when the URL or kwargs say so, so they got a plain Redis client, and load() raised MovedError as soon as a key hashed to another shard. test_cluster_load_with_ttl[None] passed only because its single key happened to land on the node it connected to. They now append ?cluster=true and assert the index holds a RedisCluster client.
  • test_cluster_pipeline_protocol_version_directly read REDIS_CLUSTER_URL with a default port (7000) the test cluster never listens on, and wrapped everything in except Exception: pytest.skip(...), so it always skipped. It now uses the redis_cluster_url fixture, is parametrised over default/RESP2/RESP3, and fails on a real failure.

Test-only change; no library code touched. This is groundwork for a nightly CI job that runs the cluster tests.

Reviewer Brief

Start here: tests/integration/test_cluster_pipelining.py, _create_cluster_index(). The three SearchIndex tests now build their index through it. It adds ?cluster=true to the URL and asserts that the index really holds a RedisCluster client, so these tests can no longer slip back onto a single-node client.

Where it could fail

  • tests/integration/test_cluster_pipelining.py:28: the isinstance check runs after create(), because the client is only built on first use. If the check ever fails, the index it just created is not dropped. The index name is unique to each test run, so the only cost is a stray index in the test container.

Not verified: CI skips every requires_cluster test, so none of these run there. They were run only against a local six-node redis:8.4 cluster (three primaries, three replicas) on macOS.

Beyond CI: All 8 cases in the file pass against that cluster under redis-py 8.1.0 and Python 3.13.9. With the URL reverted to the bare redis://localhost:7001 (and the new isinstance check removed), all four load() tests fail with MovedError raised from the plain Pipeline. So these tests do catch a single-node client.

Reviewed 0e6989f9 · Claude Code (claude-opus-5-5) · lenses: correctness, tests, Redis behaviour


Note

Low Risk
Test-only changes; no production code. Residual risk is flaky or environment-specific cluster tests if nightly CI differs from the author’s setup.

Overview
Cluster pipelining integration tests now force a real RedisCluster client and fail honestly.

SearchIndex-backed tests (batch load, batch_search, load with TTL) used to take a bare cluster node URL, so RedisVL could build a single-node Redis client and hit MovedError on shard routing—or pass by luck. They now use a cluster_index_url fixture (?cluster=true) and a shared _create_cluster_index() helper that runs create() and assert isinstance(index.client, RedisCluster) so the suite actually exercises cluster behavior.

test_cluster_pipeline_protocol_version_directly no longer reads REDIS_CLUSTER_URL with a wrong default port or wraps everything in try/except + pytest.skip. It uses the redis_cluster_url fixture, is parametrised over default / RESP2 / RESP3, and asserts get_protocol_version on a real pipeline, with cleanup in finally.

Reviewer brief note: If the isinstance assertion fails after create(), the index may be left behind until manual cleanup; names are per-test-run so impact is limited.

Not in CI: requires_cluster tests are still skipped on default CI; behavior matches the PR description.

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

Three SearchIndex tests passed a bare redis://localhost:7001 URL, so
RedisVL built a plain Redis client and load() raised MovedError as soon
as a key hashed to another shard. They now add ?cluster=true and assert
the index really holds a RedisCluster client.

test_cluster_pipeline_protocol_version_directly read REDIS_CLUSTER_URL
with a default port the test cluster never listens on, and skipped on
any exception, so it could never fail. It now uses the redis_cluster_url
fixture, is parametrised over default/RESP2/RESP3, and has no blanket
skip.
@vishal-bala vishal-bala added auto:patch Increment the patch version when merged auto:tests Add or improve existing tests and removed auto:patch Increment the patch version when merged labels Oct 30, 2026
vishal-bala added a commit that referenced this pull request Oct 30, 2026
Co-Authored-By: Claude <noreply@anthropic.com>
@vishal-bala
vishal-bala added this pull request to stack #797 October 30, 2026 10:57
@vishal-bala
vishal-bala removed this pull request from stack #797 October 30, 2026 12:39
@vishal-bala
vishal-bala added this pull request to stack #801 October 30, 2026 12:39
Co-Authored-By: Claude <noreply@anthropic.com>
@vishal-bala
vishal-bala marked this pull request as ready for review November 6, 2026 17:30

@limjoobin limjoobin 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.

LGTM! This correctly fixes the tests that were using a single-node client or silently skipping, so they now exercise a real RedisCluster client. I encountered the host.docker.internal topology-resolution issue locally, but that is addressed by #796.

@vishal-bala
vishal-bala merged commit 085f739 into main Nov 11, 2026
68 checks passed
@vishal-bala
vishal-bala deleted the test/cluster-pipelining-client branch November 11, 2026 09:29
@applied-ai-release-bot

Copy link
Copy Markdown

🚀 PR was released in v0.32.0 🚀

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

Labels

auto:tests Add or improve existing tests released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants