diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index e9b8a4b1..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,205 +0,0 @@ -# For a detailed guide to building and testing on iOS, read the docs: -# https://circleci.com/docs/2.0/testing-ios/ - -version: 2.1 - -orbs: - # codecov: codecov/codecov@3.2.5 - macos: circleci/macos@2 - -# Workflows orchestrate a set of jobs to be run -workflows: - build-test: - jobs: - - validate-code - - test-ios: - requires: - - validate-code - - test-tvos: - requires: - - validate-code - # The following jobs are conditional on branch name - - test-ios-integration: - requires: - - validate-code - filters: - branches: - only: - - main - - staging - - build_xcframework_and_app: - requires: - - validate-code - filters: - branches: - only: - - main - - staging - -commands: - install_dependencies: - steps: - # restore pods related caches - - restore_cache: - name: Restoring Gemfile Cache - keys: - - 1-gems-{{ checksum "Gemfile.lock" }} - - # make sure we're on the right version of cocoapods - - run: - name: Verify Cocoapods Version - command: bundle check || bundle install --path vendor/bundle - - # save cocoapods version gem data - - save_cache: - name: Saving Gemfile Cache - key: 1-gems-{{ checksum "Gemfile.lock" }} - paths: - - vendor/bundle - - # restore pods related caches - - restore_cache: - name: Restoring CocoaPods Cache - keys: - - cocoapods-cache-v6-{{ arch }}-{{ .Branch }}-{{ checksum "Podfile.lock" }} - - cocoapods-cache-v6-{{ arch }}-{{ .Branch }} - - cocoapods-cache-v6 - - # install CocoaPods - using default CocoaPods version, not the bundle - - run: - name: Repo Update & Install CocoaPods - command: make ci-pod-install - - # save pods related files - - save_cache: - name: Saving CocoaPods Cache - key: cocoapods-cache-v6-{{ arch }}-{{ .Branch }}-{{ checksum "Podfile.lock" }} - paths: - - ./Pods - - ./SampleApps/TestApp/Pods - - ~/.cocoapods - - prestart_ios_simulator: - steps: - - macos/preboot-simulator: - platform: "iOS" - version: "17.2" - device: "iPhone 15" - - prestart_tvos_simulator: - steps: - - macos/preboot-simulator: - platform: "tvOS" - version: "17.2" - device: "Apple TV" - -jobs: - validate-code: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - - steps: - - checkout - - - install_dependencies - - - run: - name: Lint Source Code - command: make lint - - test-ios: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - resource_class: macos.m1.medium.gen1 - - steps: - - checkout - - - install_dependencies - - - prestart_ios_simulator - - - run: - name: Run iOS Unit Tests - command: make unit-test-ios - - # Code coverage upload using Codecov - # See options explanation here: https://docs.codecov.com/docs/codecov-uploader - # - codecov/upload: - # flags: ios-unit-tests - # upload_name: Coverage report for iOS unit tests - # xtra_args: -c -v --xc --xp build/reports/iosUnitResults.xcresult - - - run: - name: Run iOS Functional Tests - command: make functional-test-ios - when: always # run even if unit tests fail - - # - codecov/upload: - # flags: ios-functional-tests - # upload_name: Coverage report for iOS functional tests - # xtra_args: -c -v --xc --xp build/reports/iosFunctionalResults.xcresult - - test-ios-integration: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - - steps: - - checkout - - - install_dependencies - - - prestart_ios_simulator - - - run: - name: Run iOS integration tests - command: make test-integration-upstream - - test-tvos: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - resource_class: macos.m1.medium.gen1 - - steps: - - checkout - - - install_dependencies - - - prestart_tvos_simulator - - - run: - name: Run tvOS Unit Tests - command: make unit-test-tvos - - # Code coverage upload using Codecov - # See options explanation here: https://docs.codecov.com/docs/codecov-uploader - # - codecov/upload: - # flags: tvos-unit-tests - # upload_name: Coverage report for tvOS unit tests - # xtra_args: -c -v --xc --xp build/reports/tvosUnitResults.xcresult - - - run: - name: Run tvOS Functional Tests - command: make functional-test-tvos - when: always # run even if unit tests fail - - # - codecov/upload: - # flags: tvos-functional-tests - # upload_name: Coverage report for tvOS functional tests - # xtra_args: -c -v --xc --xp build/reports/tvosFunctionalResults.xcresult - - build_xcframework_and_app: - macos: - xcode: 15.1.0 # Specify the Xcode version to use - - steps: - - checkout - # Verify XCFramework archive builds - - run: - name: Build XCFramework - command: make archive - # verify test app builds - - run: - name: Build Test App - command: make build-app - diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 00000000..90b58b4e --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,34 @@ +# +# Copyright 2024 Adobe. All rights reserved. +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +# OF ANY KIND, either express or implied. See the License for the specific language +# governing permissions and limitations under the License. +# + +name: Build and Test + +on: + pull_request: + +jobs: + build-and-test: + name: "CI" + uses: adobe/aepsdk-commons/.github/workflows/ios-build-and-test.yml@gha-ios-5.0.0 + with: + ios-device-names: '["iPhone 15"]' + ios-versions: '["18.1"]' + tvos-device-names: '["Apple TV"]' + tvos-versions: '["18.1"]' + run-test-ios-unit: true + run-test-ios-functional: true + run-test-ios-integration: true + run-test-tvos-unit: true + run-test-tvos-functional: true + run-build-xcframework-and-app: true + enable-codecov: true + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17cf2899..17a60338 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,97 +1,45 @@ +# +# Copyright 2024 Adobe. All rights reserved. +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +# OF ANY KIND, either express or implied. See the License for the specific language +# governing permissions and limitations under the License. +# + name: Release on: workflow_dispatch: inputs: tag: - description: 'tag/version' + description: 'The tag (version) to be released (ex: 1.2.3).' + type: string required: true - default: '1.0.0' - action_tag: - description: 'create tag ("no" to skip)' + create-github-release: + description: 'Create a GitHub release with uploaded artifacts. If the provided `tag` does not exist, it will be created.' + type: boolean required: true - default: 'yes' + default: true - release_AEPEdge: - description: 'release AEPEdge to Cocoapods ("no" to skip)' + pod-publish-extensions: + description: 'Publish AEPEdge to Cocoapods.' + type: boolean required: true - default: 'yes' + default: true jobs: - release_edge: - runs-on: macos-13 - steps: - - uses: actions/checkout@v2 - with: - ref: main - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '15.0.1' - - - name: Install jq - run: brew install jq - - - name: Install cocoapods - run: gem install cocoapods - - - name: Install xcodegen - run: brew install xcodegen - - - name: Check version in Podspec - run: | - set -eo pipefail - echo Target version: ${{ github.event.inputs.tag }} - make check-version VERSION=${{ github.event.inputs.tag }} - - - name: SPM integration test - if: ${{ github.event.inputs.action_tag == 'yes' }} - run: | - set -eo pipefail - echo SPM integration test starts: - make test-SPM-integration - - - name: podspec file verification - if: ${{ github.event.inputs.action_tag == 'yes' }} - run: | - set -eo pipefail - echo podspec file verification starts: - make test-podspec - - - name: Build Artifacts - if: ${{ github.event.inputs.action_tag == 'yes' }} - run: | - make archive - make zip - - - name: Create GH Release - id: create_release - uses: release-drafter/release-drafter@v5 - if: ${{ github.event.inputs.action_tag == 'yes' }} - with: - name: v${{ github.event.inputs.tag }} - tag: ${{ github.event.inputs.tag }} - version: ${{ github.event.inputs.tag }} - publish: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload - AEPEdge - uses: actions/upload-release-asset@v1 - if: ${{ github.event.inputs.action_tag == 'yes' }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./build/AEPEdge.xcframework.zip - asset_name: AEPEdge-${{ github.event.inputs.tag }}.xcframework.zip - asset_content_type: application/zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish Pods - AEPEdge - if: ${{ github.event.inputs.release_AEPEdge == 'yes' }} - run: | - set -eo pipefail - pod trunk push AEPEdge.podspec --allow-warnings --synchronous - pod repo update - env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + release: + permissions: + contents: write + uses: adobe/aepsdk-commons/.github/workflows/ios-release.yml@gha-ios-5.0.0 + with: + tag: ${{ github.event.inputs.tag }} + create-github-release: ${{ github.event.inputs.create-github-release == 'true' && 'AEPEdge' || '' }} + pod-publish-extensions: ${{ github.event.inputs.pod-publish-extensions == 'true' && 'AEPEdge' || '' }} + version-validation-paths: AEPEdge.podspec, AEPEdge.xcodeproj/project.pbxproj, Sources/EdgeConstants.swift, + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/update-versions.yml b/.github/workflows/update-versions.yml new file mode 100644 index 00000000..8cef57d2 --- /dev/null +++ b/.github/workflows/update-versions.yml @@ -0,0 +1,51 @@ +# +# Copyright 2024 Adobe. All rights reserved. +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +# OF ANY KIND, either express or implied. See the License for the specific language +# governing permissions and limitations under the License. +# + +name: Update Versions + +on: + workflow_dispatch: + inputs: + version: + description: 'The new version to use for the extension (ex: 1.2.3).' + type: string + required: true + + branch: + description: 'The target branch where the version update will be applied and the pull request will be merged into.' + type: string + required: true + + core-dependency: + description: 'If a version is provided, update AEPCore dependency in podspec and Package.swift.' + type: string + required: false + default: '' + + edge-identity-dependency: + description: 'If a version is provided, update AEPEdgeIdentity dependency in podspec and Package.swift.' + type: string + required: false + default: '' + +jobs: + update-versions: + permissions: + contents: write + pull-requests: write + uses: adobe/aepsdk-commons/.github/workflows/versions.yml@gha-ios-5.0.0 + with: + version: ${{ github.event.inputs.version }} + branch: ${{ github.event.inputs.branch }} + dependencies: AEPCore ${{ github.event.inputs.core-dependency }}, AEPEdgeIdentity ${{ github.event.inputs.edge-identity-dependency }} + paths: Package.swift:swift_spm, AEPEdge.podspec, AEPEdge.xcodeproj/project.pbxproj, Sources/EdgeConstants.swift + update: true \ No newline at end of file diff --git a/.github/workflows/update_versions.yml b/.github/workflows/update_versions.yml deleted file mode 100644 index 56fbb7f8..00000000 --- a/.github/workflows/update_versions.yml +++ /dev/null @@ -1,52 +0,0 @@ -# This is a basic workflow that is manually triggered - -name: Update Versions - -# Controls when the action will run. Workflow runs when manually triggered using the UI -# or API. -on: - workflow_dispatch: - # Inputs the workflow accepts. - inputs: - version: - description: 'New version to use for the extension. Example: 1.5.2' - required: true - - branch: - description: 'Branch to be used when updating versions' - required: true - - core-dependency: - description: 'If a version is provided, update AEPCore dependency in podspec and Package.swift' - required: false - - edge-identity-dependency: - description: 'If a version is provided, update AEPEdgeIdentity dependency in podspec and Package.swift' - required: false - - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - update-versions: - runs-on: macos-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - - name: Checkout - uses: actions/checkout@v3.1.0 - with: - ref: ${{ github.event.inputs.branch }} - - - name: Update AEPEdge (with core dependency update) - run: (sh ./Script/update-versions.sh -n Edge -v ${{ github.event.inputs.version }} -d "AEPCore ${{ github.event.inputs.core-dependency }}, AEPEdgeIdentity ${{ github.event.inputs.edge-identity-dependency }}") - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v4.2.3 - with: - token: ${{ github.token }} - commit-message: Updating version to ${{ github.event.inputs.version }}. - branch: version-${{ github.event.inputs.version }}-update - delete-branch: true - title: Updating version to ${{ github.event.inputs.version }} - body: Updating version to ${{ github.event.inputs.version }} diff --git a/.github/workflows/upstream-integration-test.yml b/.github/workflows/upstream-integration-test.yml index e1812a14..925b154f 100644 --- a/.github/workflows/upstream-integration-test.yml +++ b/.github/workflows/upstream-integration-test.yml @@ -1,3 +1,15 @@ +# +# Copyright 2024 Adobe. All rights reserved. +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +# OF ANY KIND, either express or implied. See the License for the specific language +# governing permissions and limitations under the License. +# + # Action to execute upstream integration tests - Edge Network (Konductor) name: Integration Tests diff --git a/AEPEdge.xcodeproj/project.pbxproj b/AEPEdge.xcodeproj/project.pbxproj index 404f5d66..5fd61de7 100644 --- a/AEPEdge.xcodeproj/project.pbxproj +++ b/AEPEdge.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 2EDD05CA286EAA7000229CB2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D4D5B5852432977F00CAB6E4 /* Preview Assets.xcassets */; }; 2EDD05CB286EAA7000229CB2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D4D5B5822432977F00CAB6E4 /* Assets.xcassets */; }; 423B5033D43ADB49049383FB /* Pods_FunctionalTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B13510405D14B13EFD1B58A /* Pods_FunctionalTests.framework */; }; + 4C089BC52CF01AA900CB500C /* FunctionalTestConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C089BC42CF01AA900CB500C /* FunctionalTestConstants.swift */; }; 4CBEE5D829D637170084BC50 /* AEPEdge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D444995F2519506B0093B364 /* AEPEdge.framework */; }; 4CBEE5E629D637E90084BC50 /* UpstreamIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CBEE5E229D637E90084BC50 /* UpstreamIntegrationTests.swift */; }; 4CBEE5FD29FB47270084BC50 /* TestConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4A473C52485938D00D31710 /* TestConstants.swift */; }; @@ -231,6 +232,7 @@ 2ECFB7512AB391F400653128 /* EdgeDatastreamConfigOverrideTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EdgeDatastreamConfigOverrideTests.swift; sourceTree = ""; }; 2EDD05D2286EAA7000229CB2 /* TestApptvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestApptvOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; 316EF062B0B622235F6BB384 /* Pods_TestAppiOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TestAppiOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4C089BC42CF01AA900CB500C /* FunctionalTestConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FunctionalTestConstants.swift; sourceTree = ""; }; 4CBEE5E029D637170084BC50 /* UpstreamIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UpstreamIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 4CBEE5E229D637E90084BC50 /* UpstreamIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpstreamIntegrationTests.swift; sourceTree = ""; }; 4CBEE60D2A156FB10084BC50 /* CompletionHandlerFunctionalTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompletionHandlerFunctionalTests.swift; sourceTree = ""; }; @@ -463,6 +465,7 @@ isa = PBXGroup; children = ( BF024B7824C6238C002131E9 /* FakeIdentityExtension.swift */, + 4C089BC42CF01AA900CB500C /* FunctionalTestConstants.swift */, BF0C09472465E42100892B5D /* TestableEdge.swift */, D48CBD2124A17EEA00A24BD8 /* TestXDMSchema.swift */, ); @@ -1348,6 +1351,7 @@ BF024B7924C6238C002131E9 /* FakeIdentityExtension.swift in Sources */, 4CBEE61F2A15764B0084BC50 /* IdentityStateFunctionalTests.swift in Sources */, 4CBEE61B2A1572E50084BC50 /* Edge+PublicAPITests.swift in Sources */, + 4C089BC52CF01AA900CB500C /* FunctionalTestConstants.swift in Sources */, 4CBEE6192A1571DC0084BC50 /* Edge+ConsentTests.swift in Sources */, D48CBD2224A17EEA00A24BD8 /* TestXDMSchema.swift in Sources */, BFDF25AB2BD02E58002114B6 /* EdgeQueuedEntityFunctionalTests.swift in Sources */, diff --git a/Makefile b/Makefile index c9e6a370..2fa0e841 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,48 @@ TVOS_SIMULATOR_ARCHIVE_DSYM_PATH = $(CURR_DIR)/build/tvos_simulator.xcarchive/dS TVOS_ARCHIVE_PATH = $(CURR_DIR)/build/tvos.xcarchive/Products/Library/Frameworks/ TVOS_ARCHIVE_DSYM_PATH = $(CURR_DIR)/build/tvos.xcarchive/dSYMs/ +# Values with defaults +IOS_DEVICE_NAME ?= iPhone 15 +# If OS version is not specified, uses the first device name match in the list of available simulators +IOS_VERSION ?= +ifeq ($(strip $(IOS_VERSION)),) + IOS_DESTINATION = "platform=iOS Simulator,name=$(IOS_DEVICE_NAME)" +else + IOS_DESTINATION = "platform=iOS Simulator,name=$(IOS_DEVICE_NAME),OS=$(IOS_VERSION)" +endif + +TVOS_DEVICE_NAME ?= Apple TV +# If OS version is not specified, uses the first device name match in the list of available simulators +TVOS_VERSION ?= +ifeq ($(strip $(TVOS_VERSION)),) + TVOS_DESTINATION = "platform=tvOS Simulator,name=$(TVOS_DEVICE_NAME)" +else + TVOS_DESTINATION = "platform=tvOS Simulator,name=$(TVOS_DEVICE_NAME),OS=$(TVOS_VERSION)" +endif + +clean-derived-data: + @if [ -z "$(SCHEME)" ]; then \ + echo "Error: SCHEME variable is not set."; \ + exit 1; \ + fi; \ + if [ -z "$(DESTINATION)" ]; then \ + echo "Error: DESTINATION variable is not set."; \ + exit 1; \ + fi; \ + echo "Cleaning derived data for scheme: $(SCHEME) with destination: $(DESTINATION)"; \ + DERIVED_DATA_PATH=`xcodebuild -workspace $(PROJECT_NAME).xcworkspace -scheme "$(SCHEME)" -destination "$(DESTINATION)" -showBuildSettings | grep -m1 'BUILD_DIR' | awk '{print $$3}' | sed 's|/Build/Products||'`; \ + echo "DerivedData Path: $$DERIVED_DATA_PATH"; \ + \ + LOGS_TEST_DIR=$$DERIVED_DATA_PATH/Logs/Test; \ + echo "Logs Test Path: $$LOGS_TEST_DIR"; \ + \ + if [ -d "$$LOGS_TEST_DIR" ]; then \ + echo "Removing existing .xcresult files in $$LOGS_TEST_DIR"; \ + rm -rf "$$LOGS_TEST_DIR"/*.xcresult; \ + else \ + echo "Logs/Test directory does not exist. Skipping cleanup."; \ + fi; + setup-tools: install-githook setup: @@ -91,37 +133,39 @@ unit-test-ios: @echo "######################################################################" @echo "### Unit Testing iOS" @echo "######################################################################" - rm -rf build/reports/iosUnitResults.xcresult - xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "UnitTests" -destination "platform=iOS Simulator,name=iPhone 15" -derivedDataPath build/out -resultBundlePath build/reports/iosUnitResults.xcresult -enableCodeCoverage YES ADB_SKIP_LINT=YES + @$(MAKE) clean-derived-data SCHEME=UnitTests DESTINATION=$(IOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "UnitTests" -destination $(IOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES functional-test-ios: @echo "######################################################################" @echo "### Functional Testing iOS" @echo "######################################################################" - rm -rf build/reports/iosFunctionalResults.xcresult - xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "FunctionalTests" -destination "platform=iOS Simulator,name=iPhone 15" -derivedDataPath build/out -resultBundlePath build/reports/iosFunctionalResults.xcresult -enableCodeCoverage YES ADB_SKIP_LINT=YES + @$(MAKE) clean-derived-data SCHEME=FunctionalTests DESTINATION=$(IOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "FunctionalTests" -destination $(IOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES unit-test-tvos: @echo "######################################################################" @echo "### Unit Testing tvOS" @echo "######################################################################" - rm -rf build/reports/tvosUnitResults.xcresult - xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "UnitTests" -destination 'platform=tvOS Simulator,name=Apple TV' -derivedDataPath build/out -resultBundlePath build/reports/tvosUnitResults.xcresult -enableCodeCoverage YES ADB_SKIP_LINT=YES + @$(MAKE) clean-derived-data SCHEME=UnitTests DESTINATION=$(TVOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "UnitTests" -destination $(TVOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES functional-test-tvos: @echo "######################################################################" @echo "### Functional Testing tvOS" @echo "######################################################################" - rm -rf build/reports/tvosFunctionalResults.xcresult - xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "FunctionalTests" -destination 'platform=tvOS Simulator,name=Apple TV' -derivedDataPath build/out -resultBundlePath build/reports/tvosFunctionalResults.xcresult -enableCodeCoverage YES ADB_SKIP_LINT=YES + @$(MAKE) clean-derived-data SCHEME=FunctionalTests DESTINATION=$(TVOS_DESTINATION) + xcodebuild test -workspace $(PROJECT_NAME).xcworkspace -scheme "FunctionalTests" -destination $(TVOS_DESTINATION) -enableCodeCoverage YES ADB_SKIP_LINT=YES + +integration-test-ios: upstream-integration-test-ios # Runs the Edge Network (Konductor) integration tests after installing pod dependencies # Usage: -# make test-integration-upstream MOBILE_PROPERTY_ID= EDGE_LOCATION_HINT= +# make upstream-integration-test-ios MOBILE_PROPERTY_ID= EDGE_LOCATION_HINT= # If MOBILE_PROPERTY_ID is not specified, test target will use its default value. -.SILENT: test-integration-upstream # Silences Makefile's automatic echo of commands -test-integration-upstream: pod-install; \ - rm -rf build/reports/iosIntegrationUpstreamResults.xcresult; \ +.SILENT: upstream-integration-test-ios # Silences Makefile's automatic echo of commands +upstream-integration-test-ios: pod-install; \ + $(MAKE) clean-derived-data SCHEME=UpstreamIntegrationTests DESTINATION=$(IOS_DESTINATION) if [ -z "$$EDGE_ENVIRONMENT" ]; then \ echo ''; \ echo '-------------------------- WARNING -------------------------------'; \ @@ -132,9 +176,7 @@ test-integration-upstream: pod-install; \ xcodebuild test \ -workspace $(PROJECT_NAME).xcworkspace \ -scheme UpstreamIntegrationTests \ - -destination 'platform=iOS Simulator,name=iPhone 15' \ - -derivedDataPath build/out \ - -resultBundlePath build/reports/iosIntegrationUpstreamResults.xcresult \ + -destination $(IOS_DESTINATION) \ -enableCodeCoverage YES \ ADB_SKIP_LINT=YES \ TAGS_MOBILE_PROPERTY_ID=$(TAGS_MOBILE_PROPERTY_ID) \ @@ -149,15 +191,8 @@ lint-autocorrect: lint: ./Pods/SwiftLint/swiftlint lint Sources TestApps -# make check-version VERSION=5.0.0 -check-version: - sh ./Script/version.sh $(VERSION) - test-SPM-integration: sh ./Script/test-SPM.sh test-podspec: - sh ./Script/test-podspec.sh - -test-version-update: - sh ./Script/update-versions.sh -n Edge -v 9.9.9 + sh ./Script/test-podspec.sh \ No newline at end of file diff --git a/Podfile b/Podfile index c3110f86..7313b7bf 100644 --- a/Podfile +++ b/Podfile @@ -25,19 +25,19 @@ end target 'UnitTests' do core_pods - pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.1' + pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.2' end target 'UpstreamIntegrationTests' do core_pods edge_pods - pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.1' + pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.2' end target 'FunctionalTests' do core_pods edge_pods - pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.1' + pod 'AEPTestUtils', :git => 'https://github.com/adobe/aepsdk-core-ios.git', :tag => 'testutils-5.2.2' end target 'TestAppiOS' do diff --git a/Podfile.lock b/Podfile.lock index d8830c5f..22f3e424 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -15,7 +15,7 @@ PODS: - AEPCore (< 6.0.0, >= 5.0.0) - AEPRulesEngine (5.0.0) - AEPServices (5.3.1) - - AEPTestUtils (5.2.1): + - AEPTestUtils (5.2.2): - AEPCore (< 6.0.0, >= 5.2.0) - AEPServices (< 6.0.0, >= 5.2.0) - SwiftLint (0.52.0) @@ -26,7 +26,7 @@ DEPENDENCIES: - AEPEdge (from `./AEPEdge.podspec`) - AEPEdgeConsent - AEPEdgeIdentity - - AEPTestUtils (from `https://github.com/adobe/aepsdk-core-ios.git`, tag `testutils-5.2.1`) + - AEPTestUtils (from `https://github.com/adobe/aepsdk-core-ios.git`, tag `testutils-5.2.2`) - SwiftLint (= 0.52.0) SPEC REPOS: @@ -44,12 +44,12 @@ EXTERNAL SOURCES: :path: "./AEPEdge.podspec" AEPTestUtils: :git: https://github.com/adobe/aepsdk-core-ios.git - :tag: testutils-5.2.1 + :tag: testutils-5.2.2 CHECKOUT OPTIONS: AEPTestUtils: :git: https://github.com/adobe/aepsdk-core-ios.git - :tag: testutils-5.2.1 + :tag: testutils-5.2.2 SPEC CHECKSUMS: AEPAssurance: df04baeace42befb0cc213fd6cdfe51651d11ba6 @@ -59,9 +59,9 @@ SPEC CHECKSUMS: AEPEdgeIdentity: 3161ff33434586962946912d6b8e9e8fca1c4d23 AEPRulesEngine: fe5800653a4bee07b1e41e61b4d5551f0dba557b AEPServices: fcba979e90f6916b066aa66f016700d7b7534d96 - AEPTestUtils: 95394464ba120b308bfdfa652b7584c8f91de6b1 + AEPTestUtils: 61de2086056f4aa3223dc7d035991ef4fdacbfdb SwiftLint: 13280e21cdda6786ad908dc6e416afe5acd1fcb7 -PODFILE CHECKSUM: c0c9dbbbe45188bea36e1e515bd704064d09a041 +PODFILE CHECKSUM: 4837da7fb6019ebb291c28bffd4cd772e0899dc5 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/Script/update-versions.sh b/Script/update-versions.sh deleted file mode 100755 index 8ab6712e..00000000 --- a/Script/update-versions.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# make this script executable from terminal: -# chmod 755 update-versions.sh - -set -e # Any subsequent(*) commands which fail will cause the shell script to exit immediately - -ROOT_DIR=$(git rev-parse --show-toplevel) -LINE="================================================================================" -VERSION_REGEX="[0-9]+\.[0-9]+\.[0-9]+" -DEPENDENCIES=none - -# make a "dictionary" to help us find the correct spm repo per dependency (if necessary) -# IMPORTANT - this will be used in a regex search so escape special chars -# usage : -# getRepo AEPCore - -declare "repos_AEPCore=https:\/\/github\.com\/adobe\/aepsdk-core-ios\.git" -declare "repos_AEPEdgeIdentity=https:\/\/github\.com\/adobe\/aepsdk-edgeidentity-ios\.git" -getRepo() { - local extensionName=$1 - local url="repos_$extensionName" - echo "${!url}" -} - -help() -{ - echo "" - echo "Usage: $0 -n EXTENSION_NAME -v NEW_VERSION -d \"PODSPEC_DEPENDENCY_1, PODSPEC_DEPENDENCY_2\"" - echo "" - echo -e " -n\t- Name of the extension getting a version update. \n\t Example: Edge, Analytics\n" - echo -e " -v\t- New version to use for the extension. \n\t Example: 3.0.2\n" - echo -e " -d (optional)\t- Dependency(ies) that require updating in the extension's podspec and Package.swift file. \n\t Example: -d \"AEPCore 3.7.3\" (update the dependency on AEPCore to version 3.7.3 or newer)\n" - exit 1 # Exit script after printing help -} - -while getopts "n:v:d:" opt -do - case "$opt" in - n ) NAME="$OPTARG" ;; - v ) NEW_VERSION="$OPTARG" ;; - d ) DEPENDENCIES="$OPTARG" ;; - ? ) help ;; # Print help in case parameter is non-existent - esac -done - -# Print help in case parameters are empty -if [ -z "$NAME" ] || [ -z "$NEW_VERSION" ] -then - echo "********** USAGE ERROR **********" - echo "Some or all of the parameters are empty. See usage below:"; - help -fi - -PODSPEC_FILE=$ROOT_DIR"/AEP"$NAME.podspec -SPM_FILE=$ROOT_DIR/Package.swift - -# Begin script when all parameters are correct -echo "" -echo "$LINE" -echo "Changing version of AEP$NAME to $NEW_VERSION with the following minimum version dependencies: $DEPENDENCIES" -echo "$LINE" - -# Replace extension version in podspec -echo "Changing value of 's.version' to '$NEW_VERSION' in '$PODSPEC_FILE'" -sed -i '' -E "/^ *s.version/{s/$VERSION_REGEX/$NEW_VERSION/;}" $PODSPEC_FILE - -# Replace dependencies in podspec and Package.swift -if [ "$DEPENDENCIES" != "none" ]; then - IFS="," - dependenciesArray=($(echo "$DEPENDENCIES")) - - IFS=" " - for dependency in "${dependenciesArray[@]}"; do - dependencyArray=(${dependency// / }) - dependencyName=${dependencyArray[0]} - dependencyVersion=${dependencyArray[1]} - - if [ "$dependencyVersion" != "" ]; then - echo "Changing value of 's.dependency' for '$dependencyName' to '>= $dependencyVersion' in '$PODSPEC_FILE'" - sed -i '' -E "/^ *s.dependency +'$dependencyName'/{s/$VERSION_REGEX/$dependencyVersion/;}" $PODSPEC_FILE - - spmRepoUrl=$(getRepo $dependencyName) - if [ "$spmRepoUrl" != "" ]; then - echo "Changing value of '.upToNextMajor(from:)' for '$spmRepoUrl' to '$dependencyVersion' in '$SPM_FILE'" - sed -i '' -E "/$spmRepoUrl\", \.upToNextMajor/{s/$VERSION_REGEX/$dependencyVersion/;}" $SPM_FILE - fi - fi - done -fi - -# Replace version in Constants file -CONSTANTS_FILE=$ROOT_DIR"/Sources/"$NAME"Constants.swift" -echo "Changing value of 'EXTENSION_VERSION' to '$NEW_VERSION' in '$CONSTANTS_FILE'" -sed -i '' -E "/^ +static let EXTENSION_VERSION/{s/$VERSION_REGEX/$NEW_VERSION/;}" $CONSTANTS_FILE - -# Replace marketing versions in project.pbxproj -PROJECT_PBX_FILE=$ROOT_DIR"/AEP$NAME.xcodeproj/project.pbxproj" -echo "Changing value of 'MARKETING_VERSION' to '$NEW_VERSION' in '$PROJECT_PBX_FILE'" -sed -i '' -E "/^\t+MARKETING_VERSION = /{s/$VERSION_REGEX/$NEW_VERSION/;}" $PROJECT_PBX_FILE diff --git a/Script/version.sh b/Script/version.sh deleted file mode 100755 index dc6e35b5..00000000 --- a/Script/version.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if which jq >/dev/null; then - echo "jq is installed" -else - echo "error: jq not installed.(brew install jq)" -fi - -NC='\033[0m' -RED='\033[0;31m' -GREEN='\033[0;32m' -BLUE='\033[0;34m' - -echo "Target version - ${BLUE}$1${NC}" -echo "------------------AEPEdge-------------------" -PODSPEC_VERSION_IN_AEPEdge=$(pod ipc spec AEPEdge.podspec | jq '.version' | tr -d '"') -echo "Local podspec version - ${BLUE}${PODSPEC_VERSION_IN_AEPEdge}${NC}" -SOUCE_CODE_VERSION_IN_AEPEdge=$(cat ./Sources/EdgeConstants.swift | egrep '\s*EXTENSION_VERSION\s*=\s*\"(.*)\"' | ruby -e "puts gets.scan(/\"(.*)\"/)[0] " | tr -d '"') -echo "Souce code version - ${BLUE}${SOUCE_CODE_VERSION_IN_AEPEdge}${NC}" - -if [[ "$1" == "$PODSPEC_VERSION_IN_AEPEdge" ]] && [[ "$1" == "$SOUCE_CODE_VERSION_IN_AEPEdge" ]]; then - echo "${GREEN}Pass!${NC}" -else - echo "${RED}[Error]${NC} Version do not match!" - exit -1 -fi -exit 0 diff --git a/Tests/FunctionalTests/AEPEdgeFunctionalTests.swift b/Tests/FunctionalTests/AEPEdgeFunctionalTests.swift index b818e3d6..18e2fca3 100644 --- a/Tests/FunctionalTests/AEPEdgeFunctionalTests.swift +++ b/Tests/FunctionalTests/AEPEdgeFunctionalTests.swift @@ -22,8 +22,7 @@ import XCTest /// End-to-end testing for the AEPEdge public APIs class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { - private let TIMEOUT_SEC: TimeInterval = 2 - private let LONGER_TIMEOUT_SEC: TimeInterval = 10 + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let event1 = Event(name: "e1", type: "eventType", source: "eventSource", data: nil) private let event2 = Event(name: "e2", type: "eventType", source: "eventSource", data: nil) private let exEdgeInteractProdUrl = URL(string: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)! // swiftlint:disable:this force_unwrapping @@ -82,7 +81,10 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { override func tearDown() { super.tearDown() + MobileCore.resetSDK() + mockNetworkService.reset() + resetTestExpectations() } func testUnregistered() { @@ -316,8 +318,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) // Note that `recordSeparator` is set in the format required by the JSON spec to be properly decoded, // not the various Swift formats @@ -382,8 +384,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let expectedJSON = createExpectedPayload( eventsPayload: @@ -449,8 +451,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let expectedJSON = createExpectedPayload( eventsPayload: @@ -503,7 +505,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(0, resultNetworkRequests.count) } @@ -520,7 +522,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(0, resultNetworkRequests.count) } @@ -537,7 +539,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(0, resultNetworkRequests.count) } @@ -561,8 +563,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let expectedJSON = #""" { @@ -643,7 +645,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { // first network call, no stored data mockNetworkService.setExpectationForNetworkRequest(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, expectedCount: 1) - var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) // Validating element count @@ -663,7 +665,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { mockNetworkService.setMockResponse(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, responseConnection: responseConnection) Edge.sendEvent(experienceEvent: experienceEvent) - resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) let expectedJSON = createExpectedPayload( @@ -723,7 +725,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { mockNetworkService.setExpectationForNetworkRequest(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, expectedCount: 1) // Validate - var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) assertTypeMatch( @@ -743,7 +745,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // Validate - resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) let expectedJSON = createExpectedPayload( @@ -792,13 +794,11 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { mockNetworkService.setMockResponse(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, responseConnection: responseConnection) let experienceEvent = ExperienceEvent(xdm: ["testString": "xdm"], data: nil) - Edge.sendEvent(experienceEvent: experienceEvent) - // first network call, no stored data - mockNetworkService.setExpectationForNetworkRequest(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, expectedCount: 1) + Edge.sendEvent(experienceEvent: experienceEvent) // Validate - var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) assertTypeMatch( @@ -821,7 +821,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // Validate - resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) assertTypeMatch( @@ -853,10 +853,10 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: ExperienceEvent(xdm: ["eventType": "personalizationEvent", "test": "xdm"], data: nil)) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) assertExpectedEvents(ignoreUnexpectedEvents: true) - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let requestId = resultNetworkRequests[0].url.queryParam("requestId") let requestEvents = getDispatchedEventsWith(type: TestConstants.EventType.EDGE, source: TestConstants.EventSource.REQUEST_CONTENT) @@ -910,10 +910,10 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: ExperienceEvent(xdm: ["eventType": "personalizationEvent", "test": "xdm"], data: nil)) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) assertExpectedEvents(ignoreUnexpectedEvents: true) - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let requestId = resultNetworkRequests[0].url.queryParam("requestId") let requestEvents = getDispatchedEventsWith(type: TestConstants.EventType.EDGE, source: TestConstants.EventSource.REQUEST_CONTENT) @@ -956,7 +956,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { "testArray": ["arrayElem1", 2, true], "testDictionary": ["key": "val"]]) Edge.sendEvent(experienceEvent: experienceEvent) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) resetTestExpectations() mockNetworkService.reset() @@ -971,7 +971,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { mockNetworkService.setMockResponse(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, responseConnection: httpConnection) // Default retry time period is 5 sec - provide extra timeout buffer - mockNetworkService.assertAllNetworkRequestExpectations(timeout: LONGER_TIMEOUT_SEC) + // Make sure this timeout is at least double the retry time period + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) } func testSendEvent_withXDMData_sendsExEdgeNetworkRequest_afterPersistingMultipleHits() { @@ -997,7 +998,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) Edge.sendEvent(experienceEvent: experienceEvent) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) resetTestExpectations() mockNetworkService.reset() @@ -1012,7 +1013,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { mockNetworkService.setMockResponse(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, responseConnection: httpConnection) // Default retry time period is 5 sec - provide extra timeout buffer - mockNetworkService.assertAllNetworkRequestExpectations(timeout: LONGER_TIMEOUT_SEC) + // Make sure this timeout is at least double the retry time period + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) } func testSendEvent_multiStatusResponse_dispatchesEvents() { @@ -1037,14 +1039,14 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { let experienceEvent = ExperienceEvent(xdm: ["testString": "xdm"], data: nil) Edge.sendEvent(experienceEvent: experienceEvent) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) assertExpectedEvents(ignoreUnexpectedEvents: false) let resultEvents = getDispatchedEventsWith(type: TestConstants.EventType.EDGE, source: TestConstants.EventSource.ERROR_RESPONSE_CONTENT) // Get original requestId and requestEventId - guard let requestId = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: .post).first?.url.queryParam("requestId") else { + guard let requestId = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: .post, timeout: TIMEOUT_SEC).first?.url.queryParam("requestId") else { XCTFail("Unable to get valid requestId.") return } @@ -1118,7 +1120,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { let experienceEvent = ExperienceEvent(xdm: ["testString": "xdm"], data: nil) Edge.sendEvent(experienceEvent: experienceEvent) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) assertExpectedEvents(ignoreUnexpectedEvents: false) let resultEvents = getDispatchedEventsWith(type: TestConstants.EventType.EDGE, @@ -1162,7 +1164,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { let experienceEvent = ExperienceEvent(xdm: ["testString": "xdm"], data: nil) Edge.sendEvent(experienceEvent: experienceEvent) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) assertExpectedEvents(ignoreUnexpectedEvents: false) let resultEvents = getDispatchedEventsWith(type: TestConstants.EventType.EDGE, @@ -1197,7 +1199,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { "testArray": ["arrayElem1", 2, true], "testDictionary": ["key": "val"]]) Edge.sendEvent(experienceEvent: experienceEvent) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) resetTestExpectations() mockNetworkService.reset() @@ -1212,7 +1214,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { mockNetworkService.setMockResponse(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, responseConnection: httpConnection) // Default retry time period is 5 sec - provide extra timeout buffer - mockNetworkService.assertAllNetworkRequestExpectations(timeout: LONGER_TIMEOUT_SEC) + // Make sure this timeout is at least double the retry time period + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) } func testSendEvent_unrecoverableNetworkTransportError_noRetry() { @@ -1235,7 +1238,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { let experienceEvent = ExperienceEvent(xdm: ["testString": "xdm"], data: nil) Edge.sendEvent(experienceEvent: experienceEvent) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) assertExpectedEvents(ignoreUnexpectedEvents: false) let resultEvents = getDispatchedEventsWith(type: TestConstants.EventType.EDGE, @@ -1267,8 +1270,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let requestUrl = resultNetworkRequests[0].url XCTAssertTrue(requestUrl.absoluteURL.absoluteString.hasPrefix(TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)) @@ -1293,8 +1296,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let requestUrl = resultNetworkRequests[0].url XCTAssertTrue(requestUrl.absoluteURL.absoluteString.hasPrefix(TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)) @@ -1319,8 +1322,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let requestUrl = resultNetworkRequests[0].url XCTAssertTrue(requestUrl.absoluteURL.absoluteString.hasPrefix(TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)) @@ -1345,7 +1348,7 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PRE_PROD_URL_STR, httpMethod: HttpMethod.post) let requestUrl = resultNetworkRequests[0].url @@ -1371,8 +1374,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_INTEGRATION_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_INTEGRATION_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let requestUrl = resultNetworkRequests[0].url XCTAssertTrue(requestUrl.absoluteURL.absoluteString.hasPrefix(TestConstants.EX_EDGE_INTERACT_INTEGRATION_URL_STR)) @@ -1398,12 +1401,12 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) XCTAssertTrue(resultNetworkRequests[0].url.absoluteURL.absoluteString.hasPrefix(TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)) - resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR_OR2_LOC, httpMethod: HttpMethod.post) + resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR_OR2_LOC, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) XCTAssertTrue(resultNetworkRequests[0].url.absoluteURL.absoluteString.hasPrefix(TestConstants.EX_EDGE_INTERACT_PROD_URL_STR_OR2_LOC)) } @@ -1431,8 +1434,8 @@ class AEPEdgeFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(2, resultNetworkRequests.count) XCTAssertTrue(resultNetworkRequests[0].url.absoluteURL.absoluteString.hasPrefix(TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)) XCTAssertTrue(resultNetworkRequests[1].url.absoluteURL.absoluteString.hasPrefix(TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)) diff --git a/Tests/FunctionalTests/CompletionHandlerFunctionalTests.swift b/Tests/FunctionalTests/CompletionHandlerFunctionalTests.swift index fcf3c68b..c93535fc 100644 --- a/Tests/FunctionalTests/CompletionHandlerFunctionalTests.swift +++ b/Tests/FunctionalTests/CompletionHandlerFunctionalTests.swift @@ -20,7 +20,7 @@ import XCTest /// End-to-end testing for the AEPEdge public APIs with completion handlers class CompletionHandlerFunctionalTests: TestBase, AnyCodableAsserts { - private let TIMEOUT_SEC: TimeInterval = 2 + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let event1 = Event(name: "e1", type: "eventType", source: "eventSource", data: nil) private let event2 = Event(name: "e2", type: "eventType", source: "eventSource", data: nil) private let responseBody = "{\"test\": \"json\"}" @@ -85,7 +85,7 @@ class CompletionHandlerFunctionalTests: TestBase, AnyCodableAsserts { mockNetworkService.assertAllNetworkRequestExpectations() wait(for: [expectation], timeout: TIMEOUT_SEC) - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, resultNetworkRequests.count) XCTAssertEqual(1, receivedHandles.count) diff --git a/Tests/FunctionalTests/Edge+ConsentTests.swift b/Tests/FunctionalTests/Edge+ConsentTests.swift index 8b1faf35..75c22ddf 100644 --- a/Tests/FunctionalTests/Edge+ConsentTests.swift +++ b/Tests/FunctionalTests/Edge+ConsentTests.swift @@ -20,7 +20,7 @@ import Foundation import XCTest class EdgeConsentTests: TestBase, AnyCodableAsserts { - private let TIMEOUT_SEC: TimeInterval = 2 + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let EVENTS_COUNT: Int32 = 5 private let experienceEvent = ExperienceEvent(xdm: ["test": "xdm"]) private let responseBody = "\u{0000}{" + diff --git a/Tests/FunctionalTests/Edge+PublicAPITests.swift b/Tests/FunctionalTests/Edge+PublicAPITests.swift index 2a81929a..0743d368 100644 --- a/Tests/FunctionalTests/Edge+PublicAPITests.swift +++ b/Tests/FunctionalTests/Edge+PublicAPITests.swift @@ -18,7 +18,7 @@ import AEPTestUtils import XCTest class EdgePublicAPITests: TestBase { - private let TIMEOUT_SEC: TimeInterval = 2 + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let exEdgeInteractProdUrlLocHint = URL(string: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR_OR2_LOC)! // swiftlint:disable:this force_unwrapping private let responseBody = "{\"test\": \"json\"}" diff --git a/Tests/FunctionalTests/EdgeDatastreamConfigOverrideTests.swift b/Tests/FunctionalTests/EdgeDatastreamConfigOverrideTests.swift index a612b4c4..5928e979 100644 --- a/Tests/FunctionalTests/EdgeDatastreamConfigOverrideTests.swift +++ b/Tests/FunctionalTests/EdgeDatastreamConfigOverrideTests.swift @@ -21,7 +21,7 @@ import XCTest // swiftlint:disable type_body_length /// Functional tests for the sendEvent API with datastreamIdOverride and datastreamConfigOverride features class AEPEdgeDatastreamOverrideTests: TestBase, AnyCodableAsserts { - private let TIMEOUT_SEC: TimeInterval = 2 + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let exEdgeInteractProdUrl = URL(string: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)! // swiftlint:disable:this force_unwrapping private let responseBody = "{\"test\": \"json\"}" #if os(iOS) @@ -111,8 +111,8 @@ class AEPEdgeDatastreamOverrideTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) // Validate URL let requestUrl = resultNetworkRequests[0].url @@ -185,8 +185,8 @@ class AEPEdgeDatastreamOverrideTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) // Validate URL let requestUrl = resultNetworkRequests[0].url @@ -235,8 +235,8 @@ class AEPEdgeDatastreamOverrideTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: experienceEvent) // verify - mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) // Valdiate URL let requestUrl = resultNetworkRequests[0].url diff --git a/Tests/FunctionalTests/EdgePathOverwriteTests.swift b/Tests/FunctionalTests/EdgePathOverwriteTests.swift index b58efdae..40a425d9 100644 --- a/Tests/FunctionalTests/EdgePathOverwriteTests.swift +++ b/Tests/FunctionalTests/EdgePathOverwriteTests.swift @@ -20,6 +20,7 @@ import XCTest /// End-to-end testing for the AEPEdge public APIs class AEPEdgePathOverwriteTests: TestBase, AnyCodableAsserts { + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC static let EDGE_MEDIA_PROD_PATH_STR = "/ee/va/v1/sessionstart" static let EDGE_MEDIA_PRE_PROD_PATH_STR = "/ee-pre-prd/va/v1/sessionstart" static let EDGE_MEDIA_INTEGRATION_PATH_STR = "/ee/va/v1/sessionstart" @@ -87,7 +88,7 @@ class AEPEdgePathOverwriteTests: TestBase, AnyCodableAsserts { // verify mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_MEDIA_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_MEDIA_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let requestUrl = resultNetworkRequests[0].url XCTAssertEqual(Self.EDGE_MEDIA_PROD_PATH_STR, requestUrl.path) @@ -163,7 +164,7 @@ class AEPEdgePathOverwriteTests: TestBase, AnyCodableAsserts { // verify mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_CONSENT_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_CONSENT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let requestUrl = resultNetworkRequests[0].url XCTAssertEqual(Self.EDGE_CONSENT_PATH_STR, requestUrl.path) @@ -184,7 +185,7 @@ class AEPEdgePathOverwriteTests: TestBase, AnyCodableAsserts { // verify mockNetworkService.assertAllNetworkRequestExpectations() - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_MEDIA_PROD_URL_STR, httpMethod: HttpMethod.post) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_MEDIA_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) let expectedJSON = "{}" assertTypeMatch( diff --git a/Tests/FunctionalTests/EdgeQueuedEntityFunctionalTests.swift b/Tests/FunctionalTests/EdgeQueuedEntityFunctionalTests.swift index 664f11d9..ee092206 100644 --- a/Tests/FunctionalTests/EdgeQueuedEntityFunctionalTests.swift +++ b/Tests/FunctionalTests/EdgeQueuedEntityFunctionalTests.swift @@ -19,8 +19,7 @@ import Foundation import XCTest class EdgeQueuedEntityFunctionalTests: TestBase, AnyCodableAsserts { - private let TIMEOUT_SEC: TimeInterval = 2 - private let LONGER_TIMEOUT_SEC: TimeInterval = 10 + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let exEdgeInteractProdUrl = URL(string: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)! // swiftlint:disable:this force_unwrapping private let mockNetworkService: MockNetworkService = MockNetworkService() @@ -69,8 +68,8 @@ class EdgeQueuedEntityFunctionalTests: TestBase, AnyCodableAsserts { startMobileSDK() // Wait for expected network requests - mockNetworkService.assertAllNetworkRequestExpectations(timeout: LONGER_TIMEOUT_SEC) - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) // Validate result - hit uses configId from Configuration shared state XCTAssertEqual(1, resultNetworkRequests.count) @@ -109,8 +108,8 @@ class EdgeQueuedEntityFunctionalTests: TestBase, AnyCodableAsserts { startMobileSDK() // Wait for expected network requests - mockNetworkService.assertAllNetworkRequestExpectations(timeout: LONGER_TIMEOUT_SEC) - let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) + let resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) // Validate result XCTAssertEqual(2, resultNetworkRequests.count) diff --git a/Tests/FunctionalTests/IdentityStateFunctionalTests.swift b/Tests/FunctionalTests/IdentityStateFunctionalTests.swift index f1f1e5af..c6a1285b 100644 --- a/Tests/FunctionalTests/IdentityStateFunctionalTests.swift +++ b/Tests/FunctionalTests/IdentityStateFunctionalTests.swift @@ -18,7 +18,7 @@ import XCTest /// Functional test suite for tests which require no Identity shared state at startup to simulate a missing or pending state. class IdentityStateFunctionalTests: TestBase, AnyCodableAsserts { - private let TIMEOUT_SEC: TimeInterval = 2 + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let exEdgeInteractUrl = URL(string: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR)! // swiftlint:disable:this force_unwrapping private let mockNetworkService: MockNetworkService = MockNetworkService() @@ -104,9 +104,9 @@ class IdentityStateFunctionalTests: TestBase, AnyCodableAsserts { } let identityMap = try? JSONSerialization.jsonObject(with: identityMapData, options: []) as? [String: Any] FakeIdentityExtension.setXDMSharedState(state: identityMap!) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) - requests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + requests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, requests.count) let expectedJSON = """ @@ -162,10 +162,10 @@ class IdentityStateFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: ExperienceEvent(xdm: ["test1": "xdm"], data: nil)) - mockNetworkService.assertAllNetworkRequestExpectations() + mockNetworkService.assertAllNetworkRequestExpectations(timeout: TIMEOUT_SEC) // Assert network request does not contain an ECID - let requests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + let requests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, requests.count) let expectedJSON = "{}" diff --git a/Tests/FunctionalTests/NoConfigFunctionalTests.swift b/Tests/FunctionalTests/NoConfigFunctionalTests.swift index 0eb10025..b4452e62 100644 --- a/Tests/FunctionalTests/NoConfigFunctionalTests.swift +++ b/Tests/FunctionalTests/NoConfigFunctionalTests.swift @@ -21,6 +21,7 @@ import XCTest class NoConfigFunctionalTests: TestBase, AnyCodableAsserts { private let TIMEOUT_SEC: TimeInterval = 1 private let SHORTER_TIMEOUT_SEC: TimeInterval = 0.2 + private let LONGER_TIMEOUT_SEC = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let mockNetworkService: MockNetworkService = MockNetworkService() override func setUp() { @@ -97,7 +98,7 @@ class NoConfigFunctionalTests: TestBase, AnyCodableAsserts { receivedHandles = handles expectation.fulfill() }) - var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + var resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: LONGER_TIMEOUT_SEC) XCTAssertEqual(0, resultNetworkRequests.count) // test event gets processed when config shared state is resolved\ @@ -108,7 +109,7 @@ class NoConfigFunctionalTests: TestBase, AnyCodableAsserts { mockNetworkService.assertAllNetworkRequestExpectations() wait(for: [expectation], timeout: SHORTER_TIMEOUT_SEC) - resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post) + resultNetworkRequests = mockNetworkService.getNetworkRequestsWith(url: TestConstants.EX_EDGE_INTERACT_PROD_URL_STR, httpMethod: HttpMethod.post, timeout: LONGER_TIMEOUT_SEC) XCTAssertEqual(2, receivedHandles.count) XCTAssertEqual("personalization:decisions", receivedHandles[0].type) XCTAssertEqual(1, receivedHandles[0].payload?.count) diff --git a/Tests/FunctionalTests/SampleFunctionalTests.swift b/Tests/FunctionalTests/SampleFunctionalTests.swift index 13170a02..38f3042a 100644 --- a/Tests/FunctionalTests/SampleFunctionalTests.swift +++ b/Tests/FunctionalTests/SampleFunctionalTests.swift @@ -20,6 +20,7 @@ import XCTest /// This Test class is an example of usages of the TestBase APIs class SampleFunctionalTests: TestBase, AnyCodableAsserts { + private let TIMEOUT_SEC: TimeInterval = FunctionalTestConstants.Defaults.TIMEOUT_SEC private let event1 = Event(name: "e1", type: "eventType", source: "eventSource", data: nil) private let event2 = Event(name: "e2", type: "eventType", source: "eventSource", data: nil) private let exEdgeInteractUrlString = "https://edge.adobedc.net/ee/v1/interact" @@ -139,7 +140,7 @@ class SampleFunctionalTests: TestBase, AnyCodableAsserts { Edge.sendEvent(experienceEvent: ExperienceEvent(xdm: ["eventType": "testType", "test": "xdm"], data: nil)) - let requests = mockNetworkService.getNetworkRequestsWith(url: exEdgeInteractUrlString, httpMethod: HttpMethod.post) + let requests = mockNetworkService.getNetworkRequestsWith(url: exEdgeInteractUrlString, httpMethod: HttpMethod.post, timeout: TIMEOUT_SEC) XCTAssertEqual(1, requests.count) diff --git a/Tests/FunctionalTests/util/FunctionalTestConstants.swift b/Tests/FunctionalTests/util/FunctionalTestConstants.swift new file mode 100644 index 00000000..43929b67 --- /dev/null +++ b/Tests/FunctionalTests/util/FunctionalTestConstants.swift @@ -0,0 +1,21 @@ +// +// Copyright 2024 Adobe. All rights reserved. +// This file is licensed to you under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy +// of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under +// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +// OF ANY KIND, either express or implied. See the License for the specific language +// governing permissions and limitations under the License. +// + + +import Foundation + +enum FunctionalTestConstants { + enum Defaults { + // Default timeout for assertions. Set to a high value to accommodate slower CI runners. + static let TIMEOUT_SEC: TimeInterval = 10 + } +}