TOOLS-4263 Convert mongorestore drop, path and stdin tests to Go - #1096
Draft
Conversation
This was referenced Aug 7, 2026
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
autarch
force-pushed
the
08-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go
branch
from
August 7, 2026 18:57
56c20e5 to
dde6481
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-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go
branch
from
August 10, 2026 20:44
dde6481 to
4f3a46b
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-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go
branch
from
August 11, 2026 16:19
4f3a46b to
330501c
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-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go
branch
from
August 11, 2026 17:11
330501c to
b73dae3
Compare
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
Adds `integration/dumprestore/drop_test.go` and `integration/dumprestore/paths_test.go`, extends `TestPipedDumpRestore` and `TestRestoreInvalidInput`, and deletes the seven JS tests they replace plus the symlink fixture that only one of them used. JS -> Go mapping: - `test/qa-tests/jstests/restore/drop_with_data.js` -> `TestRestoreDropWithData` (`integration/dumprestore/drop_test.go`) - `--drop` replaces the existing contents of two collections. The pre-dump data is swapped for a disjoint set of documents with a different count before the restore, so a restore that upserted by `_id` rather than dropping leaves both sets behind and fails on content, not just on a count that happens to match. - `test/qa-tests/jstests/restore/drop_one_collection.js` -> `TestRestoreDropOneCollection` (`integration/dumprestore/drop_test.go`) - `--drop` scoped with `--collection` replaces only that collection, leaving its sibling and a second database holding the same collection names untouched. - `test/qa-tests/jstests/restore/drop_nonexistent_db.js` -> `TestRestoreDropNonexistentDB` (`integration/dumprestore/drop_test.go`) - `--drop` against a database that does not exist is not an error and restores normally. - `test/qa-tests/jstests/restore/slash_in_collectionname.js` -> `TestRestoreSpecialCollectionNames` (`integration/dumprestore/paths_test.go`) - collections named `coll/foo`, `coll%bar` and `coll%2Fbaz` round-trip through a directory-format dump, where the name has to survive being escaped into a filename and unescaped again. The third name is a double-escaping guard: if `%` ever stopped being escaped on the dump side, `coll%2Fbaz` would unescape back to `coll/baz` and restore into the wrong namespace. - `test/qa-tests/jstests/restore/archive_stdout.js` -> `TestArchiveThroughStdout` (`integration/dumprestore/paths_test.go`) - a real `mongodump --archive` process has its standard output piped into a real `mongorestore --archive --drop` process. `TestPipedDumpRestore` covers the archive format but connects the two in-process through an `io.Pipe`, so the CLI plumbing here (`--archive` with no value selecting stdout and stdin, and a binary archive surviving a real pipe) is not covered anywhere else. - `test/qa-tests/jstests/restore/symlinks.js` -> `TestRestoreDumpWithSymlinks` (`integration/dumprestore/paths_test.go`) - a dump directory in which a database directory and a collection's bson file are both symlinks restores correctly, and a symlink to a plain file at the top level is not walked as a database directory. - `test/legacy42/jstests/tool/dumprestore1.js` -> three subtests in `TestRestoreInvalidInput` (`mongorestore/invalid_input_test.go`) - a restore target of `-` reads from stdin, which carries no namespace of its own, so it is rejected with only `--db`, rejected with only `--collection`, and accepted with both. The accepting case matters: without it the two rejections would pass even if `--dir -` were rejected unconditionally. Two things worth flagging for review. **The symlink fixture has no symlinks.** Every entry under `test/qa-tests/jstests/restore/testdata/dump_with_soft_links/` is a regular file (mode `100644`), and the supposed link targets are duplicated blobs: `dbOne/data.bson` and `soft_linked_collection.bson` are the same object, as are `dbTwo/data.bson` and `soft_linked_db/data.bson`. The links were flattened into copies at some point, so `symlinks.js` has been exercising an ordinary dump directory. The Go test builds its dump with real symlinks at runtime, which makes it a coverage increase rather than a like-for-like port, and the fixture is deleted rather than carried forward. **`TestPipedDumpRestore` now verifies what it restored.** It previously renamed every namespace and then asserted only that `Restore()` returned no error, never reading back a document, so a namespace dropped or misrouted by the archive demultiplexer would have gone unnoticed. It now checks every destination namespace.
autarch
force-pushed
the
08-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go
branch
from
August 12, 2026 18:45
b73dae3 to
8c3b16c
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/drop_test.goandintegration/dumprestore/paths_test.go, extendsTestPipedDumpRestoreandTestRestoreInvalidInput, and deletes the seven JS tests they replace plus the symlink fixture that only one of them used.JS -> Go mapping:
test/qa-tests/jstests/restore/drop_with_data.js->TestRestoreDropWithData(integration/dumprestore/drop_test.go) ---dropreplaces the existing contents of two collections. The pre-dump data is swapped for a disjoint set of documents with a different count before the restore, so a restore that upserted by_idrather than dropping leaves both sets behind and fails on content, not just on a count that happens to match.test/qa-tests/jstests/restore/drop_one_collection.js->TestRestoreDropOneCollection(integration/dumprestore/drop_test.go) ---dropscoped with--collectionreplaces only that collection, leaving its sibling and a second database holding the same collection names untouched.test/qa-tests/jstests/restore/drop_nonexistent_db.js->TestRestoreDropNonexistentDB(integration/dumprestore/drop_test.go) ---dropagainst a database that does not exist is not an error and restores normally.test/qa-tests/jstests/restore/slash_in_collectionname.js->TestRestoreSpecialCollectionNames(integration/dumprestore/paths_test.go) - collections namedcoll/foo,coll%barandcoll%2Fbazround-trip through a directory-format dump, where the name has to survive being escaped into a filename and unescaped again. The third name is a double-escaping guard: if%ever stopped being escaped on the dump side,coll%2Fbazwould unescape back tocoll/bazand restore into the wrong namespace.test/qa-tests/jstests/restore/archive_stdout.js->TestArchiveThroughStdout(integration/dumprestore/paths_test.go) - a realmongodump --archiveprocess has its standard output piped into a realmongorestore --archive --dropprocess.TestPipedDumpRestorecovers the archive format but connects the two in-process through anio.Pipe, so the CLI plumbing here (--archivewith no value selecting stdout and stdin, and a binary archive surviving a real pipe) is not covered anywhere else.test/qa-tests/jstests/restore/symlinks.js->TestRestoreDumpWithSymlinks(integration/dumprestore/paths_test.go) - a dump directory in which a database directory and a collection's bson file are both symlinks restores correctly, and a symlink to a plain file at the top level is not walked as a database directory.test/legacy42/jstests/tool/dumprestore1.js-> three subtests inTestRestoreInvalidInput(mongorestore/invalid_input_test.go) - a restore target of-reads from stdin, which carries no namespace of its own, so it is rejected with only--db, rejected with only--collection, and accepted with both. The accepting case matters: without it the two rejections would pass even if--dir -were rejected unconditionally.Two things worth flagging for review.
The symlink fixture has no symlinks. Every entry under
test/qa-tests/jstests/restore/testdata/dump_with_soft_links/is a regular file (mode100644), and the supposed link targets are duplicated blobs:dbOne/data.bsonandsoft_linked_collection.bsonare the same object, as aredbTwo/data.bsonandsoft_linked_db/data.bson. The links were flattened into copies at some point, sosymlinks.jshas been exercising an ordinary dump directory. The Go test builds its dump with real symlinks at runtime, which makes it a coverage increase rather than a like-for-like port, and the fixture is deleted rather than carried forward.TestPipedDumpRestorenow verifies what it restored. It previously renamed every namespace and then asserted only thatRestore()returned no error, never reading back a document, so a namespace dropped or misrouted by the archive demultiplexer would have gone unnoticed. It now checks every destination namespace.