Skip to content

Conversation

@orbin123
Copy link

@orbin123 orbin123 commented Dec 18, 2025

Meilisearch v1.30.0 removed the sharding flag in favor of a new Leader/Follower High Availability model. This commit updates the test suite to align with these breaking changes.

Pull Request

Related issue

Fixes #1183

What does this PR do?

This PR updates the SDK test suite to support the breaking networking changes introduced in Meilisearch v1.30.0.

Specifically, v1.30 removed the sharding boolean flag from the /network endpoint in favor of the new Leader/Follower High Availability model. The existing tests were failing because they explicitly sent sharding: true in payloads and asserted its presence in responses.

PR checklist

Please check if your PR fulfills the following requirements:

  • Tests: Removed deprecated sharding: true usage in
    test_client_network.py and test_client_sharding.py`
  • Utilities: Renamed the test utility disable_sharding to
    reset_network_config and updated its implementation to clear the remotes and leader configuration (sending remotes: {} and leader: None) instead of attempting to toggle sharding off.
  • Assertions: Removed assertions checking for the existence of the sharding key in API responses.

These changes ensure the SDK tests pass successfully when run against a Meilisearch v1.30+ instance.

Summary by CodeRabbit

  • Chores
    • Updated test utilities to use a new reset-based network configuration approach.
  • Tests
    • Simplified network-related tests by removing explicit sharding checks and relying on the updated reset behavior.
    • Adjusted test teardown to use the new reset mechanism for consistent network cleanup.

✏️ Tip: You can customize this high-level summary in your review settings.

Meilisearch v1.30.0 removed the sharding flag in favor of a new Leader/Follower High Availability model. This commit updates the test suite to align with these breaking changes.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Walkthrough

This change renames the test helper disable_sharding to reset_network_config and updates it to use the new Meilisearch network model (remotes and leader), with corresponding import and call-site updates and removal of sharding assertions in affected tests.

Changes

Cohort / File(s) Summary
Test utility definition
tests/test_utils.py
Function renamed from disable_sharding to reset_network_config. Body updated to call client.add_or_update_networks(body={"remotes": {}, "leader": None}) instead of setting sharding: False.
Test files using the utility
tests/client/test_client_multi_search_meilisearch.py, tests/client/test_client_network.py, tests/client/test_client_sharding.py
Imports changed from disable_shardingreset_network_config. Teardown/cleanup calls updated from disable_sharding(client)reset_network_config(client).
Network test assertion
tests/client/test_client_network.py
Removed sending and asserting the deprecated sharding flag from the test body and response validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Pay attention to tests/test_utils.py to ensure the new network payload matches intended Meilisearch v1.30 semantics.
  • Verify removed sharding assertions do not hide other behavior changes in tests/client/test_client_network.py.

Poem

🐰 A tiny hop, a network tune,
Sharding gone beneath the moon,
Remotes are cleared, the leader sleeps,
Tests reset where order keeps,
I nibble logs and hum a tune. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adapting network tests for Meilisearch v1.30 HA changes, which aligns with the primary objective of updating tests to handle the deprecated sharding flag and new leader/follower model.
Linked Issues check ✅ Passed The PR successfully addresses the core coding requirements: removes sharding flag usage, updates test utilities to use new leader/follower semantics (remotes and leader keys), and removes related assertions matching #1183 objectives.
Out of Scope Changes check ✅ Passed All changes are directly scoped to adapting tests and utilities for v1.30 compatibility; no unrelated modifications to production code, documentation, or unrelated test files are present.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbcfbcc and e265f0e.

📒 Files selected for processing (2)
  • tests/client/test_client_multi_search_meilisearch.py (2 hunks)
  • tests/client/test_client_sharding.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/client/test_client_sharding.py (2)
tests/test_utils.py (1)
  • reset_network_config (37-38)
tests/conftest.py (1)
  • client (15-16)
tests/client/test_client_multi_search_meilisearch.py (1)
tests/test_utils.py (1)
  • reset_network_config (37-38)
🔇 Additional comments (4)
tests/client/test_client_multi_search_meilisearch.py (2)

5-5: LGTM! Import correctly updated to new helper.

The import change from disable_sharding to reset_network_config is correct and aligns with the renamed utility function.


114-114: LGTM! Network config cleanup correctly updated.

The call to reset_network_config(client) properly cleans up the network configuration using the new v1.30 semantics (clearing remotes and leader instead of toggling sharding).

tests/client/test_client_sharding.py (2)

4-4: LGTM! Import correctly updated to new helper.

The import change from disable_sharding to reset_network_config is correct and consistent with the renamed utility function.


35-35: LGTM! Network config cleanup correctly updated.

The call to reset_network_config(client) properly resets the network configuration using the new v1.30 semantics. The past review concern about asserting on the deprecated response["sharding"] field has been addressed—no such assertion exists in the current code.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/client/test_client_multi_search_meilisearch.py (1)

85-102: Critical: Remove deprecated sharding flag from request body.

The test still sends "sharding": True at line 88, which is incompatible with Meilisearch v1.30+. According to the PR objectives, v1.30 removed the sharding boolean from the /network endpoint in favor of the leader/follower HA model.

This will cause the test to fail against v1.30+ instances, defeating the purpose of this PR.

🔎 Apply this diff to remove the deprecated sharding flag:
     resp = client.add_or_update_networks(
         {
             "self": REMOTE_MS_1,
-            "sharding": True,
             "remotes": {
                 REMOTE_MS_1: {
                     "url": "http://ms-1235.example.meilisearch.io",
                     "searchApiKey": "xxxxxxxx",
                     "writeApiKey": "xxxxxxxx",
                 },
                 REMOTE_MS_2: {
                     "url": "http://ms-1255.example.meilisearch.io",
                     "searchApiKey": "xxxxxxxx",
                     "writeApiKey": "xxxxxxxx",
                 },
             },
         }
     )
tests/client/test_client_sharding.py (1)

11-21: Critical: Remove deprecated sharding flag from test options.

The test still includes "sharding": True at line 20, which is incompatible with Meilisearch v1.30+. The PR description explicitly states that sharding usage was removed from test_client_sharding.py, but this flag remains.

This will cause the test to fail against v1.30+ instances.

🔎 Apply this diff to remove the deprecated sharding flag:
     options = {
         "self": instance_name,
         "remotes": {
             instance_name: {
                 "url": BASE_URL,
                 "searchApiKey": "search-key-1",
                 "writeApiKey": "write-key-1",
             }
         },
-        "sharding": True,
     }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5c6fe3 and 83aed44.

📒 Files selected for processing (4)
  • tests/client/test_client_multi_search_meilisearch.py (2 hunks)
  • tests/client/test_client_network.py (2 hunks)
  • tests/client/test_client_sharding.py (2 hunks)
  • tests/test_utils.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
tests/client/test_client_multi_search_meilisearch.py (2)
tests/test_utils.py (1)
  • reset_network_config (37-38)
tests/conftest.py (1)
  • client (15-16)
tests/client/test_client_network.py (2)
tests/test_utils.py (1)
  • reset_network_config (37-38)
tests/conftest.py (1)
  • client (15-16)
tests/client/test_client_sharding.py (2)
tests/test_utils.py (1)
  • reset_network_config (37-38)
tests/conftest.py (1)
  • client (15-16)
🔇 Additional comments (7)
tests/test_utils.py (1)

37-38: LGTM! Clean migration to the new network configuration model.

The function rename from disable_sharding to reset_network_config is appropriate, and the body correctly resets the network configuration using the new v1.30 HA model semantics (remotes and leader fields).

tests/client/test_client_multi_search_meilisearch.py (2)

5-5: LGTM! Import correctly updated.

The import has been properly updated to use reset_network_config instead of disable_sharding.


115-115: LGTM! Cleanup correctly updated.

The teardown call has been properly updated to use reset_network_config(client).

tests/client/test_client_network.py (2)

4-4: LGTM! Import correctly updated.

The import has been properly updated to use reset_network_config instead of disable_sharding.


16-40: LGTM! Test correctly updated for v1.30 network model.

The test body no longer includes the deprecated sharding flag, and the assertions no longer check for it in the response. The teardown correctly uses reset_network_config(client).

tests/client/test_client_sharding.py (2)

4-4: LGTM! Import correctly updated.

The import has been properly updated to use reset_network_config instead of disable_sharding.


37-37: LGTM! Cleanup correctly updated.

The teardown call has been properly updated to use reset_network_config(client).

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/client/test_client_sharding.py (1)

11-21: Critical: Remove deprecated sharding field from request body.

The test still sends "sharding": True (line 20) to the API in the options dict. According to the PR objectives and Meilisearch v1.30 changes, this field is no longer supported and should be removed from the request body, not just from assertions.

🔎 Apply this diff to remove the deprecated field:
     options = {
         "self": instance_name,
         "remotes": {
             instance_name: {
                 "url": BASE_URL,
                 "searchApiKey": "search-key-1",
                 "writeApiKey": "write-key-1",
             }
         },
-        "sharding": True,
     }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83aed44 and dbcfbcc.

📒 Files selected for processing (1)
  • tests/client/test_client_sharding.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/client/test_client_sharding.py (2)
tests/test_utils.py (1)
  • reset_network_config (37-38)
tests/conftest.py (1)
  • client (15-16)
🔇 Additional comments (2)
tests/client/test_client_sharding.py (2)

4-4: LGTM: Import updated correctly.

The import statement correctly reflects the renamed utility function reset_network_config.


36-36: LGTM: Cleanup call updated correctly.

The function call correctly uses the renamed reset_network_config utility, which properly resets the network configuration using the new v1.30 semantics (remotes: {} and leader: None).

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.

[v1.30.0] Adopt breaking sharding / network changes introduced in Meilisearch

1 participant