Skip to content

Commit 16539be

Browse files
authored
chore: update stress tests github action (#4112)
* chore: update stress tests github action * refactor testMultipleSubscriptions()
1 parent 8e6dedf commit 16539be

File tree

2 files changed

+28
-33
lines changed

2 files changed

+28
-33
lines changed

.github/workflows/stress_test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
scheme: AuthStressTests
6969
destination: ${{ env.DESTINATION }}
7070
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
71-
other_flags: -parallel-testing-enabled NO
71+
other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES
7272

7373
geo-stress-test:
7474
needs: prepare-for-test
@@ -100,7 +100,7 @@ jobs:
100100
scheme: GeoStressTests
101101
destination: ${{ env.DESTINATION }}
102102
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
103-
other_flags: -parallel-testing-enabled NO
103+
other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES
104104

105105
storage-stress-test:
106106
needs: prepare-for-test
@@ -132,7 +132,7 @@ jobs:
132132
scheme: StorageStressTests
133133
destination: ${{ env.DESTINATION }}
134134
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
135-
other_flags: -parallel-testing-enabled NO
135+
other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES
136136

137137
datastore-stress-test:
138138
needs: prepare-for-test
@@ -164,7 +164,7 @@ jobs:
164164
scheme: DatastoreStressTests
165165
destination: ${{ env.DESTINATION }}
166166
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
167-
other_flags: -parallel-testing-enabled NO
167+
other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES
168168

169169
graphql-api-stress-test:
170170
needs: prepare-for-test
@@ -196,4 +196,4 @@ jobs:
196196
scheme: GraphQLAPIStressTests
197197
destination: ${{ env.DESTINATION }}
198198
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
199-
other_flags: -parallel-testing-enabled NO
199+
other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES

AmplifyPlugins/API/Tests/APIHostApp/GraphQLAPIStressTests/GraphQLAPIStressTests.swift

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@ final class APIStressTests: XCTestCase {
4141
}
4242

4343
override func setUp() async throws {
44-
await Amplify.reset()
45-
Amplify.Logging.logLevel = .verbose
46-
let plugin = AWSAPIPlugin(modelRegistration: TestModelRegistration())
47-
4844
do {
45+
Amplify.Logging.logLevel = .verbose
46+
let plugin = AWSAPIPlugin(modelRegistration: TestModelRegistration())
4947
try Amplify.add(plugin: plugin)
50-
5148
let amplifyConfig = try TestConfigHelper.retrieveAmplifyConfiguration(
5249
forResource: Self.amplifyConfiguration)
5350
try Amplify.configure(amplifyConfig)
@@ -58,6 +55,7 @@ final class APIStressTests: XCTestCase {
5855

5956
override func tearDown() async throws {
6057
await Amplify.reset()
58+
try await Task.sleep(seconds: 1)
6159
}
6260

6361
// MARK: - Stress tests
@@ -82,33 +80,30 @@ final class APIStressTests: XCTestCase {
8280
DispatchQueue.concurrentPerform(iterations: concurrencyLimit) { index in
8381
Task {
8482
let subscription = Amplify.API.subscribe(request: .subscription(of: Post.self, type: .onCreate))
85-
Task {
86-
for try await subscriptionEvent in subscription {
87-
switch subscriptionEvent {
88-
case .connection(let state):
89-
switch state {
90-
case .connecting:
91-
break
92-
case .connected:
93-
connectedInvoked.fulfill()
94-
case .disconnected:
95-
disconnectedInvoked.fulfill()
96-
}
97-
case .data(let result):
98-
switch result {
99-
case .success(let post):
100-
if post.title == title {
101-
progressInvoked.fulfill()
102-
}
103-
case .failure(let error):
104-
XCTFail("\(error)")
83+
await sequenceActor.append(sequence: subscription)
84+
for try await subscriptionEvent in subscription {
85+
switch subscriptionEvent {
86+
case .connection(let state):
87+
switch state {
88+
case .connecting:
89+
break
90+
case .connected:
91+
connectedInvoked.fulfill()
92+
case .disconnected:
93+
disconnectedInvoked.fulfill()
94+
}
95+
case .data(let result):
96+
switch result {
97+
case .success(let post):
98+
if post.title == title {
99+
progressInvoked.fulfill()
105100
}
101+
case .failure(let error):
102+
XCTFail("\(error)")
106103
}
107104
}
108-
completedInvoked.fulfill()
109105
}
110-
111-
await sequenceActor.append(sequence: subscription)
106+
completedInvoked.fulfill()
112107
}
113108
}
114109

0 commit comments

Comments
 (0)