Skip to content
Prev Previous commit
Next Next commit
Added distinct test
  • Loading branch information
papafe committed Sep 25, 2025
commit 01faa2798af4aa43eb346944bfc8bab932f9c1bf
146 changes: 146 additions & 0 deletions specifications/sessions/tests/snapshot-sessions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,152 @@
]
}
]
},
{
"description": "Distinct operation with snapshot and snapshot time",
"operations": [
{
"name": "distinct",
"object": "collection0",
"arguments": {
"session": "session0",
"filter": {},
"fieldName": "x"
},
"expectResult": [
11
]
},
{
"name": "getSnapshotTime",
"object": "session0",
"saveResultAsEntity": "savedSnapshotTime"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 3,
"x": 33
}
}
},
{
"name": "createEntities",
"object": "testRunner",
"arguments": {
"entities": [
{
"session": {
"id": "session2",
"client": "client0",
"sessionOptions": {
"snapshot": true,
"snapshotTime": "savedSnapshotTime"
}
}
}
]
}
},
{
"name": "distinct",
"object": "collection0",
"arguments": {
"session": "session2",
"filter": {},
"fieldName": "x"
},
"expectResult": [
11
]
},
{
"name": "distinct",
"object": "collection0",
"arguments": {
"session": "session2",
"filter": {},
"fieldName": "x"
},
"expectResult": [
11
]
},
{
"name": "distinct",
"object": "collection0",
"arguments": {
"filter": {},
"fieldName": "x"
},
"expectResult": [
11,
33
]
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"distinct": "collection0",
"readConcern": {
"level": "snapshot",
"atClusterTime": {
"$$exists": false
}
}
},
"databaseName": "database0"
}
},
{
"commandStartedEvent": {
"command": {
"distinct": "collection0",
"readConcern": {
"level": "snapshot",
"atClusterTime": {
"$$matchesEntity": "savedSnapshotTime"
}
}
},
"databaseName": "database0"
}
},
{
"commandStartedEvent": {
"command": {
"distinct": "collection0",
"readConcern": {
"level": "snapshot",
"atClusterTime": {
"$$matchesEntity": "savedSnapshotTime"
}
}
},
"databaseName": "database0"
}
},
{
"commandStartedEvent": {
"command": {
"distinct": "collection0",
"readConcern": {
"$$exists": false
}
},
"databaseName": "database0"
}
}
]
}
]
}
]
}
80 changes: 80 additions & 0 deletions specifications/sessions/tests/snapshot-sessions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -565,3 +565,83 @@ tests:
readConcern:
"$$exists": false
databaseName: database0

- description: Distinct operation with snapshot and snapshot time
operations:
- name: distinct
object: collection0
arguments:
session: session0
filter: {}
fieldName: x
expectResult: [11]
- name: getSnapshotTime
object: session0
saveResultAsEntity: &savedSnapshotTime savedSnapshotTime
- name: insertOne
object: collection0
arguments:
document: { _id: 3, x: 33 }
- name: createEntities
object: testRunner
arguments:
entities:
- session:
id: session2
client: client0
sessionOptions:
snapshot: true
snapshotTime: *savedSnapshotTime
- name: distinct
object: collection0
arguments:
session: session2
filter: {}
fieldName: x
expectResult: [11]
## Calling find again to verify that atClusterTime/snapshotTime has not been modified after the first query
## as it would happen if snapshotTime had not been specified
- name: distinct
object: collection0
arguments:
session: session2
filter: {}
fieldName: x
expectResult: [11]
- name: distinct
object: collection0
arguments:
filter: {}
fieldName: x
expectResult: [11, 33]
expectEvents:
- client: client0
events:
- commandStartedEvent:
command:
distinct: collection0
readConcern:
level: snapshot
atClusterTime:
"$$exists": false
databaseName: database0
- commandStartedEvent:
command:
distinct: collection0
readConcern:
level: snapshot
atClusterTime: { $$matchesEntity: *savedSnapshotTime }
databaseName: database0
- commandStartedEvent:
command:
distinct: collection0
readConcern:
level: snapshot
atClusterTime: { $$matchesEntity: *savedSnapshotTime }
databaseName: database0
- commandStartedEvent:
command:
distinct: collection0
readConcern:
"$$exists": false
databaseName: database0
2 changes: 1 addition & 1 deletion tests/MongoDB.Driver.Tests/AtClusterTimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using Xunit;

namespace MongoDB.Driver.Tests;

//TODO This file will need to be deleted, but it's useful for testing at the moment
public class AtClusterTimeTests : IntegrationTest<AtClusterTimeTests.ClassFixture>
{
public AtClusterTimeTests(ClassFixture fixture)
Expand Down