TOOLS-4263 Convert mongorestore invalid-input tests to Go - #1046
Merged
autarch merged 1 commit intoAug 12, 2026
Merged
Conversation
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
July 16, 2026 20:27
4fe13c9 to
a8f11cc
Compare
autarch
force-pushed
the
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
branch
from
July 16, 2026 20:35
75c4e40 to
eef4eab
Compare
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
2 times, most recently
from
July 17, 2026 18:57
ae94bd6 to
ef8ebd0
Compare
autarch
force-pushed
the
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
branch
from
July 17, 2026 18:57
eef4eab to
47590df
Compare
autarch
force-pushed
the
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
branch
from
July 23, 2026 13:44
47590df to
5892362
Compare
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
July 23, 2026 13:44
ef8ebd0 to
0cea3b8
Compare
autarch
force-pushed
the
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
branch
from
July 24, 2026 16:40
5892362 to
fcdfb84
Compare
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
3 times, most recently
from
July 24, 2026 18:51
0566460 to
178b1c7
Compare
autarch
force-pushed
the
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
branch
from
July 27, 2026 21:16
fcdfb84 to
523ab1e
Compare
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
July 27, 2026 21:17
178b1c7 to
1507db7
Compare
autarch
changed the base branch from
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
to
graphite-base/1046
August 5, 2026 21:16
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
August 5, 2026 21:43
1507db7 to
b058c9d
Compare
autarch
force-pushed
the
graphite-base/1046
branch
from
August 5, 2026 21:43
523ab1e to
37b0e2c
Compare
autarch
changed the base branch from
graphite-base/1046
to
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
August 5, 2026 21:43
Collaborator
Author
|
evergreen retry |
autarch
force-pushed
the
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
branch
from
August 5, 2026 21:47
37b0e2c to
95a5707
Compare
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
August 5, 2026 21:47
b058c9d to
aaa2f97
Compare
autarch
changed the base branch from
07-16-tools-4263_delete_js_tests_fully_covered_by_existing_go_tests
to
graphite-base/1046
August 6, 2026 19:55
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
August 6, 2026 19:56
aaa2f97 to
556d7a4
Compare
autarch
force-pushed
the
graphite-base/1046
branch
from
August 6, 2026 19:56
95a5707 to
cc6dd24
Compare
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
August 6, 2026 19:57
556d7a4 to
3faea21
Compare
This was referenced Aug 6, 2026
autarch
marked this pull request as ready for review
August 7, 2026 15:23
autarch
requested review from
Ronan-mongodb and
mmcclimon
and removed request for
a team and
Ronan-mongodb
August 7, 2026 15:23
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
August 7, 2026 18:41
3faea21 to
4ce1d14
Compare
mmcclimon
approved these changes
Aug 10, 2026
Comment on lines
+67
to
+68
| // alongside --objcheck is now rejected as an unknown flag. The JS test's intent | ||
| // (the two flags cannot be combined) still holds. |
Collaborator
There was a problem hiding this comment.
This comment ("The JS test's intent") is weird.
Comment on lines
+22
to
+32
| // TestRestoreInvalidInput consolidates the mongorestore invalid-input and | ||
| // error-path coverage that previously lived in the qa-tests JS suite | ||
| // (bad_options.js, missing_dump.js, invalid_dump_target.js, malformed_bson.js, | ||
| // malformed_metadata.js, invalid_metadata.js, blank_collection_bson.js, | ||
| // blank_db.js, objcheck_valid_bson.js, oplog_replay_no_oplog.js). Each case | ||
| // asserts on the error returned by option validation or by Restore(), rather | ||
| // than on a process exit code. | ||
| // | ||
| // bad_options.js's invalid-verbosity case (-v torvalds) is intentionally not | ||
| // converted: verbosity parsing lives in the shared common/options package, not | ||
| // in mongorestore, so it is out of scope for these restore-specific tests. |
Collaborator
There was a problem hiding this comment.
I don't think this comment is necessary.
| // writeBSONCollectionFile writes the given documents to path in the | ||
| // concatenated-BSON format that mongodump produces for a collection (an empty | ||
| // docs list produces a zero-byte file, i.e. a blank collection). | ||
| func writeBSONCollectionFile(t *testing.T, path string, docs ...bson.M) { |
Collaborator
There was a problem hiding this comment.
It's weird that these use bson.M and not bson.D (which we use everywhere else)
| "dropping target collection", | ||
| ) | ||
|
|
||
| const numDocs = 50 |
Collaborator
There was a problem hiding this comment.
(nit) This constant isn't wrong, but seems really weird to me, instead of just a variable.
|
|
||
| // restoreFromArgs builds a MongoRestore from the given args, runs it, and | ||
| // returns the result. The instance is closed when the test finishes. | ||
| func restoreFromArgs(t *testing.T, args ...string) Result { |
Collaborator
There was a problem hiding this comment.
This name is pretty confusing, imo; restoreFromArgs is very similar to the existing getRestoreWithArgs, but this function actually runs .Restore() on the mongorestore instance.
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
August 10, 2026 20:44
4ce1d14 to
da61e5a
Compare
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
2 times, most recently
from
August 11, 2026 17:11
616ab13 to
4156951
Compare
Collaborator
Author
This adds a new `TestRestoreInvalidInput` test in `mongorestore/invalid_input_test.go`. This covers a number of cases for mongorestore's handling of invalid input options.
It replaces many JS tests:
- bad_options.js -> "option validation" subtests: --objcheck
with --noobjcheck, malformed --oplogLimit,
negative --writeConcern, invalid --db,
invalid --collection. (The -v verbosity
case is omitted: it exercises shared
common/options code, not mongorestore.)
- missing_dump.js -> "missing dump target" subtests (missing
dir, missing dir with --db, missing bson
file with --collection)
- invalid_dump_target.js -> "invalid dump target" subtests (file where
a dir is expected, with and without --db;
dir where a bson file is expected)
- malformed_bson.js -> "malformed bson file errors"
- malformed_metadata.js -> "malformed metadata file errors"
- invalid_metadata.js -> "invalid index in metadata errors"
- blank_collection_bson.js -> "blank collection bson" subtests (with and
without a metadata file)
- blank_db.js -> "blank db directory succeeds"
- objcheck_valid_bson.js -> "objcheck succeeds on valid bson"
- oplog_replay_no_oplog.js -> "oplogReplay with no oplog file errors"
autarch
force-pushed
the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
from
August 12, 2026 18:37
4156951 to
6173adf
Compare
autarch
deleted the
07-16-tools-4263_convert_mongorestore_invalid-input_tests_to_go
branch
August 12, 2026 18:38
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
TestRestoreInvalidInputinmongorestore/invalid_input_test.go, covering mongorestore's handling of invalid options and invalid dump input. Each case asserts on the error returned by option validation or byRestore(), rather than on a process exit code. Every case is a named subtest function referenced from the parent, so the parent reads as a flat table of cases.This also deletes the BSON/metadata fixtures under
test/qa-tests/jstests/restore/testdata/that only these JS tests used; the Go test writes the equivalent fixtures at runtime.JS -> Go mapping (all Go subtests live in
mongorestore/invalid_input_test.gounderTestRestoreInvalidInput):test/qa-tests/jstests/restore/bad_options.js->testRestoreObjcheckWithNoobjcheck,testRestoreNegativeWriteConcern,testRestoreMalformedOplogLimit,testRestoreInvalidDBName,testRestoreInvalidCollectionName -Invalid option combinations and values are rejected:--objchecktogether with the removed--noobjcheckflag, a negative--writeConcern, an--oplogLimitthat is not a timestamp, a--dbcontaining an illegal character, and a--collectioncontaining an illegal character. (The JS test's-v torvaldsverbosity case is intentionally not converted: verbosity parsing lives in the sharedcommon/optionspackage, not in mongorestore.)test/qa-tests/jstests/restore/missing_dump.js->testRestoreMissingDumpDirectory,testRestoreMissingDumpDirectoryWithDB,testRestoreMissingBSONFile- Restoring from a path that does not exist errors, whether it is a dump directory, a dump directory with--db, or a BSON file with--collection.test/qa-tests/jstests/restore/invalid_dump_target.js->testRestoreFileInsteadOfDirectory,testRestoreFileInsteadOfDBDirectory,testRestoreDirectoryInsteadOfBSONFile- Pointing mongorestore at the wrong kind of path errors: a plain file where a dump directory is expected (with and without--db), and a directory where a BSON file is expected.test/qa-tests/jstests/restore/malformed_bson.js->testRestoreMalformedBSON- A BSON file that is not valid BSON produces a read error rather than partial data.test/qa-tests/jstests/restore/malformed_metadata.js->testRestoreMalformedMetadata- A.metadata.jsonfile that is not valid JSON produces a metadata parse error.test/qa-tests/jstests/restore/invalid_metadata.js->testRestoreInvalidIndexMetadata- Well-formed metadata containing an index spec the server rejects (an empty key document) produces an error.test/qa-tests/jstests/restore/blank_collection_bson.js->testRestoreBlankCollectionBSONWithoutMetadata,testRestoreBlankCollectionBSONWithMetadata- A zero-byte collection BSON file restores successfully and inserts nothing, both with and without an accompanying metadata file.test/qa-tests/jstests/restore/blank_db.js->testRestoreBlankDBDirectory- An empty database directory restores successfully and inserts nothing.test/qa-tests/jstests/restore/objcheck_valid_bson.js->testRestoreObjcheckValidBSON - --objcheckagainst valid BSON succeeds and restores every document.test/qa-tests/jstests/restore/oplog_replay_no_oplog.js->testRestoreOplogReplayNoOplogFile---oplogReplayagainst a dump with nooplog.bsonerrors.