Skip to content

Commit 01faa27

Browse files
committed
Added distinct test
1 parent f647078 commit 01faa27

File tree

3 files changed

+227
-1
lines changed

3 files changed

+227
-1
lines changed

specifications/sessions/tests/snapshot-sessions.json

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,152 @@
11611161
]
11621162
}
11631163
]
1164+
},
1165+
{
1166+
"description": "Distinct operation with snapshot and snapshot time",
1167+
"operations": [
1168+
{
1169+
"name": "distinct",
1170+
"object": "collection0",
1171+
"arguments": {
1172+
"session": "session0",
1173+
"filter": {},
1174+
"fieldName": "x"
1175+
},
1176+
"expectResult": [
1177+
11
1178+
]
1179+
},
1180+
{
1181+
"name": "getSnapshotTime",
1182+
"object": "session0",
1183+
"saveResultAsEntity": "savedSnapshotTime"
1184+
},
1185+
{
1186+
"name": "insertOne",
1187+
"object": "collection0",
1188+
"arguments": {
1189+
"document": {
1190+
"_id": 3,
1191+
"x": 33
1192+
}
1193+
}
1194+
},
1195+
{
1196+
"name": "createEntities",
1197+
"object": "testRunner",
1198+
"arguments": {
1199+
"entities": [
1200+
{
1201+
"session": {
1202+
"id": "session2",
1203+
"client": "client0",
1204+
"sessionOptions": {
1205+
"snapshot": true,
1206+
"snapshotTime": "savedSnapshotTime"
1207+
}
1208+
}
1209+
}
1210+
]
1211+
}
1212+
},
1213+
{
1214+
"name": "distinct",
1215+
"object": "collection0",
1216+
"arguments": {
1217+
"session": "session2",
1218+
"filter": {},
1219+
"fieldName": "x"
1220+
},
1221+
"expectResult": [
1222+
11
1223+
]
1224+
},
1225+
{
1226+
"name": "distinct",
1227+
"object": "collection0",
1228+
"arguments": {
1229+
"session": "session2",
1230+
"filter": {},
1231+
"fieldName": "x"
1232+
},
1233+
"expectResult": [
1234+
11
1235+
]
1236+
},
1237+
{
1238+
"name": "distinct",
1239+
"object": "collection0",
1240+
"arguments": {
1241+
"filter": {},
1242+
"fieldName": "x"
1243+
},
1244+
"expectResult": [
1245+
11,
1246+
33
1247+
]
1248+
}
1249+
],
1250+
"expectEvents": [
1251+
{
1252+
"client": "client0",
1253+
"events": [
1254+
{
1255+
"commandStartedEvent": {
1256+
"command": {
1257+
"distinct": "collection0",
1258+
"readConcern": {
1259+
"level": "snapshot",
1260+
"atClusterTime": {
1261+
"$$exists": false
1262+
}
1263+
}
1264+
},
1265+
"databaseName": "database0"
1266+
}
1267+
},
1268+
{
1269+
"commandStartedEvent": {
1270+
"command": {
1271+
"distinct": "collection0",
1272+
"readConcern": {
1273+
"level": "snapshot",
1274+
"atClusterTime": {
1275+
"$$matchesEntity": "savedSnapshotTime"
1276+
}
1277+
}
1278+
},
1279+
"databaseName": "database0"
1280+
}
1281+
},
1282+
{
1283+
"commandStartedEvent": {
1284+
"command": {
1285+
"distinct": "collection0",
1286+
"readConcern": {
1287+
"level": "snapshot",
1288+
"atClusterTime": {
1289+
"$$matchesEntity": "savedSnapshotTime"
1290+
}
1291+
}
1292+
},
1293+
"databaseName": "database0"
1294+
}
1295+
},
1296+
{
1297+
"commandStartedEvent": {
1298+
"command": {
1299+
"distinct": "collection0",
1300+
"readConcern": {
1301+
"$$exists": false
1302+
}
1303+
},
1304+
"databaseName": "database0"
1305+
}
1306+
}
1307+
]
1308+
}
1309+
]
11641310
}
11651311
]
11661312
}

specifications/sessions/tests/snapshot-sessions.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,83 @@ tests:
565565
readConcern:
566566
"$$exists": false
567567
databaseName: database0
568+
569+
- description: Distinct operation with snapshot and snapshot time
570+
operations:
571+
- name: distinct
572+
object: collection0
573+
arguments:
574+
session: session0
575+
filter: {}
576+
fieldName: x
577+
expectResult: [11]
578+
- name: getSnapshotTime
579+
object: session0
580+
saveResultAsEntity: &savedSnapshotTime savedSnapshotTime
581+
- name: insertOne
582+
object: collection0
583+
arguments:
584+
document: { _id: 3, x: 33 }
585+
- name: createEntities
586+
object: testRunner
587+
arguments:
588+
entities:
589+
- session:
590+
id: session2
591+
client: client0
592+
sessionOptions:
593+
snapshot: true
594+
snapshotTime: *savedSnapshotTime
595+
- name: distinct
596+
object: collection0
597+
arguments:
598+
session: session2
599+
filter: {}
600+
fieldName: x
601+
expectResult: [11]
602+
## Calling find again to verify that atClusterTime/snapshotTime has not been modified after the first query
603+
## as it would happen if snapshotTime had not been specified
604+
- name: distinct
605+
object: collection0
606+
arguments:
607+
session: session2
608+
filter: {}
609+
fieldName: x
610+
expectResult: [11]
611+
- name: distinct
612+
object: collection0
613+
arguments:
614+
filter: {}
615+
fieldName: x
616+
expectResult: [11, 33]
617+
expectEvents:
618+
- client: client0
619+
events:
620+
- commandStartedEvent:
621+
command:
622+
distinct: collection0
623+
readConcern:
624+
level: snapshot
625+
atClusterTime:
626+
"$$exists": false
627+
databaseName: database0
628+
- commandStartedEvent:
629+
command:
630+
distinct: collection0
631+
readConcern:
632+
level: snapshot
633+
atClusterTime: { $$matchesEntity: *savedSnapshotTime }
634+
databaseName: database0
635+
- commandStartedEvent:
636+
command:
637+
distinct: collection0
638+
readConcern:
639+
level: snapshot
640+
atClusterTime: { $$matchesEntity: *savedSnapshotTime }
641+
databaseName: database0
642+
- commandStartedEvent:
643+
command:
644+
distinct: collection0
645+
readConcern:
646+
"$$exists": false
647+
databaseName: database0

tests/MongoDB.Driver.Tests/AtClusterTimeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
using Xunit;
2323

2424
namespace MongoDB.Driver.Tests;
25-
25+
//TODO This file will need to be deleted, but it's useful for testing at the moment
2626
public class AtClusterTimeTests : IntegrationTest<AtClusterTimeTests.ClassFixture>
2727
{
2828
public AtClusterTimeTests(ClassFixture fixture)

0 commit comments

Comments
 (0)