From 6c8abf00f0e7d7ccfab659bab36cd4ccc797d785 Mon Sep 17 00:00:00 2001 From: Samar Farooqi Date: Fri, 16 Oct 2026 20:05:49 +0000 Subject: [PATCH 1/2] 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 2a3956554a18c3ead237bda699b3589bd34fc4e8 Mon Sep 17 00:00:00 2001 From: Samar Farooqi Date: Fri, 16 Oct 2026 20:06:06 +0000 Subject: [PATCH 2/2] 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",