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

This commit is contained in:
keyonghan
2021-08-25 20:36:02 -07:00
committed by GitHub
parent 0a5f06a4fa
commit d36f246dcc
3 changed files with 9 additions and 6 deletions

View File

@@ -90,6 +90,7 @@ class Cocoon {
String? gitBranch,
String? builderName,
String? testStatus,
String? builderBucket,
}) async {
Map<String, dynamic> resultsJson = <String, dynamic>{};
if (resultsPath != null) {
@@ -102,7 +103,7 @@ class Cocoon {
resultsJson['NewStatus'] = testStatus;
}
resultsJson['TestFlaky'] = isTestFlaky ?? false;
if (_shouldUpdateCocoon(resultsJson)) {
if (_shouldUpdateCocoon(resultsJson, builderBucket: builderBucket)) {
await retry(
() async => _sendUpdateTaskRequest(resultsJson).timeout(Duration(seconds: requestTimeoutLimit)),
retryIf: (Exception e) => e is SocketException || e is TimeoutException || e is ClientException,
@@ -112,10 +113,9 @@ class 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'];
return supportedBranches.contains(resultJson['CommitBranch']) &&
!resultJson['BuilderName'].toString().toLowerCase().contains('staging');
return supportedBranches.contains(resultJson['CommitBranch']) && builderBucket != 'staging';
}
/// Write the given parameters into an update task request and store the JSON in [resultsPath].