diff --git a/.github/workflows/stress_test.yml b/.github/workflows/stress_test.yml index e3618d5e4b..88652e944b 100644 --- a/.github/workflows/stress_test.yml +++ b/.github/workflows/stress_test.yml @@ -68,7 +68,7 @@ jobs: scheme: AuthStressTests destination: ${{ env.DESTINATION }} xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app' - other_flags: -parallel-testing-enabled NO + other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES geo-stress-test: needs: prepare-for-test @@ -100,7 +100,7 @@ jobs: scheme: GeoStressTests destination: ${{ env.DESTINATION }} xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app' - other_flags: -parallel-testing-enabled NO + other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES storage-stress-test: needs: prepare-for-test @@ -132,7 +132,7 @@ jobs: scheme: StorageStressTests destination: ${{ env.DESTINATION }} xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app' - other_flags: -parallel-testing-enabled NO + other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES datastore-stress-test: needs: prepare-for-test @@ -164,7 +164,7 @@ jobs: scheme: DatastoreStressTests destination: ${{ env.DESTINATION }} xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app' - other_flags: -parallel-testing-enabled NO + other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES graphql-api-stress-test: needs: prepare-for-test @@ -196,4 +196,4 @@ jobs: scheme: GraphQLAPIStressTests destination: ${{ env.DESTINATION }} xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app' - other_flags: -parallel-testing-enabled NO \ No newline at end of file + other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES \ No newline at end of file diff --git a/AmplifyPlugins/API/Tests/APIHostApp/GraphQLAPIStressTests/GraphQLAPIStressTests.swift b/AmplifyPlugins/API/Tests/APIHostApp/GraphQLAPIStressTests/GraphQLAPIStressTests.swift index a8785951a2..3e36680a44 100644 --- a/AmplifyPlugins/API/Tests/APIHostApp/GraphQLAPIStressTests/GraphQLAPIStressTests.swift +++ b/AmplifyPlugins/API/Tests/APIHostApp/GraphQLAPIStressTests/GraphQLAPIStressTests.swift @@ -41,13 +41,10 @@ final class APIStressTests: XCTestCase { } override func setUp() async throws { - await Amplify.reset() - Amplify.Logging.logLevel = .verbose - let plugin = AWSAPIPlugin(modelRegistration: TestModelRegistration()) - do { + Amplify.Logging.logLevel = .verbose + let plugin = AWSAPIPlugin(modelRegistration: TestModelRegistration()) try Amplify.add(plugin: plugin) - let amplifyConfig = try TestConfigHelper.retrieveAmplifyConfiguration( forResource: Self.amplifyConfiguration) try Amplify.configure(amplifyConfig) @@ -58,6 +55,7 @@ final class APIStressTests: XCTestCase { override func tearDown() async throws { await Amplify.reset() + try await Task.sleep(seconds: 1) } // MARK: - Stress tests @@ -82,33 +80,30 @@ final class APIStressTests: XCTestCase { DispatchQueue.concurrentPerform(iterations: concurrencyLimit) { index in Task { let subscription = Amplify.API.subscribe(request: .subscription(of: Post.self, type: .onCreate)) - Task { - for try await subscriptionEvent in subscription { - switch subscriptionEvent { - case .connection(let state): - switch state { - case .connecting: - break - case .connected: - connectedInvoked.fulfill() - case .disconnected: - disconnectedInvoked.fulfill() - } - case .data(let result): - switch result { - case .success(let post): - if post.title == title { - progressInvoked.fulfill() - } - case .failure(let error): - XCTFail("\(error)") + await sequenceActor.append(sequence: subscription) + for try await subscriptionEvent in subscription { + switch subscriptionEvent { + case .connection(let state): + switch state { + case .connecting: + break + case .connected: + connectedInvoked.fulfill() + case .disconnected: + disconnectedInvoked.fulfill() + } + case .data(let result): + switch result { + case .success(let post): + if post.title == title { + progressInvoked.fulfill() } + case .failure(let error): + XCTFail("\(error)") } } - completedInvoked.fulfill() } - - await sequenceActor.append(sequence: subscription) + completedInvoked.fulfill() } }