Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1b72761
Add a mongot search sidecar to the replica-set target
danielfrankcom Jun 17, 2026
6504ef4
Add searchMeta stage tests
danielfrankcom Jun 19, 2026
b1e3505
merge from upstream/main
danielfrankcom Jun 25, 2026
f711134
Add facet boundary distinctness and size-limit error tests
danielfrankcom Jun 26, 2026
b76f5f3
Add date-facet default overflow bucket test
danielfrankcom Jun 26, 2026
8e8212e
Add concurrent and returnScope stage option tests
danielfrankcom Jun 26, 2026
603835d
Add returnStoredSource option tests
danielfrankcom Jun 26, 2026
4735096
Add facet numBuckets type validation tests
danielfrankcom Jun 26, 2026
c6b1070
Add facet definition field type validation tests
danielfrankcom Jun 26, 2026
17a23c0
Add cross-facet-type unrecognized field tests
danielfrankcom Jun 26, 2026
e95ad7e
Add date facet boundary validation error tests
danielfrankcom Jun 26, 2026
b1e5c40
Add per-operator acceptance compatibility tests
danielfrankcom Jun 30, 2026
223b7f2
Add returnScope success and scope-path semantics tests
danielfrankcom Jun 30, 2026
bf30c2c
Add operator path-construction and multi-analyzer path tests
danielfrankcom Jun 30, 2026
f520a26
Use the thread timeout method so wedged tests are killed
danielfrankcom Jun 25, 2026
dd35eed
Capture per-service container logs from the test jobs
danielfrankcom Jun 25, 2026
98e1b4d
Cap the mongot JVM heap to keep the replset CI runner in memory
danielfrankcom Jun 25, 2026
426f499
Pin the mongot image to 1.70.1 and migrate its config to the new sync…
danielfrankcom Jul 1, 2026
61081d8
merge from upstream/main
danielfrankcom Jul 2, 2026
b828bb7
Merge branch 'main' into pr/searchMeta-copy
eerxuan Jul 3, 2026
8d9a1cd
Share setup via package-scoped conftest fixture
danielfrankcom Jul 7, 2026
00a1213
Merge branch 'main' into pr/searchMeta-copy
eerxuan Jul 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ jobs:
--json-report --json-report-file=${{ github.workspace }}/.test-results/${{ matrix.target.name }}-report.json \
--junitxml=${{ github.workspace }}/.test-results/${{ matrix.target.name }}-results.xml

- name: Dump container logs
if: always()
run: |
# One file per service in the profile
mkdir -p "${{ github.workspace }}/.test-results/container-logs"
for svc in $(docker compose -f dev/compose.yaml --profile ${{ matrix.target.profile }} config --services); do
docker compose -f dev/compose.yaml --profile ${{ matrix.target.profile }} \
logs --no-color --timestamps "$svc" \
> "${{ github.workspace }}/.test-results/container-logs/${svc}.log" 2>&1 || true
done

- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
Expand Down
51 changes: 49 additions & 2 deletions dev/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# query: <optional connection-string query string, without leading '?'>
#
# A service with no `x-test-target` is not a test target and is ignored by the
# registry.
# registry (e.g. the mongot sidecar, which is reached only through its mongod).
#
# Memory: each mongod caps its WiredTiger cache (--wiredTigerCacheSizeGB). By
# default a mongod sizes its cache to ~50% of the host/VM RAM; with several
Expand Down Expand Up @@ -60,7 +60,26 @@ services:
mongo-replset:
image: mongo:8.2.4
profiles: ["mongo-replset", "all"]
command: ["--replSet", "rs0", "--bind_ip_all", "--wiredTigerCacheSizeGB", "1.5"]
command:
- "--replSet"
- "rs0"
- "--bind_ip_all"
- "--wiredTigerCacheSizeGB"
- "1.5"
# Point at the mongot search sidecar so this replica set also serves the
# search surfaces. mongot is transparent to all other behavior, so the
# set behaves identically to a plain replica set apart from gaining
# search; it is one target, not two.
- "--setParameter"
- "mongotHost=mongot:27028"
- "--setParameter"
- "searchIndexManagementHostAndPort=mongot:27028"
- "--setParameter"
- "useGrpcForSearch=true"
- "--setParameter"
- "skipAuthenticationToMongot=true"
- "--setParameter"
- "skipAuthenticationToSearchIndexManagementServer=true"
ports:
- "27018:27017"
healthcheck:
Expand All @@ -71,3 +90,31 @@ services:
x-test-target:
engine: mongodb
query: directConnection=true

# mongot: the search sidecar for the mongo-replset target. Not a test target
# on its own; the suite reaches it only through mongo-replset. mongot is
# MongoDB Search Community Edition (SSPL, same license as the server). It
# replicates from the replica set as an authenticated sync source and reads
# its password from a file, so the entrypoint writes that file (a fixed
# local-dev secret, matched by the searchCoordinator user the harness creates
# on the replica set) with owner-only permissions before launching. It retries
# the connection until that user exists.
mongot:
image: mongodb/mongodb-community-search:1.70.1
profiles: ["mongo-replset", "all"]
entrypoint:
- "sh"
- "-c"
- >
umask 077 &&
mkdir -p /mongot-secrets &&
printf '%s' "$$MONGOT_SYNC_PASSWORD" > /mongot-secrets/passwordFile &&
exec /mongot-community/mongot --config /mongot-config/mongot.yml
environment:
# Fixed local-dev secret shared with the searchCoordinator user the
# harness provisions on mongo-replset. Not a real credential.
MONGOT_SYNC_PASSWORD: "searchSyncPassword"
# Cap mongot's JVM heap. Unset, the JVM sizes its max heap to ~25% of host RAM.
JAVA_TOOL_OPTIONS: "-Xmx1g"
volumes:
- ./mongot.yml:/mongot-config/mongot.yml:ro
32 changes: 32 additions & 0 deletions dev/mongot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# mongot configuration for the mongo-replset target (dev/compose.yaml service
# "mongot"). mongot is MongoDB Search Community Edition (SSPL), the same license
# as the server. It runs alongside the replica set's mongod and serves the
# search and vector search surfaces.
#
# mongot replicates from the mongod replica set as a sync source. It requires an
# authenticated connection (it has no unauthenticated mode), so it logs in as a
# dedicated user holding the searchCoordinator role. That user and its password
# file are provisioned by the target's startup (see dev/compose.yaml).
syncSource:
replicaSet:
hostAndPort: "mongo-replset:27017"
scramAuth:
username: "searchSyncUser"
authSource: "admin"
passwordFile: "/mongot-secrets/passwordFile"
tls:
enabled: false
storage:
dataPath: "/var/lib/mongot"
server:
grpc:
# mongod reaches mongot here (see mongotHost / searchIndexManagementHostAndPort
# on the mongo-replset service). Bound on all interfaces so the mongod
# container can connect over the compose network.
address: "0.0.0.0:27028"
tls:
mode: "disabled"
healthCheck:
address: "0.0.0.0:8080"
logging:
verbosity: INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Shared fixtures for $searchMeta stage tests."""

from __future__ import annotations

from collections.abc import Iterator

import pytest
from pymongo.collection import Collection

from documentdb_tests.compatibility.tests.core.operator.stages.searchMeta.utils.searchMeta_common import ( # noqa: E501
open_search_collection,
)


@pytest.fixture(scope="package")
def search_collection(engine_client, worker_id) -> Iterator[Collection]:
"""Metadata search collection carrying a ``default`` and a non-default
``alt_idx`` index, for tests that select an index by name.

