Increase timeout window when awaiting tasks#1240
Conversation
📝 WalkthroughWalkthroughDocker build environment upgraded to python:3.9-slim-trixie with uv v0.11.19, and test fixtures/methods now enforce explicit task timeouts to support Meilisearch v1.46.0 compatibility. ChangesMeilisearch v1.46.0 test suite compatibility
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 (1)
tests/conftest.py (1)
77-199:⚠️ Potential issue | 🟠 MajorApply explicit
timeout_in_ms=TEST_TASK_TIMEOUT_MSto all fixturewait_for_taskcallsThe v1.46.0 timeout fix is only applied to the autouse cleanup (
meilisearch_client.wait_for_task(..., timeout_in_ms=TEST_TASK_TIMEOUT_MS)) andempty_index(client.wait_for_task(..., timeout_in_ms=TEST_TASK_TIMEOUT_MS)). The other fixtures still callwait_for_taskwithouttimeout_in_ms, so they can remain flaky:
indexes_sample:client.wait_for_task(task.task_uid)index_with_documents:index.wait_for_task(task.task_uid)index_with_documents_and_vectors:index.wait_for_task(settings_update_task.task_uid),index.wait_for_task(document_addition_task.task_uid)index_with_documents_and_facets:index.wait_for_task(task_1.task_uid),index.wait_for_task(task_2.task_uid)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/conftest.py` around lines 77 - 199, Add the explicit timeout_in_ms=TEST_TASK_TIMEOUT_MS parameter to all wait_for_task calls left without it: in indexes_sample replace client.wait_for_task(task.task_uid) with client.wait_for_task(task.task_uid, timeout_in_ms=TEST_TASK_TIMEOUT_MS); in index_with_documents replace index.wait_for_task(task.task_uid) with index.wait_for_task(task.task_uid, timeout_in_ms=TEST_TASK_TIMEOUT_MS); in index_with_documents_and_vectors add timeout_in_ms=TEST_TASK_TIMEOUT_MS to both index.wait_for_task(settings_update_task.task_uid) and index.wait_for_task(document_addition_task.task_uid); and in index_with_documents_and_facets add timeout_in_ms=TEST_TASK_TIMEOUT_MS to index.wait_for_task(task_1.task_uid) and index.wait_for_task(task_2.task_uid), ensuring all uses of client.wait_for_task / index.wait_for_task pass TEST_TASK_TIMEOUT_MS.
🧹 Nitpick comments (2)
tests/settings/test_settings_embedders.py (1)
214-214: ⚡ Quick winConsider extracting the timeout value into a module-level constant.
The 60-second timeout is now hardcoded in two places (lines 98 and 214). Similar to
tests/conftest.pyandtests/settings/test_settings_facet_search.py, consider defining a constant for embedder-specific timeouts to improve maintainability.♻️ Proposed refactor to use a constant
+# Embedder operations (especially model-based ones) can take longer +TEST_EMBEDDER_TIMEOUT_MS = 60_000 + + def test_get_default_embedders(empty_index):Then update both usages:
- index.wait_for_task(response.task_uid, timeout_in_ms=60000) # embedder config can take longer. + index.wait_for_task(response.task_uid, timeout_in_ms=TEST_EMBEDDER_TIMEOUT_MS)And:
- update = index.wait_for_task(response.task_uid, timeout_in_ms=60000) + update = index.wait_for_task(response.task_uid, timeout_in_ms=TEST_EMBEDDER_TIMEOUT_MS)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/settings/test_settings_embedders.py` at line 214, Extract the hardcoded 60000 timeout into a module-level constant (e.g., EMBEDDER_TASK_TIMEOUT_MS) and replace both hardcoded occurrences where wait_for_task is called (the calls to index.wait_for_task(..., timeout_in_ms=60000)) with the constant; ensure the constant is defined at the top of the test module and used in both places to improve maintainability and consistency.tests/settings/test_settings_facet_search.py (1)
4-4: ⚡ Quick winAvoid duplicating the timeout constant—import from conftest.py.
TEST_TASK_TIMEOUT_MSis already defined intests/conftest.pywith the same value (30,000 ms). Duplicating constants across test files creates maintenance overhead and risks divergence over time.♻️ Proposed fix to import the constant
+from tests.conftest import TEST_TASK_TIMEOUT_MS + DEFAULT_FACET_SEARCH_SETTINGS_STATUS = True ENABLED_FACET_SEARCH_SETTINGS_STATUS = True DISABLED_FACET_SEARCH_SETTINGS_STATUS = False -TEST_TASK_TIMEOUT_MS = 30_000🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/settings/test_settings_facet_search.py` at line 4, Duplicate constant TEST_TASK_TIMEOUT_MS should be removed from this test and the value imported from the shared conftest module; delete the local TEST_TASK_TIMEOUT_MS declaration in tests/settings/test_settings_facet_search.py and add an import for TEST_TASK_TIMEOUT_MS from the test conftest module (use the conftest export) and keep existing usages unchanged so the test uses the single shared constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Dockerfile`:
- Around line 1-11: The Dockerfile currently runs as root; add a non-root user
and switch to it after installing dependencies: create a user and group (e.g.,
"appuser"), chown the WORKDIR (/home/package) and any files needed by uv, and
add USER appuser before the final image runtime steps; update references around
WORKDIR and the RUN uv sync step so that files are owned by the non-root user
and the container no longer runs as root.
---
Outside diff comments:
In `@tests/conftest.py`:
- Around line 77-199: Add the explicit timeout_in_ms=TEST_TASK_TIMEOUT_MS
parameter to all wait_for_task calls left without it: in indexes_sample replace
client.wait_for_task(task.task_uid) with client.wait_for_task(task.task_uid,
timeout_in_ms=TEST_TASK_TIMEOUT_MS); in index_with_documents replace
index.wait_for_task(task.task_uid) with index.wait_for_task(task.task_uid,
timeout_in_ms=TEST_TASK_TIMEOUT_MS); in index_with_documents_and_vectors add
timeout_in_ms=TEST_TASK_TIMEOUT_MS to both
index.wait_for_task(settings_update_task.task_uid) and
index.wait_for_task(document_addition_task.task_uid); and in
index_with_documents_and_facets add timeout_in_ms=TEST_TASK_TIMEOUT_MS to
index.wait_for_task(task_1.task_uid) and index.wait_for_task(task_2.task_uid),
ensuring all uses of client.wait_for_task / index.wait_for_task pass
TEST_TASK_TIMEOUT_MS.
---
Nitpick comments:
In `@tests/settings/test_settings_embedders.py`:
- Line 214: Extract the hardcoded 60000 timeout into a module-level constant
(e.g., EMBEDDER_TASK_TIMEOUT_MS) and replace both hardcoded occurrences where
wait_for_task is called (the calls to index.wait_for_task(...,
timeout_in_ms=60000)) with the constant; ensure the constant is defined at the
top of the test module and used in both places to improve maintainability and
consistency.
In `@tests/settings/test_settings_facet_search.py`:
- Line 4: Duplicate constant TEST_TASK_TIMEOUT_MS should be removed from this
test and the value imported from the shared conftest module; delete the local
TEST_TASK_TIMEOUT_MS declaration in tests/settings/test_settings_facet_search.py
and add an import for TEST_TASK_TIMEOUT_MS from the test conftest module (use
the conftest export) and keep existing usages unchanged so the test uses the
single shared constant.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 73b25646-38f3-4cd1-a969-2f1be6b57b14
📒 Files selected for processing (4)
Dockerfiletests/conftest.pytests/settings/test_settings_embedders.pytests/settings/test_settings_facet_search.py
Pull Request
Related issue
Fixes #1239
What does this PR do?
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Summary
Increases the timeout window for awaiting Meilisearch tasks in the test suite to address compatibility with Meilisearch v1.46.0, which has stricter timing requirements.
Changes
Dockerfile
python:3.9-bustertopython:3.9-slim-trixieuvtooling image fromghcr.io/astral-sh/uv:0.11.16toghcr.io/astral-sh/uv:0.11.19WORKDIRbefore dependency installationTest Configuration and Fixtures
TEST_TASK_TIMEOUT_MS = 30_000constant intests/conftest.pyandtests/settings/test_settings_facet_search.py_clear_indexesinconftest.pyto explicitly pass timeout when waiting for task completionempty_indexfixture to wait for index creation tasks with explicit timeouttest_composite_embedder_formatintests/settings/test_settings_embedders.pyto use 60-second timeout for composite embedder updatestest_update_facet_search_settingsandtest_reset_facet_search_settings) to use explicit timeouts when waiting for background tasksThese changes ensure tests reliably complete before timing out when running against Meilisearch v1.46.0.