TOOLS-4263 Convert the replica-set routing and no-primary import tests to Go - #1161
Draft
Conversation
Collaborator
Author
This was referenced Aug 25, 2026
autarch
force-pushed
the
08-21-tools-4263_convert_the_write-concern_tests_to_go
branch
from
August 25, 2026 20:10
ef7193d to
c6c8c8a
Compare
autarch
force-pushed
the
08-21-tools-4263_convert_the_replica-set_routing_and_no-primary_import_tests_to_go
branch
from
August 25, 2026 20:10
dec9db1 to
831ae22
Compare
…s to Go - `test/qa-tests/jstests/import/replset.js` -> `integration/exportimport/replset_routing_test.go` - the two ways of addressing a replica set that have to end up writing to the primary: the primary's own host, and a set-name seedlist that names only a secondary, where the driver has to discover the primary for itself. The third thing that file checked, an import aimed straight at a secondary being refused, is already covered by `TestImportToSecondaryFails`. - `test/qa-tests/jstests/import/no_primary_error_code.js` and `test/qa-tests/jstests/import/all_primaries_down_error_code.js` -> `integration/exportimport/no_primary_test.go` - mongoimport reports a failure when there is no primary to write to, rather than exiting as if it had succeeded (TOOLS-690). Both cases use a server the test starts: a member started with `--replSet` but never initiated belongs to a set that has no primary, and a free port has no server at all. - `integration/sharedsuite/replicaset.go` - `ReplicaSetToolArgsForHosts` builds the same `--host` argument as `ReplicaSetToolArgs` over a seedlist of only the given hosts, which is what lets the routing test name just a secondary. - `integration/exportimport/multinode_test.go` - `TestImportToSecondaryFails` now drops the collection before importing, and asserts the rejected import left it empty. Without the drop the emptiness assertion could not be made. All three JS files are deleted. Coverage note: the two no-primary tests ran against a sharded cluster, and so exercised mongos's wording of the failure -- "not master", "unable to target", "could not contact primary for replica set" -- by stepping every shard's primary down. The Go test reaches the same tool-level behavior by other means, so those mongos-specific messages are no longer covered. What is covered is that the tool fails rather than claiming success.
autarch
force-pushed
the
08-21-tools-4263_convert_the_replica-set_routing_and_no-primary_import_tests_to_go
branch
from
August 25, 2026 20:18
831ae22 to
89071fc
Compare
autarch
force-pushed
the
08-21-tools-4263_convert_the_write-concern_tests_to_go
branch
from
August 25, 2026 20:18
c6c8c8a to
abb3819
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.

test/qa-tests/jstests/import/replset.js->integration/exportimport/replset_routing_test.go- the two ways of addressing a replica set that have to end up writing to the primary: the primary's own host, and a set-name seedlist that names only a secondary, where the driver has to discover the primary for itself. The third thing that file checked, an import aimed straight at a secondary being refused, is already covered byTestImportToSecondaryFails.test/qa-tests/jstests/import/no_primary_error_code.jsandtest/qa-tests/jstests/import/all_primaries_down_error_code.js->integration/exportimport/no_primary_test.go- mongoimport reports a failure when there is no primary to write to, rather than exiting as if it had succeeded (TOOLS-690). Both cases use a server the test starts: a member started with--replSetbut never initiated belongs to a set that has no primary, and a free port has no server at all.integration/sharedsuite/replicaset.go-ReplicaSetToolArgsForHostsbuilds the same--hostargument asReplicaSetToolArgsover a seedlist of only the given hosts, which is what lets the routing test name just a secondary.integration/exportimport/multinode_test.go-TestImportToSecondaryFailsnow drops the collection before importing, and asserts the rejected import left it empty. Without the drop the emptiness assertion could not be made.All three JS files are deleted.
Coverage note: the two no-primary tests ran against a sharded cluster, and so
exercised mongos's wording of the failure -- "not master", "unable to target",
"could not contact primary for replica set" -- by stepping every shard's primary
down. The Go test reaches the same tool-level behavior by other means, so those
mongos-specific messages are no longer covered. What is covered is that the tool
fails rather than claiming success.