Skip to content

TOOLS-4263 Convert mongorestore oplog-replay edge-case tests to Go - #1060

Merged
autarch merged 1 commit into
masterfrom
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go
Aug 12, 2026
Merged

TOOLS-4263 Convert mongorestore oplog-replay edge-case tests to Go#1060
autarch merged 1 commit into
masterfrom
07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go

Conversation

@autarch

@autarch autarch commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Adds five tests in mongorestore/oplog_edges_test.go covering mongorestore's oplog-replay edge cases, and moves the BSON fixtures these tests need from test/qa-tests/jstests/restore/testdata/ to mongorestore/testdata/. This also adds testutil.SkipUnlessStandalone in common/testutil/testutil.go: restoring a dumped local/oplog.rs.bson as a collection only works on a standalone, because a replica set rejects direct writes to local.oplog.rs and mongos rejects writes to the local database and does not support applyOps. Evergreen's integration-*-cluster variants are replica sets, so the affected test skips there.

JS -> Go mapping (all Go tests live in mongorestore/oplog_edges_test.go):

  • test/qa-tests/jstests/restore/oplog_replay_conflict.js -> TestOplogReplayConflict - a dump that contains an embedded oplog.bson and is also given an explicit --oplogFile must fail, and must apply no data at all.
  • test/qa-tests/jstests/restore/oplog_replay_priority_oplog.js -> TestOplogReplayPriorityOplog - when both an embedded oplog and a higher-priority --oplogFile are available, only the entries from the --oplogFile are applied. Standalone only, per the skip described above.
  • test/qa-tests/jstests/restore/oplog_replay_noop.js -> TestOplogReplayNoop - noop oplog entries are skipped during replay while the surrounding inserts are applied.
  • test/qa-tests/jstests/restore/preserve_oplog_structure_order.js -> TestOplogReplayPreservesComplexIDOrder - an update op whose _id is a multi-field subdocument preserves that subdocument's field order through replay, so the op matches the intended document. The document is pre-inserted on server 8.1+ per SERVER-88158.
  • test/qa-tests/jstests/restore/oplog_replay_size_safety.js -> TestOplogReplaySizeSafety - replay batches ops without exceeding the server's message size limit. The matrix is reduced to 50k small ops plus 8 roughly 1MB ops; the JS version swept up to a million ops, which is far slower for the same signal.

@autarch
autarch force-pushed the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch from 8fc1df8 to cb21dec Compare August 5, 2026 21:43
@autarch
autarch force-pushed the 07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go branch from 1507db7 to b058c9d Compare August 5, 2026 21:43
@autarch
autarch force-pushed the 07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go branch from b058c9d to aaa2f97 Compare August 5, 2026 21:47
@autarch
autarch force-pushed the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch from cb21dec to 20dc955 Compare August 5, 2026 21:47
@autarch
autarch force-pushed the 07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go branch 2 times, most recently from 556d7a4 to 3faea21 Compare August 6, 2026 19:57
@autarch
autarch force-pushed the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch from 20dc955 to cdfbc96 Compare August 6, 2026 21:25
@autarch
autarch requested a review from mmcclimon August 7, 2026 16:12
@autarch
autarch marked this pull request as ready for review August 7, 2026 16:12
@autarch
autarch requested a review from a team as a code owner August 7, 2026 16:12
@autarch
autarch force-pushed the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch from cdfbc96 to 2ab1f91 Compare August 7, 2026 18:41
@autarch
autarch force-pushed the 07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go branch from 3faea21 to 4ce1d14 Compare August 7, 2026 18:42
@autarch
autarch force-pushed the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch from 2ab1f91 to 0343320 Compare August 7, 2026 18:57

@mmcclimon mmcclimon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, LGTM.

Comment thread mongorestore/oplog_edges_test.go Outdated
"providing two top-priority oplogs errors",
)

count, err := coll.CountDocuments(context.Background(), bson.M{})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit agin) Usually we use bson.D here.

Comment thread mongorestore/oplog_edges_test.go Outdated
assert.EqualValues(t, 0, count, "no entries are restored when the oplogs conflict")
}

// TestOplogReplayPriorityOplog converts oplog_replay_priority_oplog.js: when a

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these comments that say "this converts whatever.js" are useful.

Comment thread mongorestore/oplog_edges_test.go Outdated

// This test restores the dump_local_oplog fixture, which contains a
// local/oplog.rs.bson. Writing local.oplog.rs is only allowed on a
// standalone. Like the JS test this replaces, it is only meaningful there.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needless reference to JS test.

// preserve_oplog_structure_order.js: replaying an update op whose _id is a
// multi-field subdocument must preserve the field order, otherwise the server
// rejects the op (the o._id and o2._id must match).
func TestOplogReplayPreservesComplexIDOrder(t *testing.T) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JS version of this tests runs restore 10 times; I'm not totally sure why, but the comment suggests that it might randomly do the correct thing, and that running it multiple times will ensure it's actually doing the right thing. Should we keep that behavior here?

@autarch
autarch force-pushed the 07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go branch from 4ce1d14 to da61e5a Compare August 10, 2026 20:44
@autarch
autarch force-pushed the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch from 0343320 to aa0f959 Compare August 10, 2026 20:44
@autarch
autarch force-pushed the 07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go branch from da61e5a to 616ab13 Compare August 10, 2026 21:22
@autarch
autarch force-pushed the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch 2 times, most recently from 4d1d9e4 to 5b3c649 Compare August 11, 2026 17:11
@autarch
autarch force-pushed the 07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go branch from 616ab13 to 4156951 Compare August 11, 2026 17:11

autarch commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Aug 12, 6:36 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 12, 6:40 PM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 12, 6:40 PM UTC: @autarch merged this pull request with Graphite.

@autarch
autarch changed the base branch from 07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go to graphite-base/1060 August 12, 2026 18:37
@autarch
autarch changed the base branch from graphite-base/1060 to master August 12, 2026 18:38
The JS -> Go mapping (all under `test/qa-tests/jstests/restore`):

- oplog_replay_conflict.js         -> TestOplogReplayConflict
    (an embedded oplog plus --oplogFile must fail and apply no data)
- oplog_replay_priority_oplog.js   -> TestOplogReplayPriorityOplog
    (only the higher-priority --oplogFile entries are applied)
- oplog_replay_noop.js             -> TestOplogReplayNoop
    (noop entries are skipped, inserts applied)
- preserve_oplog_structure_order.js -> TestOplogReplayPreservesComplexIDOrder
    (an update op with a multi-field subdocument _id preserves field
    order; the doc is pre-inserted on 8.1+ per SERVER-88158)
- oplog_replay_size_safety.js      -> TestOplogReplaySizeSafety
    (reduced matrix: 50k small ops + 8 ~1MB ops; the JS swept up to a
    million ops)

This also moves some fixtures under `mongorestore/testdata`. Move fixtures dump_oplog_conflict, dump_local_oplog, dump_with_noop_in_oplog, dump_with_complex_id_oplog, and extra_oplog.bson into mongorestore/testdata/.

The `oplog_replay_local_rs.js` and `dumprestore7.js` tests are not included in this conversion; they require a replica-set topology and will be converted separately.
@autarch
autarch force-pushed the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch from 5b3c649 to 48f39e4 Compare August 12, 2026 18:39
@autarch
autarch merged commit b5f55db into master Aug 12, 2026
6 of 7 checks passed
@autarch
autarch deleted the 07-17-tools-4263_convert_mongorestore_oplog-replay_edge-case_tests_to_go branch August 12, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants