TOOLS-4263 Convert mongorestore collection-options and metadata tests to Go - #1073
Draft
autarch wants to merge 1 commit into
Draft
Conversation
Collaborator
Author
This was referenced Aug 5, 2026
autarch
force-pushed
the
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 5, 2026 21:47
d387e39 to
b140e6a
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
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 5, 2026 21:48
b140e6a to
4f8a684
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
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 6, 2026 21:25
4f8a684 to
7aae4fa
Compare
This was referenced Aug 6, 2026
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
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 7, 2026 18:42
7aae4fa to
fe29406
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
autarch
force-pushed
the
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
2 times, most recently
from
August 10, 2026 20:44
f741073 to
8caf2b8
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
changed the base branch from
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
to
graphite-base/1073
August 10, 2026 21:22
autarch
force-pushed
the
graphite-base/1073
branch
from
August 11, 2026 16:19
5bc5a26 to
c7741dd
Compare
autarch
force-pushed
the
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 11, 2026 16:19
8caf2b8 to
bf6c0ab
Compare
autarch
changed the base branch from
graphite-base/1073
to
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
August 11, 2026 16:19
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
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 11, 2026 17:11
bf6c0ab to
e2915ba
Compare
autarch
changed the base branch from
07-23-tools-4263_convert_mongorestore_replica-set_oplog-replay_tests_to_go
to
graphite-base/1073
August 12, 2026 18:41
autarch
force-pushed
the
graphite-base/1073
branch
from
August 12, 2026 18:42
ec6cd0a to
a069aa5
Compare
autarch
force-pushed
the
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 12, 2026 18:42
e2915ba to
a76dd71
Compare
… to Go
Adds `integration/dumprestore/options_roundtrip_test.go`: six `DumpRestoreSuite` methods, 18 cases in total, covering how mongorestore handles collection options and dump metadata.
JS -> Go mapping (all Go tests live in `integration/dumprestore/options_roundtrip_test.go`):
- `test/legacy42/jstests/tool/dumprestore8.js` -> `TestCappedCollectionRoundTrip` (`integration/dumprestore/options_roundtrip_test.go`) - capped collection options, secondary indexes, and eviction behavior survive a dump/restore round trip. The fixture is a plain collection with two secondary indexes plus a capped collection that has already evicted documents, and it is restored four ways to cover each granularity: from the dump root, from a single database directory into a new database name, with `--nsInclude db.*`, and from a single BSON file into a new collection name. Each case checks document counts, index names, the capped options, and, most importantly, that the restored collection still evicts, by inserting past the cap and asserting the count does not grow.
- `test/qa-tests/jstests/restore/extended_json_metadata.js` -> `TestRestoreExtendedJSONMetadata` (`integration/dumprestore/options_roundtrip_test.go`) - metadata written by very old versions of mongodump used legacy extended JSON types for numeric values, so the test hand-writes metadata in that shape, with `{"$numberLong": ...}` for the capped `size` and for an index's `key`, `min`, `max`, and `bits`, plus `v: 1` indexes and an `ns` field, then asserts the capped options are restored and the index keys decode to plain values (`_id -> 1`, `pos -> "2d"`) rather than to documents or strings. Modern mongodump cannot produce such a dump, so the fixture is built at runtime instead of being checked in, which also lets the now-unused `testdata/dump_extended_json_options` fixture go away.
- `test/qa-tests/jstests/restore/no_options_restore.js` -> `TestNoOptionsRestore` (`integration/dumprestore/options_roundtrip_test.go`) - a default restore preserves collection options while `--noOptionsRestore` discards them, exercised against a fixture of one capped collection, one collection with a validator, and one collection with no options, all holding the same documents. In the stripped cases the restored collections are compared against the options an actual no-options collection reports on the same server, rather than against a hardcoded empty document, because servers add default option fields over time.
- `test/legacy42/jstests/tool/dumprestoreWithNoOptions.js` -> `TestNoOptionsRestore` (`integration/dumprestore/options_roundtrip_test.go`) - `--noOptionsRestore` discards options at more than one granularity, covered by cases for a whole-dump restore and for a single-collection restore.
- `test/qa-tests/jstests/restore/collation.js` -> `TestCollationRoundTrip` (`integration/dumprestore/options_roundtrip_test.go`) - a collection's default collation survives a round trip, restoring both from the dump directory and from the BSON file directly.
- `test/qa-tests/jstests/restore/restore_document_validation.js` -> `TestRestoreDocumentValidation` (`integration/dumprestore/options_roundtrip_test.go`) - how restore interacts with document validation, in six cases: a validator on the target collection rejects the invalid half of the dump and mongorestore reports those as failures; `--bypassDocumentValidation` restores all of them; a validator carried in the dump's own metadata is recreated on restore and then rejects that same dump's invalid documents; `--bypassDocumentValidation` overrides even a validator restored that way; and `--stopOnError` and `--maintainInsertionOrder` each surface the validation error instead of swallowing it.
- `test/qa-tests/jstests/restore/norestore_profile.js` -> `TestSystemProfileIsNotRestored` (`integration/dumprestore/options_roundtrip_test.go`) - mongorestore must skip a `system.profile` collection present in a dump. The JS test could never actually reach that check, because mongodump skips every `<db>.system.*` namespace, so the dump it took contained no `system.profile.bson` and the assertion passed vacuously; the Go test instead builds a dump containing `system.profile.bson` and its metadata by hand, then asserts the user data is restored, `system.profile` is not created, and mongorestore reports zero failed inserts, the last of which is what distinguishes mongorestore skipping the file from mongorestore attempting the insert and the server rejecting it.
autarch
force-pushed
the
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 12, 2026 18:43
a76dd71 to
cdd0b30
Compare
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
integration/dumprestore/options_roundtrip_test.go: sixDumpRestoreSuitemethods, 18 cases in total, covering how mongorestore handles collection options and dump metadata.JS -> Go mapping (all Go tests live in
integration/dumprestore/options_roundtrip_test.go):test/legacy42/jstests/tool/dumprestore8.js->TestCappedCollectionRoundTrip(integration/dumprestore/options_roundtrip_test.go) - capped collection options, secondary indexes, and eviction behavior survive a dump/restore round trip. The fixture is a plain collection with two secondary indexes plus a capped collection that has already evicted documents, and it is restored four ways to cover each granularity: from the dump root, from a single database directory into a new database name, with--nsInclude db.*, and from a single BSON file into a new collection name. Each case checks document counts, index names, the capped options, and, most importantly, that the restored collection still evicts, by inserting past the cap and asserting the count does not grow.test/qa-tests/jstests/restore/extended_json_metadata.js->TestRestoreExtendedJSONMetadata(integration/dumprestore/options_roundtrip_test.go) - metadata written by very old versions of mongodump used legacy extended JSON types for numeric values, so the test hand-writes metadata in that shape, with{"$numberLong": ...}for the cappedsizeand for an index'skey,min,max, andbits, plusv: 1indexes and annsfield, then asserts the capped options are restored and the index keys decode to plain values (_id -> 1,pos -> "2d") rather than to documents or strings. Modern mongodump cannot produce such a dump, so the fixture is built at runtime instead of being checked in, which also lets the now-unusedtestdata/dump_extended_json_optionsfixture go away.test/qa-tests/jstests/restore/no_options_restore.js->TestNoOptionsRestore(integration/dumprestore/options_roundtrip_test.go) - a default restore preserves collection options while--noOptionsRestorediscards them, exercised against a fixture of one capped collection, one collection with a validator, and one collection with no options, all holding the same documents. In the stripped cases the restored collections are compared against the options an actual no-options collection reports on the same server, rather than against a hardcoded empty document, because servers add default option fields over time.test/legacy42/jstests/tool/dumprestoreWithNoOptions.js->TestNoOptionsRestore(integration/dumprestore/options_roundtrip_test.go) ---noOptionsRestorediscards options at more than one granularity, covered by cases for a whole-dump restore and for a single-collection restore.test/qa-tests/jstests/restore/collation.js->TestCollationRoundTrip(integration/dumprestore/options_roundtrip_test.go) - a collection's default collation survives a round trip, restoring both from the dump directory and from the BSON file directly.test/qa-tests/jstests/restore/restore_document_validation.js->TestRestoreDocumentValidation(integration/dumprestore/options_roundtrip_test.go) - how restore interacts with document validation, in six cases: a validator on the target collection rejects the invalid half of the dump and mongorestore reports those as failures;--bypassDocumentValidationrestores all of them; a validator carried in the dump's own metadata is recreated on restore and then rejects that same dump's invalid documents;--bypassDocumentValidationoverrides even a validator restored that way; and--stopOnErrorand--maintainInsertionOrdereach surface the validation error instead of swallowing it.test/qa-tests/jstests/restore/norestore_profile.js->TestSystemProfileIsNotRestored(integration/dumprestore/options_roundtrip_test.go) - mongorestore must skip asystem.profilecollection present in a dump. The JS test could never actually reach that check, because mongodump skips every<db>.system.*namespace, so the dump it took contained nosystem.profile.bsonand the assertion passed vacuously; the Go test instead builds a dump containingsystem.profile.bsonand its metadata by hand, then asserts the user data is restored,system.profileis not created, and mongorestore reports zero failed inserts, the last of which is what distinguishes mongorestore skipping the file from mongorestore attempting the insert and the server rejecting it.