Skip to content

Commit

Permalink
test: updating integration test workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Oct 13, 2023
1 parent 58d38d8 commit b93b7b5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
1 change: 0 additions & 1 deletion .github/composite_actions/run_xcodebuild_test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ runs:
XCODE_PATH: ${{ inputs.xcode_path }}
CLONED_SOURCE_PACKAGES_PATH: ${{ inputs.cloned_source_packages_path }}
DERIVED_DATA_PATH: ${{ inputs.derived_data_path }}
FASTLANE_EXPLICIT_OPEN_SIMULATOR: "2"
run: |
if [ ! -z "$PROJECT_PATH" ]; then
cd $PROJECT_PATH
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/integ_test_analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ permissions:
id-token: write
contents: read

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
analytics-integration-test-iOS:
runs-on: macos-12
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/integ_test_logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ permissions:
id-token: write
contents: read

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
logging-integration-test-iOS:
runs-on: macos-12
Expand Down Expand Up @@ -40,7 +36,6 @@ jobs:
logging-integration-test-tvOS:
runs-on: macos-13
environment: IntegrationTest
needs: logging-integration-test-iOS
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
with:
Expand Down Expand Up @@ -69,7 +64,6 @@ jobs:
logging-integration-test-watchOS:
runs-on: macos-13
environment: IntegrationTest
needs: [logging-integration-test-iOS, logging-integration-test-tvOS]
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase {

override func tearDown() async throws {
await Amplify.reset()
let documents = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.path ?? NSTemporaryDirectory()
let directory = documents.appendingPathComponent("amplify")
.appendingPathComponent("logging")
try FileManager.default.removeItem(atPath: directory)
}

/// - Given: a AWS CloudWatch Logging plugin
Expand Down Expand Up @@ -71,12 +75,13 @@ class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase {
try await loggingPlugin.flushLogs()
try await Task.sleep(seconds: 30)
let cloudWatchClient = loggingPlugin.getEscapeHatch()
try await verifyMessagesSent(client: cloudWatchClient,
logGroupName: loggingConfiguration?.logGroupName,
messageCount: 4,
message: message,
category: category,
namespace: namespace)
try await verifyMessagesSent(plugin: loggingPlugin,
client: cloudWatchClient,
logGroupName: loggingConfiguration?.logGroupName,
messageCount: 4,
message: message,
category: category,
namespace: namespace)
}


Expand All @@ -98,7 +103,8 @@ class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase {
try await loggingPlugin.flushLogs()
try await Task.sleep(seconds: 30)
let cloudWatchClient = loggingPlugin.getEscapeHatch()
try await verifyMessageSent(client: cloudWatchClient,
try await verifyMessageSent(plugin: loggingPlugin,
client: cloudWatchClient,
logGroupName: loggingConfiguration?.logGroupName,
logLevel: "verbose",
message: message,
Expand All @@ -124,19 +130,22 @@ class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase {
try await loggingPlugin.flushLogs()
try await Task.sleep(seconds: 30)
let cloudWatchClient = loggingPlugin.getEscapeHatch()
try await verifyMessageNotSent(client: cloudWatchClient,
try await verifyMessageNotSent(plugin: loggingPlugin,
client: cloudWatchClient,
logGroupName: loggingConfiguration?.logGroupName,
message: message)
}

func verifyMessagesSent(client: CloudWatchLogsClientProtocol?,
func verifyMessagesSent(plugin: AWSCloudWatchLoggingPlugin,
client: CloudWatchLogsClientProtocol?,
logGroupName: String?,
messageCount: Int,
message: String,
category: String,
namespace: String) async throws {

let events = try await getLastMessageSent(
plugin: plugin,
client: client,
logGroupName: logGroupName,
expectedMessageCount: messageCount,
Expand All @@ -152,14 +161,16 @@ class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase {
XCTAssertTrue(sentLogMessage.contains(namespace))
}

func verifyMessageSent(client: CloudWatchLogsClientProtocol?,
func verifyMessageSent(plugin: AWSCloudWatchLoggingPlugin,
client: CloudWatchLogsClientProtocol?,
logGroupName: String?,
logLevel: String,
message: String,
category: String,
namespace: String) async throws {

let events = try await getLastMessageSent(
plugin: plugin,
client: client,
logGroupName: logGroupName,
expectedMessageCount: 1,
Expand All @@ -176,11 +187,13 @@ class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase {
XCTAssertTrue(sentLogMessage.contains(namespace))
}

func verifyMessageNotSent(client: CloudWatchLogsClientProtocol?,
func verifyMessageNotSent(plugin: AWSCloudWatchLoggingPlugin,
client: CloudWatchLogsClientProtocol?,
logGroupName: String?,
message: String) async throws {

let events = try await getLastMessageSent(
plugin: plugin,
client: client,
logGroupName: logGroupName,
expectedMessageCount: 1,
Expand All @@ -189,7 +202,8 @@ class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase {
XCTAssertEqual(events?.count, 0)
}

func getLastMessageSent(client: CloudWatchLogsClientProtocol?,
func getLastMessageSent(plugin: AWSCloudWatchLoggingPlugin,
client: CloudWatchLogsClientProtocol?,
logGroupName: String?,
expectedMessageCount: Int,
message: String,
Expand All @@ -200,9 +214,11 @@ class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase {
var events = try await AWSCloudWatchClientHelper.getFilterLogEventCount(client: client, filterPattern: message, startTime: startTime, endTime: endTime, logGroupName: logGroupName)

if events?.count != expectedMessageCount && requestAttempt <= 5 {
try await plugin.flushLogs()
try await Task.sleep(seconds: 30)
let attempted = requestAttempt + 1
events = try await getLastMessageSent(
plugin: plugin,
client: client,
logGroupName: logGroupName,
expectedMessageCount: expectedMessageCount,
Expand Down

0 comments on commit b93b7b5

Please sign in to comment.