Skip to content

[devicelab] Add results path flag to test runner#72765

Merged
CaseyHillers merged 3 commits intoflutter:masterfrom
CaseyHillers:test-results
Dec 23, 2020
Merged

[devicelab] Add results path flag to test runner#72765
CaseyHillers merged 3 commits intoflutter:masterfrom
CaseyHillers:test-results

Conversation

@CaseyHillers
Copy link
Contributor

Description

luci-auth can 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 Cocoon can upload results from a file.

@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Dec 22, 2020
@google-cla google-cla bot added the cla: yes label Dec 22, 2020
///
/// 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +108 to +114
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');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: make this block of code a sub function so that both sendResultsPath and sendTaskResult can share.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

result: result,
);
final File resultFile = fs.file(resultsPath);
if (resultFile.existsSync()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we try removing and creating again? Otherwise, we will lose metrics from this task run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It'll delete and recreate the file.

Copy link
Contributor

@keyonghan keyonghan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Leave final approval to @godofredoc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants