Skip to content

GODRIVER-1931 Sync new spec tests #646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 26, 2021

Conversation

divjotarora
Copy link
Contributor

This PR syncs the spec tests introduced in mongodb/specifications#934, mongodb/specifications#958, and mongodb/specifications#961.

@divjotarora divjotarora force-pushed the godriver1931-sync-new-tests branch 2 times, most recently from 5e3e69c to d2e9e1d Compare April 23, 2021 23:03
@@ -112,6 +112,9 @@ func VerifyConnStringOptions(t *testing.T, cs connstring.ConnString, options map
case "journal":
require.True(t, cs.JSet)
require.Equal(t, value, cs.J)
case "loadbalanced":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required by URI options tests.

@@ -60,7 +60,9 @@ type readPref struct {
TagSets []map[string]string `json:"tag_sets"`
}

func topologyKindFromString(s string) TopologyKind {
func topologyKindFromString(t *testing.T, s string) TopologyKind {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to accept a testing.T here and in serverKindFromString aren't strictly required, but it's good practice for us to fail on unrecognized topology/server kind strings rather than defaulting to Unknown as we were before, so I felt it was best to add it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice attention to detail!

case "LoadBalancer":
return LoadBalancer
case "PossiblePrimary", "Unknown":
// Go does not have a PossiblePrimary server type and per the SDAM spec, this type is synonymous with Unknown.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See ServerType.

@@ -36,13 +36,22 @@ type seedlistTest struct {
}

func TestInitialDNSSeedlistDiscoverySpec(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here are to account for the fact that the initial DNS seedlist discovery tests were split into replica-set and load-balanced sub-directories. Each sub-test corresponds to one sub-directory.

@@ -122,6 +131,10 @@ func verifyConnstringOptions(mt *mtest.T, expected bson.Raw, cs connstring.ConnS
dc := opt.Boolean()
assert.True(mt, cs.DirectConnectionSet, "expected cs.DirectConnectionSet to be true, got false")
assert.Equal(mt, dc, cs.DirectConnection, "expected cs.DirectConnection to be %v, got %v", dc, cs.DirectConnection)
case "loadBalanced":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added because loadBalanced can be present in TXT records.

assert.False(t, topo.pollingRequired, "expected SRV polling to not be required, but it is")
})

t.Run("new records are not detected", func(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is required by mongodb/specifications#934.

@divjotarora divjotarora requested a review from iwysiu April 26, 2021 16:21
Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit and deferred disconnect suggestion, but otherwise LGTM! Thanks for splitting this up from the remaining evergreen work.

@@ -60,7 +60,9 @@ type readPref struct {
TagSets []map[string]string `json:"tag_sets"`
}

func topologyKindFromString(s string) TopologyKind {
func topologyKindFromString(t *testing.T, s string) TopologyKind {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice attention to detail!

LookupTXT: mockResolver.LookupTXT,
}

topo := createLBTopology(t, "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: is ?loadBalanced=true redundant here since createLBTopology sets the topology's loadbalanced option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Removed. I also realized that createLBTopology is not setting the appropriate server/connection options to enable LB mode at all levels. This probably isn't relevant for this specific test, but I refactored it a bit to set LoadBalanced on the parsed ConnString instead so those options are all handled by WithConnString.

topo := createLBTopology(t, "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true")
topo.dnsResolver = dnsResolver
topo.rescanSRVInterval = time.Millisecond * 5
err := topo.Connect()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defer a disconnect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@divjotarora divjotarora removed the request for review from benjirewis April 26, 2021 18:59
@divjotarora divjotarora merged commit 6e18f0a into mongodb:master Apr 26, 2021
@divjotarora divjotarora deleted the godriver1931-sync-new-tests branch April 26, 2021 21:44
faem pushed a commit to kubedb/mongo-go-driver that referenced this pull request Mar 17, 2022
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.

3 participants