Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/stress_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
scheme: AuthStressTests
destination: ${{ env.DESTINATION }}
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
other_flags: -parallel-testing-enabled NO

geo-stress-test:
needs: prepare-for-test
Expand Down Expand Up @@ -99,6 +100,7 @@ jobs:
scheme: GeoStressTests
destination: ${{ env.DESTINATION }}
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
other_flags: -parallel-testing-enabled NO

storage-stress-test:
needs: prepare-for-test
Expand Down Expand Up @@ -130,6 +132,7 @@ jobs:
scheme: StorageStressTests
destination: ${{ env.DESTINATION }}
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
other_flags: -parallel-testing-enabled NO

datastore-stress-test:
needs: prepare-for-test
Expand Down Expand Up @@ -161,6 +164,7 @@ jobs:
scheme: DatastoreStressTests
destination: ${{ env.DESTINATION }}
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
other_flags: -parallel-testing-enabled NO

graphql-api-stress-test:
needs: prepare-for-test
Expand Down Expand Up @@ -191,4 +195,5 @@ jobs:
project_path: ./AmplifyPlugins/API/Tests/APIHostApp
scheme: GraphQLAPIStressTests
destination: ${{ env.DESTINATION }}
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
xcode_path: '/Applications/Xcode_${{ env.XCODE_VERSION }}.app'
other_flags: -parallel-testing-enabled NO
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ final class APIStressTests: XCTestCase {
let progressInvoked = expectation(description: "progress invoked")
progressInvoked.expectedFulfillmentCount = concurrencyLimit

let uuid = UUID().uuidString
let testMethodName = String("\(#function)".dropLast(2))
let title = testMethodName + "Title"

Expand All @@ -98,7 +97,7 @@ final class APIStressTests: XCTestCase {
case .data(let result):
switch result {
case .success(let post):
if post.id == uuid {
if post.title == title {
progressInvoked.fulfill()
}
case .failure(let error):
Expand All @@ -118,7 +117,7 @@ final class APIStressTests: XCTestCase {
let sequenceCount = await sequenceActor.sequences.count
XCTAssertEqual(sequenceCount, concurrencyLimit)

guard try await createPost(id: uuid, title: title) != nil else {
guard try await Self.createPost(id: UUID().uuidString, title: title) != nil else {
XCTFail("Failed to create post")
return
}
Expand All @@ -144,7 +143,7 @@ final class APIStressTests: XCTestCase {
Task {
let id = UUID().uuidString
let title = "title" + String(index)
let post = try await createPost(id: id, title: title)
let post = try await APIStressTests.createPost(id: id, title: title)
XCTAssertNotNil(post)
XCTAssertEqual(id, post?.id)
XCTAssertEqual(title, post?.title)
Expand All @@ -169,7 +168,7 @@ final class APIStressTests: XCTestCase {
Task {
let id = UUID().uuidString
let title = "title" + String(index)
let post = try await createPost(id: id, title: title)
let post = try await APIStressTests.createPost(id: id, title: title)
XCTAssertNotNil(post)
XCTAssertEqual(id, post?.id)
XCTAssertEqual(title, post?.title)
Expand All @@ -184,7 +183,7 @@ final class APIStressTests: XCTestCase {
Task {
var post = await postActor.posts[index]
post.title = "newTitle" + String(index)
let updatedPost = try await mutatePost(post)
let updatedPost = try await APIStressTests.mutatePost(post)
XCTAssertNotNil(updatedPost)
XCTAssertEqual(post.id, updatedPost.id)
XCTAssertEqual(post.title, updatedPost.title)
Expand All @@ -211,7 +210,7 @@ final class APIStressTests: XCTestCase {
Task {
let id = UUID().uuidString
let title = "title" + String(index)
let post = try await createPost(id: id, title: title)
let post = try await APIStressTests.createPost(id: id, title: title)
XCTAssertNotNil(post)
XCTAssertEqual(id, post?.id)
XCTAssertEqual(title, post?.title)
Expand All @@ -225,7 +224,7 @@ final class APIStressTests: XCTestCase {
DispatchQueue.concurrentPerform(iterations: concurrencyLimit) { index in
Task {
let post = await postActor.posts[index]
let deletedPost = try await deletePost(post: post)
let deletedPost = try await APIStressTests.deletePost(post: post)
XCTAssertNotNil(deletedPost)
XCTAssertEqual(post.id, deletedPost.id)
XCTAssertEqual(post.title, deletedPost.title)
Expand All @@ -252,7 +251,7 @@ final class APIStressTests: XCTestCase {
Task {
let id = UUID().uuidString
let title = "title" + String(index)
let post = try await createPost(id: id, title: title)
let post = try await APIStressTests.createPost(id: id, title: title)
XCTAssertNotNil(post)
XCTAssertEqual(id, post?.id)
XCTAssertEqual(title, post?.title)
Expand Down Expand Up @@ -301,12 +300,12 @@ final class APIStressTests: XCTestCase {

// MARK: - Helpers

func createPost(id: String, title: String) async throws -> Post? {
static func createPost(id: String, title: String) async throws -> Post? {
let post = Post(id: id, title: title, status: .active, content: "content")
return try await createPost(post: post)
}

func createPost(post: Post) async throws -> Post? {
static func createPost(post: Post) async throws -> Post? {
let data = try await Amplify.API.mutate(request: .create(post))
switch data {
case .success(let post):
Expand All @@ -316,7 +315,7 @@ final class APIStressTests: XCTestCase {
}
}

func mutatePost(_ post: Post) async throws -> Post {
static func mutatePost(_ post: Post) async throws -> Post {
let data = try await Amplify.API.mutate(request: .update(post))
switch data {
case .success(let post):
Expand All @@ -326,7 +325,7 @@ final class APIStressTests: XCTestCase {
}
}

func deletePost(post: Post) async throws -> Post {
static func deletePost(post: Post) async throws -> Post {
let data = try await Amplify.API.mutate(request: .delete(post))
switch data {
case .success(let post):
Expand Down
Loading