Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enha: sentry-cli Integration Tests #371

Merged
merged 9 commits into from Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/integration-tests-sentry-cli.yml
@@ -0,0 +1,24 @@
name: integration-tests-sentry-cli

on:
push:
branches:
- main
- release/**
pull_request:

jobs:
integration-test:
runs-on: ubuntu-latest
env:
SENTRY_URL: http://127.0.0.1:8000
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10.5'

- name: Start server and run integration test for sentry-cli commands
run: |
test/integration-test-server-start.sh &
./gradlew -p plugin-build test --tests SentryPluginIntegrationTest
8 changes: 7 additions & 1 deletion examples/android-gradle/src/main/AndroidManifest.xml
@@ -1,6 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sampleapp">
<application>
<activity android:name=".MainActivity"/>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="io.sentry.dsn" android:value="https://examplePublicKey@o0.ingest.sentry.io/0" />
</application>
</manifest>
@@ -0,0 +1,90 @@
package io.sentry.android.gradle

import kotlin.test.assertEquals
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@Suppress("FunctionName")
@RunWith(Parameterized::class)
class SentryPluginIntegrationTest(
androidGradlePluginVersion: String,
gradleVersion: String
) : BaseSentryPluginTest(androidGradlePluginVersion, gradleVersion) {

@Test
fun uploadSentryProguardMappingsIntegration() {
if (System.getenv("SENTRY_URL").isNullOrBlank()) {
return // Don't run test if local test server endpoint is not set
}
applyAutoUploadProguardMapping()

val build = runner
.appendArguments(":app:assembleRelease")
.build()

assertEquals(
build.task(":app:uploadSentryProguardMappingsRelease")?.outcome,
TaskOutcome.SUCCESS
)
}

@Test
fun uploadNativeSymbols() {
if (System.getenv("SENTRY_URL").isNullOrBlank()) {
return // Don't run test if local test server endpoint is not set
}
applyUploadNativeSymbols()

val build = runner
.appendArguments(":app:assembleRelease")
.build()

assertEquals(
build.task(":app:uploadSentryNativeSymbolsForRelease")?.outcome,
TaskOutcome.SUCCESS
)
}

private fun applyAutoUploadProguardMapping() {
appBuildFile.writeText(
// language=Groovy
"""
plugins {
id "com.android.application"
id "io.sentry.android.gradle"
}

sentry {
includeProguardMapping = true
autoUploadProguardMapping = true
uploadNativeSymbols = false
tracingInstrumentation {
enabled = false
}
}
""".trimIndent()
)
}

private fun applyUploadNativeSymbols() {
appBuildFile.writeText(
// language=Groovy
"""
plugins {
id "com.android.application"
id "io.sentry.android.gradle"
}

sentry {
autoUploadProguardMapping = false
uploadNativeSymbols = true
tracingInstrumentation {
enabled = false
}
}
""".trimIndent()
)
}
}
111 changes: 111 additions & 0 deletions test/assets/AndroidManifest.xml
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.app"
android:versionCode="11"
android:versionName="1.1.0" >

<uses-sdk
android:minSdkVersion="26"
android:targetSdkVersion="32" />

<uses-permission android:name="android.permission.INTERNET" />

<queries>
<package android:name="androidx.test.orchestrator" />
<package android:name="androidx.test.services" />
<package android:name="com.google.android.apps.common.testing.services" />
</queries>

<application
android:name="com.sample.app"
android:allowBackup="true"
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:dataExtractionRules="@xml/data_extraction_rules"
android:extractNativeLibs="false"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SampleApp" >
<activity
android:name="com.sample.app.MainActivity"
android:exported="true"
android:theme="@style/Theme.SampleApp" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="io.sentry.auto-init"
android:value="false" />

<activity
android:name="androidx.compose.ui.tooling.PreviewActivity"
android:exported="true" /> <!-- 'android:authorities' must be unique in the device, across all apps -->
<provider
android:name="io.sentry.android.core.SentryInitProvider"
android:authorities="com.sample.app.SentryInitProvider"
android:exported="false" />
<provider
android:name="io.sentry.android.core.SentryPerformanceProvider"
android:authorities="com.sample.app.SentryPerformanceProvider"
android:exported="false"
android:initOrder="200" />
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="com.sample.app.androidx-startup"
android:exported="false" >
<meta-data
android:name="androidx.emoji2.text.EmojiCompatInitializer"
android:value="androidx.startup" />
<meta-data
android:name="androidx.lifecycle.ProcessLifecycleInitializer"
android:value="androidx.startup" />
<meta-data
android:name="androidx.profileinstaller.ProfileInstallerInitializer"
android:value="androidx.startup" />
</provider>

<service
android:name="androidx.room.MultiInstanceInvalidationService"
android:directBootAware="true"
android:exported="false" /> <!-- The activities will be merged into the manifest of the hosting app. -->
<activity
android:name="com.google.android.play.core.common.PlayCoreDialogWrapperActivity"
android:exported="false"
android:stateNotNeeded="true"
android:theme="@style/Theme.PlayCore.Transparent" />

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.play.billingclient.version"
android:value="4.1.0" />

<activity
android:name="com.android.billingclient.api.ProxyBillingActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />

<receiver
android:name="androidx.profileinstaller.ProfileInstallReceiver"
android:directBootAware="false"
android:enabled="true"
android:exported="true"
android:permission="android.permission.DUMP" >
<intent-filter>
<action android:name="androidx.profileinstaller.action.INSTALL_PROFILE" />
</intent-filter>
<intent-filter>
<action android:name="androidx.profileinstaller.action.SKIP_FILE" />
</intent-filter>
</receiver>
</application>

</manifest>
10 changes: 10 additions & 0 deletions test/assets/artifact.json
@@ -0,0 +1,10 @@
{
"id": "fixture-id",
"sha1": "fixture-sha1",
"name": "fixture-name",
"size": 1,
"dist": null,
"headers": {
"fixture-header-key": "fixture-header-value"
}
}
22 changes: 22 additions & 0 deletions test/assets/artifacts.json
@@ -0,0 +1,22 @@
[
{
"id": "6796495645",
"name": "~/dist/bundle.min.js",
"dist": "foo",
"headers": {
"Sourcemap": "dist/bundle.min.js.map"
},
"size": 497,
"sha1": "2fb719956748ab7ec5ae9bcb47606733f5589b72",
"dateCreated": "2022-05-12T11:08:01.520199Z"
},
{
"id": "6796495646",
"name": "~/dist/bundle.min.js.map",
"dist": "foo",
"headers": {},
"size": 1522,
"sha1": "f818059cbf617a8fae9b4e46d08f6c0246bb1624",
"dateCreated": "2022-05-12T11:08:01.496220Z"
}
]
5 changes: 5 additions & 0 deletions test/assets/assemble-artifacts-response.json
@@ -0,0 +1,5 @@
{
"state": "ok",
"missingChunks": [],
"detail": null
}
15 changes: 15 additions & 0 deletions test/assets/associate-dsyms-response.json
@@ -0,0 +1,15 @@
{
"associatedDsymFiles": [
{
"uuid": null,
"debugId": null,
"objectName": "fixture-objectName",
"cpuName": "fixture-cpuName",
"sha1": "fixture-sha1",
"data": {
"type": null,
"features": ["fixture-feature"]
}
}
]
}
13 changes: 13 additions & 0 deletions test/assets/debug-info-files.json
@@ -0,0 +1,13 @@
[
{
"uuid": null,
"debugId": null,
"objectName": "fixture-objectName",
"cpuName": "fixture-cpuName",
"sha1": "fixture-sha1",
"data": {
"type": null,
"features": ["fixture-feature"]
}
}
]
8 changes: 8 additions & 0 deletions test/assets/deploy.json
@@ -0,0 +1,8 @@
{
"id": "1",
"environment": "production",
"dateStarted": null,
"dateFinished": "2022-01-01T12:00:00.000000Z",
"name": "fixture-deploy",
"url": null
}
44 changes: 44 additions & 0 deletions test/assets/release.json
@@ -0,0 +1,44 @@
{
"dateReleased": "2022-01-01T12:00:00.000000Z",
"newGroups": 0,
"commitCount": 0,
"url": null,
"data":
{},
"lastDeploy": null,
"deployCount": 0,
"dateCreated": "2022-01-01T12:00:00.000000Z",
"lastEvent": null,
"version": "1.1.0",
"firstEvent": null,
"lastCommit": null,
"shortVersion": "1.1.0",
"authors":
[],
"owner": null,
"versionInfo":
{
"buildHash": null,
"version":
{
"raw": "1.1.0"
},
"description": "1.1.0",
"package": null
},
"ref": null,
"projects":
[
{
"name": "Sentry Fastlane App",
"platform": "ruby",
"slug": "sentry-fastlane-plugin",
"platforms":
[
"ruby"
],
"newGroups": 0,
"id": 1234567
}
]
}
13 changes: 13 additions & 0 deletions test/assets/repos.json
@@ -0,0 +1,13 @@
[
{
"id": "1",
"name": "sentry/sentry-fastlane-plugin",
"url": null,
"provider": {
"id": "1",
"name": "fixture-name"
},
"status": "fixture-status",
"dateCreated": "2022-01-01T12:00:00.000000Z"
}
]
3 changes: 3 additions & 0 deletions test/integration-test-server-start.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

python3 test/integration-test-server.py
3 changes: 3 additions & 0 deletions test/integration-test-server-stop.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

curl http://127.0.0.1:8000/STOP