From 8f757b7d4f3f629b262c96babcfe24839a0a8548 Mon Sep 17 00:00:00 2001 From: Samar Farooqi Date: Fri, 16 Oct 2026 20:05:49 +0000 Subject: [PATCH 1/5] test(changeStream): Read the oplog only when a case needs it test_changeStream_early_start looked up the oldest oplog entry for every parametrized case, before running the change-stream command. Only oldest_minus_5s uses that value; zero, one_zero and max_increment use static start times. On a target with no readable oplog entry the lookup raises StopIteration, so those three cases never reach the server and record nothing about whether an early startAtOperationTime is accepted. Pass compute_start a callable that performs the lookup, so the oplog is read only by the case that uses it. Signed-off-by: Samar Farooqi --- .../test_changeStream_early_start.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py b/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py index 901dcd8c7..a9166034a 100644 --- a/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py +++ b/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py @@ -36,15 +36,20 @@ def _oldest_oplog_ts(collection) -> Timestamp: return cast(Timestamp, oldest) +def _seconds_before(ts: Timestamp, seconds: int) -> Timestamp: + return Timestamp(ts.time - seconds, ts.inc) + + @dataclass(frozen=True) class ChangeStreamEarlyStartTestCase(BaseTestCase): """Test case for a startAtOperationTime at or before the oldest oplog entry. Attributes: - compute_start: Receives the timestamp of the oldest retained oplog entry - captured at run time and returns the startAtOperationTime to test, so - the boundary case is expressed relative to the live oplog rather than - as a static value. + compute_start: Receives a zero-argument callable that returns the + timestamp of the oldest retained oplog entry, and returns the + startAtOperationTime to test. The oplog is read only when a case + calls it, so cases with a static start time do not depend on a + readable oplog. """ compute_start: Any = None @@ -76,7 +81,7 @@ class ChangeStreamEarlyStartTestCase(BaseTestCase): ), ChangeStreamEarlyStartTestCase( "oldest_minus_5s", - compute_start=lambda oldest: Timestamp(oldest.time - 5, oldest.inc), + compute_start=lambda oldest: _seconds_before(oldest(), 5), expected={"ok": Eq(1.0)}, msg="$changeStream should accept a startAtOperationTime five seconds before" " the oldest retained oplog entry", @@ -91,7 +96,7 @@ def test_changeStream_early_start_collection_scope( collection, test_case: ChangeStreamEarlyStartTestCase ): """Test $changeStream accepts an early startAtOperationTime on a collection-scoped stream.""" - start = test_case.compute_start(_oldest_oplog_ts(collection)) + start = test_case.compute_start(lambda: _oldest_oplog_ts(collection)) result = execute_command( collection, change_stream_command( @@ -108,7 +113,7 @@ def test_changeStream_early_start_database_scope( collection, test_case: ChangeStreamEarlyStartTestCase ): """Test $changeStream accepts an early startAtOperationTime on a database-scoped stream.""" - start = test_case.compute_start(_oldest_oplog_ts(collection)) + start = test_case.compute_start(lambda: _oldest_oplog_ts(collection)) result = execute_command( collection, change_stream_command( @@ -127,7 +132,7 @@ def test_changeStream_early_start_cluster_scope( collection, test_case: ChangeStreamEarlyStartTestCase ): """Test $changeStream accepts an early startAtOperationTime on a cluster-wide stream.""" - start = test_case.compute_start(_oldest_oplog_ts(collection)) + start = test_case.compute_start(lambda: _oldest_oplog_ts(collection)) spec = {"startAtOperationTime": start, "allChangesForCluster": True} # batchSize 0 opens the stream without materializing historical events, whose # resume tokens can exceed the BSON document size limit on a cluster-wide stream. From 3ccfb42bec3504ea9bcb2d563491b71491e21662 Mon Sep 17 00:00:00 2001 From: Samar Farooqi Date: Fri, 16 Oct 2026 20:06:06 +0000 Subject: [PATCH 2/5] fix(preconditions): Drop oplog from the amazon-documentdb profile Amazon DocumentDB does not expose its replication log as local.oplog.rs: reading the oldest entry returns no document. The amazon-documentdb profile declared the oplog capability anyway, so oplog-dependent cases ran and failed in test code rather than being gated. Remove oplog from the profile and mark the oldest_minus_5s case of test_changeStream_early_start with requires(oplog=True), the one case that reads the oplog. The two collMod oplog cases (max_target_oplog, size_target_oplog) are already gated on oplog and are now skipped on Amazon DocumentDB. Signed-off-by: Samar Farooqi --- .../changeStream/test_changeStream_early_start.py | 1 + documentdb_tests/framework/preconditions.py | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py b/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py index a9166034a..2102a7c00 100644 --- a/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py +++ b/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py @@ -85,6 +85,7 @@ class ChangeStreamEarlyStartTestCase(BaseTestCase): expected={"ok": Eq(1.0)}, msg="$changeStream should accept a startAtOperationTime five seconds before" " the oldest retained oplog entry", + marks=(pytest.mark.requires(oplog=True),), ), ] diff --git a/documentdb_tests/framework/preconditions.py b/documentdb_tests/framework/preconditions.py index 58ae49279..99f7c3e22 100644 --- a/documentdb_tests/framework/preconditions.py +++ b/documentdb_tests/framework/preconditions.py @@ -114,10 +114,9 @@ } ), # Amazon DocumentDB. A managed, replicated deployment: it presents the - # DocumentDB capability surface and, being backed by a replica set, - # additionally has the replication-dependent capabilities the reference - # server gates behind one (oplog access). Exposed as a single deployment - # form, so its one topology is named ``replica_set``. + # DocumentDB capability surface. It does not expose its replication log as + # local.oplog.rs, so it lacks the oplog capability. Exposed as a single + # deployment form, so its one topology is named ``replica_set``. ("amazon-documentdb", "replica_set"): frozenset( { "change_streams", @@ -127,7 +126,6 @@ "cluster_time", "cluster_read_concern", "quorum_write_concern", - "oplog", "unforced_compact", "reindex", "replication", From 2e1eb12baab4b8a80615be2b2988c48ccead5fd3 Mon Sep 17 00:00:00 2001 From: Samar Farooqi Date: Thu, 5 Nov 2026 23:04:06 +0000 Subject: [PATCH 3/5] fix(preconditions): Scope the replication capability description to applyOps Oplog access is covered by the separate oplog capability, so the replication description should name only applyOps to keep the two capabilities from overlapping. Signed-off-by: Samar Farooqi --- documentdb_tests/framework/preconditions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentdb_tests/framework/preconditions.py b/documentdb_tests/framework/preconditions.py index 99f7c3e22..4462b3c89 100644 --- a/documentdb_tests/framework/preconditions.py +++ b/documentdb_tests/framework/preconditions.py @@ -58,7 +58,7 @@ "reindex": "reIndex is permitted", "local_rename": "renaming into the unreplicated local database is permitted", "search": "search and vector search surfaces are available", - "replication": "replication commands are available (applyOps, oplog access)", + "replication": "replication commands are available (applyOps)", "remote_target": "the server sees the connection as originating from a non-localhost address", "validate_repair": ( "validate with repair/fixMultikey is permitted and background validation " From 637a7a72695c77976efa8972a084e50284105b1a Mon Sep 17 00:00:00 2001 From: Samar Farooqi Date: Thu, 5 Nov 2026 23:08:30 +0000 Subject: [PATCH 4/5] test(changeStream): Gate oldest_minus_5s on oplog through the closest marker The requires gate reads only the closest requires marker, and the function-level change_streams marker sits closer than a case's own marker, so the oplog requirement on oldest_minus_5s was ignored and the case still ran on targets without a readable oplog. Move the change_streams requirement to module level and restate it on the oldest_minus_5s case alongside oplog, so the case marker is the closest one and carries both requirements. Signed-off-by: Samar Farooqi --- .../changeStream/test_changeStream_early_start.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py b/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py index 2102a7c00..075c55dec 100644 --- a/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py +++ b/documentdb_tests/compatibility/tests/core/operator/system-stages/changeStream/test_changeStream_early_start.py @@ -22,6 +22,8 @@ from documentdb_tests.framework.property_checks import Eq from documentdb_tests.framework.test_case import BaseTestCase +pytestmark = pytest.mark.requires(change_streams=True) + # Return the timestamp of the oldest retained oplog entry, so a start point can # be expressed relative to the live oplog rather than as a static value. @@ -85,12 +87,13 @@ class ChangeStreamEarlyStartTestCase(BaseTestCase): expected={"ok": Eq(1.0)}, msg="$changeStream should accept a startAtOperationTime five seconds before" " the oldest retained oplog entry", - marks=(pytest.mark.requires(oplog=True),), + # The requires gate reads only the closest requires marker, so a case + # marker must restate the module-level change_streams requirement. + marks=(pytest.mark.requires(change_streams=True, oplog=True),), ), ] -@pytest.mark.requires(change_streams=True) @pytest.mark.aggregate @pytest.mark.parametrize("test_case", pytest_params(CHANGESTREAM_EARLY_START_TESTS)) def test_changeStream_early_start_collection_scope( @@ -107,7 +110,6 @@ def test_changeStream_early_start_collection_scope( assertResult(result, expected=test_case.expected, msg=test_case.msg, raw_res=True) -@pytest.mark.requires(change_streams=True) @pytest.mark.aggregate @pytest.mark.parametrize("test_case", pytest_params(CHANGESTREAM_EARLY_START_TESTS)) def test_changeStream_early_start_database_scope( @@ -126,7 +128,6 @@ def test_changeStream_early_start_database_scope( assertResult(result, expected=test_case.expected, msg=test_case.msg, raw_res=True) -@pytest.mark.requires(change_streams=True) @pytest.mark.aggregate @pytest.mark.parametrize("test_case", pytest_params(CHANGESTREAM_EARLY_START_TESTS)) def test_changeStream_early_start_cluster_scope( From 9087c2f5c2d4db8693b6460afea914600e5de634 Mon Sep 17 00:00:00 2001 From: Samar Farooqi Date: Fri, 6 Nov 2026 00:33:34 +0000 Subject: [PATCH 5/5] test(collMod): Gate the oplog.rs collMod cases on replication max_target_oplog and size_target_oplog only check that collMod rejects cappedMax/cappedSize on local.oplog.rs with InvalidOptions. They need the oplog.rs namespace to exist, not a readable oplog, so gating them on oplog skipped them on Amazon DocumentDB, which returns InvalidOptions for both. Gate them on replication instead. They still run on a MongoDB replica set and are still skipped on a standalone, which has no oplog.rs. Signed-off-by: Samar Farooqi --- .../collections/commands/collMod/test_collMod_capped_max.py | 3 ++- .../collections/commands/collMod/test_collMod_capped_size.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/documentdb_tests/compatibility/tests/core/collections/commands/collMod/test_collMod_capped_max.py b/documentdb_tests/compatibility/tests/core/collections/commands/collMod/test_collMod_capped_max.py index c6f54d567..e886b5e80 100644 --- a/documentdb_tests/compatibility/tests/core/collections/commands/collMod/test_collMod_capped_max.py +++ b/documentdb_tests/compatibility/tests/core/collections/commands/collMod/test_collMod_capped_max.py @@ -263,7 +263,8 @@ command=lambda ctx: {"collMod": "oplog.rs", "cappedMax": 1_000}, error_code=INVALID_OPTIONS_ERROR, msg="collMod should reject cappedMax on the oplog", - marks=(pytest.mark.requires(oplog=True),), + # Only the oplog.rs namespace is needed, not a readable oplog. + marks=(pytest.mark.requires(replication=True),), ), ] diff --git a/documentdb_tests/compatibility/tests/core/collections/commands/collMod/test_collMod_capped_size.py b/documentdb_tests/compatibility/tests/core/collections/commands/collMod/test_collMod_capped_size.py index 6723a3b6b..49af5457f 100644 --- a/documentdb_tests/compatibility/tests/core/collections/commands/collMod/test_collMod_capped_size.py +++ b/documentdb_tests/compatibility/tests/core/collections/commands/collMod/test_collMod_capped_size.py @@ -294,7 +294,8 @@ command=lambda ctx: {"collMod": "oplog.rs", "cappedSize": 100_000}, error_code=INVALID_OPTIONS_ERROR, msg="collMod should reject cappedSize on the oplog", - marks=(pytest.mark.requires(oplog=True),), + # Only the oplog.rs namespace is needed, not a readable oplog. + marks=(pytest.mark.requires(replication=True),), ), ]