Skip to content

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

Merged
merged 5 commits into from
Sep 15, 2022

Conversation

kmahar
Copy link
Contributor

@kmahar kmahar commented Sep 12, 2022

I picked up SWIFT-1610 which was a test sync; the sync also brought in the files from SWIFT-1378.

I also picked up SWIFT-1632 which I thought was just a test sync but it turns out we didn't have a clusterTime on ChangeStreamEvent. It seems like we decided against that in SWIFT-428 but now that there is a spec test it seems like we'd want to have one for compliance and parity with other drivers.

serverOpening, serverClosed, serverHeartbeatStarted, serverHeartbeatSucceeded,
serverHeartbeatFailed
case commandStartedEvent, commandSucceededEvent, commandFailedEvent, connectionCreatedEvent, connectionReadyEvent,
connectionClosedEvent, connectionCheckedInEvent, connectionCheckOutStartedEvent, connectionCheckedOutEvent,
Copy link
Contributor Author

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

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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 wait() to get these values. oops

@@ -182,5 +184,24 @@ final class ChangeStreamTests: MongoSwiftTestCase {
let testRunner = try await UnifiedTestRunner()
try await testRunner.runFiles(tests)
}

func testClusterTime() async throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 ChangeStream<BSONDocument> since some of them do projections, etc. and don't match the model type. so this test is to assert we correctly deserialize the clusterTime when ChangeStreamEvent is used.

@@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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. size is actually supposed to be the max size in bytes, not the number of documents (that's what max is for).
previously the server forced you to have a minimum max size of 4096, so the size option here was basically ignored. but that restriction was removed and it is now valid to actually have a 5 byte capped collection. due to this, no documents could actually fit in the collection so this test started to fail.

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's interesting; per the docs here:

If the size field is less than or equal to 4096, then the collection will have a cap of 4096 bytes.

@kmahar kmahar marked this pull request as ready for review September 13, 2022 15:29
@kmahar kmahar requested review from a team and isabelatkinson and removed request for a team September 13, 2022 15:32
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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

@kmahar kmahar requested a review from patrickfreed September 13, 2022 18:26
Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Sorry for the delayed review

@kmahar kmahar merged commit 41ec4d6 into main Sep 15, 2022
@kmahar kmahar deleted the test-syncs branch September 15, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants