Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e311e3b3
Unverified
Commit
e311e3b3
authored
Aug 30, 2021
by
keyonghan
Committed by
GitHub
Aug 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
skip staging update (#89137)
parent
0c65de16
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
28 deletions
+61
-28
upload_results.dart
dev/devicelab/lib/command/upload_results.dart
+8
-12
cocoon.dart
dev/devicelab/lib/framework/cocoon.dart
+12
-6
metrics_center.dart
dev/devicelab/lib/framework/metrics_center.dart
+8
-2
cocoon_test.dart
dev/devicelab/test/cocoon_test.dart
+33
-8
No files found.
dev/devicelab/lib/command/upload_results.dart
View file @
e311e3b3
...
...
@@ -24,6 +24,7 @@ class UploadResultsCommand extends Command<void> {
argParser
.
addOption
(
'task-name'
,
help:
'[Flutter infrastructure] Name of the task being run on.'
);
argParser
.
addOption
(
'test-status'
,
help:
'Test status: Succeeded|Failed'
);
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
...
...
@@ -42,27 +43,22 @@ class UploadResultsCommand extends Command<void> {
final
String
?
testStatus
=
argResults
![
'test-status'
]
as
String
?;
final
String
?
commitTime
=
argResults
![
'commit-time'
]
as
String
?;
final
String
?
taskName
=
argResults
![
'task-name'
]
as
String
?;
final
String
?
builderBucket
=
argResults
![
'builder-bucket'
]
as
String
?;
// Upload metrics to metrics_center from test runner when `commitTime` is specified. This
// is mainly for testing purpose.
// The upload step will be skipped from cocoon once this is validated.
// TODO(keyong): remove try block to block test when this is validated to work https://github.com/flutter/flutter/issues/88484
try
{
if
(
commitTime
!=
null
)
{
await
uploadToMetricsCenter
(
resultsPath
,
commitTime
,
taskName
);
print
(
'Successfully uploaded metrics to metrics center'
);
}
}
on
Exception
catch
(
e
,
stacktrace
)
{
print
(
'Uploading metrics failure:
$e
\n\n
$stacktrace
'
);
// Upload metrics to skia perf from test runner when `resultsPath` is specified.
if
(
resultsPath
!=
null
)
{
await
uploadToSkiaPerf
(
resultsPath
,
commitTime
,
taskName
);
print
(
'Successfully uploaded metrics to skia perf'
);
}
final
Cocoon
cocoon
=
Cocoon
(
serviceAccountTokenPath:
serviceAccountTokenFile
);
return
cocoon
.
send
ResultsPath
(
return
cocoon
.
send
TaskStatus
(
resultsPath:
resultsPath
,
isTestFlaky:
testFlakyStatus
==
'True'
,
gitBranch:
gitBranch
,
builderName:
builderName
,
testStatus:
testStatus
,
builderBucket:
builderBucket
,
);
}
}
dev/devicelab/lib/framework/cocoon.dart
View file @
e311e3b3
...
...
@@ -75,21 +75,22 @@ class Cocoon {
return
_commitSha
=
result
.
stdout
as
String
;
}
/// Up
load the JSON results in [resultsPath]
to Cocoon.
/// Up
date test status
to Cocoon.
///
/// Flutter infrastructure's workflow is:
/// 1. Run DeviceLab test
, writing results to a known path
/// 1. Run DeviceLab test
/// 2. Request service account token from luci auth (valid for at least 3 minutes)
/// 3. Up
load result
s from (1) to Cocoon
/// 3. Up
date test statu
s from (1) to Cocoon
///
/// The `resultsPath` is not available for all tests. When it doesn't show up, we
/// need to append `CommitBranch`, `CommitSha`, and `BuilderName`.
Future
<
void
>
send
ResultsPath
({
Future
<
void
>
send
TaskStatus
({
String
?
resultsPath
,
bool
?
isTestFlaky
,
String
?
gitBranch
,
String
?
builderName
,
String
?
testStatus
,
String
?
builderBucket
,
})
async
{
Map
<
String
,
dynamic
>
resultsJson
=
<
String
,
dynamic
>{};
if
(
resultsPath
!=
null
)
{
...
...
@@ -102,8 +103,7 @@ class Cocoon {
resultsJson
[
'NewStatus'
]
=
testStatus
;
}
resultsJson
[
'TestFlaky'
]
=
isTestFlaky
??
false
;
const
List
<
String
>
supportedBranches
=
<
String
>[
'master'
];
if
(
supportedBranches
.
contains
(
resultsJson
[
'CommitBranch'
]))
{
if
(
_shouldUpdateCocoon
(
resultsJson
,
builderBucket
??
'prod'
))
{
await
retry
(
()
async
=>
_sendUpdateTaskRequest
(
resultsJson
).
timeout
(
Duration
(
seconds:
requestTimeoutLimit
)),
retryIf:
(
Exception
e
)
=>
e
is
SocketException
||
e
is
TimeoutException
||
e
is
ClientException
,
...
...
@@ -112,6 +112,12 @@ class Cocoon {
}
}
/// Only post-submit tests on `master` are allowed to update in cocoon.
bool
_shouldUpdateCocoon
(
Map
<
String
,
dynamic
>
resultJson
,
String
builderBucket
)
{
const
List
<
String
>
supportedBranches
=
<
String
>[
'master'
];
return
supportedBranches
.
contains
(
resultJson
[
'CommitBranch'
])
&&
builderBucket
==
'prod'
;
}
/// Write the given parameters into an update task request and store the JSON in [resultsPath].
Future
<
void
>
writeTaskResultToFile
({
String
?
builderName
,
...
...
dev/devicelab/lib/framework/metrics_center.dart
View file @
e311e3b3
...
...
@@ -45,6 +45,7 @@ Future<FlutterDestination> connectFlutterDestination() async {
/// ]
/// }
List
<
MetricPoint
>
parse
(
Map
<
String
,
dynamic
>
resultsJson
)
{
print
(
'Results to upload to skia perf:
$resultsJson
'
);
final
List
<
String
>
scoreKeys
=
(
resultsJson
[
'BenchmarkScoreKeys'
]
as
List
<
dynamic
>?)?.
cast
<
String
>()
??
const
<
String
>[];
final
Map
<
String
,
dynamic
>
resultData
=
...
...
@@ -95,8 +96,13 @@ Future<void> upload(
);
}
/// Upload test metrics to metrics center.
Future
<
void
>
uploadToMetricsCenter
(
String
?
resultsPath
,
String
?
commitTime
,
String
?
taskName
)
async
{
/// Upload JSON results to skia perf.
///
/// Flutter infrastructure's workflow is:
/// 1. Run DeviceLab test, writing results to a known path
/// 2. Request service account token from luci auth (valid for at least 3 minutes)
/// 3. Upload results from (1) to skia perf.
Future
<
void
>
uploadToSkiaPerf
(
String
?
resultsPath
,
String
?
commitTime
,
String
?
taskName
)
async
{
int
commitTimeSinceEpoch
;
if
(
resultsPath
==
null
)
{
return
;
...
...
dev/devicelab/test/cocoon_test.dart
View file @
e311e3b3
...
...
@@ -132,7 +132,7 @@ void main() {
'"ResultData":{},'
'"BenchmarkScoreKeys":[]}'
;
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
await
cocoon
.
send
ResultsPath
(
resultsPath:
resultsPath
);
await
cocoon
.
send
TaskStatus
(
resultsPath:
resultsPath
);
});
test
(
'uploads expected update task payload from results file'
,
()
async
{
...
...
@@ -154,7 +154,7 @@ void main() {
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
'"BenchmarkScoreKeys":["i","j"]}'
;
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
await
cocoon
.
send
ResultsPath
(
resultsPath:
resultsPath
);
await
cocoon
.
send
TaskStatus
(
resultsPath:
resultsPath
);
});
test
(
'Verify retries for task result upload'
,
()
async
{
...
...
@@ -186,7 +186,7 @@ void main() {
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
'"BenchmarkScoreKeys":["i","j"]}'
;
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
await
cocoon
.
send
ResultsPath
(
resultsPath:
resultsPath
);
await
cocoon
.
send
TaskStatus
(
resultsPath:
resultsPath
);
});
test
(
'Verify timeout and retry for task result upload'
,
()
async
{
...
...
@@ -221,7 +221,7 @@ void main() {
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
'"BenchmarkScoreKeys":["i","j"]}'
;
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
await
cocoon
.
send
ResultsPath
(
resultsPath:
resultsPath
);
await
cocoon
.
send
TaskStatus
(
resultsPath:
resultsPath
);
});
test
(
'Verify timeout does not trigger for result upload'
,
()
async
{
...
...
@@ -256,7 +256,7 @@ void main() {
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
'"BenchmarkScoreKeys":["i","j"]}'
;
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
await
cocoon
.
send
ResultsPath
(
resultsPath:
resultsPath
);
await
cocoon
.
send
TaskStatus
(
resultsPath:
resultsPath
);
});
test
(
'Verify failure without retries for task result upload'
,
()
async
{
...
...
@@ -288,7 +288,7 @@ void main() {
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
'"BenchmarkScoreKeys":["i","j"]}'
;
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
expect
(()
=>
cocoon
.
send
ResultsPath
(
resultsPath:
resultsPath
),
throwsA
(
isA
<
ClientException
>()));
expect
(()
=>
cocoon
.
send
TaskStatus
(
resultsPath:
resultsPath
),
throwsA
(
isA
<
ClientException
>()));
});
test
(
'throws client exception on non-200 responses'
,
()
async
{
...
...
@@ -310,7 +310,7 @@ void main() {
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
'"BenchmarkScoreKeys":["i","j"]}'
;
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
expect
(()
=>
cocoon
.
send
ResultsPath
(
resultsPath:
resultsPath
),
throwsA
(
isA
<
ClientException
>()));
expect
(()
=>
cocoon
.
send
TaskStatus
(
resultsPath:
resultsPath
),
throwsA
(
isA
<
ClientException
>()));
});
test
(
'does not upload results on non-supported branches'
,
()
async
{
...
...
@@ -335,7 +335,32 @@ void main() {
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
// This will fail if it decided to upload results
await
cocoon
.
sendResultsPath
(
resultsPath:
resultsPath
);
await
cocoon
.
sendTaskStatus
(
resultsPath:
resultsPath
);
});
test
(
'does not update for staging test'
,
()
async
{
// Any network failure would cause the upoad to fail
mockClient
=
MockClient
((
Request
request
)
async
=>
Response
(
''
,
500
));
cocoon
=
Cocoon
(
serviceAccountTokenPath:
serviceAccountTokenPath
,
fs:
fs
,
httpClient:
mockClient
,
requestRetryLimit:
0
,
);
const
String
resultsPath
=
'results.json'
;
const
String
updateTaskJson
=
'{'
'"CommitBranch":"master",'
'"CommitSha":"
$commitSha
",'
'"BuilderName":"builderAbc",'
'"NewStatus":"Succeeded",'
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
'"BenchmarkScoreKeys":["i","j"]}'
;
fs
.
file
(
resultsPath
).
writeAsStringSync
(
updateTaskJson
);
// This will fail if it decided to upload results
await
cocoon
.
sendTaskStatus
(
resultsPath:
resultsPath
,
builderBucket:
'staging'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment