Commit 80fa258
## Motivation
The integration suite runs under `pytest -n auto`, and now and then a
single matrix job fails on a test that passes everywhere else — and
passes again on rerun. The most recent example was
`test_hybrid_query_with_geo_filter` returning 0 results instead of 3 on
exactly one Python/redis-py/Redis combination. These failures read as
version-specific, but they aren't: they're a test-isolation problem
wearing a disguise.
The key fact is how the suite isolates workers. Each xdist worker gets
its **own** Redis container, so two tests can only interfere when they
run on the **same** worker *and* reach for the **same** Redis key names.
For that to actually corrupt a result, two things have to line up:
1. a **shared resource name** (a name scoped only to the worker, or a
hard-coded one), and
2. a **way for state to outlive its test** — cleanup that only runs on
the success path, or an index recreated with `overwrite=True` but no
`drop=True`, leaving stale documents under a reused prefix.
When both hold, one test sees another's leftovers — empty results,
inflated counts, dtype mismatches — and which test loses depends
entirely on the order the scheduler picked. That's the retry-passing,
pseudo-random signature.
#543 introduced a `redis_test_name` helper that mints per-test-unique
names and began migrating fixtures onto it. This PR finishes that
migration for the modules that can genuinely cause flakiness, and
tightens their recreate/cleanup so leftovers can't survive.
## What changed
**Recreate group** — per-test names + `create(overwrite=True,
drop=True)`:
- `test_hybrid.py` and `test_aggregation.py` (these two shared the
*identical* `user_index_{worker_id}` / `v1_{worker_id}` — the direct
cause of the geo-filter failure), plus `test_search_results.py`,
`test_svs_integration.py`, and the shared `conftest.py` index fixtures.
**Fixed-name collisions** — per-test names + guaranteed teardown:
- `from_existing_complex` (hard-coded `"test"`) and
`no_proactive_module_validation` (`"my_index"`) in the sync + async
search-index suites.
- The three `test_embedcache_warnings.py` tests sharing `"test_cache"`.
- The shared `"doc"` prefix / `"test-index"` name across
`test_no_proactive_module_checks.py`.
**Raw `worker_id` collision** — unique names + cleanup:
- The two `test_llmcache.py` tests that both created
`float64_cache_{worker_id}` and never cleaned up.
**Cluster tests** — the one place cross-worker collisions are real,
since every cluster test points at a single hard-coded
`redis://localhost:7001`: `test_redis_cluster_support.py` and
`test_cluster_pipelining.py` now use per-test names, `drop=True`, and
`try/finally` cleanup.
## Scope and follow-ups
- The `SemanticRouter.delete()` leak of its `{name}:route_config` key is
a product-code gap, not a test-only fix, so it's split into #634 (which
also owns the dependent `test_key_separator_handling.py` cleanup).
- The remaining #546 items are **benign hygiene** — leaks under
per-test-unique names that can't contaminate another test, only
accumulate harmless keys in a worker's throwaway Redis. Their exact
remaining scope is enumerated in a comment on #546.
## Testing
Honest caveat for reviewers: this was developed in an environment
without Docker, so I could **not** run the integration suite. `black`,
`isort`, and `mypy` pass. Please run `make test` and a repeated `pytest
-n auto` pass to confirm the flake is gone before merging — this is a
test-only change, so behavior is fully validated by the suite itself.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Changes are confined to the test suite; production library behavior is
unchanged.
>
> **Overview**
> **Hardens integration tests** so parallel `pytest-xdist` workers and
shared Redis/cluster endpoints do not leave stale keys or collide on
index/cache names.
>
> Fixtures and tests now use **`redis_test_name`** (per-test unique
index/prefix/cache names) instead of **`worker_id`-only** or hard-coded
names like `"test"` / `"my_index"` / `"test_cache"`. Shared
**`conftest`** index fixtures (`flat_index`, `hnsw_index`, async
variants) and modules such as **`test_hybrid`**, **`test_aggregation`**,
**`test_search_results`**, and **`test_svs_integration`** adopt that
naming and call **`create(overwrite=True, drop=True)`** so documents
under a reused prefix are cleared before load.
>
> **Teardown** is tightened with **`try/finally`**,
**`delete(drop=True)`**, and cache **`clear()`** / **`aclear()`** on
failure paths (e.g. `from_existing_complex`, module-validation tests,
**`test_llmcache`** dtype caches, **`test_embedcache_warnings`**).
**Cluster** tests use per-test names and **`drop=True`** because all
workers share **`localhost:7001`**.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c4e6b33. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 93b29be commit 80fa258
12 files changed
Lines changed: 268 additions & 185 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
| 521 | + | |
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
578 | | - | |
| 578 | + | |
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
634 | | - | |
| 634 | + | |
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
| |||
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
690 | | - | |
| 690 | + | |
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
| 119 | + | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
165 | 159 | | |
166 | | - | |
167 | | - | |
| 160 | + | |
| 161 | + | |
168 | 162 | | |
169 | 163 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
| |||
493 | 497 | | |
494 | 498 | | |
495 | 499 | | |
496 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
497 | 503 | | |
498 | 504 | | |
499 | 505 | | |
| |||
505 | 511 | | |
506 | 512 | | |
507 | 513 | | |
508 | | - | |
| 514 | + | |
509 | 515 | | |
510 | 516 | | |
511 | 517 | | |
| |||
517 | 523 | | |
518 | 524 | | |
519 | 525 | | |
520 | | - | |
521 | | - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
522 | 531 | | |
523 | 532 | | |
524 | 533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| 43 | + | |
41 | 44 | | |
42 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| |||
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
55 | | - | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| |||
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
70 | | - | |
| 77 | + | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
74 | | - | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
114 | 121 | | |
115 | 122 | | |
116 | 123 | | |
117 | | - | |
| 124 | + | |
118 | 125 | | |
119 | 126 | | |
120 | 127 | | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
124 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
125 | 136 | | |
126 | 137 | | |
127 | 138 | | |
| |||
131 | 142 | | |
132 | 143 | | |
133 | 144 | | |
134 | | - | |
| 145 | + | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
| |||
151 | 162 | | |
152 | 163 | | |
153 | 164 | | |
154 | | - | |
| 165 | + | |
155 | 166 | | |
156 | 167 | | |
157 | 168 | | |
158 | 169 | | |
159 | | - | |
| 170 | + | |
160 | 171 | | |
161 | 172 | | |
162 | 173 | | |
163 | 174 | | |
164 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
165 | 180 | | |
166 | 181 | | |
167 | 182 | | |
| |||
171 | 186 | | |
172 | 187 | | |
173 | 188 | | |
174 | | - | |
| 189 | + | |
175 | 190 | | |
176 | 191 | | |
177 | 192 | | |
| |||
190 | 205 | | |
191 | 206 | | |
192 | 207 | | |
193 | | - | |
| 208 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
56 | | - | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
61 | 68 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| |||
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
77 | | - | |
| 82 | + | |
78 | 83 | | |
79 | 84 | | |
80 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
81 | 88 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
86 | 96 | | |
87 | | - | |
88 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | | - | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
0 commit comments