@@ -70,11 +70,15 @@ func TestSessions(t *testing.T) {
70
70
mtOpts := mtest .NewOptions ().MinServerVersion ("3.6" ).Topologies (mtest .ReplicaSet , mtest .Sharded ).
71
71
CreateClient (false )
72
72
mt := mtest .New (t , mtOpts )
73
+ hosts := options .Client ().ApplyURI (mt .ConnString ()).Hosts
73
74
74
75
// 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 )
75
80
clusterTimeOpts := mtest .NewOptions ().
76
- ClientOptions (options .Client ().SetHeartbeatInterval (50 * time .Second )).
77
- ClientType (mtest .Pinned ).
81
+ ClientOptions (clusterTimeClientOpts ).
78
82
CreateClient (false )
79
83
mt .RunOpts ("cluster time" , clusterTimeOpts , func (mt * mtest.T ) {
80
84
// $clusterTime included in commands
@@ -117,7 +121,6 @@ func TestSessions(t *testing.T) {
117
121
}
118
122
})
119
123
120
- hosts := options .Client ().ApplyURI (mt .ConnString ()).Hosts
121
124
clusterTimeHandshakeOpts := options .Client ().
122
125
SetHosts (hosts [:1 ]). // Prevent handshakes to other hosts from updating the cluster time.
123
126
SetDirect (true ).
@@ -134,12 +137,12 @@ func TestSessions(t *testing.T) {
134
137
assert .True (mt , len (msgPairs ) > 2 , "expected more than two messages, got %d" , len (msgPairs ))
135
138
136
139
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
139
142
// connections that don't know the server's wire version and therefore don't know if the server supports
140
143
// $clusterTime.
141
144
_ , err = pair .Sent .Command .LookupErr ("$clusterTime" )
142
- if idx <= 1 {
145
+ if idx <= 2 {
143
146
assert .NotNil (mt , err , "expected no $clusterTime field in command %s" , pair .Sent .Command )
144
147
continue
145
148
}
0 commit comments