Unverified Commit d36f246d authored by keyonghan's avatar keyonghan Committed by GitHub

Use bucket to check staging test instead of builder name (#88908)

parent 0a5f06a4
...@@ -23,6 +23,7 @@ class UploadResultsCommand extends Command<void> { ...@@ -23,6 +23,7 @@ class UploadResultsCommand extends Command<void> {
argParser.addOption('luci-builder', help: '[Flutter infrastructure] Name of the LUCI builder being run on.'); argParser.addOption('luci-builder', help: '[Flutter infrastructure] Name of the LUCI builder being run on.');
argParser.addOption('test-status', help: 'Test status: Succeeded|Failed'); argParser.addOption('test-status', help: 'Test status: Succeeded|Failed');
argParser.addOption('commit-time', help: 'Commit time in UNIX timestamp'); argParser.addOption('commit-time', help: 'Commit time in UNIX timestamp');
argParser.addOption('builder-bucket', help: '[Flutter infrastructure] Luci builder bucket the test is running in.');
} }
@override @override
...@@ -40,6 +41,7 @@ class UploadResultsCommand extends Command<void> { ...@@ -40,6 +41,7 @@ class UploadResultsCommand extends Command<void> {
final String? builderName = argResults!['luci-builder'] as String?; final String? builderName = argResults!['luci-builder'] as String?;
final String? testStatus = argResults!['test-status'] as String?; final String? testStatus = argResults!['test-status'] as String?;
final String? commitTime = argResults!['commit-time'] as String?; final String? commitTime = argResults!['commit-time'] as String?;
final String? builderBucket = argResults!['builder-bucket'] as String?;
// Upload metrics to skia perf from test runner when `resultsPath` is specified. // Upload metrics to skia perf from test runner when `resultsPath` is specified.
if (resultsPath != null) { if (resultsPath != null) {
...@@ -54,6 +56,7 @@ class UploadResultsCommand extends Command<void> { ...@@ -54,6 +56,7 @@ class UploadResultsCommand extends Command<void> {
gitBranch: gitBranch, gitBranch: gitBranch,
builderName: builderName, builderName: builderName,
testStatus: testStatus, testStatus: testStatus,
builderBucket: builderBucket,
); );
} }
} }
...@@ -90,6 +90,7 @@ class Cocoon { ...@@ -90,6 +90,7 @@ class Cocoon {
String? gitBranch, String? gitBranch,
String? builderName, String? builderName,
String? testStatus, String? testStatus,
String? builderBucket,
}) async { }) async {
Map<String, dynamic> resultsJson = <String, dynamic>{}; Map<String, dynamic> resultsJson = <String, dynamic>{};
if (resultsPath != null) { if (resultsPath != null) {
...@@ -102,7 +103,7 @@ class Cocoon { ...@@ -102,7 +103,7 @@ class Cocoon {
resultsJson['NewStatus'] = testStatus; resultsJson['NewStatus'] = testStatus;
} }
resultsJson['TestFlaky'] = isTestFlaky ?? false; resultsJson['TestFlaky'] = isTestFlaky ?? false;
if (_shouldUpdateCocoon(resultsJson)) { if (_shouldUpdateCocoon(resultsJson, builderBucket: builderBucket)) {
await retry( await retry(
() async => _sendUpdateTaskRequest(resultsJson).timeout(Duration(seconds: requestTimeoutLimit)), () async => _sendUpdateTaskRequest(resultsJson).timeout(Duration(seconds: requestTimeoutLimit)),
retryIf: (Exception e) => e is SocketException || e is TimeoutException || e is ClientException, retryIf: (Exception e) => e is SocketException || e is TimeoutException || e is ClientException,
...@@ -112,10 +113,9 @@ class Cocoon { ...@@ -112,10 +113,9 @@ class Cocoon {
} }
/// Only post-submit tests on `master` are allowed to update in cocoon. /// Only post-submit tests on `master` are allowed to update in cocoon.
bool _shouldUpdateCocoon(Map<String, dynamic> resultJson) { bool _shouldUpdateCocoon(Map<String, dynamic> resultJson, {String? builderBucket = 'prod'}) {
const List<String> supportedBranches = <String>['master']; const List<String> supportedBranches = <String>['master'];
return supportedBranches.contains(resultJson['CommitBranch']) && return supportedBranches.contains(resultJson['CommitBranch']) && builderBucket != 'staging';
!resultJson['BuilderName'].toString().toLowerCase().contains('staging');
} }
/// Write the given parameters into an update task request and store the JSON in [resultsPath]. /// Write the given parameters into an update task request and store the JSON in [resultsPath].
......
...@@ -353,14 +353,14 @@ void main() { ...@@ -353,14 +353,14 @@ void main() {
const String updateTaskJson = '{' const String updateTaskJson = '{'
'"CommitBranch":"master",' '"CommitBranch":"master",'
'"CommitSha":"$commitSha",' '"CommitSha":"$commitSha",'
'"BuilderName":"Linux_staging_test",' '"BuilderName":"builderAbc",'
'"NewStatus":"Succeeded",' '"NewStatus":"Succeeded",'
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},' '"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
'"BenchmarkScoreKeys":["i","j"]}'; '"BenchmarkScoreKeys":["i","j"]}';
fs.file(resultsPath).writeAsStringSync(updateTaskJson); fs.file(resultsPath).writeAsStringSync(updateTaskJson);
// This will fail if it decided to upload results // This will fail if it decided to upload results
await cocoon.sendTaskStatus(resultsPath: resultsPath); await cocoon.sendTaskStatus(resultsPath: resultsPath, builderBucket: 'staging');
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment