-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Streaming + Event Streams (#946)
* refactor: streams (#889) smithy-lang/smithy-swift#530 * feat: event stream runtime support (#910) To support event streaming, SDK needs implementations for MessageSigner, MessageEncoder, MessageDecoder, MessageDecoderStream and MessageEncoderStream. - Add AWSMessageEncoder which is a MessageEncoder implementation along with its tests - Add AWSMessageDecoder which is a MessageDecoder implementation along with its tests - Add AWSMessageDecoderStream which is a MessageDecoderStream implementation along with its tests - Add AWSMessageEncoderStream which is a MessageEncoderStream implementation along with its tests - Integrate Payload signer in the SDK which is used in MessageEncoderStream implementation All tests pass. * feat: codegen and integration (#925) * wip * revert to explict header types * comments and fixes for Int/Long * fix test cases * fix test case input * mark * Update Sources/Core/AWSClientRuntime/EventStream/AWSEventStream.swift Co-authored-by: Ed Paulosky <[email protected]> * docs * lint * remove messageDecoder from protocol instead use as local variable * rename method * docs * Update Sources/Core/AWSClientRuntime/HttpContextBuilder+Extension.swift Co-authored-by: Ed Paulosky <[email protected]> * use same pattern * update other places too * remove local deps check * update branch * ALPN change * remove env var * remove ALPN from setup --------- Co-authored-by: Ganesh Jangir <[email protected]> Co-authored-by: Ed Paulosky <[email protected]> * chore: regen models * feat: Forces http2 for bidirectional event streams (#950) * Fixes tests * Fixes codegen test * Some tweaks to tests * Fixes encoder stream tests some times failing * fixes linter warnings * regens models * Post rebase fixes * Adds command to CLI to generate package.swift with integration tests (#965) --------- Co-authored-by: Ganesh Jangir <[email protected]> Co-authored-by: Ganesh Jangir <[email protected]>
- Loading branch information
1 parent
f9be124
commit beefc57
Showing
754 changed files
with
50,303 additions
and
49,690 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
1 change: 1 addition & 0 deletions
1
IntegrationTests/Services/AWSS3IntegrationTests/Resources/hello-world
This file contains 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 @@ | ||
Hello, world! |
112 changes: 112 additions & 0 deletions
112
IntegrationTests/Services/AWSS3IntegrationTests/S3Tests.swift
This file contains 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,112 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import XCTest | ||
import AWSS3 | ||
|
||
final class S3Tests: XCTestCase { | ||
var sut: S3Client! | ||
let bucketName = "aws-sdk-swift-test-\(UUID().uuidString.split(separator: "-").first!.lowercased())" | ||
let objectName = "hello-world" | ||
let expected = "Hello, world!" | ||
|
||
override func setUp() async throws { | ||
sut = try S3Client(region: "us-west-2") | ||
try await createBucket() | ||
} | ||
|
||
override func tearDown() async throws { | ||
try await emptyBucket() | ||
try await deleteBucket() | ||
} | ||
|
||
func testGetObject() async throws { | ||
try await putObject() | ||
let input = GetObjectInput(bucket: bucketName, key: objectName) | ||
let output = try await sut.getObject(input: input) | ||
XCTAssertNotNil(output) | ||
XCTAssertNotNil(output.body) | ||
|
||
switch output.body! { | ||
case .data(let data): | ||
let actual = String(data: data!, encoding: .utf8) | ||
XCTAssertEqual(actual, expected) | ||
case .stream(let stream): | ||
let actual = String(data: try stream.readToEnd()!, encoding: .utf8) | ||
print(actual) | ||
XCTAssertEqual(actual, expected) | ||
} | ||
} | ||
|
||
func testPutObject_givenDataBody() async throws { | ||
let input = PutObjectInput(body: .data(expected.data(using: .utf8)), bucket: bucketName, key: objectName) | ||
let output = try await sut.putObject(input: input) | ||
XCTAssertNotNil(output) | ||
|
||
let actual = try await getObject() | ||
XCTAssertEqual(expected, actual) | ||
} | ||
|
||
func testPutObject_givenStreamBody() async throws { | ||
let audioURL = Bundle.module.url(forResource: "hello-world", withExtension: nil)! | ||
let fileHandle = FileHandle(forReadingAtPath: audioURL.relativePath)! | ||
let input = PutObjectInput(body: .from(fileHandle: fileHandle), bucket: bucketName, key: objectName) | ||
let output = try await sut.putObject(input: input) | ||
XCTAssertNotNil(output) | ||
|
||
let actual = try await getObject() | ||
XCTAssertEqual(expected, actual) | ||
} | ||
|
||
// MARK: Helpers | ||
|
||
private func createBucket() async throws { | ||
let input = CreateBucketInput(bucket: bucketName, createBucketConfiguration: S3ClientTypes.CreateBucketConfiguration(locationConstraint: S3ClientTypes.BucketLocationConstraint.usWest2)) | ||
let output = try await sut.createBucket(input: input) | ||
print(output) | ||
} | ||
|
||
private func getObject() async throws -> String? { | ||
let input = GetObjectInput(bucket: bucketName, key: objectName) | ||
let output = try await sut.getObject(input: input) | ||
XCTAssertNotNil(output) | ||
XCTAssertNotNil(output.body) | ||
|
||
switch output.body! { | ||
case .data(let data): | ||
return String(data: data!, encoding: .utf8) | ||
case .stream(let stream): | ||
return String(data: try stream.readToEnd()!, encoding: .utf8) | ||
} | ||
} | ||
|
||
private func deleteBucket() async throws { | ||
let input = DeleteBucketInput(bucket: bucketName) | ||
let output = try await sut.deleteBucket(input: input) | ||
print(output) | ||
} | ||
|
||
private func emptyBucket() async throws { | ||
let input = ListObjectsV2Input(bucket: bucketName) | ||
let output = try await sut.listObjectsV2(input: input) | ||
let objects = output.contents ?? [] | ||
print("Deleting \(objects.count) objects in \(bucketName)") | ||
for object in objects { | ||
print("Deleting \(String(describing: object.key)) in \(bucketName)") | ||
let deleteInput = DeleteObjectInput(bucket: bucketName, key: object.key) | ||
let deleteOutput = try await sut.deleteObject(input: deleteInput) | ||
print(deleteOutput) | ||
} | ||
} | ||
|
||
private func putObject() async throws { | ||
let input = PutObjectInput(body: .data(expected.data(using: .utf8)), bucket: bucketName, key: objectName) | ||
let output = try await sut.putObject(input: input) | ||
print(output) | ||
} | ||
|
||
} |
Binary file added
BIN
+46.6 KB
IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/Resources/hello-swift.wav
Binary file not shown.
Oops, something went wrong.