Skip to content

Commit

Permalink
fix: run retry integration tests
Browse files Browse the repository at this point in the history
SmithyRetriesTests test target was accidentally removed from Package.swift
in smithy-lang#692, so this commit adds it back. The test was also not working properly,
because Context.partitionID's attribute key name used by RetryMiddleware
was different from the one being set in the test. This caused the test to
exit early when partitionID wasn't found.
  • Loading branch information
milesziemer committed Jul 12, 2024
1 parent 6d3bb34 commit 65795e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,9 @@ let package = Package(
name: "SmithyWaitersAPITests",
dependencies: ["Smithy", "SmithyWaitersAPI"]
),
.testTarget(
name: "SmithyRetriesTests",
dependencies: ["ClientRuntime", "SmithyRetriesAPI", "SmithyRetries", "SmithyTestUtil"]
),
].compactMap { $0 }
)
10 changes: 7 additions & 3 deletions Tests/SmithyRetriesTests/RetryIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import SmithyRetriesAPI

// This test class reproduces the "Standard Mode" test cases defined in "Retry Behavior 2.0"
final class RetryIntegrationTests: XCTestCase {
private let partitionIDKey = AttributeKey<String>(name: "PartitionID")
private let partitionID = "partition"

private var context: Context!
Expand All @@ -28,7 +27,7 @@ final class RetryIntegrationTests: XCTestCase {
private func setUp(availableCapacity: Int, maxCapacity: Int, maxRetriesBase: Int, maxBackoff: TimeInterval) async {
// Setup the HTTP context, used by the retry middleware
context = Context(attributes: Attributes())
context.attributes.set(key: partitionIDKey, value: partitionID)
context.partitionID = partitionID
context.socketTimeout = 60.0
context.estimatedSkew = 30.0

Expand Down Expand Up @@ -239,7 +238,12 @@ private class TestOutputHandler: Handler {
}

func verifyResult(atEnd: Bool = true) async throws {
guard let testStep = latestTestStep else { return }
guard let testStep = latestTestStep else {
if atEnd {
XCTFail("No test steps were run! Encountered error: \(String(describing: finalError!))")
}
return
}

// Test available capacity
let availableCapacity = await quota.availableCapacity
Expand Down

0 comments on commit 65795e9

Please sign in to comment.