Repository navigation
test: add FT.SEARCH server-timeout coverage for return and fail policies - #4186
Merged
Merged
Conversation
vladvildanov
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change summary
This pull request adds integration test coverage for
FT.SEARCHserver-sidetimeout behaviour, which was previously untested end-to-end β the existing
test_query_timeoutonly checked argument encoding and the error for anon-numeric timeout, never triggering a real timeout or inspecting the result.
The new tests mirror the existing
test_hybrid_search_query_with_timeoutpatternfor the plain search command.
Two tests are added to
TestBaseSearchFunctionalityin bothtests/test_search.pyand
tests/test_asyncio/test_search.py, backed by two small private helpers(
_create_search_timeout_index/_add_data_for_search_timeout) and classconstants (
_SEARCH_TIMEOUT_DIM = 8192,_SEARCH_TIMEOUT_DOCS = 1500). Thehelpers build a large FLAT vector index and bulk-load 1500 documents so a
KNN 1500query withQuery(...).timeout(1)(1 ms) reliably exceeds the limit.test_search_query_with_timeoutexercises the defaultreturnpolicy: theserver returns partial results plus a timeout warning. Assertions are shape-
and wire-aware β under
expects_resp3_shapethe raw RESP3 dict is read(
res["total_results"],res.get("warning", [])), otherwise theResultobject (
res.total,res.warnings). The"Timeout limit was reached"warningis only carried on the RESP3 wire, so it is asserted when
int(get_protocol_version(...)) == 3(theint()normalizes a pinned--protocol=3, which arrives as the string"3") and asserted empty on theRESP2 wire.
test_search_query_with_timeout_fail_policysets the newsearch-on-timeoutpolicy to
failvia nativeconfig_set(FT.CONFIG is removed at 7.9.0+) andasserts the timed-out search raises
redis.ResponseError. It captures theoriginal config value and restores it in a
finallyblock so global serverstate 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_versionimport isadded to both test modules'
conftestimport 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.SEARCHwhenQuery(...).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 heavyKNNquery with a 1 ms timeout so the server reliably hits the limit.test_search_query_with_timeoutchecks the defaultreturnbehavior: partial results with a valid total, and the"Timeout limit was reached"warning only on RESP3 (viaget_protocol_version).test_search_query_with_timeout_fail_policy(Redis β₯ 8.9.0) temporarily setssearch-on-timeouttofailwithconfig_setand expectsResponseError, restoring the prior value infinally.Also bumps
clickindev_requirements.txtfrom 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.