TOOLS-4263 Convert mongorestore index round-trip tests to Go - #1074
Conversation
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. |
This was referenced Aug 6, 2026
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
from
August 6, 2026 21:25
dc89c96 to
a464f74
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
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
from
August 7, 2026 18:41
a464f74 to
9af89c7
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
from
August 7, 2026 18:57
9af89c7 to
fa54faa
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
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
from
August 10, 2026 20:44
fa54faa to
79a1fc6
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
force-pushed
the
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
from
August 11, 2026 16:19
79a1fc6 to
7424f8b
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
force-pushed
the
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
from
August 11, 2026 17:11
7424f8b to
871f7d6
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 12, 2026 18:43
a76dd71 to
cdd0b30
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
2 times, most recently
from
August 13, 2026 20:55
1f368aa to
65e5458
Compare
autarch
force-pushed
the
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 13, 2026 20:55
cdd0b30 to
1f88bc2
Compare
autarch
marked this pull request as ready for review
August 13, 2026 21:01
autarch
marked this pull request as draft
August 14, 2026 16:31
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
from
August 14, 2026 16:43
65e5458 to
f1b10a5
Compare
autarch
force-pushed
the
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 14, 2026 16:43
1f88bc2 to
8bbfe97
Compare
autarch
marked this pull request as ready for review
August 14, 2026 16:52
autarch
marked this pull request as draft
August 14, 2026 16:54
Adds `integration/dumprestore/index_roundtrip_test.go`: three `DumpRestoreSuite` methods, seven cases in total, covering how mongorestore round-trips index specifications. This also deletes two fixture directories that only the replaced JS tests used, `test/legacy42/jstests/tool/data/dumprestore6/` and `test/qa-tests/jstests/restore/testdata/dump_ordered_partial_index/`, since the Go tests build the equivalent dumps at runtime.
JS -> Go mapping (all Go tests live in `integration/dumprestore/index_roundtrip_test.go`):
- `test/qa-tests/jstests/restore/indexes.js` -> `TestIndexRoundTrip` (`integration/dumprestore/index_roundtrip_test.go`) - one collection carrying every index type the JS covered (simple, sparse and unique, compound, compound with int64 key values, multikey via array data, text with a non-default `default_language`, and 2dsphere) survives a dump/restore round trip, restored both from the dump directory and from the BSON file directly. The JS only compared index counts, so a mangled text-index weight or a dropped sparse flag would have gone unnoticed; this compares the complete spec of every index before and after, with fixture preconditions asserting the int64 key types and the Spanish text language really landed so that comparison cannot go vacuous. Note that the JS passed `{language: 'spanish'}`, which is not the `createIndex` option name and was therefore ignored by the server, so the Spanish text index is new coverage.
- `test/legacy42/jstests/tool/dumprestore6.js` -> `TestIndexVersionRoundTrip`, the `a legacy system.indexes dump is converted` case (`integration/dumprestore/index_roundtrip_test.go`) - a pre-2.6 dump stores index specs in a `system.indexes.bson` file rather than a per-collection metadata file, and mongorestore falls back to that file when a database directory has no metadata. The test builds such a dump at runtime, deliberately naming a different database in the specs' `ns` fields than the restore target so that mongorestore has to take the target from `--db`, then asserts the document and both indexes are created and the legacy v1 specs are converted to the current index version.
- `test/qa-tests/jstests/restore/index_version_roundtrip.js` -> `TestIndexVersionRoundTrip` (`integration/dumprestore/index_roundtrip_test.go`) - `--keepIndexVersion` restores each `_id` index at its original version, while a restore without the flag gets the server's default version instead. Coverage is limited to `_id` indexes because the version can only be set through the create command's `idIndex` argument: a v1 secondary index is silently upgraded to the current version at creation on supported servers, so there is no secondary index version to round-trip. The secondary indexes are still created and asserted to survive both restores, along with the document counts.
- `test/qa-tests/jstests/restore/ordered_partial_index.js` -> `TestOrderedPartialIndex` (`integration/dumprestore/index_roundtrip_test.go`) - an index whose `partialFilterExpression` has ten fields keeps that document's field order through a real dump and restore, since reordering it would produce an index the server treats as different from the one that was dumped. The index is created on the server, dumped, dropped and restored, with the field order asserted before the dump as well so that a server which reordered the expression on its own could not make the test pass. The fields are given in a deliberately unsorted order and the restored spec is read back as a `bson.D`, so both a sorted reordering and a randomized one are detectable; an ascending field list would have matched its own most likely corruption.
autarch
force-pushed
the
08-05-tools-4263_convert_mongorestore_collection-options_and_metadata_tests_to_go
branch
from
August 14, 2026 19:02
8bbfe97 to
e14c2fe
Compare
autarch
force-pushed
the
08-06-tools-4263_convert_mongorestore_index_round-trip_tests_to_go
branch
from
August 14, 2026 19:02
f1b10a5 to
9d8cf10
Compare
autarch
marked this pull request as ready for review
August 14, 2026 19:53
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/index_roundtrip_test.go: covering how mongorestore round-trips index specifications.JS -> Go mapping (all Go tests live in
integration/dumprestore/index_roundtrip_test.go):test/qa-tests/jstests/restore/indexes.js->TestIndexRoundTrip(integration/dumprestore/index_roundtrip_test.go) - one collection carrying every index type the JS covered (simple, sparse and unique, compound, compound with int64 key values, multikey via array data, text with a non-defaultdefault_language, and 2dsphere) survives a dump/restore round trip, restored both from the dump directory and from the BSON file directly. The JS only compared index counts, so a mangled text-index weight or a dropped sparse flag would have gone unnoticed; this compares the complete spec of every index before and after, with fixture preconditions asserting the int64 key types and the Spanish text language really landed so that we're testing what we think we're testing. Note that the JS passed{language: 'spanish'}, which is not thecreateIndexoption name and was therefore ignored by the server, so the Spanish text index is new coverage.test/legacy42/jstests/tool/dumprestore6.js->TestRestoreLegacySystemIndexes(integration/dumprestore/index_roundtrip_test.go) - a pre-2.6 dump stores index specs in asystem.indexes.bsonfile rather than a per-collection metadata file, and mongorestore falls back to that file when a database directory has no metadata. The test builds such a dump at runtime, deliberately naming a different database in the specs'nsfields than the restore target so that mongorestore has to take the target from--db, then asserts the document and both indexes are created and the legacy v1 specs are converted to the current index version.test/qa-tests/jstests/restore/index_version_roundtrip.js->TestIndexVersionRoundTrip(integration/dumprestore/index_roundtrip_test.go) ---keepIndexVersionrestores each_idindex at its original version, while a restore without the flag gets the server's default version instead. Coverage is limited to_idindexes because the version can only be set through the create command'sidIndexargument: a v1 secondary index is silently upgraded to the current version at creation on supported servers, so there is no secondary index version to round-trip. The secondary indexes are still created and asserted to survive both restores, along with the document counts.test/qa-tests/jstests/restore/ordered_partial_index.js->TestOrderedPartialIndex(integration/dumprestore/index_roundtrip_test.go) - an index whosepartialFilterExpressionhas ten fields keeps that document's field order through the metadata file, since reordering it would produce an index the server treats as different from the one that was dumped. The fields are written in a deliberately unsorted order and the restored spec is read back as abson.D, so both a sorted reordering and a randomized one are detectable; an ascending field list would have matched its own most likely corruption.