From a228a17c57976eeabb0655b0f0ed8e3b4e7787f2 Mon Sep 17 00:00:00 2001 From: Casey Hillers Date: Tue, 17 Nov 2020 11:28:03 -0800 Subject: [PATCH] [devicelab] LUCI builder flag (#70702) --- dev/devicelab/bin/run.dart | 16 ++++++++++++++-- dev/devicelab/lib/framework/cocoon.dart | 4 ++-- dev/devicelab/test/cocoon_test.dart | 4 ++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dev/devicelab/bin/run.dart b/dev/devicelab/bin/run.dart index 2b34d5ec84..41903c66ec 100644 --- a/dev/devicelab/bin/run.dart +++ b/dev/devicelab/bin/run.dart @@ -30,6 +30,12 @@ String localEngine; /// The path to the engine "src/" directory. String localEngineSrcPath; +/// Name of the LUCI builder this test is currently running on. +/// +/// This is only passed on CI runs for Cocoon to be able to uniquely identify +/// this test run. +String luciBuilder; + /// Whether to exit on first test failure. bool exitOnFirstTestFailure; @@ -81,9 +87,10 @@ Future main(List rawArgs) async { } deviceId = args['device-id'] as String; + exitOnFirstTestFailure = args['exit'] as bool; localEngine = args['local-engine'] as String; localEngineSrcPath = args['local-engine-src-path'] as String; - exitOnFirstTestFailure = args['exit'] as bool; + luciBuilder = args['luci-builder'] as String; serviceAccountTokenFile = args['service-account-token-file'] as String; silent = args['silent'] as bool; @@ -111,7 +118,8 @@ Future _runTasks() async { if (serviceAccountTokenFile != null) { final Cocoon cocoon = Cocoon(serviceAccountTokenPath: serviceAccountTokenFile); - await cocoon.sendTaskResult(taskName: taskName, result: result); + /// Cocoon references LUCI tasks by the [luciBuilder] instead of [taskName]. + await cocoon.sendTaskResult(builderName: luciBuilder, result: result); } if (!result.succeeded) { @@ -338,6 +346,10 @@ final ArgParser _argParser = ArgParser() 'locally. Defaults to \$FLUTTER_ENGINE if set, or tries to guess at\n' 'the location based on the value of the --flutter-root option.', ) + ..addOption( + 'luci-builder', + help: '[Flutter infrastructure] Name of the LUCI builder being run on.' + ) ..addFlag( 'match-host-platform', defaultsTo: true, diff --git a/dev/devicelab/lib/framework/cocoon.dart b/dev/devicelab/lib/framework/cocoon.dart index 8811500bc6..01f509be7d 100644 --- a/dev/devicelab/lib/framework/cocoon.dart +++ b/dev/devicelab/lib/framework/cocoon.dart @@ -75,7 +75,7 @@ class Cocoon { } /// Send [TaskResult] to Cocoon. - Future sendTaskResult({String taskName, TaskResult result}) async { + Future sendTaskResult({String builderName, TaskResult result}) async { // Skip logging on test runs Logger.root.level = Level.ALL; Logger.root.onRecord.listen((LogRecord rec) { @@ -85,7 +85,7 @@ class Cocoon { final Map status = { 'CommitBranch': commitBranch, 'CommitSha': commitSha, - 'TaskName': taskName, + 'BuilderName': builderName, 'NewStatus': result.succeeded ? 'Succeeded' : 'Failed', }; diff --git a/dev/devicelab/test/cocoon_test.dart b/dev/devicelab/test/cocoon_test.dart index 21d8cff4f9..467cc67567 100644 --- a/dev/devicelab/test/cocoon_test.dart +++ b/dev/devicelab/test/cocoon_test.dart @@ -93,7 +93,7 @@ void main() { final TaskResult result = TaskResult.success({}); // This should not throw an error. - await cocoon.sendTaskResult(taskName: 'taskAbc', result: result); + await cocoon.sendTaskResult(builderName: 'builderAbc', result: result); }); test('throws client exception on non-200 responses', () async { @@ -106,7 +106,7 @@ void main() { ); final TaskResult result = TaskResult.success({}); - expect(() => cocoon.sendTaskResult(taskName: 'taskAbc', result: result), throwsA(isA())); + expect(() => cocoon.sendTaskResult(builderName: 'builderAbc', result: result), throwsA(isA())); }); });