[devicelab] Add results path flag to test runner#72765
[devicelab] Add results path flag to test runner#72765CaseyHillers merged 3 commits intoflutter:masterfrom
Conversation
| /// | ||
| /// If passed along with a task name, the Cocoon test results will be stored in this file. | ||
| /// If passed without a task name, the file contents will be uploaded to Cocoon. | ||
| String resultsPath; |
There was a problem hiding this comment.
Can we separate the functionality with commands? eg
- run.dart test ...
- run.dart upload_metrics ...
That way we can extend this file later with a compile command to optimize the resources usage.
There was a problem hiding this comment.
I created a separate bin/test_runner.dart to reduce the complexity of the migration, and only added upload-metrics for now. Once we have migrated off of Cocoon agents, we can remove the global args code in bin/run.dart.
I can follow up in another PR with the test command.
| final Map<String, dynamic> response = await _sendCocoonRequest('update-task-status', updateRequest); | ||
| if (response['Name'] != null) { | ||
| logger.info('Updated Cocoon with results from this task'); | ||
| } else { | ||
| logger.info(response); | ||
| logger.severe('Failed to updated Cocoon with results from this task'); | ||
| } |
There was a problem hiding this comment.
Nit: make this block of code a sub function so that both sendResultsPath and sendTaskResult can share.
| result: result, | ||
| ); | ||
| final File resultFile = fs.file(resultsPath); | ||
| if (resultFile.existsSync()) { |
There was a problem hiding this comment.
shall we try removing and creating again? Otherwise, we will lose metrics from this task run.
There was a problem hiding this comment.
Done. It'll delete and recreate the file.
keyonghan
left a comment
There was a problem hiding this comment.
LGTM. Leave final approval to @godofredoc
Description
luci-authcan only guarantee service account tokens are valid for 3 minutes after minted. These tokens can last up to 45 minutes. There's a race condition where when a test has finished, it's token is no longer valid.To fix this, we need to split the recipe to:
(1) Run devicelab test
(2) Write results to a file
(3) Request token from
luci-auth(4) Upload results from file to Cocoon
Since this is running in prod, this adds some complexity for the migration period. Once the recipe and branched recipes are using this method we can remove the extra branching logic. This is expected to be a no-op until enabled in the recipe.
Related Issues
#72457
Tests
Added tests to validate the json body being written to the file and that
Cocooncan upload results from a file.