-
Notifications
You must be signed in to change notification settings - Fork 67
SWIFT-1609 Async-ifying the Unified Test Runner and underlying operations #769
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
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
ad8e4c8
Changing import in UTR.swift and adding makeAsyncClient
rchhaya 102b400
Changing all imports
rchhaya 9fa5a6b
Async execute + try awaits for operations
rchhaya c289649
Fully async-ifying and migrating files
rchhaya a01c138
Print debugging close failures
rchhaya 0a4cf01
Bug on BSON decoder, unbox()
rchhaya fca3858
Fixing failpont/utils errors, need to fix client deinit
rchhaya 7887707
Remedying package, hanging clients
rchhaya f0219f4
Entity clients no longer hang, expected errs still fail
rchhaya dec988e
Problem was with configureFailpoint mLaunch, all pass except ursors c…
rchhaya c2625b8
Failpoints are closed properly, linted
rchhaya 2a1cd9a
Removing duplicate retrievespectests
rchhaya 4ced5b6
Compiler directives
rchhaya 1de51bf
Compiler directives for users of UTR
rchhaya 55027fe
Failpoint compiler directives
rchhaya bac6885
Matching compiler directives
rchhaya e253340
Function compiler directives
rchhaya 778735d
Compilers
rchhaya 8e66be5
More compilers for matching.swift:
rchhaya 4469489
even more compilers for entities
rchhaya 05941a6
Compilers for testfile
rchhaya 0cc50d8
TestWriteModel compiler
rchhaya 08d04c0
Undoing error from prior push:
rchhaya 520a2b2
Closing self-created async client
rchhaya 9a57df0
Taking sharding into account
rchhaya f99e356
self annotation
rchhaya 33007c0
Closing clients upon sharding thrown err
rchhaya 858b7ab
Flaky entity-find-cursor, operation-failure
rchhaya 5692453
Trying try? to resolve killCursor stuff
rchhaya 659da4c
Linting:
rchhaya b22084a
Removing print statements but 1 flakyish test:
rchhaya 3268f88
Try await on killing cursors
rchhaya 8e4fe01
Removing prints
rchhaya 78f57f8
Update .swift-version
rchhaya 8886a41
Remnant extra comment:
rchhaya beb38cb
Merge branch 'SWIFT-1609/utr-async' of github.com:rchhaya/mongo-swift…
rchhaya f99c747
Update .swift-version
rchhaya 462aba2
Reviewing failpoint, comments, renames, methods, tests, etc.
rchhaya 624a764
Deleting .swift-version
rchhaya 079340e
merge conflicts
rchhaya 597e76a
forgotten commented out compiler directive
rchhaya 82c5163
Undoing setUp() removal for scoping
rchhaya a222b53
Addressing comments-elg,failpoints,comments,deinits
rchhaya 0d48bf8
Switching order of elg/client shutdown
rchhaya 1c31d13
Apply suggestions from code review
rchhaya b887bb2
Removing try? for try to see evergreen results
rchhaya 2874160
to try? or not to try?, that is the question
rchhaya 46dfa9e
Specifying command error, docs, and removing imports'
rchhaya b7369a5
Reusing elg for entities, changing print
rchhaya 697b0d7
remove some unneeded stuff
patrickfreed c134cbd
Merge remote-tracking branch 'origin/main' into SWIFT-1609/utr-async
patrickfreed c55c058
Merge remote-tracking branch 'origin/main' into SWIFT-1609/utr-async
patrickfreed 0cdf086
revert to NIOPosix import
patrickfreed 2d8e274
sort imports
patrickfreed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,4 @@ | |
| Package.resolved | ||
| **/xcuserdata/ | ||
| .DS_Store | ||
| .swift-version | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import MongoSwift | ||
| /// Protocol that test cases which configure fail points during their execution conform to. | ||
| public protocol FailPointConfigured { | ||
| /// The fail point currently set, if one exists. | ||
| var activeFailPoint: FailPoint? { get set } | ||
|
|
||
| /// The address of the host in which this failpoint was set on, if applicable. | ||
| var targetedHost: ServerAddress? { get set } | ||
| } | ||
|
|
||
| /// Struct modeling a MongoDB fail point. | ||
| /// | ||
| /// - Note: if a fail point results in a connection being closed / interrupted, libmongoc built in debug mode will print | ||
| /// a warning. | ||
| public struct FailPoint: Decodable { | ||
| public var failPoint: BSONDocument | ||
|
|
||
| /// The fail point being configured. | ||
| public var name: String { | ||
| self.failPoint["configureFailPoint"]?.stringValue ?? "" | ||
| } | ||
|
|
||
| private init(_ document: BSONDocument) { | ||
| self.failPoint = document | ||
| } | ||
|
|
||
| public init(from decoder: Decoder) throws { | ||
| let container = try decoder.singleValueContainer() | ||
| let unordered = try container.decode(BSONDocument.self) | ||
| guard let command = unordered["configureFailPoint"] else { | ||
| throw DecodingError.dataCorruptedError( | ||
| in: container, | ||
| debugDescription: "fail point \(unordered) did not contain \"configureFailPoint\" command" | ||
| ) | ||
| } | ||
| var ordered: BSONDocument = ["configureFailPoint": command] | ||
| for (k, v) in unordered { | ||
| guard k != "configureFailPoint" else { | ||
| continue | ||
| } | ||
| ordered[k] = v | ||
| } | ||
| self.failPoint = ordered | ||
| } | ||
|
|
||
| /// Enum representing the options for the "mode" field of a `configureFailPoint` command. | ||
| public enum Mode { | ||
| case times(Int) | ||
| case alwaysOn | ||
| case off | ||
| case activationProbability(Double) | ||
|
|
||
| internal func toBSON() -> BSON { | ||
| switch self { | ||
| case let .times(i): | ||
| return ["times": BSON(i)] | ||
| case let .activationProbability(d): | ||
| return ["activationProbability": .double(d)] | ||
| default: | ||
| return .string(String(describing: self)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Factory function for creating a `failCommand` failpoint. | ||
| /// Note: enabling a `failCommand` failpoint will override any other `failCommand` failpoint that is currently | ||
| /// enabled. | ||
| /// For more information, see the wiki: https://github.com/mongodb/mongo/wiki/The-%22failCommand%22-fail-point | ||
| public static func failCommand( | ||
| failCommands: [String], | ||
| mode: Mode, | ||
| blockTimeMS: Int? = nil, | ||
| closeConnection: Bool? = nil, | ||
| errorCode: Int? = nil, | ||
| errorLabels: [String]? = nil, | ||
| writeConcernError: BSONDocument? = nil | ||
| ) -> FailPoint { | ||
| var data: BSONDocument = [ | ||
| "failCommands": .array(failCommands.map { .string($0) }) | ||
| ] | ||
| if let blockTime = blockTimeMS { | ||
| data["blockTimeMS"] = BSON(blockTime) | ||
| data["blockConnection"] = true | ||
| } | ||
| if let close = closeConnection { | ||
| data["closeConnection"] = .bool(close) | ||
| } | ||
| if let code = errorCode { | ||
| data["errorCode"] = BSON(code) | ||
| } | ||
| if let labels = errorLabels { | ||
| data["errorLabels"] = .array(labels.map { .string($0) }) | ||
| } | ||
| if let writeConcernError = writeConcernError { | ||
| data["writeConcernError"] = .document(writeConcernError) | ||
| } | ||
|
|
||
| let command: BSONDocument = [ | ||
| "configureFailPoint": "failCommand", | ||
| "mode": mode.toBSON(), | ||
| "data": .document(data) | ||
| ] | ||
| return FailPoint(command) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.