Package-scoped and read-only: the search index is built and polled to READY
once for all $searchMeta tests that request it."""
with open_search_collection(
engine_client, worker_id, "stages_searchmeta_shared::search_collection"
) as coll:
yield coll
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
"""Tests for $searchMeta on empty, unindexed, and nonexistent collections."""

from __future__ import annotations

from collections.abc import Iterator

import pytest
from pymongo.collection import Collection

from documentdb_tests.compatibility.tests.core.operator.stages.searchMeta.utils.searchMeta_common import ( # noqa: E501
SEARCH_DOCS,
CollectionFixtureTestCase,
build_collection,
)
from documentdb_tests.framework.assertions import assertResult
from documentdb_tests.framework.executor import execute_command
from documentdb_tests.framework.parametrize import pytest_params
from documentdb_tests.framework.test_constants import INT64_ZERO

pytestmark = pytest.mark.requires(search=True)


@pytest.fixture(scope="module")
def empty_search_collection(engine_client, worker_id) -> Iterator[Collection]:
"""Indexed but empty collection."""
with build_collection(
engine_client,
worker_id,
f"{__name__}::empty_search_collection",
"searchmeta_empty",
[],
[{"name": "default", "definition": {"mappings": {"dynamic": True}}}],
) as coll:
yield coll


# Property [Empty Collection Count]: on an indexed but empty collection,
# $searchMeta returns a zero count respecting the requested count.type,
# defaulting to lowerBound.
SEARCHMETA_EMPTY_COLLECTION_TESTS: list[CollectionFixtureTestCase] = [
CollectionFixtureTestCase(
"empty_default",
collection_fixture="empty_search_collection",
pipeline=[{"$searchMeta": {"text": {"query": "quick", "path": "title"}}}],
expected=[{"count": {"lowerBound": INT64_ZERO}}],
msg="$searchMeta should default to a lower-bound zero count on an indexed empty "
"collection",
),
CollectionFixtureTestCase(
"empty_total",
collection_fixture="empty_search_collection",
pipeline=[
{
"$searchMeta": {
"text": {"query": "quick", "path": "title"},
"count": {"type": "total"},
}
}
],
expected=[{"count": {"total": INT64_ZERO}}],
msg="$searchMeta should return a total-zero count on an indexed empty collection when "
"count.type is total",
),
CollectionFixtureTestCase(
"empty_lower_bound",
collection_fixture="empty_search_collection",
pipeline=[
{
"$searchMeta": {
"text": {"query": "quick", "path": "title"},
"count": {"type": "lowerBound"},
}
}
],
expected=[{"count": {"lowerBound": INT64_ZERO}}],
msg="$searchMeta should return a lower-bound-zero count on an indexed empty collection "
"when count.type is lowerBound",
),
]


@pytest.fixture(scope="module")
def no_index_collection(engine_client, worker_id) -> Iterator[Collection]:
"""Populated collection with no search index."""
with build_collection(
engine_client,
worker_id,
f"{__name__}::no_index_collection",
"searchmeta_no_index",
SEARCH_DOCS,
None,
) as coll:
yield coll


# Property [No-Index Behavior]: on a populated collection with no search index,
# $searchMeta succeeds and returns a total-zero count that ignores the requested
# count.type, and a facet collector omits the facet field.
SEARCHMETA_NO_INDEX_TESTS: list[CollectionFixtureTestCase] = [
CollectionFixtureTestCase(
"no_index_default",
collection_fixture="no_index_collection",
pipeline=[{"$searchMeta": {"text": {"query": "quick", "path": "title"}}}],
expected=[{"count": {"total": INT64_ZERO}}],
msg="$searchMeta should return a total-zero count without error on a populated "
"collection that has no search index",
),
CollectionFixtureTestCase(
"no_index_lower_bound",
collection_fixture="no_index_collection",
pipeline=[
{
"$searchMeta": {
"text": {"query": "quick", "path": "title"},
"count": {"type": "lowerBound"},
}
}
],
expected=[{"count": {"total": INT64_ZERO}}],
msg="$searchMeta should ignore a lowerBound count.type and still key the no-index "
"count as total",
),
CollectionFixtureTestCase(
"no_index_facet_omits_facet",
collection_fixture="no_index_collection",
pipeline=[
{
"$searchMeta": {
"facet": {
"facets": {"nf": {"type": "number", "path": "n", "boundaries": [0, 25]}}
}
}
}
],
expected=[{"count": {"total": INT64_ZERO}}],
msg="$searchMeta should omit the facet field and return a total-zero count for a facet "
"collector on a collection that has no search index",
),
]


@pytest.fixture(scope="module")
def nonexistent_collection(engine_client, worker_id) -> Iterator[Collection]:
"""Handle to a collection that is never created."""
with build_collection(
engine_client,
worker_id,
f"{__name__}::nonexistent_collection",
"searchmeta_nonexistent",
None,
None,
) as coll:
yield coll


# Property [Nonexistent Collection]: on a nonexistent collection, $searchMeta
# returns an empty result with no metadata document, for both an operator and a
# facet collector.
SEARCHMETA_NONEXISTENT_COLLECTION_TESTS: list[CollectionFixtureTestCase] = [
CollectionFixtureTestCase(
"nonexistent_operator",
collection_fixture="nonexistent_collection",
pipeline=[{"$searchMeta": {"text": {"query": "quick", "path": "title"}}}],
expected=[],
msg="$searchMeta should return an empty result with no metadata document for an "
"operator on a nonexistent collection",
),
CollectionFixtureTestCase(
"nonexistent_facet",
collection_fixture="nonexistent_collection",
pipeline=[
{
"$searchMeta": {
"facet": {
"facets": {"nf": {"type": "number", "path": "n", "boundaries": [0, 25]}}
}
}
}
],
expected=[],
msg="$searchMeta should return an empty result with no metadata document for a facet "
"collector on a nonexistent collection",
),
]

# All collection-state cases share one execution path; the state is carried as
# data via the fixture each case names.
SEARCHMETA_COLLECTION_STATE_TESTS: list[CollectionFixtureTestCase] = (
SEARCHMETA_EMPTY_COLLECTION_TESTS
+ SEARCHMETA_NO_INDEX_TESTS
+ SEARCHMETA_NONEXISTENT_COLLECTION_TESTS
)


@pytest.mark.aggregate
@pytest.mark.parametrize("test_case", pytest_params(SEARCHMETA_COLLECTION_STATE_TESTS))
def test_searchMeta_collection_state(engine_client, request, test_case: CollectionFixtureTestCase):
"""Test $searchMeta across empty, no-index, and nonexistent collection states."""
collection = request.getfixturevalue(test_case.collection_fixture)
result = execute_command(
collection,
{
"aggregate": collection.name,
"pipeline": test_case.pipeline,
"cursor": {},
},
)
assertResult(
result,
expected=test_case.expected,
error_code=test_case.error_code,
msg=test_case.msg,
)
Loading
Loading