Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions agent/lib/src/agent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class Agent {
return JSON.decode(resp.body);
}

Future<Null> uploadLogChunk(CocoonTask task, String chunk) async {
String url = '$baseCocoonUrl/api/append-log?ownerKey=${task.key}';
Future<Null> uploadLogChunk(String taskKey, String chunk) async {
String url = '$baseCocoonUrl/api/append-log?ownerKey=${taskKey}';
Response resp = await httpClient.post(url, body: chunk);
if (resp.statusCode != 200) {
throw 'Failed uploading log chunk. Server responded with HTTP status ${resp.statusCode}\n'
Expand Down Expand Up @@ -102,7 +102,8 @@ class Agent {
await _cocoon('update-task-status', status);
}

Future<Null> reportFailure(String taskKey) async {
Future<Null> reportFailure(String taskKey, String reason) async {
await uploadLogChunk(taskKey, '\n\nTask failed with the following reason:\n$reason\n');
await _cocoon('update-task-status', {
'TaskKey': taskKey,
'NewStatus': 'Failed',
Expand Down
7 changes: 4 additions & 3 deletions agent/lib/src/commands/ci.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class ContinuousIntegrationCommand extends Command {
await _runTask(task);
}
} catch(error, stackTrace) {
print('ERROR: $error\n$stackTrace');
await agent.reportFailure(task.key);
String errorMessage = 'ERROR: $error\n$stackTrace';
print(errorMessage);
await agent.reportFailure(task.key, errorMessage);
}
} catch(error, stackTrace) {
print('ERROR: $error\n$stackTrace');
Expand All @@ -102,7 +103,7 @@ class ContinuousIntegrationCommand extends Command {
await agent.reportSuccess(task.key, result.data, result.benchmarkScoreKeys);
await _uploadDataToFirebase(task, result);
} else {
await agent.reportFailure(task.key);
await agent.reportFailure(task.key, result.reason);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion agent/lib/src/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Future<TaskResult> runTask(Agent agent, CocoonTask task) async {
if (flush || buffer.length > _kLogChunkSize) {
String chunk = buffer.toString();
buffer = new StringBuffer();
await agent.uploadLogChunk(task, chunk);
await agent.uploadLogChunk(task.key, chunk);
}
}

Expand Down