-
Notifications
You must be signed in to change notification settings - Fork 65
SWIFT-1610, SWIFT-1378, SWIFT-1632: Spec tests sync + expose clusterTime on ChangeStreamEvent #775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,9 +165,9 @@ extension MongoClient { | |
} | ||
|
||
internal func getUnmetRequirement(_ testRequirement: TestRequirement) async throws -> UnmetRequirement? { | ||
async let topologyType = try self.topologyType() | ||
async let serverVersion = try self.serverVersion() | ||
async let params = try self.serverParameters() | ||
async let topologyType = try await self.topologyType() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. happened to notice while adding new test using this that this method was actually still calling the blocking methods that |
||
async let serverVersion = try await self.serverVersion() | ||
async let params = try await self.serverParameters() | ||
return try await testRequirement.getUnmetRequirement(givenCurrent: serverVersion, topologyType, params) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,7 +234,7 @@ final class MongoCursorAsyncAwaitTests: MongoSwiftTestCase { | |
} | ||
|
||
testAsync { | ||
let opts = CreateCollectionOptions(capped: true, size: 5) | ||
let opts = CreateCollectionOptions(capped: true, max: 5, size: 100_000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is unrelated but this test starting failing against latest once SERVER-67246 went in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting, i'm surprised the previously incorrect value was silently ignored by the server There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it's interesting; per the docs here:
|
||
try await self.withTestNamespace(collectionOptions: opts) { _, _, coll in | ||
try await coll.insertMany([["x": 1], ["x": 2], ["x": 3]]) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,7 +171,9 @@ final class ChangeStreamTests: MongoSwiftTestCase { | |
// TODO: SWIFT-1458 Unskip. | ||
"change-streams-showExpandedEvents.json", | ||
// TODO: SWIFT-1472 Unskip. | ||
"change-streams-pre_and_post_images.json" | ||
"change-streams-pre_and_post_images.json", | ||
// TODO: SWIFT-1614 Unskip. | ||
"change-streams-disambiguatedPaths.json" | ||
] | ||
let tests = try retrieveSpecTestFiles( | ||
specName: "change-streams", | ||
|
@@ -182,5 +184,29 @@ final class ChangeStreamTests: MongoSwiftTestCase { | |
let testRunner = try await UnifiedTestRunner() | ||
try await testRunner.runFiles(tests) | ||
} | ||
|
||
func testClusterTime() async throws { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while there is a spec test, we run all of the spec tests with a |
||
try await self.withTestClient { client in | ||
// cluster time is only included as of 4.0. | ||
let requirement = TestRequirement( | ||
minServerVersion: ServerVersion(major: 4, minor: 0, patch: 0), | ||
acceptableTopologies: [.replicaSet, .sharded, .shardedReplicaSet, .loadBalanced] | ||
) | ||
let unmetRequirement = try await client.getUnmetRequirement(requirement) | ||
guard unmetRequirement == nil else { | ||
printSkipMessage(testName: self.name, unmetRequirement: unmetRequirement!) | ||
return | ||
} | ||
let db = client.db(Self.testDatabase) | ||
try await db.collection(self.getCollectionName()).drop() | ||
let coll = try await db.createCollection(self.getCollectionName()) | ||
|
||
let stream = try await coll.watch() | ||
|
||
_ = try await coll.insertOne(["x": 1]) | ||
let event = try await stream.next() | ||
expect(event?.clusterTime).toNot(beNil()) | ||
} | ||
} | ||
} | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"description": "change-streams-clusterTime", | ||
"schemaVersion": "1.3", | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client0", | ||
"useMultipleMongoses": false | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database0", | ||
"client": "client0", | ||
"databaseName": "database0" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection0", | ||
"database": "database0", | ||
"collectionName": "collection0" | ||
} | ||
} | ||
], | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "4.0.0", | ||
"topologies": [ | ||
"replicaset", | ||
"sharded-replicaset", | ||
"load-balanced", | ||
"sharded" | ||
] | ||
} | ||
], | ||
"initialData": [ | ||
{ | ||
"collectionName": "collection0", | ||
"databaseName": "database0", | ||
"documents": [] | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "clusterTime is present", | ||
"operations": [ | ||
{ | ||
"name": "createChangeStream", | ||
"object": "collection0", | ||
"arguments": { | ||
"pipeline": [] | ||
}, | ||
"saveResultAsEntity": "changeStream0" | ||
}, | ||
{ | ||
"name": "insertOne", | ||
"object": "collection0", | ||
"arguments": { | ||
"document": { | ||
"_id": 1 | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "iterateUntilDocumentOrError", | ||
"object": "changeStream0", | ||
"expectResult": { | ||
"ns": { | ||
"db": "database0", | ||
"coll": "collection0" | ||
}, | ||
"clusterTime": { | ||
"$$exists": true | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
description: "change-streams-clusterTime" | ||
schemaVersion: "1.3" | ||
createEntities: | ||
- client: | ||
id: &client0 client0 | ||
useMultipleMongoses: false | ||
- database: | ||
id: &database0 database0 | ||
client: *client0 | ||
databaseName: *database0 | ||
- collection: | ||
id: &collection0 collection0 | ||
database: *database0 | ||
collectionName: *collection0 | ||
|
||
runOnRequirements: | ||
- minServerVersion: "4.0.0" | ||
topologies: [ replicaset, sharded-replicaset, load-balanced, sharded ] | ||
|
||
initialData: | ||
- collectionName: *collection0 | ||
databaseName: *database0 | ||
documents: [] | ||
|
||
tests: | ||
- description: "clusterTime is present" | ||
operations: | ||
- name: createChangeStream | ||
object: *collection0 | ||
arguments: { pipeline: [] } | ||
saveResultAsEntity: &changeStream0 changeStream0 | ||
- name: insertOne | ||
object: *collection0 | ||
arguments: | ||
document: { _id: 1 } | ||
- name: iterateUntilDocumentOrError | ||
object: *changeStream0 | ||
expectResult: | ||
ns: { db: *database0, coll: *collection0 } | ||
clusterTime: { $$exists: true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only actual change here mod reorganizing lines was adding
connectionCheckOutStartedEvent
which one of the tests I synced uses