Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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:latest
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
30 changes: 30 additions & 0 deletions dev/mongot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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"
username: "searchSyncUser"
passwordFile: "/mongot-secrets/passwordFile"
authSource: "admin"
tls: 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,31 @@
"""Shared fixtures for $search stage tests.
The dynamic-mapping ``indexed_collection`` corpus is queried read-only by most
$search test files, so it is built once per package here rather than duplicated
per file. Single-operator corpora (wildcard, equals, in, ...) stay inline in
their own test file, since each is used by exactly one file."""

from __future__ import annotations

import pytest

from documentdb_tests.compatibility.tests.core.operator.stages.search.utils.search_common import (
FIXTURE_DOCS,
create_dynamic_search_index,
)
from documentdb_tests.framework import fixtures


@pytest.fixture(scope="package")
def indexed_collection(engine_client, worker_id):
"""A package-scoped collection populated with the fixture docs and a ready
dynamic search index, shared read-only across the matching tests so the
index is built and polled once rather than per test."""
db_name = fixtures.generate_database_name("stages_search_shared", worker_id)
fixtures.cleanup_database(engine_client, db_name)
db = engine_client[db_name]
coll = db["indexed"]
coll.insert_many(FIXTURE_DOCS)
create_dynamic_search_index(coll)
yield coll
fixtures.cleanup_database(engine_client, db_name)
Loading
Loading