Skip to content

TOOLS-4263 Convert mongorestore users and roles temp collection tests to Go - #1097

Draft
autarch wants to merge 1 commit into
08-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_gofrom
08-07-tools-4263_convert_mongorestore_users_and_roles_temp_collection_tests_to_go
Draft

TOOLS-4263 Convert mongorestore users and roles temp collection tests to Go#1097
autarch wants to merge 1 commit into
08-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_gofrom
08-07-tools-4263_convert_mongorestore_users_and_roles_temp_collection_tests_to_go

Conversation

@autarch

@autarch autarch commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Extends TestRestoreUsersOrRoles in integration/dumprestore/roundtrip_test.go with two cases covering how mongorestore handles the temporary collections it stages users and roles in, and deletes the two JS tests they replace.

JS -> Go mapping:

  • test/qa-tests/jstests/restore/nonempty_temp_users.js -> the "with a nonempty temp users collection" case of TestRestoreUsersOrRoles (integration/dumprestore/roundtrip_test.go) - mongorestore stages users in admin.tempusers before merging them into the real user collection, so a document left there by an interrupted earlier run must neither derail the restore nor survive it. The test seeds that collection with a junk document before restoring, then asserts the restore succeeded, the temp collections are gone, and the user and role from the dump actually exist.
  • test/qa-tests/jstests/restore/users_and_roles_temp_collections.js -> the "with custom temp collection names" case of TestRestoreUsersOrRoles (integration/dumprestore/roundtrip_test.go) - this is the first coverage anywhere of --tempUsersColl and --tempRolesColl. The restore is run with custom names for both, and the test asserts those custom collections are cleaned up afterwards and that the user and role were restored.

Both JS tests asserted only the tool's exit code; these assert that the user and role exist afterwards, which is what the temp-collection machinery is in service of. The fixture user and role are dropped before each case, because BeforeTest deliberately leaves the admin database alone and that is where they live.

@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_users_and_roles_temp_collection_tests_to_go branch from 6c8805c to 8a19082 Compare August 7, 2026 18:57
@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go branch from 56c20e5 to dde6481 Compare August 7, 2026 18:57
@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_users_and_roles_temp_collection_tests_to_go branch from 8a19082 to 8b003ae Compare August 10, 2026 20:44
@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go branch from dde6481 to 4f3a46b Compare August 10, 2026 20:44
@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_users_and_roles_temp_collection_tests_to_go branch from 8b003ae to 3e2ec35 Compare August 11, 2026 16:19
@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go branch 2 times, most recently from 330501c to b73dae3 Compare August 11, 2026 17:11
@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_users_and_roles_temp_collection_tests_to_go branch from 3e2ec35 to 43362fe Compare August 11, 2026 17:11
@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_drop_path_and_stdin_tests_to_go branch from b73dae3 to 8c3b16c Compare August 12, 2026 18:45
… to Go

Extends `TestRestoreUsersOrRoles` in `integration/dumprestore/roundtrip_test.go` with two cases covering how mongorestore handles the temporary collections it stages users and roles in, and deletes the two JS tests they replace.

JS -> Go mapping:

- `test/qa-tests/jstests/restore/nonempty_temp_users.js` -> the "with a nonempty temp users collection" case of `TestRestoreUsersOrRoles` (`integration/dumprestore/roundtrip_test.go`) - mongorestore stages users in `admin.tempusers` before merging them into the real user collection, so a document left there by an interrupted earlier run must neither derail the restore nor survive it. The test seeds that collection with a junk document before restoring, then asserts the restore succeeded, the temp collections are gone, and the user and role from the dump actually exist.
- `test/qa-tests/jstests/restore/users_and_roles_temp_collections.js` -> the "with custom temp collection names" case of `TestRestoreUsersOrRoles` (`integration/dumprestore/roundtrip_test.go`) - this is the first coverage anywhere of `--tempUsersColl` and `--tempRolesColl`. The restore is run with custom names for both, and the test asserts those custom collections are cleaned up afterwards and that the user and role were restored.

Both JS tests asserted only the tool's exit code; these assert that the user and role exist afterwards, which is what the temp-collection machinery is in service of. The fixture user and role are dropped before each case, because `BeforeTest` deliberately leaves the `admin` database alone and that is where they live.
@autarch
autarch force-pushed the 08-07-tools-4263_convert_mongorestore_users_and_roles_temp_collection_tests_to_go branch from 43362fe to 7e8aa42 Compare August 12, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant