From 466d6958d9c93624f799c8f92dc31d0c3c153a68 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 13 Jul 2022 16:48:53 +0200 Subject: [PATCH 01/63] test: appium-based android startup test (WIP) --- performance-tests/appium/.gitignore | 24 ++++ performance-tests/appium/README.md | 3 + performance-tests/appium/pom.xml | 100 ++++++++++++++ .../test/java/tests/AndroidStartupTest.java | 128 ++++++++++++++++++ .../src/test/resources/config/android.xml | 8 ++ 5 files changed, 263 insertions(+) create mode 100644 performance-tests/appium/.gitignore create mode 100644 performance-tests/appium/README.md create mode 100644 performance-tests/appium/pom.xml create mode 100644 performance-tests/appium/src/test/java/tests/AndroidStartupTest.java create mode 100644 performance-tests/appium/src/test/resources/config/android.xml diff --git a/performance-tests/appium/.gitignore b/performance-tests/appium/.gitignore new file mode 100644 index 00000000000..26044769d74 --- /dev/null +++ b/performance-tests/appium/.gitignore @@ -0,0 +1,24 @@ +target/ +.idea/ +*.setting +*.DS_store +*.classpath +.settings/ +*.project +*.png +test-output/ +build/ +.DS_Store +test-order-details/ +test-results/ +img/ +perfectoReports/ +.git/ +*.log +/logs/ +/dashboard/ +*.pdf +/bin +Drivers/ +target/surefire-reports/index.html +*.iml diff --git a/performance-tests/appium/README.md b/performance-tests/appium/README.md new file mode 100644 index 00000000000..631142a9198 --- /dev/null +++ b/performance-tests/appium/README.md @@ -0,0 +1,3 @@ +# Android performance-impact tests + +Run `mvn clean test` to execute in SauceLabs. diff --git a/performance-tests/appium/pom.xml b/performance-tests/appium/pom.xml new file mode 100644 index 00000000000..6f0304ac7c4 --- /dev/null +++ b/performance-tests/appium/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + + io.sentry.java.tests + AppiumTests + 1.0-SNAPSHOT + + + 6.14.3 + 1.2 + 3.141.59 + 2.19.1 + 7.5.1 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M4 + + + src/test/resources/config/android.xml + + + + + maven-compiler-plugin + 3.0 + + 1.8 + 1.8 + + + + + + + + + org.testng + testng + ${testng.version} + + + + + org.seleniumhq.selenium + selenium-api + ${selenium.version} + + + + org.seleniumhq.selenium + selenium-java + ${selenium.version} + + + + + commons-logging + commons-logging + ${commons-logging.version} + + + + org.hamcrest + hamcrest-core + 1.3 + + + + log4j + log4j + 1.2.17 + + + + org.assertj + assertj-core + 3.10.0 + + + + io.appium + java-client + ${appium.version} + + + org.json + json + 20201115 + + + + + diff --git a/performance-tests/appium/src/test/java/tests/AndroidStartupTest.java b/performance-tests/appium/src/test/java/tests/AndroidStartupTest.java new file mode 100644 index 00000000000..84ad7dcaf1d --- /dev/null +++ b/performance-tests/appium/src/test/java/tests/AndroidStartupTest.java @@ -0,0 +1,128 @@ +package tests; + +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; +import java.util.Optional; + +import org.openqa.selenium.By; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import io.appium.java_client.MobileBy; +import io.appium.java_client.android.Activity; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.serverevents.CommandEvent; +import io.appium.java_client.serverevents.ServerEvents; + +public class AndroidStartupTest { + private static final int RUNS = 10; + + // TODO element lookup doesn't work yet + // private By elementToWaitFor = + // MobileBy.className("androidx.appcompat.widget.Toolbar"); + private static final String APP_PKG = "io.sentry.samples.instrumentation"; + private static final String APP_ACT = ".ui.MainActivity"; + private static final String APP_WAIT = ".ui.MainActivity"; + + private AndroidDriver driver; + + @BeforeMethod + public void setup(Method method) throws MalformedURLException { + + System.out.println("Sauce - BeforeMethod hook"); + String username = System.getenv("SAUCE_USERNAME"); + String accesskey = System.getenv("SAUCE_ACCESS_KEY"); + String sauceUrl = "@ondemand.us-west-1.saucelabs.com:443"; + + String SAUCE_REMOTE_URL = "https://" + username + ":" + accesskey + sauceUrl + "/wd/hub"; + String appName = "android-instrumentation-sample-release.apk"; + // String appID = "9068cfba-d0cd-4027-99dc-ca70c5bf5278"; + String methodName = method.getName(); + URL url = new URL(SAUCE_REMOTE_URL); + + DesiredCapabilities capabilities = new DesiredCapabilities(); + // capabilities.setCapability("deviceName", "Google Pixel 2"); + capabilities.setCapability("platformVersion", "11"); + capabilities.setCapability("platformName", "Android"); + // capabilities.setCapability("automationName", "XCuiTest"); + capabilities.setCapability("app", "storage:filename=" + appName); // or "storage:"+appID + capabilities.setCapability("name", methodName); + capabilities.setCapability("autoLaunch", false); + + // capabilities.setCapability("privateDevicesOnly", "true"); + // capabilities.setCapability("platformVersion", "14.3"); //added + // capabilities.setCapability("appiumVersion", ""); //added + // capabilities.setCapability("app", + // "https://github.com/saucelabs/sample-app-mobile/releases/download/2.7.1/iOS.RealDevice.SauceLabs.Mobile.Sample.app.2.7.1.ipa"); + // capabilities.setCapability("noReset", true); + // capabilities.setCapability("cacheId", "1234"); + // capabilities.setCapability("tags", "sauceDemo1"); + // capabilities.setCapability("build", "myBuild1"); + try { + driver = new AndroidDriver<>(url, capabilities); + } catch (Exception e) { + System.out.println("*** Problem to create the driver " + e.getMessage()); + throw new RuntimeException(e); + } + } + + @AfterMethod + public void teardown(ITestResult result) { + if (driver != null) { + driver.executeScript("sauce:job-result=" + (result.isSuccess() ? "passed" : "failed")); + driver.quit(); + } + } + + @Test + public void testAppLaunch() throws Exception { + Activity act = new Activity(APP_PKG, APP_ACT); + act.setAppWaitActivity(APP_WAIT); + + for (int i = 0; i < RUNS; i++) { + if (i > 0) { + // kill the app and sleep before running the next iteration + driver.terminateApp(APP_PKG); + Thread.sleep(1000); + } + + driver.startActivity(act); + + // TODO doesn't work yet + // WebDriverWait wait = new WebDriverWait(driver, 10); + // wait.until(ExpectedConditions.presenceOfElementLocated(elementToWaitFor)); + + // pull out the events + ServerEvents evts = driver.getEvents(); + List cmds = evts.getCommands(); + CommandEvent startActCmd = getCommand(cmds, "startActivity", i); + // CommandEvent findCmd = getCommand(cmds, "findElement", i); + + long launchMs = startActCmd.endTimestamp - startActCmd.startTimestamp; + // long interactMs = findCmd.endTimestamp - startActCmd.startTimestamp; + + System.out.println("The app took " + launchMs + "ms to launch"); + } + + // TODO: collect numbers, print the average, stddev + } + + private static CommandEvent getCommand(List list, String name, int index) throws Exception { + Optional result = list.stream() + .filter((cmd) -> cmd.getName().equals(name)) + .skip(index) + .findFirst(); + + if (!result.isPresent()) { + throw new Exception("Could not find given command: " + name); + } + return result.get(); + } +} diff --git a/performance-tests/appium/src/test/resources/config/android.xml b/performance-tests/appium/src/test/resources/config/android.xml new file mode 100644 index 00000000000..bbfdb6f892c --- /dev/null +++ b/performance-tests/appium/src/test/resources/config/android.xml @@ -0,0 +1,8 @@ + + + + + + + + From be814f5fd725b45742d0d6b4a4836e2aeb23ab2f Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 13 Jul 2022 17:24:40 +0200 Subject: [PATCH 02/63] chore: update appium test dependencies --- performance-tests/appium/pom.xml | 34 ++++++++++--------- .../test/java/tests/AndroidStartupTest.java | 7 +--- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/performance-tests/appium/pom.xml b/performance-tests/appium/pom.xml index 6f0304ac7c4..7a9cdef8abf 100644 --- a/performance-tests/appium/pom.xml +++ b/performance-tests/appium/pom.xml @@ -8,11 +8,8 @@ 1.0-SNAPSHOT - 6.14.3 - 1.2 - 3.141.59 - 2.19.1 - 7.5.1 + UTF-8 + 4.3.0 @@ -43,10 +40,9 @@ org.testng testng - ${testng.version} + 7.6.1 - org.seleniumhq.selenium selenium-api @@ -59,40 +55,46 @@ ${selenium.version} - commons-logging commons-logging - ${commons-logging.version} + 1.2 org.hamcrest hamcrest-core - 1.3 + 2.2 - log4j - log4j - 1.2.17 + org.slf4j + slf4j-jdk14 + 1.7.36 + + + + org.apache.logging.log4j + log4j-core + 2.18.0 org.assertj assertj-core - 3.10.0 + 3.23.1 io.appium java-client - ${appium.version} + 8.1.1 + org.json json - 20201115 + 20220320 diff --git a/performance-tests/appium/src/test/java/tests/AndroidStartupTest.java b/performance-tests/appium/src/test/java/tests/AndroidStartupTest.java index 84ad7dcaf1d..0e717239d67 100644 --- a/performance-tests/appium/src/test/java/tests/AndroidStartupTest.java +++ b/performance-tests/appium/src/test/java/tests/AndroidStartupTest.java @@ -6,16 +6,12 @@ import java.util.List; import java.util.Optional; -import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.ITestResult; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import io.appium.java_client.MobileBy; import io.appium.java_client.android.Activity; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.serverevents.CommandEvent; @@ -35,7 +31,6 @@ public class AndroidStartupTest { @BeforeMethod public void setup(Method method) throws MalformedURLException { - System.out.println("Sauce - BeforeMethod hook"); String username = System.getenv("SAUCE_USERNAME"); String accesskey = System.getenv("SAUCE_ACCESS_KEY"); @@ -66,7 +61,7 @@ public void setup(Method method) throws MalformedURLException { // capabilities.setCapability("tags", "sauceDemo1"); // capabilities.setCapability("build", "myBuild1"); try { - driver = new AndroidDriver<>(url, capabilities); + driver = new AndroidDriver(url, capabilities); } catch (Exception e) { System.out.println("*** Problem to create the driver " + e.getMessage()); throw new RuntimeException(e); From 5de4fccb3932af494e573bd1b3ca16854728ec69 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 13 Jul 2022 18:15:25 +0200 Subject: [PATCH 03/63] test: add performance test apps --- performance-tests/README.md | 5 + performance-tests/appium/README.md | 3 - performance-tests/test-app-plain/.gitignore | 15 ++ .../test-app-plain/app/.gitignore | 1 + .../test-app-plain/app/build.gradle | 37 ++++ .../test-app-plain/app/proguard-rules.pro | 21 ++ .../app/src/main/AndroidManifest.xml | 29 +++ .../tests/perf/appplain/FirstFragment.java | 47 +++++ .../tests/perf/appplain/MainActivity.java | 76 +++++++ .../tests/perf/appplain/SecondFragment.java | 47 +++++ .../drawable-v24/ic_launcher_foreground.xml | 30 +++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++ .../app/src/main/res/layout/activity_main.xml | 34 ++++ .../app/src/main/res/layout/content_main.xml | 19 ++ .../src/main/res/layout/fragment_first.xml | 28 +++ .../src/main/res/layout/fragment_second.xml | 27 +++ .../app/src/main/res/menu/menu_main.xml | 10 + .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes .../app/src/main/res/navigation/nav_graph.xml | 28 +++ .../app/src/main/res/values-land/dimens.xml | 3 + .../app/src/main/res/values-night/themes.xml | 16 ++ .../src/main/res/values-w1240dp/dimens.xml | 3 + .../app/src/main/res/values-w600dp/dimens.xml | 3 + .../app/src/main/res/values/colors.xml | 10 + .../app/src/main/res/values/dimens.xml | 3 + .../app/src/main/res/values/strings.xml | 12 ++ .../app/src/main/res/values/themes.xml | 25 +++ .../app/src/main/res/xml/backup_rules.xml | 13 ++ .../main/res/xml/data_extraction_rules.xml | 19 ++ performance-tests/test-app-plain/build.gradle | 9 + .../test-app-plain/gradle.properties | 21 ++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + performance-tests/test-app-plain/gradlew | 185 ++++++++++++++++++ performance-tests/test-app-plain/gradlew.bat | 89 +++++++++ .../test-app-plain/settings.gradle | 16 ++ performance-tests/test-app-sentry/.gitignore | 15 ++ .../test-app-sentry/app/.gitignore | 1 + .../test-app-sentry/app/build.gradle | 37 ++++ .../test-app-sentry/app/proguard-rules.pro | 21 ++ .../app/src/main/AndroidManifest.xml | 29 +++ .../tests/perf/appsentry/FirstFragment.java | 47 +++++ .../tests/perf/appsentry/MainActivity.java | 76 +++++++ .../tests/perf/appsentry/SecondFragment.java | 47 +++++ .../drawable-v24/ic_launcher_foreground.xml | 30 +++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++ .../app/src/main/res/layout/activity_main.xml | 34 ++++ .../app/src/main/res/layout/content_main.xml | 19 ++ .../src/main/res/layout/fragment_first.xml | 28 +++ .../src/main/res/layout/fragment_second.xml | 27 +++ .../app/src/main/res/menu/menu_main.xml | 10 + .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes .../app/src/main/res/navigation/nav_graph.xml | 28 +++ .../app/src/main/res/values-land/dimens.xml | 3 + .../app/src/main/res/values-night/themes.xml | 16 ++ .../src/main/res/values-w1240dp/dimens.xml | 3 + .../app/src/main/res/values-w600dp/dimens.xml | 3 + .../app/src/main/res/values/colors.xml | 10 + .../app/src/main/res/values/dimens.xml | 3 + .../app/src/main/res/values/strings.xml | 12 ++ .../app/src/main/res/values/themes.xml | 25 +++ .../app/src/main/res/xml/backup_rules.xml | 13 ++ .../main/res/xml/data_extraction_rules.xml | 19 ++ .../test-app-sentry/build.gradle | 9 + .../test-app-sentry/gradle.properties | 21 ++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + performance-tests/test-app-sentry/gradlew | 185 ++++++++++++++++++ performance-tests/test-app-sentry/gradlew.bat | 89 +++++++++ .../test-app-sentry/settings.gradle | 16 ++ 92 files changed, 2129 insertions(+), 3 deletions(-) create mode 100644 performance-tests/README.md delete mode 100644 performance-tests/appium/README.md create mode 100644 performance-tests/test-app-plain/.gitignore create mode 100644 performance-tests/test-app-plain/app/.gitignore create mode 100644 performance-tests/test-app-plain/app/build.gradle create mode 100644 performance-tests/test-app-plain/app/proguard-rules.pro create mode 100644 performance-tests/test-app-plain/app/src/main/AndroidManifest.xml create mode 100644 performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/FirstFragment.java create mode 100644 performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/MainActivity.java create mode 100644 performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/SecondFragment.java create mode 100644 performance-tests/test-app-plain/app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/layout/activity_main.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/layout/content_main.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/layout/fragment_first.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/layout/fragment_second.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/menu/menu_main.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-plain/app/src/main/res/navigation/nav_graph.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/values-land/dimens.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/values-night/themes.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/values-w1240dp/dimens.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/values-w600dp/dimens.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/values/colors.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/values/dimens.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/values/strings.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/values/themes.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/xml/backup_rules.xml create mode 100644 performance-tests/test-app-plain/app/src/main/res/xml/data_extraction_rules.xml create mode 100644 performance-tests/test-app-plain/build.gradle create mode 100644 performance-tests/test-app-plain/gradle.properties create mode 100644 performance-tests/test-app-plain/gradle/wrapper/gradle-wrapper.jar create mode 100644 performance-tests/test-app-plain/gradle/wrapper/gradle-wrapper.properties create mode 100644 performance-tests/test-app-plain/gradlew create mode 100644 performance-tests/test-app-plain/gradlew.bat create mode 100644 performance-tests/test-app-plain/settings.gradle create mode 100644 performance-tests/test-app-sentry/.gitignore create mode 100644 performance-tests/test-app-sentry/app/.gitignore create mode 100644 performance-tests/test-app-sentry/app/build.gradle create mode 100644 performance-tests/test-app-sentry/app/proguard-rules.pro create mode 100644 performance-tests/test-app-sentry/app/src/main/AndroidManifest.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/java/io/sentry/java/tests/perf/appsentry/FirstFragment.java create mode 100644 performance-tests/test-app-sentry/app/src/main/java/io/sentry/java/tests/perf/appsentry/MainActivity.java create mode 100644 performance-tests/test-app-sentry/app/src/main/java/io/sentry/java/tests/perf/appsentry/SecondFragment.java create mode 100644 performance-tests/test-app-sentry/app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/layout/activity_main.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/layout/content_main.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/layout/fragment_first.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/layout/fragment_second.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/menu/menu_main.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 performance-tests/test-app-sentry/app/src/main/res/navigation/nav_graph.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/values-land/dimens.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/values-night/themes.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/values-w1240dp/dimens.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/values-w600dp/dimens.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/values/colors.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/values/dimens.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/values/strings.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/values/themes.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/xml/backup_rules.xml create mode 100644 performance-tests/test-app-sentry/app/src/main/res/xml/data_extraction_rules.xml create mode 100644 performance-tests/test-app-sentry/build.gradle create mode 100644 performance-tests/test-app-sentry/gradle.properties create mode 100644 performance-tests/test-app-sentry/gradle/wrapper/gradle-wrapper.jar create mode 100644 performance-tests/test-app-sentry/gradle/wrapper/gradle-wrapper.properties create mode 100644 performance-tests/test-app-sentry/gradlew create mode 100644 performance-tests/test-app-sentry/gradlew.bat create mode 100644 performance-tests/test-app-sentry/settings.gradle diff --git a/performance-tests/README.md b/performance-tests/README.md new file mode 100644 index 00000000000..0e98adbd35f --- /dev/null +++ b/performance-tests/README.md @@ -0,0 +1,5 @@ +# Android performance-impact tests + +* [Empty app](./test-app-plain) created with Android Studio -> New Project -> Basic Activity +* [Same app, but with Sentry included](./test-app-sentry) created with Android Studio -> New Project -> Basic Activity +* [Appium based tests](./appium/) diff --git a/performance-tests/appium/README.md b/performance-tests/appium/README.md deleted file mode 100644 index 631142a9198..00000000000 --- a/performance-tests/appium/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Android performance-impact tests - -Run `mvn clean test` to execute in SauceLabs. diff --git a/performance-tests/test-app-plain/.gitignore b/performance-tests/test-app-plain/.gitignore new file mode 100644 index 00000000000..aa724b77071 --- /dev/null +++ b/performance-tests/test-app-plain/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/performance-tests/test-app-plain/app/.gitignore b/performance-tests/test-app-plain/app/.gitignore new file mode 100644 index 00000000000..42afabfd2ab --- /dev/null +++ b/performance-tests/test-app-plain/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/build.gradle b/performance-tests/test-app-plain/app/build.gradle new file mode 100644 index 00000000000..d4bd6a2e3d8 --- /dev/null +++ b/performance-tests/test-app-plain/app/build.gradle @@ -0,0 +1,37 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdk 32 + + defaultConfig { + applicationId "io.sentry.java.tests.perf.appplain" + minSdk 21 + targetSdk 32 + versionCode 1 + versionName "1.0" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + buildFeatures { + viewBinding true + } +} + +dependencies { + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.navigation:navigation-fragment:2.3.5' + implementation 'androidx.navigation:navigation-ui:2.3.5' +} \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/proguard-rules.pro b/performance-tests/test-app-plain/app/proguard-rules.pro new file mode 100644 index 00000000000..481bb434814 --- /dev/null +++ b/performance-tests/test-app-plain/app/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 \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/src/main/AndroidManifest.xml b/performance-tests/test-app-plain/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..85c4f7ca430 --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/FirstFragment.java b/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/FirstFragment.java new file mode 100644 index 00000000000..8e2b4ba360a --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/FirstFragment.java @@ -0,0 +1,47 @@ +package io.sentry.java.tests.perf.appplain; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +import io.sentry.java.tests.perf.appplain.databinding.FragmentFirstBinding; + +public class FirstFragment extends Fragment { + + private FragmentFirstBinding binding; + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + + binding = FragmentFirstBinding.inflate(inflater, container, false); + return binding.getRoot(); + + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + binding.buttonFirst.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(FirstFragment.this) + .navigate(R.id.action_FirstFragment_to_SecondFragment); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + +} \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/MainActivity.java b/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/MainActivity.java new file mode 100644 index 00000000000..9365dc11109 --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/MainActivity.java @@ -0,0 +1,76 @@ +package io.sentry.java.tests.perf.appplain; + +import android.os.Bundle; + +import com.google.android.material.snackbar.Snackbar; + +import androidx.appcompat.app.AppCompatActivity; + +import android.view.View; + +import androidx.navigation.NavController; +import androidx.navigation.Navigation; +import androidx.navigation.ui.AppBarConfiguration; +import androidx.navigation.ui.NavigationUI; + +import io.sentry.java.tests.perf.appplain.databinding.ActivityMainBinding; + +import android.view.Menu; +import android.view.MenuItem; + +public class MainActivity extends AppCompatActivity { + + private AppBarConfiguration appBarConfiguration; + private ActivityMainBinding binding; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + binding = ActivityMainBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + setSupportActionBar(binding.toolbar); + + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main); + appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build(); + NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); + + binding.fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + public boolean onSupportNavigateUp() { + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main); + return NavigationUI.navigateUp(navController, appBarConfiguration) + || super.onSupportNavigateUp(); + } +} \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/SecondFragment.java b/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/SecondFragment.java new file mode 100644 index 00000000000..afc41e26b29 --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/java/io/sentry/java/tests/perf/appplain/SecondFragment.java @@ -0,0 +1,47 @@ +package io.sentry.java.tests.perf.appplain; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +import io.sentry.java.tests.perf.appplain.databinding.FragmentSecondBinding; + +public class SecondFragment extends Fragment { + + private FragmentSecondBinding binding; + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + + binding = FragmentSecondBinding.inflate(inflater, container, false); + return binding.getRoot(); + + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + binding.buttonSecond.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(SecondFragment.this) + .navigate(R.id.action_SecondFragment_to_FirstFragment); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + +} \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/performance-tests/test-app-plain/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000000..2b068d11462 --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/src/main/res/drawable/ic_launcher_background.xml b/performance-tests/test-app-plain/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000000..07d5da9cbf1 --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/performance-tests/test-app-plain/app/src/main/res/layout/activity_main.xml b/performance-tests/test-app-plain/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000000..4d4bbbfbdd2 --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/src/main/res/layout/content_main.xml b/performance-tests/test-app-plain/app/src/main/res/layout/content_main.xml new file mode 100644 index 00000000000..e416e1c18d5 --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/res/layout/content_main.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/performance-tests/test-app-plain/app/src/main/res/layout/fragment_first.xml b/performance-tests/test-app-plain/app/src/main/res/layout/fragment_first.xml new file mode 100644 index 00000000000..fb44a3d9176 --- /dev/null +++ b/performance-tests/test-app-plain/app/src/main/res/layout/fragment_first.xml @@ -0,0 +1,28 @@ + + + + + +