Skip to content

Commit c72402b

Browse files
authored
chore: kickoff release
2 parents da608f0 + 27a2217 commit c72402b

File tree

9 files changed

+61
-57
lines changed

9 files changed

+61
-57
lines changed

AmplifyPlugins/API/Sources/AWSAPIPlugin/AWSAPIPlugin+Resettable.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Amplify
99
import Foundation
10-
// import AwsCommonRuntimeKit
1110

1211
extension AWSAPIPlugin: Resettable {
1312

@@ -27,9 +26,6 @@ extension AWSAPIPlugin: Resettable {
2726
}
2827

2928
subscriptionConnectionFactory = nil
30-
31-
// Issue: https://github.com/aws-amplify/amplify-ios/issues/2120
32-
// AwsCommonRuntimeKit.cleanUp()
3329
}
3430

3531
}

AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginGraphQLIAMTests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Do you want to use the default authentication and security configuration?
4444
Please enter a name for your identity pool.
4545
<amplifyintegtestCIDP>
4646
Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM)
47-
No
47+
Yes
4848
Do you want to enable 3rd party authentication providers in your identity pool?
4949
No
5050
Please provide a name for your user pool:

AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/AWSDataStorePlugin+DataStoreBaseBehavior.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ extension AWSDataStorePlugin: DataStoreBaseBehavior {
500500
private func publishMutationEvent<M: Model>(from model: M,
501501
modelSchema: ModelSchema,
502502
mutationType: MutationEvent.MutationType) {
503-
504503
let metadata = MutationSyncMetadata.keys
505504
let metadataId = MutationSyncMetadata.identifier(modelName: modelSchema.name,
506505
modelId: model.identifier(schema: modelSchema).stringValue)

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/AWSDataStorePluginConfigurationTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
//
77

88
import XCTest
9-
import Amplify
9+
@testable import Amplify
1010
import AWSDataStorePlugin
1111

1212
class AWSDataStorePluginConfigurationTests: XCTestCase {
1313

14+
override func tearDown() async throws {
15+
await Amplify.reset()
16+
try await Task.sleep(seconds: 1)
17+
}
18+
1419
// Note this test requires the ability to write a new database in the Documents directcory, so it must be embedded
1520
// in a host app
1621
func testDoesNotThrowOnMissingConfig() throws {

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario6Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class DataStoreConnectionScenario6Tests: SyncEngineIntegrationTestBase {
205205
let post2 = try await savePost(title: "title", blog: blog2)
206206
_ = try await saveComment(id: commentId2, post: post2, content: "content")
207207

208-
await waitForExpectations(timeout: 5)
208+
await waitForExpectations(timeout: 10)
209209

210210
let outboxMutationProcessed = expectation(description: "received outboxMutationProcessed")
211211
var processedSoFar = 0

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreConfigurationTests.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@ import AWSPluginsCore
1414

1515
class DataStoreConfigurationTests: XCTestCase {
1616

17-
override func setUp() async throws {
18-
await Amplify.reset()
19-
}
20-
2117
override func tearDown() async throws {
2218
try await Amplify.DataStore.clear()
2319
await Amplify.reset()
20+
try await Task.sleep(seconds: 1)
2421
}
2522

2623
func testConfigureWithSameSchemaDoesNotDeleteDatabase() async throws {

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreEndToEndTests.swift

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -489,50 +489,52 @@ class DataStoreEndToEndTests: SyncEngineIntegrationTestBase {
489489
func testParallelMutations_whenWaitingForEventToProcess_noMutationLoss() async throws {
490490
await setUp(withModels: TestModelRegistration())
491491
try await startAmplifyAndWaitForSync()
492+
492493
let parallelSize = 100
493-
let initExpectation = expectation(description: "expect MutationEventPublisher works fine")
494-
let parallelExpectation = expectation(description: "expect parallel processing no data loss")
494+
let initExpectation = asyncExpectation(description: "expect MutationEventPublisher works fine")
495+
let parallelExpectation = asyncExpectation(description: "expect parallel processing no data loss")
495496

496497
let newPost = Post(title: UUID().uuidString, content: UUID().uuidString, createdAt: .now())
497498

498499
let titlePrefix = UUID().uuidString
499500
let posts = (0..<parallelSize).map { Post(title: "\(titlePrefix)-\($0)", content: UUID().uuidString, createdAt: .now()) }
500501
var expectedResult = Set<String>()
502+
let extractPost: (DataStoreHubEvent) -> Post? = {
503+
if case .outboxMutationProcessed(let mutationEvent) = $0,
504+
mutationEvent.modelName == Post.modelName
505+
{
506+
return mutationEvent.element.model as? Post
507+
}
508+
return nil
509+
}
510+
501511
let cancellable = Amplify.Hub.publisher(for: .dataStore)
502-
.sink { payload in
503-
let event = DataStoreHubEvent(payload: payload)
504-
switch event {
505-
case .outboxMutationProcessed(let mutationEvent):
506-
guard mutationEvent.modelName == Post.modelName,
507-
let post = mutationEvent.element.model as? Post
508-
else
509-
{ break }
510-
511-
if post.title == newPost.title {
512-
initExpectation.fulfill()
513-
}
512+
.filter { $0.eventName == HubPayload.EventName.DataStore.outboxMutationProcessed }
513+
.map { DataStoreHubEvent(payload: $0) }
514+
.compactMap(extractPost)
515+
.sink { post in
516+
if post.title == newPost.title {
517+
Task { await initExpectation.fulfill() }
518+
}
514519

515-
if post.title.hasPrefix(titlePrefix) {
516-
expectedResult.insert(post.title)
517-
}
520+
if post.title.hasPrefix(titlePrefix) {
521+
expectedResult.insert(post.title)
522+
}
518523

519-
if expectedResult.count == parallelSize {
520-
parallelExpectation.fulfill()
521-
}
522-
default: break
524+
if expectedResult.count == parallelSize {
525+
Task { await parallelExpectation.fulfill() }
523526
}
524527
}
525528
try await Amplify.DataStore.save(newPost)
526-
wait(for: [initExpectation], timeout: 5)
529+
await AsyncTesting.waitForExpectations([initExpectation], timeout: 10)
527530
try await Task.sleep(seconds: 1)
528531

529532
for post in posts {
530533
Task {
531534
try? await Amplify.DataStore.save(post)
532535
}
533536
}
534-
535-
wait(for: [parallelExpectation], timeout: Double(parallelSize))
537+
await AsyncTesting.waitForExpectations([parallelExpectation], timeout: Double(parallelSize))
536538
cancellable.cancel()
537539
XCTAssertEqual(expectedResult, Set(posts.map(\.title)))
538540
}

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/HubEventsIntegrationTestBase.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@ class HubEventsIntegrationTestBase: XCTestCase {
3333
// swiftlint:enable force_try
3434
// swiftlint:enable force_cast
3535

36-
override func setUp() {
37-
super.setUp()
36+
override func setUp() async throws {
37+
try await super.setUp()
3838
continueAfterFailure = false
3939
}
4040

41+
override func tearDown() async throws {
42+
storageAdapter.delete(untypedModelType: ModelSyncMetadata.self, withIdentifier: ModelIdentifier<ModelSyncMetadata, ModelIdentifierFormat.Default>.makeDefault(id:"Post")) { _ in }
43+
storageAdapter.delete(untypedModelType: ModelSyncMetadata.self, withIdentifier: ModelIdentifier<ModelSyncMetadata, ModelIdentifierFormat.Default>.makeDefault(id:"Comment")) { _ in }
44+
await Amplify.reset()
45+
try await Task.sleep(seconds: 1)
46+
}
47+
4148
func startAmplify(withModels models: AmplifyModelRegistration) async {
4249
do {
4350
let amplifyConfig = try TestConfigHelper.retrieveAmplifyConfiguration(forResource: Self.amplifyConfigurationFile)
@@ -51,11 +58,4 @@ class HubEventsIntegrationTestBase: XCTestCase {
5158
return
5259
}
5360
}
54-
55-
override func tearDown() async throws {
56-
print("Amplify reset")
57-
storageAdapter.delete(untypedModelType: ModelSyncMetadata.self, withIdentifier: ModelIdentifier<ModelSyncMetadata, ModelIdentifierFormat.Default>.makeDefault(id:"Post")) { _ in }
58-
storageAdapter.delete(untypedModelType: ModelSyncMetadata.self, withIdentifier: ModelIdentifier<ModelSyncMetadata, ModelIdentifierFormat.Default>.makeDefault(id:"Comment")) { _ in }
59-
await Amplify.reset()
60-
}
6161
}

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/SyncEngineIntegrationTestBase.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ class SyncEngineIntegrationTestBase: DataStoreTestBase {
3232
// swiftlint:enable force_try
3333
// swiftlint:enable force_cast
3434

35+
override func setUp() async throws {
36+
try await super.setUp()
37+
continueAfterFailure = false
38+
}
39+
40+
override func tearDown() async throws {
41+
try await super.tearDown()
42+
try await stopDataStore()
43+
await Amplify.reset()
44+
try await Task.sleep(seconds: 1)
45+
}
46+
3547
func setUp(
3648
withModels models: AmplifyModelRegistration,
3749
logLevel: LogLevel = .error,
3850
dataStoreConfiguration: DataStoreConfiguration? = nil
3951
) async {
40-
continueAfterFailure = false
41-
4252
Amplify.Logging.logLevel = logLevel
4353

4454
do {
@@ -55,11 +65,6 @@ class SyncEngineIntegrationTestBase: DataStoreTestBase {
5565
}
5666
}
5767

58-
override func tearDown() async throws {
59-
try await Amplify.DataStore.stop()
60-
await Amplify.reset()
61-
}
62-
6368
func stopDataStore() async throws {
6469
try await Amplify.DataStore.stop()
6570
}
@@ -91,8 +96,9 @@ class SyncEngineIntegrationTestBase: DataStoreTestBase {
9196
}
9297

9398
private func startAmplifyAndWait(for eventName: String) async throws {
94-
let eventReceived = expectation(description: "DataStore \(eventName) event")
99+
try startAmplify()
95100

101+
let eventReceived = expectation(description: "DataStore \(eventName) event")
96102
var token: UnsubscribeToken!
97103
token = Amplify.Hub.listen(to: .dataStore,
98104
eventName: eventName) { _ in
@@ -105,11 +111,10 @@ class SyncEngineIntegrationTestBase: DataStoreTestBase {
105111
return
106112
}
107113

108-
try startAmplify()
109-
// try await Amplify.DataStore.start()
110-
try await deleteMutationEvents()
114+
try await Amplify.DataStore.start()
115+
await waitForExpectations(timeout: 10.0)
111116

112-
await waitForExpectations(timeout: 100.0)
117+
try await deleteMutationEvents()
113118
}
114119

115120
func deleteMutationEvents() async throws {

0 commit comments

Comments
 (0)