Skip to content

test: add FT.SEARCH server-timeout coverage for return and fail policies - #4186

Merged
petyaslavova merged 2 commits into
masterfrom
ps_add_rqe_timeout_tests
Jul 14, 2026
Merged

petyaslavova merged 2 commits into
masterfrom
ps_add_rqe_timeout_tests

Conversation

@petyaslavova

@petyaslavova petyaslavova commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Change summary

This pull request adds integration test coverage for FT.SEARCH server-side
timeout behaviour, which was previously untested end-to-end β€” the existing
test_query_timeout only checked argument encoding and the error for a
non-numeric timeout, never triggering a real timeout or inspecting the result.
The new tests mirror the existing test_hybrid_search_query_with_timeout pattern
for the plain search command.

Two tests are added to TestBaseSearchFunctionality in both tests/test_search.py
and tests/test_asyncio/test_search.py, backed by two small private helpers
(_create_search_timeout_index / _add_data_for_search_timeout) and class
constants (_SEARCH_TIMEOUT_DIM = 8192, _SEARCH_TIMEOUT_DOCS = 1500). The
helpers build a large FLAT vector index and bulk-load 1500 documents so a
KNN 1500 query with Query(...).timeout(1) (1 ms) reliably exceeds the limit.

  • test_search_query_with_timeout exercises the default return policy: the
    server returns partial results plus a timeout warning. Assertions are shape-
    and wire-aware β€” under expects_resp3_shape the raw RESP3 dict is read
    (res["total_results"], res.get("warning", [])), otherwise the Result
    object (res.total, res.warnings). The "Timeout limit was reached" warning
    is only carried on the RESP3 wire, so it is asserted when
    int(get_protocol_version(...)) == 3 (the int() normalizes a pinned
    --protocol=3, which arrives as the string "3") and asserted empty on the
    RESP2 wire.
  • test_search_query_with_timeout_fail_policy sets the new search-on-timeout
    policy to fail via native config_set (FT.CONFIG is removed at 7.9.0+) and
    asserts the timed-out search raises redis.ResponseError. It captures the
    original config value and restores it in a finally block so global server
    state is always reverted, and is guarded by @skip_if_server_version_lt("8.9.0")
    since that is the first server exposing the policy.

This is a tests-only change with no runtime or public-API impact, and the sync
and async stacks are kept fully in parity. A new get_protocol_version import is
added to both test modules' conftest import blocks.


Note

Low Risk
Tests-only plus a dev dependency pin bump; no production code or client API changes.

Overview
Adds end-to-end integration tests for FT.SEARCH when Query(...).timeout() actually fires on the server, complementing the existing tests that only check query argument encoding.

In both sync and async TestBaseSearchFunctionality, new helpers build a large FLAT vector index (8192-dim, 1500 docs) and run a heavy KNN query with a 1 ms timeout so the server reliably hits the limit. test_search_query_with_timeout checks the default return behavior: partial results with a valid total, and the "Timeout limit was reached" warning only on RESP3 (via get_protocol_version). test_search_query_with_timeout_fail_policy (Redis β‰₯ 8.9.0) temporarily sets search-on-timeout to fail with config_set and expects ResponseError, restoring the prior value in finally.

Also bumps click in dev_requirements.txt from 8.0.4 to 8.3.3. No library or public API changes.

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

@petyaslavova petyaslavova added the maintenance Maintenance (CI, Releases, etc) label Jul 14, 2026
@petyaslavova
petyaslavova merged commit 41818bd into master Jul 14, 2026
368 checks passed
@petyaslavova
petyaslavova deleted the ps_add_rqe_timeout_tests branch July 14, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance (CI, Releases, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants