Skip to content

Commit

Permalink
Reporting all issues with taskExecutionId on the console of attester
Browse files Browse the repository at this point in the history
This commit makes sure all issues with taskExecutionId are reported on the
console of the attester server.
It also fixes a case in which a task could be re-executed even when it did
not fail.
  • Loading branch information
divdavem committed Oct 5, 2016
1 parent 098957b commit b20a5eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/test-server/client/slave-client.js
Expand Up @@ -187,7 +187,9 @@
var checkTaskExecutionId = function (scope, name) {
var res = currentTask && scope.__taskExecutionId === currentTask.taskExecutionId;
if (!res) {
log("<i>warning</i> ignoring call to attester." + name + " for a task that is not valid.");
var message = "ignoring call to attester." + name + " for a task that is not (or no longer) valid.";
reportLogToServer("warn", [message]);
log("<i>warning</i> " + message);
}
return res;
};
Expand Down
18 changes: 11 additions & 7 deletions lib/test-server/slave-server.js
Expand Up @@ -201,12 +201,12 @@ Slave.prototype.assignTask = function (campaign, task) {

Slave.prototype.onTestUpdate = function (event, taskExecutionId) {
var eventName = event.event;
if (eventName == "error" && this.config.taskRestartOnFailure) {
this.currentTaskRestartPlanned = true;
if (!this.checkTaskExecutionId(taskExecutionId, eventName)) {
return;
}
if (allowedTestUpdateEvents.hasOwnProperty(eventName)) {
if (!this.checkTaskExecutionId(taskExecutionId)) {
return;
if (eventName == "error" && this.config.taskRestartOnFailure) {
this.currentTaskRestartPlanned = true;
}
feedEventWithTaskData(event, this.currentTask);
this.currentCampaign.addResult(event);
Expand Down Expand Up @@ -257,14 +257,18 @@ Slave.prototype.onClientLog = function (event, taskExecutionId) {
};

Slave.prototype.onTaskFinished = function (taskExecutionId) {
if (!this.checkTaskExecutionId(taskExecutionId)) {
if (!this.checkTaskExecutionId(taskExecutionId, "taskFinished")) {
return;
}
campaignTaskFinished(this);
};

Slave.prototype.checkTaskExecutionId = function (taskExecutionId) {
return taskExecutionId === this.taskExecutionId;
Slave.prototype.checkTaskExecutionId = function (taskExecutionId, eventName) {
var res = taskExecutionId === this.taskExecutionId;
if (!res) {
this.logger.logWarn("Ignoring %s event from a previous task, not filtered by the client.", [eventName]);
}
return res;
};

Slave.prototype.disconnect = function () {
Expand Down

0 comments on commit b20a5eb

Please sign in to comment.