From b79821c01974cb4c17d0ead7e96a504a499803e7 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 7 Feb 2024 12:58:41 -0800 Subject: [PATCH] Fix Android `scenario_app` to actually run and block on CI (flutter/engine#50414) https://github.com/flutter/engine/pull/50414/commits/20337eaea438e505d4bd215b4e84362fa9935d2d (now reverted) intentionally re-introduced a bug (https://github.com/flutter/engine/pull/49938) on a now working test runner, and verified that (with some fixes in this PR), we can now catch regressions on CI with SkiaGold: ---
ExternalTextureTests_testCanvasSurface.png This test shows that what previously was a picture has been reduced down to a single stretched pixel. **BEFORE**: ![ExternalTextureTests_testCanvasSurface](https://github.com/flutter/engine/assets/168174/1509ea21-2887-4a3b-b200-b857bbfb8304) **AFTER**: ![ExternalTextureTests_testCanvasSurface](https://github.com/flutter/engine/assets/168174/d9ae19c8-dd39-4e7f-859c-5d82bd1ba0a3)
ExternalTextureTests_testRotatedMediaSurface_180.png Similar to above, but shows _another_ bug (kClamp versus kRepeat) **BEFORE**: ![ExternalTextureTests_testRotatedMediaSurface_180](https://github.com/flutter/engine/assets/168174/fee5bc8d-749f-4a59-976a-a573515fecea) **AFTER**: ![ExternalTextureTests_testRotatedMediaSurface_180](https://github.com/flutter/engine/assets/168174/a5249f70-22b4-4d36-8b63-e88c8a6846fe)/cc
--- This PR now makes the `scenario_test` useful and blocking for Android engine rolls: - Add support for connecting to SkiaGold by depending on `goldctl` in the appropriate configs. - Add some useful local debugging flags for skipping SkiaGold or running specific tests (not used by default). - Failing to connect to Skia gold is now a test failure. --- engine/src/flutter/.ci.yaml | 8 ++++ .../ci/builders/linux_android_emulator.json | 6 +++ .../linux_android_emulator_api_33.json | 6 +++ .../bin/android_integration_tests.dart | 39 ++++++++++++++----- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/engine/src/flutter/.ci.yaml b/engine/src/flutter/.ci.yaml index 45cbaacfe2..5d9d99027b 100644 --- a/engine/src/flutter/.ci.yaml +++ b/engine/src/flutter/.ci.yaml @@ -54,6 +54,10 @@ targets: recipe: engine_v2/engine_v2 properties: config_name: linux_android_emulator + dependencies: >- + [ + {"dependency": "goldctl", "version": "git_revision:720a542f6fe4f92922c3b8f0fdcc4d2ac6bb83cd"} + ] timeout: 60 runIf: - .ci.yaml @@ -71,6 +75,10 @@ targets: recipe: engine_v2/engine_v2 properties: config_name: linux_android_emulator_api_33 + dependencies: >- + [ + {"dependency": "goldctl", "version": "git_revision:720a542f6fe4f92922c3b8f0fdcc4d2ac6bb83cd"} + ] timeout: 60 runIf: - .ci.yaml diff --git a/engine/src/flutter/ci/builders/linux_android_emulator.json b/engine/src/flutter/ci/builders/linux_android_emulator.json index 4ef64af57e..643eb4da6c 100644 --- a/engine/src/flutter/ci/builders/linux_android_emulator.json +++ b/engine/src/flutter/ci/builders/linux_android_emulator.json @@ -17,6 +17,12 @@ "--rbe", "--no-goma" ], + "dependencies": [ + { + "dependency": "goldctl", + "version": "git_revision:720a542f6fe4f92922c3b8f0fdcc4d2ac6bb83cd" + } + ], "name": "android_debug_x64", "ninja": { "config": "android_debug_x64", diff --git a/engine/src/flutter/ci/builders/linux_android_emulator_api_33.json b/engine/src/flutter/ci/builders/linux_android_emulator_api_33.json index 3e518f1ab4..2457782fda 100644 --- a/engine/src/flutter/ci/builders/linux_android_emulator_api_33.json +++ b/engine/src/flutter/ci/builders/linux_android_emulator_api_33.json @@ -17,6 +17,12 @@ "--rbe", "--no-goma" ], + "dependencies": [ + { + "dependency": "goldctl", + "version": "git_revision:720a542f6fe4f92922c3b8f0fdcc4d2ac6bb83cd" + } + ], "name": "android_debug_x64", "ninja": { "config": "android_debug_x64", diff --git a/engine/src/flutter/testing/scenario_app/bin/android_integration_tests.dart b/engine/src/flutter/testing/scenario_app/bin/android_integration_tests.dart index 9517ee350d..07b31d0a4a 100644 --- a/engine/src/flutter/testing/scenario_app/bin/android_integration_tests.dart +++ b/engine/src/flutter/testing/scenario_app/bin/android_integration_tests.dart @@ -21,18 +21,23 @@ void main(List args) async { final ArgParser parser = ArgParser() ..addOption( 'adb', - help: 'absolute path to the adb tool', + help: 'Absolute path to the adb tool', mandatory: true, ) ..addOption( 'out-dir', - help: 'out directory', + help: 'Out directory', mandatory: true, ) - ..addFlag( + ..addOption( 'smoke-test', help: 'runs a single test to verify the setup', - negatable: false, + valueHelp: 'The class to execute, defaults to dev.flutter.scenarios.EngineLaunchE2ETest', + ) + ..addFlag( + 'use-skia-gold', + help: 'Use Skia Gold to compare screenshots.', + defaultsTo: isLuciEnv, ); runZonedGuarded( @@ -40,8 +45,17 @@ void main(List args) async { final ArgResults results = parser.parse(args); final Directory outDir = Directory(results['out-dir'] as String); final File adb = File(results['adb'] as String); - final bool smokeTest = results['smoke-test'] as bool; - await _run(outDir: outDir, adb: adb, smokeTest: smokeTest); + final bool useSkiaGold = results['use-skia-gold'] as bool; + String? smokeTest = results['smoke-test'] as String?; + if (results.wasParsed('smoke-test') && smokeTest!.isEmpty) { + smokeTest = 'dev.flutter.scenarios.EngineLaunchE2ETest'; + } + await _run( + outDir: outDir, + adb: adb, + smokeTestFullPath: smokeTest, + useSkiaGold: useSkiaGold, + ); exit(0); }, (Object error, StackTrace stackTrace) { @@ -57,7 +71,8 @@ void main(List args) async { Future _run({ required Directory outDir, required File adb, - required bool smokeTest, + required String? smokeTestFullPath, + required bool useSkiaGold, }) async { const ProcessManager pm = LocalProcessManager(); @@ -178,7 +193,11 @@ Future _run({ await skiaGoldClient!.auth(); log('skia gold client is available'); } else { - log('skia gold client is unavailable'); + if (useSkiaGold) { + panic(['skia gold client is unavailable']); + } else { + log('skia gold client is unavaialble'); + } } }); @@ -210,8 +229,8 @@ Future _run({ 'am', 'instrument', '-w', - if (smokeTest) - '-e class dev.flutter.scenarios.EngineLaunchE2ETest', + if (smokeTestFullPath != null) + '-e class $smokeTestFullPath', 'dev.flutter.scenarios.test/dev.flutter.TestRunner', ]); if (exitCode != 0) {