Skip to content

Commit

Permalink
Merge pull request #168 from adobe/staging
Browse files Browse the repository at this point in the history
Staging -> Main [NON-RELEASE]
  • Loading branch information
timkimadobe authored Oct 14, 2024
2 parents d712e5b + f737601 commit a70fa2f
Show file tree
Hide file tree
Showing 54 changed files with 2,686 additions and 6,319 deletions.
140 changes: 104 additions & 36 deletions .github/workflows/upstream-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,53 @@
# Action to execute upstream integration tests - Edge Network (Konductor)
name: Integration Tests

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
# `*` is a special character in YAML so you have to quote this string
# Avoiding start of hour and other common times to avoid conflicts with peak times
schedule:
# Run every weekday at 12:45 PM PDT (Daylight saving time) -> 7:45 PM UTC
# Add +1 hour when back in PST
- cron: '45 19 * * 1-5'

workflow_dispatch:
inputs:
branch:
description: 'Branch to use when running integration tests'
description: 'The branch to use when running the integration tests'
required: false
default: 'main'
id:
description: 'Identifier for the run (optional)'
description: '(Optional) The identifier for the run.'
required: false
environment:
type: choice
description: 'Edge Network environment to test'
required: true
default: 'prod'
options:
- prod
- pre-prod
- int
tags-mobile-property-id:
type: string
description: '(Optional) The tags mobile property ID to use for the test. A default is used if not set.'
required: false
default: ''
edge-location-hint:
type: choice
description: 'Edge location hint to set before each test (optional)'
description: '(Optional) The Edge location hint to set before each test.'
required: false
default: ''
default: 'None'
options:
- '' # Interpreted in the test code as no preset location hint; any non-valid location hint string is interpreted this way
- 'or2'
- 'va6'
- 'irl1'
- 'ind1'
- 'jpn3'
- 'sgp3'
- 'aus3'
- 'EmptyString'
- 'Invalid'
- 'None'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test-integration-upstream:
# The type of runner that the job will run on
runs-on: macos-latest
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [29]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:

- name: Job run identifier ${{ github.event.inputs.id }}
run: |
if [ -z "${{ github.event.inputs.id }}" ]; then \
Expand All @@ -69,33 +68,102 @@ jobs:
echo 'Job run identifier is:' ${{ inputs.id }}
fi;
- name: Check branch mismatch
run: |
CURRENT_BRANCH=$(echo "${GITHUB_REF##*/}")
INPUT_BRANCH="${{ github.event.inputs.branch }}"
echo "Running on branch: ${CURRENT_BRANCH}"
echo "Input branch: ${INPUT_BRANCH}"
if [ "${CURRENT_BRANCH}" != "${INPUT_BRANCH}" ]; then
echo "::warning title=Branch Mismatch::Input branch '${INPUT_BRANCH}' does not match current branch '${CURRENT_BRANCH}'"
fi
# This is to help reduce Android emulator boot up flakiness issues:
# See: https://github.com/ReactiveCircus/android-emulator-runner/issues/324#issuecomment-2009351180
- name: Delete unnecessary tools 🔧
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
android: false # Don't remove Android tools
tool-cache: true # Remove image tool cache - rm -rf "$AGENT_TOOLSDIRECTORY"
dotnet: true # rm -rf /usr/share/dotnet
haskell: true # rm -rf /opt/ghc...
swap-storage: true # rm -f /mnt/swapfile (4GiB)
docker-images: false # Takes 16s, enable if needed in the future
large-packages: false # includes google-cloud-sdk and it's slow

# The Android emulator requires Kernel-based Virtual Machine (KVM) access to run efficiently.
# This step ensures that the KVM is accessible with the proper permissions across all users.
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
ls /dev/kvm
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4.2.0
with:
ref: ${{ github.event.inputs.branch }}

- name: Setup JAVA 11
uses: actions/setup-java@v3
- name: Set up Java
uses: actions/setup-java@v4.4.0
with:
distribution: 'temurin'
java-version: 11
distribution: 'zulu'
java-version: 17

- name: Gradle cache
uses: gradle/actions/[email protected]

- name: Cache Gradle packages
uses: actions/cache@v2
- name: AVD cache
uses: actions/[email protected]
id: avd-cache
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

# Note that the AVD configurations must match what's used in the test step, otherwise the cache will not be used.
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # v2.32.0
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
disk-size: 6000M
heap-size: 600M
force-avd-creation: false
emulator-options: -no-metrics -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: run tests
uses: reactivecircus/android-emulator-runner@v2
# Logcat logging from: https://github.com/ReactiveCircus/android-emulator-runner/issues/9#issuecomment-867909354
- name: Run tests
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # v2.32.0
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
disk-size: 6000M
heap-size: 600M
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-options: -no-metrics -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: make upstream-integration-test EDGE_ENVIRONMENT=${{ github.event.inputs.environment }} EDGE_LOCATION_HINT=${{ github.event.inputs.edge-location-hint }}

script: |
mkdir -p logs # Ensure the 'logs' directory exists
adb logcat -c # Clear logs
touch logs/emulator.log # Create log file
chmod 777 logs/emulator.log # Allow writing to log file
adb logcat >> logs/emulator.log & # Pipe all logcat messages into log file as a background process
make upstream-integration-test TAGS_MOBILE_PROPERTY_ID=${{ github.event.inputs.tags-mobile-property-id }} EDGE_LOCATION_HINT=${{ github.event.inputs.edge-location-hint }}
- name: Upload Logcat Logs
if: always()
uses: actions/[email protected]
with:
name: logcat-logs
path: logs/emulator.log

# Potential workflow solutions on job failure
- name: On failure
if: ${{ failure() }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ functional-test-coverage:

upstream-integration-test:
(./code/gradlew -p code/upstream-integration-tests uninstallDebugAndroidTest)
(./code/gradlew -p code/upstream-integration-tests connectedDebugAndroidTest -PEDGE_ENVIRONMENT=$(EDGE_ENVIRONMENT) -PEDGE_LOCATION_HINT=$(EDGE_LOCATION_HINT))
(./code/gradlew -p code/upstream-integration-tests connectedDebugAndroidTest -PTAGS_MOBILE_PROPERTY_IDD=$(TAGS_MOBILE_PROPERTY_ID) -PEDGE_LOCATION_HINT=$(EDGE_LOCATION_HINT))

javadoc:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) javadocJar)
Expand Down
3 changes: 2 additions & 1 deletion code/app-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ plugins {
}

val mavenCoreVersion: String by project
val mavenEdgeConsentVersion: String by project
val mavenEdgeIdentityVersion: String by project

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
Expand Down Expand Up @@ -77,7 +78,7 @@ dependencies {

implementation("com.adobe.marketing.mobile:core:$mavenCoreVersion")
implementation("com.adobe.marketing.mobile:edgeidentity:$mavenEdgeIdentityVersion")
implementation("com.adobe.marketing.mobile:edgeconsent:3.0.0-SNAPSHOT") {
implementation("com.adobe.marketing.mobile:edgeconsent:$mavenEdgeConsentVersion") {
exclude(group = "com.adobe.marketing.mobile", module = "edge")
}
implementation("com.adobe.marketing.mobile:assurance:3.0.0")
Expand Down
3 changes: 2 additions & 1 deletion code/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins {
}

val mavenCoreVersion: String by project
val mavenEdgeConsentVersion: String by project
val mavenEdgeIdentityVersion: String by project

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
Expand Down Expand Up @@ -74,7 +75,7 @@ dependencies {

implementation("com.adobe.marketing.mobile:core:$mavenCoreVersion")
implementation("com.adobe.marketing.mobile:edgeidentity:$mavenEdgeIdentityVersion")
implementation("com.adobe.marketing.mobile:edgeconsent:3.0.0-SNAPSHOT") {
implementation("com.adobe.marketing.mobile:edgeconsent:$mavenEdgeConsentVersion") {
exclude(group = "com.adobe.marketing.mobile", module = "edge")
}
implementation("com.adobe.marketing.mobile:assurance:3.0.0")
Expand Down
9 changes: 5 additions & 4 deletions code/edge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ plugins {
}

val mavenCoreVersion: String by project
val mavenEdgeConsentVersion: String by project
val mavenEdgeIdentityVersion: String by project
val mavenTestUtilsVersion: String by project

aepLibrary {
namespace = "com.adobe.marketing.mobile.edge"
Expand All @@ -34,11 +36,10 @@ dependencies {
implementation("com.adobe.marketing.mobile:core:$mavenCoreVersion")
implementation("com.adobe.marketing.mobile:edgeidentity:$mavenEdgeIdentityVersion")

testImplementation(project(":test-utils"))
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.12.7")
testImplementation("com.github.adobe:aepsdk-testutils-android:$mavenTestUtilsVersion")

androidTestImplementation(project(":test-utils"))
androidTestImplementation("com.adobe.marketing.mobile:edgeconsent:3.0.0-SNAPSHOT")
androidTestImplementation("com.github.adobe:aepsdk-testutils-android:$mavenTestUtilsVersion")
androidTestImplementation("com.adobe.marketing.mobile:edgeconsent:$mavenEdgeConsentVersion")
{
exclude(group = "com.adobe.marketing.mobile", module = "edge")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@
import com.adobe.marketing.mobile.services.HttpConnecting;
import com.adobe.marketing.mobile.services.ServiceProvider;
import com.adobe.marketing.mobile.services.TestableNetworkRequest;
import com.adobe.marketing.mobile.util.JSONAsserts;
import com.adobe.marketing.mobile.util.MockNetworkService;
import com.adobe.marketing.mobile.util.MonitorExtension;
import com.adobe.marketing.mobile.util.TestConstants;
import com.adobe.marketing.mobile.util.TestHelper;
import com.adobe.marketing.mobile.util.TestUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.After;
Expand Down Expand Up @@ -128,16 +127,26 @@ public void testSendEvent_withCompletionHandler_callsCompletionCorrectly() throw
assertEquals(1, resultNetworkRequests.size());
assertEquals(1, receivedHandles.size());

assertEquals("personalization:decisions", receivedHandles.get(0).getType());
assertEquals(1, receivedHandles.get(0).getPayload().size());

Map<String, String> data = TestUtils.flattenMap(receivedHandles.get(0).getPayload().get(0));

assertEquals(4, data.size());
assertEquals("AT:eyJhY3Rpdml0eUlkIjoiMTE3NTg4IiwiZXhwZXJpZW5jZUlkIjoiMSJ9", data.get("id"));
assertEquals("#D41DBA", data.get("items[0].data.content.value"));
assertEquals("https://ns.adobe.com/personalization/json-content-item", data.get("items[0].schema"));
assertEquals("buttonColor", data.get("scope"));
EdgeEventHandle edgeEventHandle = receivedHandles.get(0);
assertEquals("personalization:decisions", edgeEventHandle.getType());
assertEquals(1, edgeEventHandle.getPayload().size());

String expected =
"{" +
" \"id\": \"AT:eyJhY3Rpdml0eUlkIjoiMTE3NTg4IiwiZXhwZXJpZW5jZUlkIjoiMSJ9\"," +
" \"items\": [" +
" {" +
" \"data\": {" +
" \"content\": {" +
" \"value\": \"#D41DBA\"" +
" }" +
" }," +
" \"schema\": \"https://ns.adobe.com/personalization/json-content-item\"" +
" }" +
" ]," +
" \"scope\": \"buttonColor\"" +
"}";
JSONAsserts.assertEquals(expected, edgeEventHandle.getPayload().get(0));
}

@Test
Expand Down
Loading

0 comments on commit a70fa2f

Please sign in to comment.