Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ require (
github.com/vulcand/predicate v1.2.0 // replaced
go.etcd.io/etcd/api/v3 v3.5.11
go.etcd.io/etcd/client/v3 v3.5.11
go.mongodb.org/mongo-driver v1.13.0
go.mongodb.org/mongo-driver v1.13.1
go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.46.1
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1559,8 +1559,8 @@ go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R7
go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng=
go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8=
go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
go.mongodb.org/mongo-driver v1.13.0 h1:67DgFFjYOCMWdtTEmKFpV3ffWlFnh+CYZ8ZS/tXWUfY=
go.mongodb.org/mongo-driver v1.13.0/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ=
go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk=
go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
4 changes: 2 additions & 2 deletions lib/srv/db/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,12 @@ func TestMongoDBMaxMessageSize(t *testing.T) {
expectedQueryError bool
}{
"default message size": {
messageSize: 300,
messageSize: 400,
},
"message size exceeded": {
// Set a value that will enable handshake message to complete
// successfully.
maxMessageSize: 300,
maxMessageSize: 400,
messageSize: 500,
expectedQueryError: true,
},
Expand Down
31 changes: 29 additions & 2 deletions lib/srv/db/mongodb/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ func (s *TestServer) handleMessage(message protocol.Message) (protocol.Message,
switch command {
case commandIsMaster:
return s.handleIsMaster(message)
case commandHello:
return s.handleHello(message)
case commandAuth:
return s.handleAuth(message)
case commandPing:
Expand Down Expand Up @@ -274,7 +276,7 @@ func (s *TestServer) handleAuth(message protocol.Message) (protocol.Message, err
// handleIsMaster makes response to the client's "isMaster" command.
//
// isMaster command is used as a handshake by the client to determine the
// cluster topology.
// cluster topology. Replaced by hello command in newer versions.
func (s *TestServer) handleIsMaster(message protocol.Message) (protocol.Message, error) {
isMasterReply, err := makeIsMasterReply(s.getWireVersion(), s.getMaxMessageSize())
if err != nil {
Expand All @@ -289,6 +291,28 @@ func (s *TestServer) handleIsMaster(message protocol.Message) (protocol.Message,
return nil, trace.NotImplemented("unsupported message: %v", message)
}

// handleHello makes response to the client's "hello" command.
//
// hello command is used as a handshake by the client to determine the
// cluster topology.
func (s *TestServer) handleHello(message protocol.Message) (protocol.Message, error) {
reply, err := bson.Marshal(bson.M{
"ok": 1,
"isWritablePrimary": true,
"maxMessageSizeBytes": s.getMaxMessageSize(),
"maxWireVersion": s.getWireVersion(),
"readOnly": false,
"compression": []string{"zlib"},
// `serviceId` is required for LoadBalanced mode. Reference:
// https://github.com/mongodb/specifications/blob/master/source/load-balancers/load-balancers.rst
"serviceId": primitive.NewObjectID(),
})
if err != nil {
return nil, trace.Wrap(err)
}
return protocol.MakeOpMsg(reply), nil
}

// handlePing makes response to the client's "ping" command.
//
// ping command is usually used by client to test connectivity to the server.
Expand Down Expand Up @@ -718,6 +742,7 @@ const (

commandAuth = "authenticate"
commandIsMaster = "isMaster"
commandHello = "hello"
commandPing = "ping"
commandFind = "find"
commandSaslStart = "saslStart"
Expand Down Expand Up @@ -747,7 +772,9 @@ func makeIsMasterReply(wireVersion int, maxMessageSize uint32) ([]byte, error) {
"maxWireVersion": wireVersion,
"maxMessageBytes": maxMessageSize,
"compression": []string{"zlib"},
"serviceId": primitive.NewObjectID(),
// `serviceId` is required for LoadBalanced mode. Reference:
// https://github.com/mongodb/specifications/blob/master/source/load-balancers/load-balancers.rst
"serviceId": primitive.NewObjectID(),
})
}

Expand Down