Skip to content

Commit d387c1d

Browse files
author
Divjot Arora
committed
rebase proxy dialer work
1 parent 78bb014 commit d387c1d

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

mongo/integration/sdam_prose_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ func TestSDAMProse(t *testing.T) {
1919
mt := mtest.New(t)
2020
defer mt.Close()
2121

22-
proxyDialer := newProxyDialer()
2322
lowHeartbeatFrequency := 50 * time.Millisecond
2423
heartbeatFrequencyClientOpts := options.Client().
25-
SetHeartbeatInterval(lowHeartbeatFrequency).
26-
SetDialer(proxyDialer)
24+
SetHeartbeatInterval(lowHeartbeatFrequency)
2725
heartbeatFrequencyMtOpts := mtest.NewOptions().
2826
ClientOptions(heartbeatFrequencyClientOpts).
2927
CreateCollection(false).
30-
SSL(false)
28+
ClientType(mtest.Proxy)
3129
mt.RunOpts("heartbeats processed more frequently", heartbeatFrequencyMtOpts, func(mt *mtest.T) {
3230
// Test that lowering heartbeat frequency to 50ms causes the client to process heartbeats more frequently.
3331
//
@@ -47,8 +45,9 @@ func TestSDAMProse(t *testing.T) {
4745
mt.Logf("num responses expected: %d\n", numExpectedResponses)
4846

4947
time.Sleep(timeDuration + 50*time.Millisecond)
50-
assert.True(mt, len(proxyDialer.messages) >= numExpectedResponses, "expected at least %d responses, got %d",
51-
numExpectedResponses, len(proxyDialer.messages))
48+
messages := mt.GetProxiedMessages()
49+
assert.True(mt, len(messages) >= numExpectedResponses, "expected at least %d responses, got %d",
50+
numExpectedResponses, len(messages))
5251
})
5352

5453
mt.RunOpts("rtt tests", noClientOpts, func(mt *mtest.T) {

mongo/integration/sessions_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,15 @@ func TestSessions(t *testing.T) {
7070
mtOpts := mtest.NewOptions().MinServerVersion("3.6").Topologies(mtest.ReplicaSet, mtest.Sharded).
7171
CreateClient(false)
7272
mt := mtest.New(t, mtOpts)
73+
hosts := options.Client().ApplyURI(mt.ConnString()).Hosts
7374

7475
// Pin to a single mongos so heartbeats/handshakes to other mongoses won't cause errors.
76+
clusterTimeClientOpts := options.Client().
77+
SetHosts(hosts[:1]).
78+
SetDirect(true).
79+
SetHeartbeatInterval(50 * time.Second)
7580
clusterTimeOpts := mtest.NewOptions().
76-
ClientOptions(options.Client().SetHeartbeatInterval(50 * time.Second)).
77-
ClientType(mtest.Pinned).
81+
ClientOptions(clusterTimeClientOpts).
7882
CreateClient(false)
7983
mt.RunOpts("cluster time", clusterTimeOpts, func(mt *mtest.T) {
8084
// $clusterTime included in commands
@@ -117,7 +121,6 @@ func TestSessions(t *testing.T) {
117121
}
118122
})
119123

120-
hosts := options.Client().ApplyURI(mt.ConnString()).Hosts
121124
clusterTimeHandshakeOpts := options.Client().
122125
SetHosts(hosts[:1]). // Prevent handshakes to other hosts from updating the cluster time.
123126
SetDirect(true).
@@ -134,12 +137,12 @@ func TestSessions(t *testing.T) {
134137
assert.True(mt, len(msgPairs) > 2, "expected more than two messages, got %d", len(msgPairs))
135138

136139
for idx, pair := range mt.GetProxiedMessages() {
137-
// Get the $clusterTime value sent to the server. The first two messages are the handshakes for the
138-
// heartbeat and application connections. These should not contain $clusterTime because they happen on
140+
// Get the $clusterTime value sent to the server. The first three messages are the handshakes for the
141+
// heartbeat, RTT, and application connections. These should not contain $clusterTime because they happen on
139142
// connections that don't know the server's wire version and therefore don't know if the server supports
140143
// $clusterTime.
141144
_, err = pair.Sent.Command.LookupErr("$clusterTime")
142-
if idx <= 1 {
145+
if idx <= 2 {
143146
assert.NotNil(mt, err, "expected no $clusterTime field in command %s", pair.Sent.Command)
144147
continue
145148
}

0 commit comments

Comments
 (0)