Skip to content

Commit 79f377d

Browse files
author
Casey Hillers
authored
[devicelab] Only upload results on master (flutter#87125)
1 parent 889ab83 commit 79f377d

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

dev/devicelab/lib/framework/cocoon.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ class Cocoon {
9898
resultsJson['NewStatus'] = testStatus;
9999
}
100100
resultsJson['TestFlaky'] = isTestFlaky ?? false;
101-
await _sendUpdateTaskRequest(resultsJson);
101+
const List<String> supportedBranches = <String>['master'];
102+
if(supportedBranches.contains(resultsJson['CommitBranch'])) {
103+
await _sendUpdateTaskRequest(resultsJson);
104+
}
102105
}
103106

104107
/// Write the given parameters into an update task request and store the JSON in [resultsPath].

dev/devicelab/test/cocoon_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,31 @@ void main() {
178178
expect(() => cocoon.sendResultsPath(resultsPath: resultsPath),
179179
throwsA(isA<ClientException>()));
180180
});
181+
182+
test('does not upload results on non-supported branches', () async {
183+
// Any network failure would cause the upoad to fail
184+
mockClient = MockClient((Request request) async => Response('', 500));
185+
186+
cocoon = Cocoon(
187+
serviceAccountTokenPath: serviceAccountTokenPath,
188+
fs: fs,
189+
httpClient: mockClient,
190+
requestRetryLimit: 0,
191+
);
192+
193+
const String resultsPath = 'results.json';
194+
const String updateTaskJson = '{'
195+
'"CommitBranch":"stable",'
196+
'"CommitSha":"$commitSha",'
197+
'"BuilderName":"builderAbc",'
198+
'"NewStatus":"Succeeded",'
199+
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
200+
'"BenchmarkScoreKeys":["i","j"]}';
201+
fs.file(resultsPath).writeAsStringSync(updateTaskJson);
202+
203+
// This will fail if it decided to upload results
204+
await cocoon.sendResultsPath(resultsPath: resultsPath);
205+
});
181206
});
182207

183208
group('AuthenticatedCocoonClient', () {

0 commit comments

Comments
 (0)