From 62cf67de7f47760d6a79174e7c44bce19aaa664b Mon Sep 17 00:00:00 2001 From: julius Date: Thu, 17 Mar 2022 03:22:50 -0700 Subject: [PATCH 01/10] initial commit, for some reason some spec tests not passing --- .gitignore | 1 + pymongo/collection.py | 7 +- pymongo/command_cursor.py | 5 ++ pymongo/cursor.py | 1 + pymongo/database.py | 1 + pymongo/message.py | 11 ++- pymongo/mongo_client.py | 2 +- .../unified/change-streams.json | 82 +++++++++++++++++++ test/crud/unified/aggregate.json | 10 +-- test/crud/unified/find-comment.json | 10 +-- test/test_client.py | 3 +- 11 files changed, 113 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index de435d109e..f7ad6563ff 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ pymongo.egg-info/ .tox mongocryptd.pid .idea/ +.nova/ diff --git a/pymongo/collection.py b/pymongo/collection.py index d0ebd9311a..3de1210522 100644 --- a/pymongo/collection.py +++ b/pymongo/collection.py @@ -2180,7 +2180,12 @@ def _cmd(session, server, sock_info, read_preference): raise cursor = {"id": 0, "firstBatch": []} cmd_cursor = CommandCursor( - coll, cursor, sock_info.address, session=session, explicit_session=explicit_session + coll, + cursor, + sock_info.address, + session=session, + explicit_session=explicit_session, + comment=cmd.get("comment"), ) cmd_cursor._maybe_pin_connection(sock_info) return cmd_cursor diff --git a/pymongo/command_cursor.py b/pymongo/command_cursor.py index 0bd99f0bbb..d071224e8c 100644 --- a/pymongo/command_cursor.py +++ b/pymongo/command_cursor.py @@ -43,6 +43,7 @@ def __init__( max_await_time_ms: Optional[int] = None, session: Optional["ClientSession"] = None, explicit_session: bool = False, + comment: Any = None, ) -> None: """Create a new command cursor.""" self.__sock_mgr: Any = None @@ -56,6 +57,7 @@ def __init__( self.__session = session self.__explicit_session = explicit_session self.__killed = self.__id == 0 + self.__comment = comment if self.__killed: self.__end_session(True) @@ -156,6 +158,8 @@ def _maybe_pin_connection(self, sock_info): def __send_message(self, operation): """Send a getmore message and handle the response.""" client = self.__collection.database.client + if self.__comment is not None: + operation["comment"] = self.__comment try: response = client._run_operation( operation, self._unpack_response, address=self.__address @@ -224,6 +228,7 @@ def _refresh(self): self.__max_await_time_ms, self.__sock_mgr, False, + self.__comment, ) ) else: # Cursor id is zero nothing else to return diff --git a/pymongo/cursor.py b/pymongo/cursor.py index 9f6f0898b4..350cc255bb 100644 --- a/pymongo/cursor.py +++ b/pymongo/cursor.py @@ -1183,6 +1183,7 @@ def _refresh(self): self.__max_await_time_ms, self.__sock_mgr, self.__exhaust, + self.__comment, ) self.__send_message(g) diff --git a/pymongo/database.py b/pymongo/database.py index 17cba06b65..d3d1b274fd 100644 --- a/pymongo/database.py +++ b/pymongo/database.py @@ -780,6 +780,7 @@ def _list_collections(self, sock_info, session, read_preference, **kwargs): sock_info.address, session=tmp_session, explicit_session=session is not None, + comment=cmd.get("comment"), ) cmd_cursor._maybe_pin_connection(sock_info) return cmd_cursor diff --git a/pymongo/message.py b/pymongo/message.py index 6aa8e4e7f9..34e09b2cb3 100644 --- a/pymongo/message.py +++ b/pymongo/message.py @@ -222,13 +222,15 @@ def _gen_find_command( return cmd -def _gen_get_more_command(cursor_id, coll, batch_size, max_await_time_ms): +def _gen_get_more_command(cursor_id, coll, batch_size, max_await_time_ms, comment): """Generate a getMore command document.""" cmd = SON([("getMore", cursor_id), ("collection", coll)]) if batch_size: cmd["batchSize"] = batch_size if max_await_time_ms is not None: cmd["maxTimeMS"] = max_await_time_ms + if comment is not None: + cmd["comment"] = comment return cmd @@ -421,6 +423,7 @@ class _GetMore(object): "sock_mgr", "_as_command", "exhaust", + "comment", ) name = "getMore" @@ -438,6 +441,7 @@ def __init__( max_await_time_ms, sock_mgr, exhaust, + comment, ): self.db = db self.coll = coll @@ -451,6 +455,7 @@ def __init__( self.sock_mgr = sock_mgr self._as_command = None self.exhaust = exhaust + self.comment = comment def namespace(self): return "%s.%s" % (self.db, self.coll) @@ -469,13 +474,13 @@ def use_command(self, sock_info): def as_command(self, sock_info): """Return a getMore command document for this query.""" # See _Query.as_command for an explanation of this caching. + if self._as_command is not None: return self._as_command cmd = _gen_get_more_command( - self.cursor_id, self.coll, self.ntoreturn, self.max_await_time_ms + self.cursor_id, self.coll, self.ntoreturn, self.max_await_time_ms, self.comment ) - if self.session: self.session._apply_to(cmd, False, self.read_preference, sock_info) sock_info.add_server_api(cmd) diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index 280818ce00..957c9da410 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -1763,7 +1763,7 @@ def list_databases( "firstBatch": res["databases"], "ns": "admin.$cmd", } - return CommandCursor(admin["$cmd"], cursor, None) + return CommandCursor(admin["$cmd"], cursor, None, comment) def list_database_names( self, diff --git a/test/change_streams/unified/change-streams.json b/test/change_streams/unified/change-streams.json index 4aea9a4aa1..9187d4eda5 100644 --- a/test/change_streams/unified/change-streams.json +++ b/test/change_streams/unified/change-streams.json @@ -247,6 +247,88 @@ ] } ] + }, + { + "description": "Test that comment is set on getMore", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0" + } + ], + "operations": [ + { + "name": "createChangeStream", + "object": "collection0", + "arguments": { + "pipeline": [], + "comment": "comment" + }, + "saveResultAsEntity": "changeStream0" + }, + { + "name": "insertOne", + "object": "collection0", + "arguments": { + "document": { + "_id": 1, + "a": 1 + } + } + }, + { + "name": "iterateUntilDocumentOrError", + "object": "changeStream0" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "collection0", + "pipeline": [ + { + "$changeStream": {} + } + ], + "comment": "comment" + } + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "collection0", + "documents": [ + { + "_id": 1, + "a": 1 + } + ] + } + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "collection0", + "comment": "comment" + }, + "commandName": "getMore", + "databaseName": "database0" + } + } + ] + } + ] } ] } diff --git a/test/crud/unified/aggregate.json b/test/crud/unified/aggregate.json index f6da8ff32f..73d37917df 100644 --- a/test/crud/unified/aggregate.json +++ b/test/crud/unified/aggregate.json @@ -327,7 +327,7 @@ ] }, { - "description": "aggregate with comment does not set comment on getMore", + "description": "aggregate with comment sets comment on getMore", "runOnRequirements": [ { "minServerVersion": "3.6.0" @@ -411,9 +411,7 @@ }, "collection": "coll0", "batchSize": 2, - "comment": { - "$$exists": false - } + "comment": "comment" }, "commandName": "getMore", "databaseName": "aggregate-tests" @@ -430,9 +428,7 @@ }, "collection": "coll0", "batchSize": 2, - "comment": { - "$$exists": false - } + "comment": "comment" }, "commandName": "getMore", "databaseName": "aggregate-tests" diff --git a/test/crud/unified/find-comment.json b/test/crud/unified/find-comment.json index 6000bb0172..d7cf859688 100644 --- a/test/crud/unified/find-comment.json +++ b/test/crud/unified/find-comment.json @@ -195,7 +195,7 @@ ] }, { - "description": "find with comment does not set comment on getMore", + "description": "find with comment sets comment on getMore", "runOnRequirements": [ { "minServerVersion": "3.6" @@ -267,9 +267,7 @@ }, "collection": "coll0", "batchSize": 2, - "comment": { - "$$exists": false - } + "comment": "comment" } } }, @@ -284,9 +282,7 @@ }, "collection": "coll0", "batchSize": 2, - "comment": { - "$$exists": false - } + "comment": "comment" } } } diff --git a/test/test_client.py b/test/test_client.py index a0d6e22d53..7300ab5580 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -1332,7 +1332,7 @@ def test_stale_getmore(self): with self.assertRaises(AutoReconnect): client = rs_client(connect=False, serverSelectionTimeoutMS=100) client._run_operation( - operation=message._GetMore( + operation=message.kge_GetMore( "pymongo_test", "collection", 101, @@ -1344,6 +1344,7 @@ def test_stale_getmore(self): None, None, False, + None, ), unpack_res=Cursor(client.pymongo_test.collection)._unpack_response, address=("not-a-member", 27017), From 1ae5c26ea3a7fdc2550aa11758bb503d991759af Mon Sep 17 00:00:00 2001 From: julius Date: Fri, 18 Mar 2022 14:14:53 -0700 Subject: [PATCH 02/10] add in more routing to hopefully make it work --- pymongo/aggregation.py | 1 + pymongo/command_cursor.py | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pymongo/aggregation.py b/pymongo/aggregation.py index 84ecffe5fb..62fe4bd055 100644 --- a/pymongo/aggregation.py +++ b/pymongo/aggregation.py @@ -174,6 +174,7 @@ def get_cursor(self, session, server, sock_info, read_preference): max_await_time_ms=self._max_await_time_ms, session=session, explicit_session=self._explicit_session, + comment=self._options.get("comment"), ) cmd_cursor._maybe_pin_connection(sock_info) return cmd_cursor diff --git a/pymongo/command_cursor.py b/pymongo/command_cursor.py index d071224e8c..ccb98d70ef 100644 --- a/pymongo/command_cursor.py +++ b/pymongo/command_cursor.py @@ -158,8 +158,6 @@ def _maybe_pin_connection(self, sock_info): def __send_message(self, operation): """Send a getmore message and handle the response.""" client = self.__collection.database.client - if self.__comment is not None: - operation["comment"] = self.__comment try: response = client._run_operation( operation, self._unpack_response, address=self.__address @@ -211,7 +209,6 @@ def _refresh(self): """ if len(self.__data) or self.__killed: return len(self.__data) - if self.__id: # Get More dbname, collname = self.__ns.split(".", 1) read_pref = self.__collection._read_preference_for(self.session) From 895541ada2055eec3fac27587a86aa8294835db7 Mon Sep 17 00:00:00 2001 From: julius Date: Fri, 18 Mar 2022 14:33:25 -0700 Subject: [PATCH 03/10] add support for raw command cursors --- pymongo/command_cursor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pymongo/command_cursor.py b/pymongo/command_cursor.py index ccb98d70ef..4a96661ca2 100644 --- a/pymongo/command_cursor.py +++ b/pymongo/command_cursor.py @@ -316,6 +316,7 @@ def __init__( max_await_time_ms: Optional[int] = None, session: Optional["ClientSession"] = None, explicit_session: bool = False, + comment: Any = None, ) -> None: """Create a new cursor / iterator over raw batches of BSON data. @@ -334,6 +335,7 @@ def __init__( max_await_time_ms, session, explicit_session, + comment, ) def _unpack_response( From 476ceb6915a0c6587a9e79b4be54a70ff47edf44 Mon Sep 17 00:00:00 2001 From: julius Date: Fri, 18 Mar 2022 14:50:00 -0700 Subject: [PATCH 04/10] should fix last remaining test errors --- pymongo/mongo_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index 957c9da410..83295fccc9 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -1763,7 +1763,7 @@ def list_databases( "firstBatch": res["databases"], "ns": "admin.$cmd", } - return CommandCursor(admin["$cmd"], cursor, None, comment) + return CommandCursor(admin["$cmd"], cursor, None, comment=comment) def list_database_names( self, From ed6abd3ace2b4ff3a079f4037c87671cb7a77911 Mon Sep 17 00:00:00 2001 From: julius Date: Fri, 18 Mar 2022 15:04:54 -0700 Subject: [PATCH 05/10] missed a typo --- test/test_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_client.py b/test/test_client.py index 7300ab5580..7a66792873 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -1332,7 +1332,7 @@ def test_stale_getmore(self): with self.assertRaises(AutoReconnect): client = rs_client(connect=False, serverSelectionTimeoutMS=100) client._run_operation( - operation=message.kge_GetMore( + operation=message._GetMore( "pymongo_test", "collection", 101, From d650ba89b40bf1075b1c041db16c1b25588d0d41 Mon Sep 17 00:00:00 2001 From: julius Date: Sat, 19 Mar 2022 01:11:01 -0700 Subject: [PATCH 06/10] forgot to pull when I resynced tests, lol --- test/change_streams/unified/change-streams.json | 6 +++++- test/crud/unified/aggregate.json | 6 +++++- test/crud/unified/bulkWrite-updateMany-let.json | 2 +- test/crud/unified/bulkWrite-updateOne-let.json | 2 +- test/crud/unified/find-comment.json | 6 +++++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/test/change_streams/unified/change-streams.json b/test/change_streams/unified/change-streams.json index 9187d4eda5..bc9d462ee3 100644 --- a/test/change_streams/unified/change-streams.json +++ b/test/change_streams/unified/change-streams.json @@ -252,7 +252,11 @@ "description": "Test that comment is set on getMore", "runOnRequirements": [ { - "minServerVersion": "3.6.0" + "minServerVersion": "4.4.0", + "topologies": [ + "single", + "replicaset" + ] } ], "operations": [ diff --git a/test/crud/unified/aggregate.json b/test/crud/unified/aggregate.json index 73d37917df..3ce353d808 100644 --- a/test/crud/unified/aggregate.json +++ b/test/crud/unified/aggregate.json @@ -330,7 +330,11 @@ "description": "aggregate with comment sets comment on getMore", "runOnRequirements": [ { - "minServerVersion": "3.6.0" + "minServerVersion": "4.4.0", + "topologies": [ + "single", + "replicaset" + ] } ], "operations": [ diff --git a/test/crud/unified/bulkWrite-updateMany-let.json b/test/crud/unified/bulkWrite-updateMany-let.json index 3cc8da4c53..fbeba1a607 100644 --- a/test/crud/unified/bulkWrite-updateMany-let.json +++ b/test/crud/unified/bulkWrite-updateMany-let.json @@ -142,7 +142,7 @@ "description": "BulkWrite updateMany with let option unsupported (server-side error)", "runOnRequirements": [ { - "minServerVersion": "3.6.0", + "minServerVersion": "4.2.0", "maxServerVersion": "4.9" } ], diff --git a/test/crud/unified/bulkWrite-updateOne-let.json b/test/crud/unified/bulkWrite-updateOne-let.json index 2a3e4f79dc..96783c782f 100644 --- a/test/crud/unified/bulkWrite-updateOne-let.json +++ b/test/crud/unified/bulkWrite-updateOne-let.json @@ -144,7 +144,7 @@ "description": "BulkWrite updateOne with let option unsupported (server-side error)", "runOnRequirements": [ { - "minServerVersion": "3.6.0", + "minServerVersion": "4.2.0", "maxServerVersion": "4.9" } ], diff --git a/test/crud/unified/find-comment.json b/test/crud/unified/find-comment.json index d7cf859688..3d92be7c33 100644 --- a/test/crud/unified/find-comment.json +++ b/test/crud/unified/find-comment.json @@ -198,7 +198,11 @@ "description": "find with comment sets comment on getMore", "runOnRequirements": [ { - "minServerVersion": "3.6" + "minServerVersion": "4.4.0", + "topologies": [ + "single", + "replicaset" + ] } ], "operations": [ From b8398fe4c029eea92a84f0e49894016517e65cd8 Mon Sep 17 00:00:00 2001 From: julius Date: Sat, 19 Mar 2022 03:38:49 -0700 Subject: [PATCH 07/10] add a skiptest because comments on getmores aren't supported on earlier versions --- test/test_monitoring.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_monitoring.py b/test/test_monitoring.py index 0b8200c019..f317dde553 100644 --- a/test/test_monitoring.py +++ b/test/test_monitoring.py @@ -239,6 +239,7 @@ def _test_find_options(self, query, expected_cmd): # Exhaust the cursor to avoid kill cursors. tuple(cursor) + @client_context.require_version_min(4, 4, 4) def test_find_options(self): query = dict( filter={}, From a960050c2118f3526ddb40733c939ed051da4d30 Mon Sep 17 00:00:00 2001 From: julius Date: Tue, 22 Mar 2022 15:07:11 -0700 Subject: [PATCH 08/10] fix blank lines added/removed --- pymongo/command_cursor.py | 1 + pymongo/message.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pymongo/command_cursor.py b/pymongo/command_cursor.py index 4a96661ca2..6f3f244419 100644 --- a/pymongo/command_cursor.py +++ b/pymongo/command_cursor.py @@ -209,6 +209,7 @@ def _refresh(self): """ if len(self.__data) or self.__killed: return len(self.__data) + if self.__id: # Get More dbname, collname = self.__ns.split(".", 1) read_pref = self.__collection._read_preference_for(self.session) diff --git a/pymongo/message.py b/pymongo/message.py index 34e09b2cb3..14c00492c2 100644 --- a/pymongo/message.py +++ b/pymongo/message.py @@ -474,7 +474,6 @@ def use_command(self, sock_info): def as_command(self, sock_info): """Return a getMore command document for this query.""" # See _Query.as_command for an explanation of this caching. - if self._as_command is not None: return self._as_command From cfc97bd4afa1ad6a86e516e5966c5e8e98c82357 Mon Sep 17 00:00:00 2001 From: julius Date: Thu, 24 Mar 2022 16:13:50 -0700 Subject: [PATCH 09/10] only send comment on getmore with wire version >9 --- pymongo/message.py | 11 ++++++++--- test/test_monitoring.py | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pymongo/message.py b/pymongo/message.py index 14c00492c2..1fdf0ece35 100644 --- a/pymongo/message.py +++ b/pymongo/message.py @@ -222,14 +222,14 @@ def _gen_find_command( return cmd -def _gen_get_more_command(cursor_id, coll, batch_size, max_await_time_ms, comment): +def _gen_get_more_command(cursor_id, coll, batch_size, max_await_time_ms, comment, sock_info): """Generate a getMore command document.""" cmd = SON([("getMore", cursor_id), ("collection", coll)]) if batch_size: cmd["batchSize"] = batch_size if max_await_time_ms is not None: cmd["maxTimeMS"] = max_await_time_ms - if comment is not None: + if comment is not None and sock_info.max_wire_version >= 9: cmd["comment"] = comment return cmd @@ -478,7 +478,12 @@ def as_command(self, sock_info): return self._as_command cmd = _gen_get_more_command( - self.cursor_id, self.coll, self.ntoreturn, self.max_await_time_ms, self.comment + self.cursor_id, + self.coll, + self.ntoreturn, + self.max_await_time_ms, + self.comment, + sock_info, ) if self.session: self.session._apply_to(cmd, False, self.read_preference, sock_info) diff --git a/test/test_monitoring.py b/test/test_monitoring.py index f317dde553..0b8200c019 100644 --- a/test/test_monitoring.py +++ b/test/test_monitoring.py @@ -239,7 +239,6 @@ def _test_find_options(self, query, expected_cmd): # Exhaust the cursor to avoid kill cursors. tuple(cursor) - @client_context.require_version_min(4, 4, 4) def test_find_options(self): query = dict( filter={}, From fc9b637eef437890a67aadb96b6b5e04a5af1c58 Mon Sep 17 00:00:00 2001 From: julius Date: Fri, 25 Mar 2022 12:53:51 -0700 Subject: [PATCH 10/10] updated spec tests from Dmitry's PR --- .../unified/change-streams.json | 97 ++++++++++++- test/crud/unified/aggregate.json | 133 +++++++++++++++++- test/crud/unified/find-comment.json | 117 ++++++++++++++- 3 files changed, 333 insertions(+), 14 deletions(-) diff --git a/test/change_streams/unified/change-streams.json b/test/change_streams/unified/change-streams.json index bc9d462ee3..5fd2544ce0 100644 --- a/test/change_streams/unified/change-streams.json +++ b/test/change_streams/unified/change-streams.json @@ -254,7 +254,98 @@ { "minServerVersion": "4.4.0", "topologies": [ - "single", + "replicaset" + ] + } + ], + "operations": [ + { + "name": "createChangeStream", + "object": "collection0", + "arguments": { + "pipeline": [], + "comment": { + "key": "value" + } + }, + "saveResultAsEntity": "changeStream0" + }, + { + "name": "insertOne", + "object": "collection0", + "arguments": { + "document": { + "_id": 1, + "a": 1 + } + } + }, + { + "name": "iterateUntilDocumentOrError", + "object": "changeStream0" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "collection0", + "pipeline": [ + { + "$changeStream": {} + } + ], + "comment": { + "key": "value" + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "collection0", + "documents": [ + { + "_id": 1, + "a": 1 + } + ] + } + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "collection0", + "comment": { + "key": "value" + } + }, + "commandName": "getMore", + "databaseName": "database0" + } + } + ] + } + ] + }, + { + "description": "Test that comment is not set on getMore - pre 4.4", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.3.99", + "topologies": [ "replicaset" ] } @@ -324,7 +415,9 @@ ] }, "collection": "collection0", - "comment": "comment" + "comment": { + "$$exists": false + } }, "commandName": "getMore", "databaseName": "database0" diff --git a/test/crud/unified/aggregate.json b/test/crud/unified/aggregate.json index 3ce353d808..0cbfb4e6e9 100644 --- a/test/crud/unified/aggregate.json +++ b/test/crud/unified/aggregate.json @@ -330,12 +330,129 @@ "description": "aggregate with comment sets comment on getMore", "runOnRequirements": [ { - "minServerVersion": "4.4.0", - "topologies": [ - "single", - "replicaset" + "minServerVersion": "4.4.0" + } + ], + "operations": [ + { + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + } + ], + "batchSize": 2, + "comment": { + "content": "test" + } + }, + "object": "collection0", + "expectResult": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + }, + { + "_id": 5, + "x": 55 + }, + { + "_id": 6, + "x": 66 + } + ] + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + } + ], + "cursor": { + "batchSize": 2 + }, + "comment": { + "content": "test" + } + }, + "commandName": "aggregate", + "databaseName": "aggregate-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "coll0", + "batchSize": 2, + "comment": { + "content": "test" + } + }, + "commandName": "getMore", + "databaseName": "aggregate-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "coll0", + "batchSize": 2, + "comment": { + "content": "test" + } + }, + "commandName": "getMore", + "databaseName": "aggregate-tests" + } + } ] } + ] + }, + { + "description": "aggregate with comment does not set comment on getMore - pre 4.4", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.3.99" + } ], "operations": [ { @@ -415,7 +532,9 @@ }, "collection": "coll0", "batchSize": 2, - "comment": "comment" + "comment": { + "$$exists": false + } }, "commandName": "getMore", "databaseName": "aggregate-tests" @@ -432,7 +551,9 @@ }, "collection": "coll0", "batchSize": 2, - "comment": "comment" + "comment": { + "$$exists": false + } }, "commandName": "getMore", "databaseName": "aggregate-tests" diff --git a/test/crud/unified/find-comment.json b/test/crud/unified/find-comment.json index 3d92be7c33..600a3723f1 100644 --- a/test/crud/unified/find-comment.json +++ b/test/crud/unified/find-comment.json @@ -198,13 +198,114 @@ "description": "find with comment sets comment on getMore", "runOnRequirements": [ { - "minServerVersion": "4.4.0", - "topologies": [ - "single", - "replicaset" + "minServerVersion": "4.4.0" + } + ], + "operations": [ + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "batchSize": 2, + "comment": { + "key": "value" + } + }, + "expectResult": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + }, + { + "_id": 4, + "x": 44 + }, + { + "_id": 5, + "x": 55 + }, + { + "_id": 6, + "x": 66 + } ] } ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": { + "_id": { + "$gt": 1 + } + }, + "batchSize": 2, + "comment": { + "key": "value" + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "coll0", + "batchSize": 2, + "comment": { + "key": "value" + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "coll0", + "batchSize": 2, + "comment": { + "key": "value" + } + } + } + } + ] + } + ] + }, + { + "description": "find with comment does not set comment on getMore - pre 4.4", + "runOnRequirements": [ + { + "minServerVersion": "3.6.0", + "maxServerVersion": "4.3.99" + } + ], "operations": [ { "name": "find", @@ -271,7 +372,9 @@ }, "collection": "coll0", "batchSize": 2, - "comment": "comment" + "comment": { + "$$exists": false + } } } }, @@ -286,7 +389,9 @@ }, "collection": "coll0", "batchSize": 2, - "comment": "comment" + "comment": { + "$$exists": false + } } } }