Skip to content

Commit 3cb04ff

Browse files
authored
Shard firebase_test_lab_tests (flutter#56594)
1 parent e04450c commit 3cb04ff

File tree

3 files changed

+55
-19
lines changed

3 files changed

+55
-19
lines changed

.cirrus.yml

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# CIRRUS CONFIGURATION FILE
22
# https://cirrus-ci.org/guide/writing-tasks/
33

4+
# YAML anchors used to share fields between tasks.
5+
# See https://confluence.atlassian.com/bitbucket/yaml-anchors-960154027.html
46
web_shard_template: &WEB_SHARD_TEMPLATE
57
only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'packages/flutter_web_plugins/**', 'bin/internal/**') || $CIRRUS_PR == ''"
68
environment:
@@ -32,6 +34,18 @@ macos_shard_template: &MACOS_SHARD_TEMPLATE
3234
- ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
3335
- dart --enable-asserts ./dev/bots/test.dart
3436

37+
firebase_shard_template: &FIREBASE_SHARD_TEMPLATE
38+
environment:
39+
# Empirically, this shard runs in 20-25 minutes with just one CPU and 4G of RAM, as of
40+
# October 2019. It does not seem to be sensitive to the number of CPUs or amount of RAM;
41+
# doubling CPUs had no effect (mere seconds under 20 minutes), increasing RAM to 24G left it
42+
# on the high end of the 20-25 minute range. (This makes sense, as it's just driving the
43+
# Firebase test lab remotely.) Less than 4G of RAM made it go OOM.
44+
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
45+
GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[1c140257edc48f5578fa5a0e5038b84c8e53270c405efa5a8e35ea303a4e0d135853989f448f72136206de854d17fbec]
46+
script:
47+
- dart --enable-asserts ./dev/bots/test.dart
48+
3549
use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'
3650

3751
environment:
@@ -268,17 +282,15 @@ task:
268282
- git clone https://github.com/flutter/tests.git bin/cache/pkg/tests
269283
- dart --enable-asserts dev/customer_testing/run_tests.dart --skip-on-fetch-failure --skip-template bin/cache/pkg/tests/registry/*.test
270284

271-
- name: firebase_test_lab_tests-linux # linux-only
272-
environment:
273-
# Empirically, this shard runs in 20-25 minutes with just one CPU and 4G of RAM, as of
274-
# October 2019. It does not seem to be sensitive to the number of CPUs or amount of RAM;
275-
# doubling CPUs had no effect (mere seconds under 20 minutes), increasing RAM to 24G left it
276-
# on the high end of the 20-25 minute range. (This makes sense, as it's just driving the
277-
# Firebase test lab remotely.) Less than 4G of RAM made it go OOM.
278-
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
279-
GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[1c140257edc48f5578fa5a0e5038b84c8e53270c405efa5a8e35ea303a4e0d135853989f448f72136206de854d17fbec]
280-
script:
281-
- ./dev/bots/firebase_testlab.sh
285+
# firebase_test_lab_tests are linux-only
286+
- name: firebase_test_lab_tests-0-linux
287+
<<: *FIREBASE_SHARD_TEMPLATE
288+
289+
- name: firebase_test_lab_tests-1-linux
290+
<<: *FIREBASE_SHARD_TEMPLATE
291+
292+
- name: firebase_test_lab_tests-2-linux
293+
<<: *FIREBASE_SHARD_TEMPLATE
282294

283295
- name: web_smoke_test
284296
only_if: "changesInclude('.cirrus.yml', 'examples/hello_world/**' ,'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'packages/flutter_web_plugins/**', 'bin/internal/**') || $CIRRUS_PR == ''"

dev/bots/firebase_testlab.sh

+3-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
# that the app doesn't crash upon startup.
99
#
1010
# When adding a test, ensure that there's at least a `print()` statement under lib/*.dart.
11-
tests=(
12-
"dev/integration_tests/release_smoke_test"
13-
"dev/integration_tests/abstract_method_smoke_test"
14-
"dev/integration_tests/android_embedding_v2_smoke_test"
15-
)
11+
#
12+
# The first and only parameter should be the path to an integration test.
1613

1714
# The devices where the tests are run.
1815
#
@@ -79,6 +76,4 @@ function test_app_bundle() {
7976
popd
8077
}
8178

82-
for test in ${tests[*]}; do
83-
test_app_bundle $test
84-
done
79+
test_app_bundle "$1"

dev/bots/test.dart

+29
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Future<void> main(List<String> args) async {
118118
'add_to_app_tests': _runAddToAppTests,
119119
'add_to_app_life_cycle_tests': _runAddToAppLifeCycleTests,
120120
'build_tests': _runBuildTests,
121+
'firebase_test_lab_tests': _runFirebaseTestLabTests,
121122
'framework_coverage': _runFrameworkCoverage,
122123
'framework_tests': _runFrameworkTests,
123124
'hostonly_devicelab_tests': _runHostOnlyDeviceLabTests,
@@ -634,6 +635,34 @@ Future<void> _runFrameworkTests() async {
634635
});
635636
}
636637

638+
Future<void> _runFirebaseTestLabTests() async {
639+
// Firebase Lab tests take ~20 minutes per integration test,
640+
// so only one test is run per shard. Therefore, there are as
641+
// many shards available as there are integration tests in this list.
642+
// If you add a new test, add a corresponding firebase_test_lab-#-linux
643+
// to .cirrus.yml
644+
final List<String> integrationTests = <String>[
645+
'release_smoke_test',
646+
'abstract_method_smoke_test',
647+
'android_embedding_v2_smoke_test',
648+
];
649+
final Map<String, ShardRunner> subshards = <String, ShardRunner>{};
650+
651+
final String firebaseScript = path.join(flutterRoot, 'dev', 'bots', 'firebase_testlab.sh');
652+
final String integrationTestDirectory = path.join(flutterRoot, 'dev', 'integration_tests');
653+
654+
for (int index = 0; index < integrationTests.length; index += 1) {
655+
final String integrationTestPath = path.join(integrationTestDirectory, integrationTests[index]);
656+
subshards['$index'] = () => runCommand(
657+
firebaseScript,
658+
<String>[ integrationTestPath ],
659+
workingDirectory: flutterRoot,
660+
);
661+
}
662+
663+
await selectSubshard(subshards);
664+
}
665+
637666
Future<void> _runFrameworkCoverage() async {
638667
final File coverageFile = File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info'));
639668
if (!coverageFile.existsSync()) {

0 commit comments

Comments
 (0)