TOOLS-4263 Convert mongorestore replica-set oplog-replay tests to Go - #1049
Merged
autarch merged 1 commit intoAug 12, 2026
Conversation
Collaborator
Author
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
July 23, 2026 18:19
6e72aea to
60200d1
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
July 23, 2026 18:19
f43b301 to
e8077fc
Compare
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
July 24, 2026 16:40
60200d1 to
04c98db
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
July 24, 2026 16:40
e8077fc to
c060980
Compare
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
July 27, 2026 21:16
04c98db to
8fc1df8
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
July 27, 2026 21:17
c060980 to
6b97a36
Compare
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
August 5, 2026 21:43
8fc1df8 to
cb21dec
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 5, 2026 21:43
6b97a36 to
6108e99
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 5, 2026 21:47
6108e99 to
d36edee
Compare
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
August 5, 2026 21:48
cb21dec to
20dc955
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 6, 2026 21:25
d36edee to
b2f3635
Compare
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
August 6, 2026 21:25
20dc955 to
cdfbc96
Compare
This was referenced Aug 6, 2026
autarch
marked this pull request as ready for review
August 7, 2026 16:36
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 7, 2026 18:41
b2f3635 to
dee6aeb
Compare
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
August 7, 2026 18:42
cdfbc96 to
2ab1f91
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 7, 2026 18:57
dee6aeb to
51f2499
Compare
mmcclimon
approved these changes
Aug 10, 2026
mmcclimon
left a comment
Collaborator
There was a problem hiding this comment.
Alright, though I'd probably move these to the dumprestore package and write them to match that style.
| `{"ts":{"$gt":{"$timestamp":{"t":%d,"i":%d}}},"ns":%q,"op":"i"}`, | ||
| checkpoint.T, checkpoint.I, ns, | ||
| ) | ||
| require.NoError(t, runDump(t, baseToolOpts(t), dumpDir, func(md *mongodump.MongoDump) { |
Collaborator
There was a problem hiding this comment.
Should these really go in the mongorestore directory, since they're actually running dump + restore?
| checkpoint := latestOplogTimestamp(t, client) | ||
|
|
||
| // Second batch: these ops follow the checkpoint and must be replayed. | ||
| const secondBatch = 7 |
Collaborator
There was a problem hiding this comment.
(nit) This const is pretty weird, as is the choice of the number 7?
Collaborator
Author
There was a problem hiding this comment.
Claude picked this semi-randomly, but it should differ from the first batch size, so we can be sure that it picks the right "side" of the oplog (with 7 entries after the timestamp rather than 5 before).
| "only the ops after the checkpoint are replayed", | ||
| ) | ||
|
|
||
| batch1Count, err := coll.CountDocuments(ctx, bson.M{"batch": 1}) |
Collaborator
There was a problem hiding this comment.
We usually use bson.D for all of these.
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
August 10, 2026 20:44
0343320 to
aa0f959
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 10, 2026 20:44
51f2499 to
5bc5a26
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 10, 2026 21:22
5bc5a26 to
c7741dd
Compare
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
August 10, 2026 21:22
aa0f959 to
4d1d9e4
Compare
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 11, 2026 17:11
c7741dd to
ec6cd0a
Compare
autarch
force-pushed
the
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
branch
from
August 11, 2026 17:11
4d1d9e4 to
5b3c649
Compare
Collaborator
Author
autarch
changed the base branch from
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
to
graphite-base/1049
August 12, 2026 18:39
This adds a new `TestOplogReplayFromLocalOplogRS` test in `mongorestore/oplog_replset_test.go`. This ports two JS tests into one Go test. It dumps `local.oplog.rs` with a `$gt` timestamp query and replays the dump via `--oplogReplay --oplogFile ...`, verifying only the ops after the checkpoint are applied.
JS -> Go mapping:
- test/qa-tests/jstests/restore/oplog_replay_local_rs.js -> the
--oplogReplay --oplogFile replay of a dumped local/oplog.rs.bson
- test/legacy42/jstests/tool/dumprestore7.js -> the mongodump of
local.oplog.rs with a {ts:{$gt:...}} timestamp query
autarch
force-pushed
the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
from
August 12, 2026 18:41
ec6cd0a to
bf3464c
Compare
autarch
deleted the
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
branch
August 12, 2026 18:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
TestOplogReplayFromLocalOplogRSinmongorestore/oplog_replset_test.go, which ports two JS tests into a single Go test. It records a checkpoint timestamp, performs more writes, dumpslocal.oplog.rswith a{ts: {$gt: <checkpoint>}}query, and replays that dump with--oplogReplay --oplogFile, asserting only the ops after the checkpoint are applied. This test requires a replica set, so it is gated ontesttype.ReplSetTestType(TOOLS_TESTING_REPLSET) rather than the plain integration test type; that is why these two JS tests were deliberately left out of the earlier oplog edge-case conversion.JS -> Go mapping (both map to
TestOplogReplayFromLocalOplogRSinmongorestore/oplog_replset_test.go):test/qa-tests/jstests/restore/oplog_replay_local_rs.js->TestOplogReplayFromLocalOplogRS(mongorestore/oplog_replset_test.go) - the--oplogReplay --oplogFilereplay half: a dumpedlocal/oplog.rs.bsonis replayed against the live replica set and only the expected ops take effect.test/legacy42/jstests/tool/dumprestore7.js->TestOplogReplayFromLocalOplogRS(mongorestore/oplog_replset_test.go) - the mongodump half: dumpinglocal.oplog.rswith a{ts: {$gt: ...}}timestamp query captures exactly the ops after the checkpoint.