Skip to content

Commit 89d2b0e

Browse files
committed
PYTHON-5993 Support the $$gte unified test format operator
DRIVERS-3598 introduces $$gte, the lower-bound counterpart to $$lte, as unified test format schema version 1.29. The OTel getMore fixtures use it to assert that db.mongodb.cursor_id is non-zero, which pins the requirement that a getMore records the cursor id it sent rather than the 0 its reply returns — $$type alone cannot express that, since 0 is a valid int. Adds _operation_gte and raises the runner's supported schema version to 1.29. Both fixtures come from a specification change that is not merged yet.
1 parent 4e0293d commit 89d2b0e

5 files changed

Lines changed: 23 additions & 30 deletions

File tree

test/asynchronous/unified_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ class UnifiedSpecTestMixinV1(AsyncIntegrationTest):
509509
a class attribute ``TEST_SPEC``.
510510
"""
511511

512-
SCHEMA_VERSION = Version.from_string("1.28")
512+
SCHEMA_VERSION = Version.from_string("1.29")
513513
RUN_ON_LOAD_BALANCER = True
514514
TEST_SPEC: Any
515515
TEST_PATH = "" # This gets filled in by generate_test_classes

test/open_telemetry/operation/get_more.json

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "operation getMore",
3-
"schemaVersion": "1.27",
3+
"schemaVersion": "1.29",
44
"createEntities": [
55
{
66
"client": {
@@ -90,10 +90,7 @@
9090
"db.operation.name": "find",
9191
"db.operation.summary": "find operation-get-more.test",
9292
"db.mongodb.cursor_id": {
93-
"$$type": [
94-
"int",
95-
"long"
96-
]
93+
"$$gte": 1
9794
}
9895
},
9996
"nested": [
@@ -128,10 +125,7 @@
128125
},
129126
"db.query.summary": "find operation-get-more.test",
130127
"db.mongodb.cursor_id": {
131-
"$$type": [
132-
"int",
133-
"long"
134-
]
128+
"$$gte": 1
135129
},
136130
"db.mongodb.server_connection_id": {
137131
"$$type": [
@@ -158,10 +152,7 @@
158152
"db.operation.name": "getMore",
159153
"db.operation.summary": "getMore operation-get-more.test",
160154
"db.mongodb.cursor_id": {
161-
"$$type": [
162-
"int",
163-
"long"
164-
]
155+
"$$gte": 1
165156
}
166157
},
167158
"nested": [
@@ -196,10 +187,7 @@
196187
},
197188
"db.query.summary": "getMore operation-get-more.test",
198189
"db.mongodb.cursor_id": {
199-
"$$type": [
200-
"int",
201-
"long"
202-
]
190+
"$$gte": 1
203191
},
204192
"db.mongodb.server_connection_id": {
205193
"$$type": [

test/open_telemetry/transaction/get_more.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "transaction getMore spans",
3-
"schemaVersion": "1.27",
3+
"schemaVersion": "1.29",
44
"runOnRequirements": [
55
{
66
"minServerVersion": "4.0",
@@ -124,7 +124,10 @@
124124
"db.namespace": "transaction-get-more",
125125
"db.collection.name": "test",
126126
"db.operation.name": "find",
127-
"db.operation.summary": "find transaction-get-more.test"
127+
"db.operation.summary": "find transaction-get-more.test",
128+
"db.mongodb.cursor_id": {
129+
"$$gte": 1
130+
}
128131
},
129132
"nested": [
130133
{
@@ -136,10 +139,7 @@
136139
"db.command.name": "find",
137140
"db.query.summary": "find transaction-get-more.test",
138141
"db.mongodb.cursor_id": {
139-
"$$type": [
140-
"int",
141-
"long"
142-
]
142+
"$$gte": 1
143143
}
144144
}
145145
}
@@ -152,7 +152,10 @@
152152
"db.namespace": "transaction-get-more",
153153
"db.collection.name": "test",
154154
"db.operation.name": "getMore",
155-
"db.operation.summary": "getMore transaction-get-more.test"
155+
"db.operation.summary": "getMore transaction-get-more.test",
156+
"db.mongodb.cursor_id": {
157+
"$$gte": 1
158+
}
156159
},
157160
"nested": [
158161
{
@@ -164,10 +167,7 @@
164167
"db.command.name": "getMore",
165168
"db.query.summary": "getMore transaction-get-more.test",
166169
"db.mongodb.cursor_id": {
167-
"$$type": [
168-
"int",
169-
"long"
170-
]
170+
"$$gte": 1
171171
}
172172
}
173173
}

test/unified_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
508508
a class attribute ``TEST_SPEC``.
509509
"""
510510

511-
SCHEMA_VERSION = Version.from_string("1.28")
511+
SCHEMA_VERSION = Version.from_string("1.29")
512512
RUN_ON_LOAD_BALANCER = True
513513
TEST_SPEC: Any
514514
TEST_PATH = "" # This gets filled in by generate_test_classes

test/unified_format_shared.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,11 @@ def _operation_lte(self, spec, actual, key_to_compare):
474474
self.test.fail(f"Actual command is missing the {key_to_compare} field: {spec}")
475475
self.test.assertLessEqual(actual[key_to_compare], spec)
476476

477+
def _operation_gte(self, spec, actual, key_to_compare):
478+
if key_to_compare not in actual:
479+
self.test.fail(f"Actual command is missing the {key_to_compare} field: {spec}")
480+
self.test.assertGreaterEqual(actual[key_to_compare], spec)
481+
477482
def _operation_matchAsDocument(self, spec, actual, key_to_compare):
478483
self._match_document(spec, json_util.loads(actual[key_to_compare]), False, test=True)
479484

0 commit comments

Comments
 (0)