TOOLS-4263 Convert mongorestore namespace mapping tests to Go - #1093
Draft
autarch wants to merge 1 commit into
Conversation
Collaborator
Author
This was referenced Aug 6, 2026
Collaborator
Author
|
evergreen retry |
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_namespace_mapping_tests_to_go
branch
from
August 7, 2026 18:41
85f592d to
5ed60e7
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_bulk_sizing_tests_to_go
branch
from
August 7, 2026 18:42
7e7a9c9 to
8fd09dd
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_bulk_sizing_tests_to_go
branch
from
August 7, 2026 18:57
8fd09dd to
fd416b5
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_namespace_mapping_tests_to_go
branch
2 times, most recently
from
August 10, 2026 20:44
3ca21f8 to
b77f71d
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_bulk_sizing_tests_to_go
branch
from
August 10, 2026 20:44
fd416b5 to
a19b7e3
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_namespace_mapping_tests_to_go
branch
from
August 11, 2026 16:19
b77f71d to
b6ef562
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_bulk_sizing_tests_to_go
branch
2 times, most recently
from
August 11, 2026 17:11
8158853 to
e4aa6bb
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_namespace_mapping_tests_to_go
branch
from
August 11, 2026 17:11
b6ef562 to
e24c7be
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_bulk_sizing_tests_to_go
branch
from
August 12, 2026 18:43
e4aa6bb to
bd5eab2
Compare
Adds `integration/dumprestore/namespace_test.go`: six `DumpRestoreSuite` methods, fourteen cases in total, covering how mongorestore targets and rewrites namespaces. Every fixture document's `_id` records the namespace it was inserted into, because the JS tests mostly asserted document counts and a count cannot tell a correct restore apart from one that swapped two same-named collections between databases. Every restore also asserts an exact insert count, since mongorestore returns a nil error for a restore that found nothing to do. JS -> Go mapping (all Go tests live in `integration/dumprestore/namespace_test.go`): - `test/qa-tests/jstests/restore/different_collection.js` -> `TestRestoreIntoDifferentCollection` (`integration/dumprestore/namespace_test.go`) - a single collection's bson file is restored through `--db` and `--collection` into a different collection in the same database, into the same collection name in a different database, and into a different collection in a different database, with the documents landing only in the requested target each time. - `test/qa-tests/jstests/restore/different_db.js` -> `TestRestoreIntoDifferentDB` (`integration/dumprestore/namespace_test.go`) - a whole database directory is redirected with `--db`, and then the same dump is remapped with `--nsFrom '$db$.$collection$' --nsTo 'otherdest.$db$_$collection$'` so that both halves of the namespace are rewritten and the source database name ends up folded into the destination collection names. - `test/qa-tests/jstests/restore/namespaces.js` -> `TestRestoreNamespaceMappings` (`integration/dumprestore/namespace_test.go`) - a three-database fixture is restored through a mapping that flattens every source database into one destination, combined in turn with `--nsExclude`, `--nsInclude`, and `--excludeCollectionsWithPrefix`, and then restored again with two `--nsFrom`/`--nsTo` pairs that exchange a pair of databases. The swap case is the interesting one: mongorestore resolves every mapping against the original namespace and returns on the first match rather than chaining them, so applying the two pairs in sequence would send everything to one database, and the encoded `_id`s catch that. Each restored collection is also checked to have kept the index built over a field named for its source namespace, asserting the index key rather than just its name. - `test/qa-tests/jstests/restore/multiple_dbs.js` -> `TestRestoreMultipleDBs` (`integration/dumprestore/namespace_test.go`) - two databases that share a collection name round-trip together and each ends up with exactly its own documents. - `test/qa-tests/jstests/restore/partial_restore.js` -> `TestPartialRestore` (`integration/dumprestore/namespace_test.go`) - from a dump spanning two databases, restoring one database and then one collection leaves every namespace that was not asked for absent rather than merely empty. - `test/legacy42/jstests/tool/dumprestore4.js` -> `TestRestoreIntoDifferentDBBuildsIndexes` (`integration/dumprestore/namespace_test.go`) - covers SERVER-2186: restoring a dump into a differently named database gives the destination the source's indexes, while a same-named database that happens to exist alongside it is left untouched. One implementation note worth recording: `mongodump` accepts a single `--db` and has no `--nsInclude`, so a dump spanning several databases has to be assembled one database at a time into a shared root, which `withMultiDBDump` does. Dumping everything instead would sweep `admin` and `config` into the dump and then into the restores.
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_namespace_mapping_tests_to_go
branch
from
August 12, 2026 18:44
e24c7be to
ba45e6a
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/namespace_test.go: sixDumpRestoreSuitemethods, fourteen cases in total, covering how mongorestore targets and rewrites namespaces. Every fixture document's_idrecords the namespace it was inserted into, because the JS tests mostly asserted document counts and a count cannot tell a correct restore apart from one that swapped two same-named collections between databases. Every restore also asserts an exact insert count, since mongorestore returns a nil error for a restore that found nothing to do.JS -> Go mapping (all Go tests live in
integration/dumprestore/namespace_test.go):test/qa-tests/jstests/restore/different_collection.js->TestRestoreIntoDifferentCollection(integration/dumprestore/namespace_test.go) - a single collection's bson file is restored through--dband--collectioninto a different collection in the same database, into the same collection name in a different database, and into a different collection in a different database, with the documents landing only in the requested target each time.test/qa-tests/jstests/restore/different_db.js->TestRestoreIntoDifferentDB(integration/dumprestore/namespace_test.go) - a whole database directory is redirected with--db, and then the same dump is remapped with--nsFrom '$db$.$collection$' --nsTo 'otherdest.$db$_$collection$'so that both halves of the namespace are rewritten and the source database name ends up folded into the destination collection names.test/qa-tests/jstests/restore/namespaces.js->TestRestoreNamespaceMappings(integration/dumprestore/namespace_test.go) - a three-database fixture is restored through a mapping that flattens every source database into one destination, combined in turn with--nsExclude,--nsInclude, and--excludeCollectionsWithPrefix, and then restored again with two--nsFrom/--nsTopairs that exchange a pair of databases. The swap case is the interesting one: mongorestore resolves every mapping against the original namespace and returns on the first match rather than chaining them, so applying the two pairs in sequence would send everything to one database, and the encoded_ids catch that. Each restored collection is also checked to have kept the index built over a field named for its source namespace, asserting the index key rather than just its name.test/qa-tests/jstests/restore/multiple_dbs.js->TestRestoreMultipleDBs(integration/dumprestore/namespace_test.go) - two databases that share a collection name round-trip together and each ends up with exactly its own documents.test/qa-tests/jstests/restore/partial_restore.js->TestPartialRestore(integration/dumprestore/namespace_test.go) - from a dump spanning two databases, restoring one database and then one collection leaves every namespace that was not asked for absent rather than merely empty.test/legacy42/jstests/tool/dumprestore4.js->TestRestoreIntoDifferentDBBuildsIndexes(integration/dumprestore/namespace_test.go) - covers SERVER-2186: restoring a dump into a differently named database gives the destination the source's indexes, while a same-named database that happens to exist alongside it is left untouched.One implementation note worth recording:
mongodumpaccepts a single--dband has no--nsInclude, so a dump spanning several databases has to be assembled one database at a time into a shared root, whichwithMultiDBDumpdoes. Dumping everything instead would sweepadminandconfiginto the dump and then into the restores.