From cf95dfe68b986b264f8c9dec6c9b47a946e150d0 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Mon, 5 Jun 2023 15:12:43 -0500 Subject: [PATCH 1/7] Add sdk.properties configured for testing --- sdk.properties | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdk.properties b/sdk.properties index 8dde0a87788..a7a5db98767 100644 --- a/sdk.properties +++ b/sdk.properties @@ -1 +1,7 @@ -# No excluded models \ No newline at end of file +# No excluded models +# onlyIncludeModels=s3.2006-03-01,sts.2011-06-15,kinesis.2013-12-02 +onlyIncludeModels=s3.2006-03-01,transcribe-streaming.2017-10-26,kinesis.2013-12-02,sts.2011-06-15 +# onlyIncludeModels=workdocs.2016-05-01 +# onlyIncludeModels=workspaces-web.2020-07-08 +# onlyIncludeModels=account.2021-02-01 +# onlyIncludeModels=route-53.2013-04-01 From 00d8decdabccd712fe6d00c0d64bdef3152c9435 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Mon, 26 Jun 2023 10:02:33 -0500 Subject: [PATCH 2/7] Support URLSession client testing --- .../TranscribeStreamingTests.swift | 1 + Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift index bf9a005b677..65373fed549 100644 --- a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift +++ b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift @@ -26,6 +26,7 @@ final class TranscribeStreamingTests: XCTestCase { var currentEnd = min(chunkSize, audioDataSize - currentStart) while currentStart < audioDataSize { + try await Task.sleep(nanoseconds: 3_000_000_000) let dataChunk = audioData[currentStart ..< currentEnd] let audioEvent = TranscribeStreamingClientTypes.AudioStream.audioevent(.init(audioChunk: dataChunk)) diff --git a/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift b/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift index 349645a208b..f5fe02f2458 100644 --- a/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift +++ b/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift @@ -117,7 +117,8 @@ public class AWSClientConfiguration Date: Tue, 27 Jun 2023 12:02:17 -0500 Subject: [PATCH 3/7] Test tweaks --- .../AWSMediaConvertTests.swift | 5 +++-- .../TranscribeStreamingTests.swift | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/IntegrationTests/Services/AWSMediaConvertIntegrationTests/AWSMediaConvertTests.swift b/IntegrationTests/Services/AWSMediaConvertIntegrationTests/AWSMediaConvertTests.swift index 387c569e43b..5bca0f3ce4d 100644 --- a/IntegrationTests/Services/AWSMediaConvertIntegrationTests/AWSMediaConvertTests.swift +++ b/IntegrationTests/Services/AWSMediaConvertIntegrationTests/AWSMediaConvertTests.swift @@ -88,7 +88,8 @@ class AWSMediaConvertTests: XCTestCase { let input2 = GetJobTemplateInput(name: name) let output2 = try await client.getJobTemplate(input: input2) - // Verify the name of the retrieved template is the same as the - XCTAssertEqual(output2.jobTemplate?.name, name) + // Verify the name of the created & retrieved templates is the same as the original + XCTAssertEqual(output1.jobTemplate?.name, name) + XCTAssertEqual(output1.jobTemplate?.name, output2.jobTemplate?.name) } } diff --git a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift index 65373fed549..c23c8d12dbc 100644 --- a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift +++ b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift @@ -26,7 +26,7 @@ final class TranscribeStreamingTests: XCTestCase { var currentEnd = min(chunkSize, audioDataSize - currentStart) while currentStart < audioDataSize { - try await Task.sleep(nanoseconds: 3_000_000_000) + try await Task.sleep(nanoseconds: 1_000_000_000) let dataChunk = audioData[currentStart ..< currentEnd] let audioEvent = TranscribeStreamingClientTypes.AudioStream.audioevent(.init(audioChunk: dataChunk)) From 4b7f5ef5ccbd9510fc51d68b38a33db2828e1939 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Tue, 2 Jan 2024 18:37:26 -0600 Subject: [PATCH 4/7] Improvements to transcribe streaming test --- .../TranscribeStreamingTests.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift index c23c8d12dbc..7292c23ff92 100644 --- a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift +++ b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift @@ -12,11 +12,20 @@ import AWSTranscribeStreaming final class TranscribeStreamingTests: XCTestCase { func testStartStreamTranscription() async throws { + + // The heelo-swift.wav resource is an audio file that contains an automated voice + // saying the words "Hello transcribed streaming from Swift S. D. K.". + // It is 2.976 seconds in duration. let audioURL = Bundle.module.url(forResource: "hello-swift", withExtension: "wav")! let audioData = try Data(contentsOf: audioURL) + // A delay will be imposed between chunks to keep the audio streaming to the Teranscribe + // service at approximately real-time. + let duration = 2.976 let chunkSize = 4096 let audioDataSize = audioData.count + let dataRate = Double(audioDataSize) / duration + let delay = Double(chunkSize) / dataRate let client = try TranscribeStreamingClient(region: "us-west-2") @@ -26,7 +35,7 @@ final class TranscribeStreamingTests: XCTestCase { var currentEnd = min(chunkSize, audioDataSize - currentStart) while currentStart < audioDataSize { - try await Task.sleep(nanoseconds: 1_000_000_000) + if currentStart != 0 { try await Task.sleep(for: .seconds(delay)) } let dataChunk = audioData[currentStart ..< currentEnd] let audioEvent = TranscribeStreamingClientTypes.AudioStream.audioevent(.init(audioChunk: dataChunk)) From c82a642646f7c788b4bcd9e23aebf54968c54581 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Tue, 2 Jan 2024 22:17:07 -0600 Subject: [PATCH 5/7] Integrate smithy-swift config changes --- .../AWSS3IntegrationTests/S3StreamTests.swift | 4 +-- .../TranscribeStreamingTests.swift | 2 +- Package.swift | 2 +- .../AWSClientConfiguration.swift | 34 +++++++------------ sdk.properties | 6 ---- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/IntegrationTests/Services/AWSS3IntegrationTests/S3StreamTests.swift b/IntegrationTests/Services/AWSS3IntegrationTests/S3StreamTests.swift index 03d22402d92..83864750e18 100644 --- a/IntegrationTests/Services/AWSS3IntegrationTests/S3StreamTests.swift +++ b/IntegrationTests/Services/AWSS3IntegrationTests/S3StreamTests.swift @@ -7,7 +7,7 @@ import XCTest import AWSS3 -import ClientRuntime +@testable import ClientRuntime final class S3StreamTests: S3XCTestCase { let objectName = "hello-world" @@ -43,7 +43,7 @@ final class S3StreamTests: S3XCTestCase { func test_putObject_givenStreamBody() async throws { let audioURL = Bundle.module.url(forResource: objectName, withExtension: nil)! let fileHandle = FileHandle(forReadingAtPath: audioURL.relativePath)! - let fileByteStream = try ByteStream.data(try fileHandle.readToEnd() ?? Data()) + let fileByteStream = ByteStream.stream(FileStream(fileHandle: fileHandle)) let input = PutObjectInput(body: fileByteStream, bucket: bucketName, key: objectName) let output = try await client.putObject(input: input) XCTAssertNotNil(output) diff --git a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift index 7292c23ff92..13af83cf57c 100644 --- a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift +++ b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift @@ -35,7 +35,7 @@ final class TranscribeStreamingTests: XCTestCase { var currentEnd = min(chunkSize, audioDataSize - currentStart) while currentStart < audioDataSize { - if currentStart != 0 { try await Task.sleep(for: .seconds(delay)) } + if currentStart != 0 { try await Task.sleep(nanoseconds: UInt64(delay * 1_000_000_000)) } let dataChunk = audioData[currentStart ..< currentEnd] let audioEvent = TranscribeStreamingClientTypes.AudioStream.audioevent(.init(audioChunk: dataChunk)) diff --git a/Package.swift b/Package.swift index c253bb9cdc2..d246e3ffc69 100644 --- a/Package.swift +++ b/Package.swift @@ -627,7 +627,7 @@ let servicesWithIntegrationTests: [String] = [ ] // Uncomment this line to enable integration tests -// addIntegrationTests() +addIntegrationTests() // Uncomment this line to enable protocol tests // addProtocolTests() diff --git a/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift b/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift index e832fac42b9..5b96651a09d 100644 --- a/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift +++ b/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift @@ -30,10 +30,12 @@ public class AWSClientConfiguration @@ -134,15 +131,8 @@ public class AWSClientConfiguration Date: Tue, 2 Jan 2024 22:33:24 -0600 Subject: [PATCH 6/7] Fix tests --- .../AWSClientConfigurationTests.swift | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Tests/Core/AWSClientRuntimeTests/AWSClientConfigurationTests.swift b/Tests/Core/AWSClientRuntimeTests/AWSClientConfigurationTests.swift index 1a6769ab5fb..e7fcda6a3f0 100644 --- a/Tests/Core/AWSClientRuntimeTests/AWSClientConfigurationTests.swift +++ b/Tests/Core/AWSClientRuntimeTests/AWSClientConfigurationTests.swift @@ -63,14 +63,6 @@ class AWSClientConfigurationTests: XCTestCase { let subject = try await Subject(region: region, appID: appID) XCTAssertEqual(subject.appID, appID) } - - // MARK: - Timeout - - func test_sync_configureTimeoutOptionsFromParams() throws { - let customTimeout: UInt32 = 10_000 - let subject = try Subject(region: region, connectTimeoutMs: customTimeout) - XCTAssertEqual(subject.connectTimeoutMs, customTimeout) - } } struct TestAWSServiceSpecificConfiguration: AWSServiceSpecificConfiguration { From 3abfff4006627574915b19c68337f554cba0d9c9 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Thu, 4 Jan 2024 14:57:12 -0600 Subject: [PATCH 7/7] Revert Package.swift --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index d246e3ffc69..c253bb9cdc2 100644 --- a/Package.swift +++ b/Package.swift @@ -627,7 +627,7 @@ let servicesWithIntegrationTests: [String] = [ ] // Uncomment this line to enable integration tests -addIntegrationTests() +// addIntegrationTests() // Uncomment this line to enable protocol tests // addProtocolTests()