Commit bb89755
authored
CSHARP-5840: Proper XUnit shared test fixture for Atlas tests (#2007)
* Self-seed Atlas Search test data via shared XUnit fixture
Replaces the suite's dependence on pre-configured Atlas sample databases
and search indexes. The new AtlasSearchFixture (collection-scoped) owns
a single client, an EventCapturer, and a fixture-managed
atlas_search_<guid> database. Lazy seeders populate historical_documents,
movies, embedded_movies, airbnb_listings, test_classes, binary_vector_items,
auto_embed_movies, two synonym source collections, and the existing
return-scope directors collection, and create the ten search/vector
indexes required by the tests (waiting for READY). Dispose drops the
whole database.
The seed data is baked in as C# literals in AtlasSearchFixtureSeedData.cs
(generated by tests/Tools/AtlasSeedExtractor from Atlas Local sample
data once) so the test suite has zero runtime dependency on sample
databases — only on an Atlas-search-capable cluster being reachable at
ATLAS_SEARCH_URI. Embeddings are preserved as real Voyage-AI float32
vectors via BinaryVectorFloat32.
AtlasSearchTests, VectorSearchTests, AutoEmbedVectorSearchTests, and
AtlasSearchIndexManagementTests join via [Collection(AtlasSearchCollection.Name)]
and pull their client / collections through the fixture. AtlasSearchTests
loses its static __indexesCreated / __databaseUniquifier /
__returnScopeTestCount machinery and the inline return-scope seed.
AtlasSearchTestsUtils is obsoleted.
AutoEmbedVectorSearchTests now run for real (the previous CSHARP-5840
skip is gone): the auto-embed collection and index live in the fixture
so the Voyage AI embedding work happens once per test session instead
of three times, the corpus is reduced to 4 movies (2 pass the
runtime+year filter, 2 don't), and the ctor's unbounded wait loop is
replaced with a 15-minute deadline that surfaces a clear error mentioning
VOYAGE_API_KEY. Gated on a new AUTO_EMBEDDING_TESTS_ENABLED env var so contributors
without a Voyage AI key can still run the rest of the Atlas Search
suite. When enabled, the Atlas Local container must have
VOYAGE_API_KEY provisioned via the Atlas UI's Model API Keys page (the
key must authenticate against ai.mongodb.com, not api.voyageai.com).
docker-compose.atlas-local.yml is included as a convenience launcher.
Count- and ranking-dependent assertions are recalibrated for the lean
corpus: phrase-match counts drop from 108 to 1, geo-result counts from
25 to membership checks, and vector-search top-K assertions switch from
order-sensitive ShouldBeEquivalentTo to order-insensitive BeEquivalentTo.
The Pinocchio→Oz swap in VectorSearch top-5 is documented in the test
where it lives. The Rerank test guards on AtlasSearchFixture.IsRerankSupported,
which probes the deployment on first use.
Validated against Atlas Local: 77/77 AtlasSearch* tests pass, 36/36
AtlasSearchIndexManagement tests pass, 3/3 AutoEmbedVectorSearchTests
pass (with a valid VOYAGE_API_KEY), 74 tests skip cleanly when env vars
are unset, and no atlas_search_* databases remain after the suite exits.
[review-iter 1] Address review findings
[review-iter 2] Address review findings
* Copilot feedback
* Review feedback
* Remove atlas-search-index-helpers-test
* Remove AtlasSeedExtractor tool and simplify fixture init locking
The AtlasSeedExtractor project was a one-shot generator that produced the
baked-in literals in AtlasSearchFixtureSeedData.cs. That seed data is now
static and checked in, so the tool is no longer needed: delete the project
and drop the generator references from the seed-data file header.
Also collapse the eight near-identical double-checked-locking blocks in
AtlasSearchFixture into a single EnsureInitialized(isInitialized, initialize)
helper, and mark the per-collection init guards volatile so the lock-free
fast-path read is correctly published. Behavior is unchanged: the shared
_initLock still serializes seeding, and a throwing seeder still leaves its
guard unset so the next access retries (unlike Lazy<T>, which would cache
and re-throw the failure).1 parent ddffda4 commit bb89755
12 files changed
Lines changed: 7582 additions & 701 deletions
File tree
- evergreen
- tests/MongoDB.Driver.Tests/Search
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | 675 | | |
687 | 676 | | |
688 | 677 | | |
| |||
1383 | 1372 | | |
1384 | 1373 | | |
1385 | 1374 | | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
1390 | | - | |
1391 | | - | |
1392 | | - | |
1393 | 1375 | | |
1394 | 1376 | | |
1395 | 1377 | | |
| |||
2187 | 2169 | | |
2188 | 2170 | | |
2189 | 2171 | | |
2190 | | - | |
2191 | | - | |
2192 | | - | |
2193 | | - | |
2194 | | - | |
2195 | | - | |
2196 | | - | |
2197 | | - | |
2198 | | - | |
2199 | | - | |
2200 | | - | |
2201 | | - | |
2202 | | - | |
2203 | | - | |
2204 | | - | |
2205 | | - | |
2206 | | - | |
2207 | | - | |
2208 | | - | |
2209 | | - | |
2210 | | - | |
2211 | | - | |
2212 | | - | |
2213 | | - | |
2214 | | - | |
2215 | | - | |
2216 | | - | |
2217 | | - | |
2218 | | - | |
2219 | | - | |
2220 | | - | |
2221 | | - | |
2222 | | - | |
2223 | | - | |
2224 | | - | |
2225 | 2172 | | |
2226 | 2173 | | |
2227 | 2174 | | |
| |||
2748 | 2695 | | |
2749 | 2696 | | |
2750 | 2697 | | |
2751 | | - | |
2752 | | - | |
2753 | | - | |
2754 | | - | |
2755 | | - | |
2756 | | - | |
2757 | | - | |
2758 | 2698 | | |
2759 | 2699 | | |
2760 | 2700 | | |
| |||
This file was deleted.
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments