From a7b38d464ec664f3ed61852c96c9e36602cb753d Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Thu, 17 Oct 2024 16:54:21 +0200 Subject: [PATCH 01/28] Add New UI Tests App for critical tests --- build.gradle.kts | 3 +- .../sentry-uitest-android-critical/.gitignore | 2 + .../build.gradle.kts | 58 +++++++++++++++++++ .../maestro/corruptEnvelope.yaml | 11 ++++ .../maestro/crash.yaml | 6 ++ .../src/main/AndroidManifest.xml | 21 +++++++ .../uitest/android/critical/MainActivity.kt | 51 ++++++++++++++++ settings.gradle.kts | 1 + 8 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/.gitignore create mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts create mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/maestro/corruptEnvelope.yaml create mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/maestro/crash.yaml create mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml create mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/src/main/java/io/sentry/uitest/android/critical/MainActivity.kt diff --git a/build.gradle.kts b/build.gradle.kts index 7985a55486e..60045e073f7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -70,7 +70,8 @@ apiValidation { "sentry-uitest-android-benchmark", "test-app-plain", "test-app-sentry", - "sentry-samples-netflix-dgs" + "sentry-samples-netflix-dgs", + "sentry-uitest-android-critical" ) ) } diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/.gitignore b/sentry-android-integration-tests/sentry-uitest-android-critical/.gitignore new file mode 100644 index 00000000000..48fc28dcf58 --- /dev/null +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/.gitignore @@ -0,0 +1,2 @@ +/build +/maestro-logs diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts new file mode 100644 index 00000000000..48e57835e39 --- /dev/null +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts @@ -0,0 +1,58 @@ +import io.gitlab.arturbosch.detekt.Detekt + +plugins { + id("com.android.application") + kotlin("android") +} + +android { + compileSdk = Config.Android.compileSdkVersion + namespace = "io.sentry.uitest.android.critical" + + defaultConfig { + applicationId = "io.sentry.uitest.android.critical" + minSdk = 21 + targetSdk = Config.Android.targetSdkVersion + versionCode = 1 + versionName = "1.0" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = Config.androidComposeCompilerVersion + } +} + +dependencies { + implementation(kotlin(Config.kotlinStdLib, org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION)) + implementation(Config.Libs.androidxCore) + implementation(Config.Libs.composeActivity) + implementation(Config.Libs.composeFoundation) + implementation(Config.Libs.composeMaterial) + implementation(Config.Libs.constraintLayout) + implementation(projects.sentryAndroidCore) +} + +tasks.withType { + // Target version of the generated JVM bytecode. It is used for type resolution. + jvmTarget = JavaVersion.VERSION_1_8.toString() +} + +kotlin { + explicitApi() +} + diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/maestro/corruptEnvelope.yaml b/sentry-android-integration-tests/sentry-uitest-android-critical/maestro/corruptEnvelope.yaml new file mode 100644 index 00000000000..dec889731b9 --- /dev/null +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/maestro/corruptEnvelope.yaml @@ -0,0 +1,11 @@ +appId: io.sentry.uitest.android.critical +--- +- launchApp +- tapOn: "Write Corrupted Envelope" +# The close here ensures the next corrupted envelope +# will be present on the next app launch +- tapOn: "Close SDK" +- tapOn: "Write Corrupted Envelope" +- stopApp +- launchApp +- assertVisible: "Welcome!" diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/maestro/crash.yaml b/sentry-android-integration-tests/sentry-uitest-android-critical/maestro/crash.yaml new file mode 100644 index 00000000000..f9543f365cd --- /dev/null +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/maestro/crash.yaml @@ -0,0 +1,6 @@ +appId: io.sentry.uitest.android.critical +--- +- launchApp +- tapOn: "Crash" +- launchApp +- assertVisible: "Welcome!" diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml b/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..0ab5e6052df --- /dev/null +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/java/io/sentry/uitest/android/critical/MainActivity.kt b/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/java/io/sentry/uitest/android/critical/MainActivity.kt new file mode 100644 index 00000000000..8802f3dca27 --- /dev/null +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/java/io/sentry/uitest/android/critical/MainActivity.kt @@ -0,0 +1,51 @@ +package io.sentry.uitest.android.critical + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.Column +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import io.sentry.Sentry +import java.io.File + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val outboxPath = Sentry.getCurrentHub().options.outboxPath + ?: throw RuntimeException("Outbox path is not set.") + + setContent { + MaterialTheme { + Surface() { + Column() { + Text(text = "Welcome!") + Button(onClick = { + throw RuntimeException("Crash the test app.") + }) { + Text("Crash") + } + Button(onClick = { + Sentry.close() + }) { + Text("Close SDK") + } + Button(onClick = { + val file = File(outboxPath, "corrupted.envelope") + val corruptedEnvelopeContent = """ + {"event_id":"1990b5bc31904b7395fd07feb72daf1c","sdk":{"name":"sentry.java.android","version":"7.21.0"}} + {"type":"test","length":50} + """.trimIndent() + file.writeText(corruptedEnvelopeContent) + println("Wrote corrupted envelope to: ${file.absolutePath}") + }) { + Text("Write Corrupted Envelope") + } + } + } + } + } + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 760c6e69054..77b3be021da 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -61,6 +61,7 @@ include( "sentry-samples:sentry-samples-spring-boot-webflux", "sentry-samples:sentry-samples-spring-boot-webflux-jakarta", "sentry-samples:sentry-samples-netflix-dgs", + "sentry-android-integration-tests:sentry-uitest-android-critical", "sentry-android-integration-tests:sentry-uitest-android-benchmark", "sentry-android-integration-tests:sentry-uitest-android", "sentry-android-integration-tests:test-app-plain", From 855903a67c6d6108e71b9d19fd5640774fc178eb Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Thu, 17 Oct 2024 15:03:25 +0000 Subject: [PATCH 02/28] Format code --- .../sentry-uitest-android-critical/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts index 48e57835e39..43644e09e9c 100644 --- a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts @@ -55,4 +55,3 @@ tasks.withType { kotlin { explicitApi() } - From 835d432046122143af70d1e2417a05aafdfaea6f Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Thu, 17 Oct 2024 17:03:49 +0200 Subject: [PATCH 03/28] Return proguard rules file --- .../proguard-rules.pro | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/proguard-rules.pro diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/proguard-rules.pro b/sentry-android-integration-tests/sentry-uitest-android-critical/proguard-rules.pro new file mode 100644 index 00000000000..f1b424510da --- /dev/null +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile From 339a8d7e84a0d693f24672b47bdff8758b728853 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 16:23:04 +0200 Subject: [PATCH 04/28] Add CI build and test jobs --- .../integration-tests-ui-critical.yml | 89 +++++++++++++++++++ Makefile | 8 ++ scripts/test-ui-critical.sh | 35 ++++++++ .../build.gradle.kts | 7 ++ 4 files changed, 139 insertions(+) create mode 100644 .github/workflows/integration-tests-ui-critical.yml create mode 100755 scripts/test-ui-critical.sh diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml new file mode 100644 index 00000000000..570a666fe81 --- /dev/null +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -0,0 +1,89 @@ +name: UI Tests Critical + +on: + push: + branches: + - main + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + BASE_PATH: "sentry-android-integration-tests/sentry-uitest-android-critical" + BUILD_PATH: "build/outputs/apk/release" + APK_NAME: "sentry-uitest-android-critical-release.apk" + APK_ARTIFACT_NAME: "sentry-uitest-android-critical-release" + +jobs: + build: + name: Build sentry-uitest-android-critical + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@bb0c460cbf5354b0cddd15bacdf0d6aaa3e5a32b # pin@v3 + with: + gradle-home-cache-cleanup: true + + - name: Build debug APK + run: make assembleUiTestCriticalRelease + + - name: Upload APK artifact + uses: actions/upload-artifact@v4 + with: + name: ${{env.APK_ARTIFACT_NAME}} + path: "${{env.BASE_PATH}}/${{env.BUILD_PATH}}/${{env.APK_NAME}}" + retention-days: 1 + + run-maestro-tests: + name: Run Maestro Tests + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup KVM + shell: bash + run: | + # check if virtualization is supported... + sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok + # allow access to KVM to run the emulator + 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 + + - name: Download APK artifact + uses: actions/download-artifact@v4 + with: + name: ${{env.APK_ARTIFACT_NAME}} + + - name: Install Maestro + run: | + brew tap mobile-dev-inc/tap + brew install maestro + + - name: Run Maestro tests + run: | + maestro test \ + "${{env.BASE_PATH}}/maestro" \ + --debug-output "${{env.BASE_PATH}}/maestro-logs" + + - name: Upload Maestro test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: maestro-logs + path: "${{env.BASE_PATH}}/maestro-logs" + retention-days: 1 diff --git a/Makefile b/Makefile index 2117e6da215..14eefb5b4d8 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,14 @@ assembleUiTestRelease: ./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleRelease ./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleAndroidTest -DtestBuildType=release +# Assemble release of the uitest-android-critical module +assembleUiTestCriticalRelease: + ./gradlew :sentry-android-integration-tests:sentry-uitest-android-critical:assembleRelease + +# Run Maestro tests for the uitest-android-critical module +runUiTestCritical: + ./scripts/test-ui-critical.sh + # Create coverage reports # - Jacoco for Java & Android modules # - Kover for KMP modules e.g sentry-compose diff --git a/scripts/test-ui-critical.sh b/scripts/test-ui-critical.sh new file mode 100755 index 00000000000..7bb36eebec7 --- /dev/null +++ b/scripts/test-ui-critical.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -e + +echo "Checking if ADB is installed..." +if ! command -v adb &> /dev/null; then + echo "ADB is not installed or not in PATH. Please install Android SDK platform tools and ensure ADB is in your PATH." + exit 1 +fi + +echo "Checking if an Android emulator is running..." +if ! adb devices | grep -q "emulator"; then + echo "No Android emulator is currently running. Please start an emulator before running this script." + exit 1 +fi + +echo "Checking if Maestro is installed..." +if ! command -v maestro &> /dev/null; then + echo "Maestro is not installed. Please install Maestro before running this script." + exit 1 +fi + +echo "Building the UI Test Critical app..." +make assembleUiTestCriticalRelease + +echo "Installing the UI Test Critical app on the emulator..." +baseDir="sentry-android-integration-tests/sentry-uitest-android-critical" +buildDir="build/outputs/apk/release" +apkName="sentry-uitest-android-critical-release.apk" +appPath="${baseDir}/${buildDir}/${apkName}" +adb install -r -d "$appPath" + +echo "Running the Maestro tests..." +maestro test \ + "${baseDir}/maestro" \ + --debug-output "${baseDir}/maestro-logs" diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts index 48e57835e39..90b9e20ea40 100644 --- a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts @@ -9,6 +9,12 @@ android { compileSdk = Config.Android.compileSdkVersion namespace = "io.sentry.uitest.android.critical" + signingConfigs { + getByName("debug") { + // Debug config remains unchanged + } + } + defaultConfig { applicationId = "io.sentry.uitest.android.critical" minSdk = 21 @@ -20,6 +26,7 @@ android { buildTypes { release { isMinifyEnabled = false + signingConfig = signingConfigs.getByName("debug") proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" From 26ff65e344d36ac49bfdc0f22e77de748d23ee03 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 17:04:54 +0200 Subject: [PATCH 05/28] Fix maestro install and emulator boot --- .../integration-tests-ui-critical.yml | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 570a666fe81..29b8c1d1bb1 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -15,6 +15,7 @@ env: BUILD_PATH: "build/outputs/apk/release" APK_NAME: "sentry-uitest-android-critical-release.apk" APK_ARTIFACT_NAME: "sentry-uitest-android-critical-release" + MAESTRO_VERSION: "1.39.0" jobs: build: @@ -70,15 +71,30 @@ jobs: name: ${{env.APK_ARTIFACT_NAME}} - name: Install Maestro - run: | - brew tap mobile-dev-inc/tap - brew install maestro + run: curl -Ls "https://get.maestro.mobile.dev" | bash - - name: Run Maestro tests - run: | - maestro test \ - "${{env.BASE_PATH}}/maestro" \ - --debug-output "${{env.BASE_PATH}}/maestro-logs" + - name: Run tests + uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # pin@v2.32.0 + with: + api-level: 30 + force-avd-creation: false + disable-animations: true + disable-spellchecker: true + target: 'aosp_atd' + channel: canary # Necessary for ATDs + emulator-options: > + -no-window + -no-snapshot-save + -gpu swiftshader_indirect + -noaudio + -no-boot-anim + -camera-back none + -camera-front none + -timezone US/Pacific + script: | + maestro test \ + "${{env.BASE_PATH}}/maestro" \ + --debug-output "${{env.BASE_PATH}}/maestro-logs" - name: Upload Maestro test results if: failure() From d675e3f18909f617b87eab54e32e51c488aae3d7 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 17:08:42 +0200 Subject: [PATCH 06/28] Fix apk install --- .github/workflows/integration-tests-ui-critical.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 29b8c1d1bb1..8edaf8db089 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -69,6 +69,7 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{env.APK_ARTIFACT_NAME}} + path: ${{env.APK_NAME}} - name: Install Maestro run: curl -Ls "https://get.maestro.mobile.dev" | bash @@ -92,6 +93,7 @@ jobs: -camera-front none -timezone US/Pacific script: | + adb install -r -d "${{env.APK_NAME}}" maestro test \ "${{env.BASE_PATH}}/maestro" \ --debug-output "${{env.BASE_PATH}}/maestro-logs" From 80496126c309ee9fd0f37d00ce2279e50d6832f6 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 17:25:13 +0200 Subject: [PATCH 07/28] fix apk name when testing --- .github/workflows/integration-tests-ui-critical.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 8edaf8db089..4c3489eae98 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -69,7 +69,6 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{env.APK_ARTIFACT_NAME}} - path: ${{env.APK_NAME}} - name: Install Maestro run: curl -Ls "https://get.maestro.mobile.dev" | bash From 304f261f9f8714466cd80618bc6cc864e70b18d2 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 17:51:19 +0200 Subject: [PATCH 08/28] use maestro action --- .github/workflows/integration-tests-ui-critical.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 4c3489eae98..c705e3835c9 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -71,7 +71,9 @@ jobs: name: ${{env.APK_ARTIFACT_NAME}} - name: Install Maestro - run: curl -Ls "https://get.maestro.mobile.dev" | bash + uses: maestro-mobile/setup-maestro@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # pin@v1.0.0 + with: + maestro-version: ${{env.MAESTRO_VERSION}} - name: Run tests uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # pin@v2.32.0 From 069f17dae0ef5847aa6c7d9e21440a611eda79c2 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 17:56:11 +0200 Subject: [PATCH 09/28] fix the action name --- .github/workflows/integration-tests-ui-critical.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index c705e3835c9..cfad55c5c82 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -71,7 +71,7 @@ jobs: name: ${{env.APK_ARTIFACT_NAME}} - name: Install Maestro - uses: maestro-mobile/setup-maestro@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # pin@v1.0.0 + uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # pin@v1.0.0 with: maestro-version: ${{env.MAESTRO_VERSION}} From 7fc41c171be3b0b6fae8ed120ffe1daf3b6b31d4 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 18:07:08 +0200 Subject: [PATCH 10/28] fix path --- .github/workflows/integration-tests-ui-critical.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index cfad55c5c82..1db9c722068 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -95,9 +95,7 @@ jobs: -timezone US/Pacific script: | adb install -r -d "${{env.APK_NAME}}" - maestro test \ - "${{env.BASE_PATH}}/maestro" \ - --debug-output "${{env.BASE_PATH}}/maestro-logs" + maestro test "${{env.BASE_PATH}}/maestro" --debug-output "${{env.BASE_PATH}}/maestro-logs" - name: Upload Maestro test results if: failure() From eab8424094eb415507c6ee60e613597749f4bb21 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 18:35:09 +0200 Subject: [PATCH 11/28] Fix java and server tests --- .github/workflows/system-tests-backend.yml | 2 +- .../sentry-uitest-android-critical/build.gradle.kts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/system-tests-backend.yml b/.github/workflows/system-tests-backend.yml index 0098644d971..a5f1f598c71 100644 --- a/.github/workflows/system-tests-backend.yml +++ b/.github/workflows/system-tests-backend.yml @@ -46,7 +46,7 @@ jobs: - name: Exclude android modules from build run: | - sed -i -e '/.*"sentry-android-ndk",/d' -e '/.*"sentry-android",/d' -e '/.*"sentry-compose",/d' -e '/.*"sentry-android-core",/d' -e '/.*"sentry-android-fragment",/d' -e '/.*"sentry-android-navigation",/d' -e '/.*"sentry-android-okhttp",/d' -e '/.*"sentry-android-sqlite",/d' -e '/.*"sentry-android-timber",/d' -e '/.*"sentry-android-integration-tests:sentry-uitest-android-benchmark",/d' -e '/.*"sentry-android-integration-tests:sentry-uitest-android",/d' -e '/.*"sentry-android-integration-tests:test-app-sentry",/d' -e '/.*"sentry-samples:sentry-samples-android",/d' -e '/.*"sentry-android-replay",/d' settings.gradle.kts + sed -i -e '/.*"sentry-android-ndk",/d' -e '/.*"sentry-android",/d' -e '/.*"sentry-compose",/d' -e '/.*"sentry-android-core",/d' -e '/.*"sentry-android-fragment",/d' -e '/.*"sentry-android-navigation",/d' -e '/.*"sentry-android-okhttp",/d' -e '/.*"sentry-android-sqlite",/d' -e '/.*"sentry-android-timber",/d' -e '/.*"sentry-android-integration-tests:sentry-uitest-android-benchmark",/d' -e '/.*"sentry-android-integration-tests:sentry-uitest-android",/d' -e '/.*"sentry-android-integration-tests:sentry-uitest-android-critical",/d' -e '/.*"sentry-android-integration-tests:test-app-sentry",/d' -e '/.*"sentry-samples:sentry-samples-android",/d' -e '/.*"sentry-android-replay",/d' settings.gradle.kts - name: Exclude android modules from ignore list run: | diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts index 228da6f467e..4cfa02bb660 100644 --- a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts @@ -42,6 +42,11 @@ android { composeOptions { kotlinCompilerExtensionVersion = Config.androidComposeCompilerVersion } + variantFilter { + if (Config.Android.shouldSkipDebugVariant(buildType.name)) { + ignore = true + } + } } dependencies { From bba38d6e095b76e35aa232454ab2d10a833401be Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 18:49:11 +0200 Subject: [PATCH 12/28] ref and fix server build --- .github/workflows/system-tests-backend.yml | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/system-tests-backend.yml b/.github/workflows/system-tests-backend.yml index a5f1f598c71..2222f910adb 100644 --- a/.github/workflows/system-tests-backend.yml +++ b/.github/workflows/system-tests-backend.yml @@ -46,11 +46,33 @@ jobs: - name: Exclude android modules from build run: | - sed -i -e '/.*"sentry-android-ndk",/d' -e '/.*"sentry-android",/d' -e '/.*"sentry-compose",/d' -e '/.*"sentry-android-core",/d' -e '/.*"sentry-android-fragment",/d' -e '/.*"sentry-android-navigation",/d' -e '/.*"sentry-android-okhttp",/d' -e '/.*"sentry-android-sqlite",/d' -e '/.*"sentry-android-timber",/d' -e '/.*"sentry-android-integration-tests:sentry-uitest-android-benchmark",/d' -e '/.*"sentry-android-integration-tests:sentry-uitest-android",/d' -e '/.*"sentry-android-integration-tests:sentry-uitest-android-critical",/d' -e '/.*"sentry-android-integration-tests:test-app-sentry",/d' -e '/.*"sentry-samples:sentry-samples-android",/d' -e '/.*"sentry-android-replay",/d' settings.gradle.kts + sed -i \ + -e '/.*"sentry-android-ndk",/d' \ + -e '/.*"sentry-android",/d' \ + -e '/.*"sentry-compose",/d' \ + -e '/.*"sentry-android-core",/d' \ + -e '/.*"sentry-android-fragment",/d' \ + -e '/.*"sentry-android-navigation",/d' \ + -e '/.*"sentry-android-okhttp",/d' \ + -e '/.*"sentry-android-sqlite",/d' \ + -e '/.*"sentry-android-timber",/d' \ + -e '/.*"sentry-android-integration-tests:sentry-uitest-android-benchmark",/d' \ + -e '/.*"sentry-android-integration-tests:sentry-uitest-android",/d' \ + -e '/.*"sentry-android-integration-tests:sentry-uitest-android-critical",/d' \ + -e '/.*"sentry-android-integration-tests:test-app-sentry",/d' \ + -e '/.*"sentry-samples:sentry-samples-android",/d' \ + -e '/.*"sentry-android-replay",/d' \ + settings.gradle.kts - name: Exclude android modules from ignore list run: | - sed -i -e '/.*"sentry-uitest-android",/d' -e '/.*"sentry-uitest-android-benchmark",/d' -e '/.*"test-app-sentry",/d' -e '/.*"sentry-samples-android",/d' build.gradle.kts + sed -i \ + -e '/.*"sentry-uitest-android",/d' \ + -e '/.*"sentry-uitest-android-benchmark",/d' \ + -e '/.*"sentry-uitest-android-critical",/d' \ + -e '/.*"test-app-sentry",/d' \ + -e '/.*"sentry-samples-android",/d' \ + build.gradle.kts - name: Build server jar run: | @@ -58,7 +80,12 @@ jobs: - name: Start server and run integration test for sentry-cli commands run: | - test/system-test-sentry-server-start.sh > sentry-mock-server.txt 2>&1 & test/system-test-spring-server-start.sh "${{ matrix.sample }}" > spring-server.txt 2>&1 & test/wait-for-spring.sh && ./gradlew :sentry-samples:${{ matrix.sample }}:systemTest + test/system-test-sentry-server-start.sh \ + > sentry-mock-server.txt 2>&1 & \ + test/system-test-spring-server-start.sh "${{ matrix.sample }}" \ + > spring-server.txt 2>&1 & \ + test/wait-for-spring.sh && \ + ./gradlew :sentry-samples:${{ matrix.sample }}:systemTest - name: Upload test results if: always() From 32c0ab6449e2d48e8c3420de1e815e1d0b1d7441 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 18 Oct 2024 18:54:00 +0200 Subject: [PATCH 13/28] fix maybe --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 60045e073f7..9d532525628 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -68,10 +68,10 @@ apiValidation { "sentry-samples-spring-boot-webflux-jakarta", "sentry-uitest-android", "sentry-uitest-android-benchmark", + "sentry-uitest-android-critical", "test-app-plain", "test-app-sentry", - "sentry-samples-netflix-dgs", - "sentry-uitest-android-critical" + "sentry-samples-netflix-dgs" ) ) } From 9cbfacf9a172fc571a1326d6472284455613cc9d Mon Sep 17 00:00:00 2001 From: Stefano Date: Mon, 21 Oct 2024 12:50:13 +0200 Subject: [PATCH 14/28] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 14eefb5b4d8..62e6e258f32 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease createCoverageReports check preMerge publish +.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease assembleUiTestCriticalRelease createCoverageReports runUiTestCritical check preMerge publish all: stop clean javadocs compile createCoverageReports assembleBenchmarks: assembleBenchmarkTestRelease From 88c7396a8378188b404654f979748bcdb7805d5e Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:46:12 +0200 Subject: [PATCH 15/28] Update sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts Co-authored-by: Stefano --- .../sentry-uitest-android-critical/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts index 4cfa02bb660..cebf744a24d 100644 --- a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts @@ -17,7 +17,7 @@ android { defaultConfig { applicationId = "io.sentry.uitest.android.critical" - minSdk = 21 + minSdk = Config.Android.minSdkVersionCompose targetSdk = Config.Android.targetSdkVersion versionCode = 1 versionName = "1.0" From 76a5effe2a4526b504e01d77e16848681daecf66 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 21 Oct 2024 14:24:14 +0200 Subject: [PATCH 16/28] test(critical): Add API Level matrix --- .../workflows/integration-tests-ui-critical.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 1db9c722068..3efe95198d2 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -19,7 +19,7 @@ env: jobs: build: - name: Build sentry-uitest-android-critical + name: Build runs-on: ubuntu-latest steps: - name: Checkout code @@ -47,9 +47,20 @@ jobs: retention-days: 1 run-maestro-tests: - name: Run Maestro Tests + name: Run Tests for API Level ${{ matrix.api-level }} needs: build runs-on: ubuntu-latest + strategy: + # we want that the matrix keeps running, default is to cancel them if it fails. + fail-fast: false + matrix: + api-level: [ + 29, # Android 10 + 30, # Android 11 + 31, # Android 12 + 33, # Android 13 + 34, # Android 14 + ] steps: - name: Checkout code uses: actions/checkout@v4 @@ -78,7 +89,7 @@ jobs: - name: Run tests uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # pin@v2.32.0 with: - api-level: 30 + api-level: ${{ matrix.api-level }} force-avd-creation: false disable-animations: true disable-spellchecker: true From 88f290b43394a48816f2f60c49a97ddc17bbeb24 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 21 Oct 2024 14:53:06 +0200 Subject: [PATCH 17/28] fix maestro version --- .github/workflows/integration-tests-ui-critical.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 1db9c722068..6729e40ca5e 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -73,7 +73,7 @@ jobs: - name: Install Maestro uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # pin@v1.0.0 with: - maestro-version: ${{env.MAESTRO_VERSION}} + version: ${{env.MAESTRO_VERSION}} - name: Run tests uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # pin@v2.32.0 From 229409c1fde6b6a4714f38fc07f9f67651a09f46 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 21 Oct 2024 14:58:58 +0200 Subject: [PATCH 18/28] Fix atd only runs on api level 30 --- .../integration-tests-ui-critical.yml | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 5464db888c6..f71f1176c5a 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -54,13 +54,22 @@ jobs: # we want that the matrix keeps running, default is to cancel them if it fails. fail-fast: false matrix: - api-level: [ - 29, # Android 10 - 30, # Android 11 - 31, # Android 12 - 33, # Android 13 - 34, # Android 14 - ] + include: + - api-level: 29 # Android 10 + target: default + channel: stable + - api-level: 30 # Android 11 + target: aosp_atd + channel: canary # Necessary for ATDs + - api-level: 31 # Android 12 + target: default + channel: stable + - api-level: 33 # Android 13 + target: default + channel: stable + - api-level: 34 # Android 14 + target: default + channel: stable steps: - name: Checkout code uses: actions/checkout@v4 @@ -93,8 +102,8 @@ jobs: force-avd-creation: false disable-animations: true disable-spellchecker: true - target: 'aosp_atd' - channel: canary # Necessary for ATDs + target: ${{ matrix.target }} + channel: ${{ matrix.channel }} emulator-options: > -no-window -no-snapshot-save From 85326e8c041d81a6c7b257b1385425a4782ad2e9 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 21 Oct 2024 15:26:48 +0200 Subject: [PATCH 19/28] update 31 and newer runners --- .github/workflows/integration-tests-ui-critical.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index f71f1176c5a..83c82942d23 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -62,13 +62,13 @@ jobs: target: aosp_atd channel: canary # Necessary for ATDs - api-level: 31 # Android 12 - target: default + target: google_apis channel: stable - api-level: 33 # Android 13 - target: default + target: google_apis channel: stable - api-level: 34 # Android 14 - target: default + target: google_apis channel: stable steps: - name: Checkout code From c332e7d66d04743ae4dcceef5dedc782c299bae6 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 21 Oct 2024 15:49:05 +0200 Subject: [PATCH 20/28] tmp: list available images --- .github/workflows/integration-tests-ui-critical.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 83c82942d23..a3a9c154fd2 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -22,6 +22,9 @@ jobs: name: Build runs-on: ubuntu-latest steps: + - name: List available system images + run: sdkmanager --list + - name: Checkout code uses: actions/checkout@v4 From 1e560ea3d1bb4ca55e2328de403d5df1c729754b Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 21 Oct 2024 15:51:03 +0200 Subject: [PATCH 21/28] tmp: fix path --- .github/workflows/integration-tests-ui-critical.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index a3a9c154fd2..5d59e466ee4 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: List available system images - run: sdkmanager --list + run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --list - name: Checkout code uses: actions/checkout@v4 From d4b00cb7a481ed3cf4a0936e7659a9fda18fd28c Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 21 Oct 2024 15:59:59 +0200 Subject: [PATCH 22/28] change default arch for 31 and higher --- .../integration-tests-ui-critical.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 5d59e466ee4..ee2463c6a1c 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -61,18 +61,23 @@ jobs: - api-level: 29 # Android 10 target: default channel: stable + arch: x86 - api-level: 30 # Android 11 target: aosp_atd channel: canary # Necessary for ATDs + arch: x86 - api-level: 31 # Android 12 - target: google_apis - channel: stable + target: aosp_atd + channel: canary # Necessary for ATDs + arch: x86_64 - api-level: 33 # Android 13 - target: google_apis - channel: stable + target: aosp_atd + channel: canary # Necessary for ATDs + arch: x86_64 - api-level: 34 # Android 14 - target: google_apis - channel: stable + target: aosp_atd + channel: canary # Necessary for ATDs + arch: x86_64 steps: - name: Checkout code uses: actions/checkout@v4 @@ -107,6 +112,7 @@ jobs: disable-spellchecker: true target: ${{ matrix.target }} channel: ${{ matrix.channel }} + arch: ${{ matrix.arch }} emulator-options: > -no-window -no-snapshot-save From 0cf0a0cece2bdc869c05139b1b14ee542e40105f Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Mon, 21 Oct 2024 16:00:17 +0200 Subject: [PATCH 23/28] tmp: remove images list --- .github/workflows/integration-tests-ui-critical.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index ee2463c6a1c..b34bfd01bea 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -22,9 +22,6 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - name: List available system images - run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --list - - name: Checkout code uses: actions/checkout@v4 From a99c02f3834f2948077823b9e3f693c992417efb Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 22 Oct 2024 11:44:21 +0200 Subject: [PATCH 24/28] remove api level 29, the test would succeed but the runner timeout on killing the emulator --- .github/workflows/integration-tests-ui-critical.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index b34bfd01bea..b0ef7bea70d 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -55,14 +55,10 @@ jobs: fail-fast: false matrix: include: - - api-level: 29 # Android 10 - target: default - channel: stable - arch: x86 - api-level: 30 # Android 11 target: aosp_atd channel: canary # Necessary for ATDs - arch: x86 + arch: x86_64 - api-level: 31 # Android 12 target: aosp_atd channel: canary # Necessary for ATDs From 837a64f47e3bd43a22118a07c50ad4a997632543 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 22 Oct 2024 14:46:40 +0200 Subject: [PATCH 25/28] test(critical): Add Mock Relay to verify crash envelope --- .../integration-tests-ui-critical.yml | 33 ++++++- .github/workflows/system-tests-backend.yml | 2 + Makefile | 6 +- build.gradle.kts | 1 + buildSrc/src/main/java/Config.kt | 4 + scripts/test-ui-critical.sh | 20 +++++ .../sentry-mock-relay/.gitignore | 36 ++++++++ .../sentry-mock-relay/build.gradle.kts | 28 ++++++ .../src/main/kotlin/io/sentry/Application.kt | 89 +++++++++++++++++++ .../src/main/resources/application.yaml | 6 ++ .../src/main/resources/logback.xml | 12 +++ .../build.gradle.kts | 2 + .../src/main/AndroidManifest.xml | 6 +- .../src/main/res/xml/network.xml | 8 ++ settings.gradle.kts | 1 + 15 files changed, 250 insertions(+), 4 deletions(-) create mode 100644 sentry-android-integration-tests/sentry-mock-relay/.gitignore create mode 100644 sentry-android-integration-tests/sentry-mock-relay/build.gradle.kts create mode 100644 sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt create mode 100644 sentry-android-integration-tests/sentry-mock-relay/src/main/resources/application.yaml create mode 100644 sentry-android-integration-tests/sentry-mock-relay/src/main/resources/logback.xml create mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/src/main/res/xml/network.xml diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index b0ef7bea70d..9c5eeb0cc46 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -11,11 +11,14 @@ concurrency: cancel-in-progress: true env: - BASE_PATH: "sentry-android-integration-tests/sentry-uitest-android-critical" + INTEGRATION_TESTS_PATH: "sentry-android-integration-tests" + BASE_PATH: "${{env.INTEGRATION_TESTS_PATH}}/sentry-uitest-android-critical" BUILD_PATH: "build/outputs/apk/release" APK_NAME: "sentry-uitest-android-critical-release.apk" APK_ARTIFACT_NAME: "sentry-uitest-android-critical-release" MAESTRO_VERSION: "1.39.0" + MOCK_RELAY_ARTIFACT_NAME: "sentry-mock-relay" + MOCK_RELAY_PATH: "sentry-mock-relay-0.0.1.zip" jobs: build: @@ -36,6 +39,16 @@ jobs: with: gradle-home-cache-cleanup: true + - name: Build mock relay + run: make buildMockRelay + + - name: Upload Mock Relay + uses: actions/upload-artifact@v4 + with: + name: ${{env.MOCK_RELAY_ARTIFACT_NAME}} + path: "${{env.INTEGRATION_TESTS_PATH}}/sentry-mock-relay/build/distributions/${{env.MOCK_RELAY_PATH}}" + retention-days: 1 + - name: Build debug APK run: make assembleUiTestCriticalRelease @@ -91,6 +104,14 @@ jobs: with: name: ${{env.APK_ARTIFACT_NAME}} + - name: Download Mock Relay + uses: actions/download-artifact@v4 + with: + name: ${{env.MOCK_RELAY_ARTIFACT_NAME}} + + - name: Unzip Mock Relay + run: unzip -o ${{env.MOCK_RELAY_PATH}} + - name: Install Maestro uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # pin@v1.0.0 with: @@ -117,7 +138,17 @@ jobs: -timezone US/Pacific script: | adb install -r -d "${{env.APK_NAME}}" + ./sentry-mock-relay-0.0.1/bin/sentry-mock-relay > /dev/null & MOCK_RELAY_PID=$! + + set +e maestro test "${{env.BASE_PATH}}/maestro" --debug-output "${{env.BASE_PATH}}/maestro-logs" + MAESTRO_EXIT_CODE=$? + + curl --fail http://localhost:8961/assertReceivedAtLeastOneCrashReport + MOCK_RELAY_EXIT_CODE=$? + + kill $MOCK_RELAY_PID + exit $(($MAESTRO_EXIT_CODE || $MOCK_RELAY_EXIT_CODE)) - name: Upload Maestro test results if: failure() diff --git a/.github/workflows/system-tests-backend.yml b/.github/workflows/system-tests-backend.yml index 2222f910adb..7482b216bae 100644 --- a/.github/workflows/system-tests-backend.yml +++ b/.github/workflows/system-tests-backend.yml @@ -59,6 +59,7 @@ jobs: -e '/.*"sentry-android-integration-tests:sentry-uitest-android-benchmark",/d' \ -e '/.*"sentry-android-integration-tests:sentry-uitest-android",/d' \ -e '/.*"sentry-android-integration-tests:sentry-uitest-android-critical",/d' \ + -e '/.*"sentry-android-integration-tests:sentry-mock-relay",/d' \ -e '/.*"sentry-android-integration-tests:test-app-sentry",/d' \ -e '/.*"sentry-samples:sentry-samples-android",/d' \ -e '/.*"sentry-android-replay",/d' \ @@ -70,6 +71,7 @@ jobs: -e '/.*"sentry-uitest-android",/d' \ -e '/.*"sentry-uitest-android-benchmark",/d' \ -e '/.*"sentry-uitest-android-critical",/d' \ + -e '/.*"sentry-mock-relay",/d' \ -e '/.*"test-app-sentry",/d' \ -e '/.*"sentry-samples-android",/d' \ build.gradle.kts diff --git a/Makefile b/Makefile index 62e6e258f32..e35928d0c77 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease assembleUiTestCriticalRelease createCoverageReports runUiTestCritical check preMerge publish +.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease assembleUiTestCriticalRelease createCoverageReports runUiTestCritical buildMockRelay check preMerge publish all: stop clean javadocs compile createCoverageReports assembleBenchmarks: assembleBenchmarkTestRelease @@ -61,6 +61,10 @@ assembleUiTestCriticalRelease: runUiTestCritical: ./scripts/test-ui-critical.sh +# Build the mock relay for critical tests +buildMockRelay: + ./gradlew :sentry-android-integration-tests:sentry-mock-relay:build + # Create coverage reports # - Jacoco for Java & Android modules # - Kover for KMP modules e.g sentry-compose diff --git a/build.gradle.kts b/build.gradle.kts index 9d532525628..f5d6a19e9bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,6 +69,7 @@ apiValidation { "sentry-uitest-android", "sentry-uitest-android-benchmark", "sentry-uitest-android-critical", + "sentry-mock-relay", "test-app-plain", "test-app-sentry", "sentry-samples-netflix-dgs" diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index 8e4b6832fb8..94fb281c528 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -201,6 +201,10 @@ object Config { val javaFaker = "com.github.javafaker:javafaker:1.0.2" val msgpack = "org.msgpack:msgpack-core:0.9.8" val leakCanaryInstrumentation = "com.squareup.leakcanary:leakcanary-android-instrumentation:2.14" + val kotlinxSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1" + val pluginSerializationVersion = "1.5.0" + val logbackClassic = "ch.qos.logback:logback-classic:1.4.14" + val ktorVersion = "2.3.12" } object QualityPlugins { diff --git a/scripts/test-ui-critical.sh b/scripts/test-ui-critical.sh index 7bb36eebec7..4a4cd0052da 100755 --- a/scripts/test-ui-critical.sh +++ b/scripts/test-ui-critical.sh @@ -19,6 +19,9 @@ if ! command -v maestro &> /dev/null; then exit 1 fi +echo "Building the mock relay..." +make buildMockRelay + echo "Building the UI Test Critical app..." make assembleUiTestCriticalRelease @@ -29,7 +32,24 @@ apkName="sentry-uitest-android-critical-release.apk" appPath="${baseDir}/${buildDir}/${apkName}" adb install -r -d "$appPath" +echo "Starting the mock relay..." +cd sentry-android-integration-tests/sentry-mock-relay/build/distributions +unzip -o sentry-mock-relay-0.0.1.zip +./sentry-mock-relay-0.0.1/bin/sentry-mock-relay > /dev/null & MOCK_RELAY_PID=$! +echo "Mock relay PID: $MOCK_RELAY_PID" + +set +e echo "Running the Maestro tests..." maestro test \ "${baseDir}/maestro" \ --debug-output "${baseDir}/maestro-logs" +MAESTRO_EXIT_CODE=$? + +echo "Checking mock relay results..." +curl --fail http://localhost:8961/assertReceivedAtLeastOneCrashReport +MOCK_RELAY_EXIT_CODE=$? + +echo "Stopping the mock relay..." +kill $MOCK_RELAY_PID + +exit $(($MAESTRO_EXIT_CODE || $MOCK_RELAY_EXIT_CODE)) diff --git a/sentry-android-integration-tests/sentry-mock-relay/.gitignore b/sentry-android-integration-tests/sentry-mock-relay/.gitignore new file mode 100644 index 00000000000..c426c32f86f --- /dev/null +++ b/sentry-android-integration-tests/sentry-mock-relay/.gitignore @@ -0,0 +1,36 @@ +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ \ No newline at end of file diff --git a/sentry-android-integration-tests/sentry-mock-relay/build.gradle.kts b/sentry-android-integration-tests/sentry-mock-relay/build.gradle.kts new file mode 100644 index 00000000000..cc4df2b62ab --- /dev/null +++ b/sentry-android-integration-tests/sentry-mock-relay/build.gradle.kts @@ -0,0 +1,28 @@ + +plugins { + kotlin("jvm") + id("io.ktor.plugin") version Config.TestLibs.ktorVersion + kotlin("plugin.serialization") version Config.TestLibs.pluginSerializationVersion +} + +group = "io.sentry.mock-relay" +version = "0.0.1" + +application { + mainClass.set("io.ktor.server.netty.EngineMain") + + val isDevelopment: Boolean = project.ext.has("development") + applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment") +} + +repositories { + mavenCentral() +} + +dependencies { + implementation(Config.TestLibs.kotlinxSerializationJson) + implementation("io.ktor:ktor-server-core-jvm") + implementation("io.ktor:ktor-server-netty-jvm") + implementation(Config.TestLibs.logbackClassic) + implementation("io.ktor:ktor-server-config-yaml") +} diff --git a/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt b/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt new file mode 100644 index 00000000000..d043aaddf93 --- /dev/null +++ b/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt @@ -0,0 +1,89 @@ +package io.sentry + +import io.ktor.server.request.receive +import io.ktor.server.request.receiveText +import io.ktor.server.request.uri +import io.ktor.server.response.respondText +import io.ktor.server.routing.get +import io.ktor.server.routing.post +import io.ktor.server.routing.routing +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonElement +import kotlinx.serialization.json.jsonArray +import kotlinx.serialization.json.jsonObject +import kotlinx.serialization.json.jsonPrimitive +import java.util.zip.GZIPInputStream +import io.ktor.server.application.Application +import io.ktor.server.application.call + +fun main(args: Array) { + io.ktor.server.netty.EngineMain.main(args) +} + +fun Application.module() { + configureRouting() +} + +fun Application.configureRouting() { + val receivedEnvelopes = mutableListOf>() + + routing { + post("/{...}") { + println("Received request: ${call.request.uri}") + val textBody: String = if (call.request.headers["Content-Encoding"] == "gzip") { + call.receive().let { + GZIPInputStream(it.inputStream()).bufferedReader().use { reader -> + reader.readText() + } + } + } else { + call.receiveText() + } + + val jsonItems = textBody.split('\n').mapNotNull { line -> + try { + Json.parseToJsonElement(line) + } catch (e: Exception) { + null + } + } + + receivedEnvelopes.add(jsonItems) + + call.respondText("{}") + } + get("/healthCheck") { + call.respondText("OK") + } + get("/assertReceivedAtLeastOneCrashReport") { + if (receivedEnvelopes.isEmpty()) { + call.respondText("Mocked Replay have not received any envelopes", status = io.ktor.http.HttpStatusCode.BadRequest) + } + + val hasCrashReport = receivedEnvelopes.any { envelope -> + envelope.any { item -> + try { + if (item.jsonObject.containsKey("exception")) { + val exception = item.jsonObject["exception"]?.jsonObject + val values = exception?.get("values")?.jsonArray + values?.any { value -> + val message = value.jsonObject["value"]?.jsonPrimitive?.content + message == "Crash the test app." + } ?: false + } else { + false + } + } catch (e: Exception) { + false + } + } + } + + if (hasCrashReport) { + call.respondText("Received at least one crash report") + } else { + call.respondText("No crash report received", status = io.ktor.http.HttpStatusCode.BadRequest) + } + } + } +} diff --git a/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/application.yaml b/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/application.yaml new file mode 100644 index 00000000000..2c74879be83 --- /dev/null +++ b/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/application.yaml @@ -0,0 +1,6 @@ +ktor: + application: + modules: + - io.sentry.ApplicationKt.module + deployment: + port: 8961 diff --git a/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/logback.xml b/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/logback.xml new file mode 100644 index 00000000000..3e11d7811a6 --- /dev/null +++ b/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/logback.xml @@ -0,0 +1,12 @@ + + + + %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts index cebf744a24d..f5ff32820c8 100644 --- a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts @@ -51,6 +51,8 @@ android { dependencies { implementation(kotlin(Config.kotlinStdLib, org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION)) + implementation(Config.Libs.okhttp) + implementation(Config.TestLibs.mockWebserver) implementation(Config.Libs.androidxCore) implementation(Config.Libs.composeActivity) implementation(Config.Libs.composeFoundation) diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml b/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml index 0ab5e6052df..65a0c51f30a 100644 --- a/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml @@ -5,8 +5,10 @@ - + tools:targetApi="31" + android:networkSecurityConfig="@xml/network" + > + + + + + + 10.0.2.2 + + diff --git a/settings.gradle.kts b/settings.gradle.kts index 77b3be021da..d6861ab2e86 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -62,6 +62,7 @@ include( "sentry-samples:sentry-samples-spring-boot-webflux-jakarta", "sentry-samples:sentry-samples-netflix-dgs", "sentry-android-integration-tests:sentry-uitest-android-critical", + "sentry-android-integration-tests:sentry-mock-relay", "sentry-android-integration-tests:sentry-uitest-android-benchmark", "sentry-android-integration-tests:sentry-uitest-android", "sentry-android-integration-tests:test-app-plain", From d03418e0330161eab2817e6cd7c84d01d8e383ae Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Tue, 22 Oct 2024 12:49:49 +0000 Subject: [PATCH 26/28] Format code --- .../src/main/kotlin/io/sentry/Application.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt b/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt index d043aaddf93..2b6fe4d91a5 100644 --- a/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt +++ b/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt @@ -1,5 +1,7 @@ package io.sentry +import io.ktor.server.application.Application +import io.ktor.server.application.call import io.ktor.server.request.receive import io.ktor.server.request.receiveText import io.ktor.server.request.uri @@ -13,8 +15,6 @@ import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive import java.util.zip.GZIPInputStream -import io.ktor.server.application.Application -import io.ktor.server.application.call fun main(args: Array) { io.ktor.server.netty.EngineMain.main(args) From a18acf34e88d9a489f041938d56c22f84fc399cf Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 22 Oct 2024 14:51:52 +0200 Subject: [PATCH 27/28] Revert "Format code" This reverts commit d03418e0330161eab2817e6cd7c84d01d8e383ae. --- .../src/main/kotlin/io/sentry/Application.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt b/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt index 2b6fe4d91a5..d043aaddf93 100644 --- a/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt +++ b/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt @@ -1,7 +1,5 @@ package io.sentry -import io.ktor.server.application.Application -import io.ktor.server.application.call import io.ktor.server.request.receive import io.ktor.server.request.receiveText import io.ktor.server.request.uri @@ -15,6 +13,8 @@ import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive import java.util.zip.GZIPInputStream +import io.ktor.server.application.Application +import io.ktor.server.application.call fun main(args: Array) { io.ktor.server.netty.EngineMain.main(args) From aa01a76a5253d846796dd54ec190766cc1e67393 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 22 Oct 2024 14:51:56 +0200 Subject: [PATCH 28/28] Revert "test(critical): Add Mock Relay to verify crash envelope" This reverts commit 837a64f47e3bd43a22118a07c50ad4a997632543. --- .../integration-tests-ui-critical.yml | 33 +------ .github/workflows/system-tests-backend.yml | 2 - Makefile | 6 +- build.gradle.kts | 1 - buildSrc/src/main/java/Config.kt | 4 - scripts/test-ui-critical.sh | 20 ----- .../sentry-mock-relay/.gitignore | 36 -------- .../sentry-mock-relay/build.gradle.kts | 28 ------ .../src/main/kotlin/io/sentry/Application.kt | 89 ------------------- .../src/main/resources/application.yaml | 6 -- .../src/main/resources/logback.xml | 12 --- .../build.gradle.kts | 2 - .../src/main/AndroidManifest.xml | 6 +- .../src/main/res/xml/network.xml | 8 -- settings.gradle.kts | 1 - 15 files changed, 4 insertions(+), 250 deletions(-) delete mode 100644 sentry-android-integration-tests/sentry-mock-relay/.gitignore delete mode 100644 sentry-android-integration-tests/sentry-mock-relay/build.gradle.kts delete mode 100644 sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt delete mode 100644 sentry-android-integration-tests/sentry-mock-relay/src/main/resources/application.yaml delete mode 100644 sentry-android-integration-tests/sentry-mock-relay/src/main/resources/logback.xml delete mode 100644 sentry-android-integration-tests/sentry-uitest-android-critical/src/main/res/xml/network.xml diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 9c5eeb0cc46..b0ef7bea70d 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -11,14 +11,11 @@ concurrency: cancel-in-progress: true env: - INTEGRATION_TESTS_PATH: "sentry-android-integration-tests" - BASE_PATH: "${{env.INTEGRATION_TESTS_PATH}}/sentry-uitest-android-critical" + BASE_PATH: "sentry-android-integration-tests/sentry-uitest-android-critical" BUILD_PATH: "build/outputs/apk/release" APK_NAME: "sentry-uitest-android-critical-release.apk" APK_ARTIFACT_NAME: "sentry-uitest-android-critical-release" MAESTRO_VERSION: "1.39.0" - MOCK_RELAY_ARTIFACT_NAME: "sentry-mock-relay" - MOCK_RELAY_PATH: "sentry-mock-relay-0.0.1.zip" jobs: build: @@ -39,16 +36,6 @@ jobs: with: gradle-home-cache-cleanup: true - - name: Build mock relay - run: make buildMockRelay - - - name: Upload Mock Relay - uses: actions/upload-artifact@v4 - with: - name: ${{env.MOCK_RELAY_ARTIFACT_NAME}} - path: "${{env.INTEGRATION_TESTS_PATH}}/sentry-mock-relay/build/distributions/${{env.MOCK_RELAY_PATH}}" - retention-days: 1 - - name: Build debug APK run: make assembleUiTestCriticalRelease @@ -104,14 +91,6 @@ jobs: with: name: ${{env.APK_ARTIFACT_NAME}} - - name: Download Mock Relay - uses: actions/download-artifact@v4 - with: - name: ${{env.MOCK_RELAY_ARTIFACT_NAME}} - - - name: Unzip Mock Relay - run: unzip -o ${{env.MOCK_RELAY_PATH}} - - name: Install Maestro uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # pin@v1.0.0 with: @@ -138,17 +117,7 @@ jobs: -timezone US/Pacific script: | adb install -r -d "${{env.APK_NAME}}" - ./sentry-mock-relay-0.0.1/bin/sentry-mock-relay > /dev/null & MOCK_RELAY_PID=$! - - set +e maestro test "${{env.BASE_PATH}}/maestro" --debug-output "${{env.BASE_PATH}}/maestro-logs" - MAESTRO_EXIT_CODE=$? - - curl --fail http://localhost:8961/assertReceivedAtLeastOneCrashReport - MOCK_RELAY_EXIT_CODE=$? - - kill $MOCK_RELAY_PID - exit $(($MAESTRO_EXIT_CODE || $MOCK_RELAY_EXIT_CODE)) - name: Upload Maestro test results if: failure() diff --git a/.github/workflows/system-tests-backend.yml b/.github/workflows/system-tests-backend.yml index 7482b216bae..2222f910adb 100644 --- a/.github/workflows/system-tests-backend.yml +++ b/.github/workflows/system-tests-backend.yml @@ -59,7 +59,6 @@ jobs: -e '/.*"sentry-android-integration-tests:sentry-uitest-android-benchmark",/d' \ -e '/.*"sentry-android-integration-tests:sentry-uitest-android",/d' \ -e '/.*"sentry-android-integration-tests:sentry-uitest-android-critical",/d' \ - -e '/.*"sentry-android-integration-tests:sentry-mock-relay",/d' \ -e '/.*"sentry-android-integration-tests:test-app-sentry",/d' \ -e '/.*"sentry-samples:sentry-samples-android",/d' \ -e '/.*"sentry-android-replay",/d' \ @@ -71,7 +70,6 @@ jobs: -e '/.*"sentry-uitest-android",/d' \ -e '/.*"sentry-uitest-android-benchmark",/d' \ -e '/.*"sentry-uitest-android-critical",/d' \ - -e '/.*"sentry-mock-relay",/d' \ -e '/.*"test-app-sentry",/d' \ -e '/.*"sentry-samples-android",/d' \ build.gradle.kts diff --git a/Makefile b/Makefile index e35928d0c77..62e6e258f32 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease assembleUiTestCriticalRelease createCoverageReports runUiTestCritical buildMockRelay check preMerge publish +.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease assembleUiTestCriticalRelease createCoverageReports runUiTestCritical check preMerge publish all: stop clean javadocs compile createCoverageReports assembleBenchmarks: assembleBenchmarkTestRelease @@ -61,10 +61,6 @@ assembleUiTestCriticalRelease: runUiTestCritical: ./scripts/test-ui-critical.sh -# Build the mock relay for critical tests -buildMockRelay: - ./gradlew :sentry-android-integration-tests:sentry-mock-relay:build - # Create coverage reports # - Jacoco for Java & Android modules # - Kover for KMP modules e.g sentry-compose diff --git a/build.gradle.kts b/build.gradle.kts index f5d6a19e9bd..9d532525628 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,7 +69,6 @@ apiValidation { "sentry-uitest-android", "sentry-uitest-android-benchmark", "sentry-uitest-android-critical", - "sentry-mock-relay", "test-app-plain", "test-app-sentry", "sentry-samples-netflix-dgs" diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index 94fb281c528..8e4b6832fb8 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -201,10 +201,6 @@ object Config { val javaFaker = "com.github.javafaker:javafaker:1.0.2" val msgpack = "org.msgpack:msgpack-core:0.9.8" val leakCanaryInstrumentation = "com.squareup.leakcanary:leakcanary-android-instrumentation:2.14" - val kotlinxSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1" - val pluginSerializationVersion = "1.5.0" - val logbackClassic = "ch.qos.logback:logback-classic:1.4.14" - val ktorVersion = "2.3.12" } object QualityPlugins { diff --git a/scripts/test-ui-critical.sh b/scripts/test-ui-critical.sh index 4a4cd0052da..7bb36eebec7 100755 --- a/scripts/test-ui-critical.sh +++ b/scripts/test-ui-critical.sh @@ -19,9 +19,6 @@ if ! command -v maestro &> /dev/null; then exit 1 fi -echo "Building the mock relay..." -make buildMockRelay - echo "Building the UI Test Critical app..." make assembleUiTestCriticalRelease @@ -32,24 +29,7 @@ apkName="sentry-uitest-android-critical-release.apk" appPath="${baseDir}/${buildDir}/${apkName}" adb install -r -d "$appPath" -echo "Starting the mock relay..." -cd sentry-android-integration-tests/sentry-mock-relay/build/distributions -unzip -o sentry-mock-relay-0.0.1.zip -./sentry-mock-relay-0.0.1/bin/sentry-mock-relay > /dev/null & MOCK_RELAY_PID=$! -echo "Mock relay PID: $MOCK_RELAY_PID" - -set +e echo "Running the Maestro tests..." maestro test \ "${baseDir}/maestro" \ --debug-output "${baseDir}/maestro-logs" -MAESTRO_EXIT_CODE=$? - -echo "Checking mock relay results..." -curl --fail http://localhost:8961/assertReceivedAtLeastOneCrashReport -MOCK_RELAY_EXIT_CODE=$? - -echo "Stopping the mock relay..." -kill $MOCK_RELAY_PID - -exit $(($MAESTRO_EXIT_CODE || $MOCK_RELAY_EXIT_CODE)) diff --git a/sentry-android-integration-tests/sentry-mock-relay/.gitignore b/sentry-android-integration-tests/sentry-mock-relay/.gitignore deleted file mode 100644 index c426c32f86f..00000000000 --- a/sentry-android-integration-tests/sentry-mock-relay/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ \ No newline at end of file diff --git a/sentry-android-integration-tests/sentry-mock-relay/build.gradle.kts b/sentry-android-integration-tests/sentry-mock-relay/build.gradle.kts deleted file mode 100644 index cc4df2b62ab..00000000000 --- a/sentry-android-integration-tests/sentry-mock-relay/build.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ - -plugins { - kotlin("jvm") - id("io.ktor.plugin") version Config.TestLibs.ktorVersion - kotlin("plugin.serialization") version Config.TestLibs.pluginSerializationVersion -} - -group = "io.sentry.mock-relay" -version = "0.0.1" - -application { - mainClass.set("io.ktor.server.netty.EngineMain") - - val isDevelopment: Boolean = project.ext.has("development") - applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment") -} - -repositories { - mavenCentral() -} - -dependencies { - implementation(Config.TestLibs.kotlinxSerializationJson) - implementation("io.ktor:ktor-server-core-jvm") - implementation("io.ktor:ktor-server-netty-jvm") - implementation(Config.TestLibs.logbackClassic) - implementation("io.ktor:ktor-server-config-yaml") -} diff --git a/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt b/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt deleted file mode 100644 index d043aaddf93..00000000000 --- a/sentry-android-integration-tests/sentry-mock-relay/src/main/kotlin/io/sentry/Application.kt +++ /dev/null @@ -1,89 +0,0 @@ -package io.sentry - -import io.ktor.server.request.receive -import io.ktor.server.request.receiveText -import io.ktor.server.request.uri -import io.ktor.server.response.respondText -import io.ktor.server.routing.get -import io.ktor.server.routing.post -import io.ktor.server.routing.routing -import kotlinx.serialization.json.Json -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.jsonArray -import kotlinx.serialization.json.jsonObject -import kotlinx.serialization.json.jsonPrimitive -import java.util.zip.GZIPInputStream -import io.ktor.server.application.Application -import io.ktor.server.application.call - -fun main(args: Array) { - io.ktor.server.netty.EngineMain.main(args) -} - -fun Application.module() { - configureRouting() -} - -fun Application.configureRouting() { - val receivedEnvelopes = mutableListOf>() - - routing { - post("/{...}") { - println("Received request: ${call.request.uri}") - val textBody: String = if (call.request.headers["Content-Encoding"] == "gzip") { - call.receive().let { - GZIPInputStream(it.inputStream()).bufferedReader().use { reader -> - reader.readText() - } - } - } else { - call.receiveText() - } - - val jsonItems = textBody.split('\n').mapNotNull { line -> - try { - Json.parseToJsonElement(line) - } catch (e: Exception) { - null - } - } - - receivedEnvelopes.add(jsonItems) - - call.respondText("{}") - } - get("/healthCheck") { - call.respondText("OK") - } - get("/assertReceivedAtLeastOneCrashReport") { - if (receivedEnvelopes.isEmpty()) { - call.respondText("Mocked Replay have not received any envelopes", status = io.ktor.http.HttpStatusCode.BadRequest) - } - - val hasCrashReport = receivedEnvelopes.any { envelope -> - envelope.any { item -> - try { - if (item.jsonObject.containsKey("exception")) { - val exception = item.jsonObject["exception"]?.jsonObject - val values = exception?.get("values")?.jsonArray - values?.any { value -> - val message = value.jsonObject["value"]?.jsonPrimitive?.content - message == "Crash the test app." - } ?: false - } else { - false - } - } catch (e: Exception) { - false - } - } - } - - if (hasCrashReport) { - call.respondText("Received at least one crash report") - } else { - call.respondText("No crash report received", status = io.ktor.http.HttpStatusCode.BadRequest) - } - } - } -} diff --git a/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/application.yaml b/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/application.yaml deleted file mode 100644 index 2c74879be83..00000000000 --- a/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/application.yaml +++ /dev/null @@ -1,6 +0,0 @@ -ktor: - application: - modules: - - io.sentry.ApplicationKt.module - deployment: - port: 8961 diff --git a/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/logback.xml b/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/logback.xml deleted file mode 100644 index 3e11d7811a6..00000000000 --- a/sentry-android-integration-tests/sentry-mock-relay/src/main/resources/logback.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts index f5ff32820c8..cebf744a24d 100644 --- a/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts @@ -51,8 +51,6 @@ android { dependencies { implementation(kotlin(Config.kotlinStdLib, org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION)) - implementation(Config.Libs.okhttp) - implementation(Config.TestLibs.mockWebserver) implementation(Config.Libs.androidxCore) implementation(Config.Libs.composeActivity) implementation(Config.Libs.composeFoundation) diff --git a/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml b/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml index 65a0c51f30a..0ab5e6052df 100644 --- a/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml +++ b/sentry-android-integration-tests/sentry-uitest-android-critical/src/main/AndroidManifest.xml @@ -5,10 +5,8 @@ - + tools:targetApi="31"> + - - - - - 10.0.2.2 - - diff --git a/settings.gradle.kts b/settings.gradle.kts index d6861ab2e86..77b3be021da 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -62,7 +62,6 @@ include( "sentry-samples:sentry-samples-spring-boot-webflux-jakarta", "sentry-samples:sentry-samples-netflix-dgs", "sentry-android-integration-tests:sentry-uitest-android-critical", - "sentry-android-integration-tests:sentry-mock-relay", "sentry-android-integration-tests:sentry-uitest-android-benchmark", "sentry-android-integration-tests:sentry-uitest-android", "sentry-android-integration-tests:test-app-plain",