Skip to content

Commit

Permalink
#192 Executor test finally works
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeijer committed Feb 27, 2015
1 parent ba7b451 commit ca0442a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/middleware/executor/Executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ define(['logManager',
}
});

var workerRefreshInterval = 5 * 1000;
var workerRefreshInterval = typeof TESTING !== 'undefined' ? 100 : 5 * 1000;
// worker = { clientId:, lastSeen: }
var workerList = new DataStore({filename: workerListDBFile, autoload: true});
var workerTimeout = function () {
Expand Down
33 changes: 14 additions & 19 deletions test/middleware/executor/worker/node_worker.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*globals require, describe, it, before, after, WebGMEGlobal, WebGME, setInterval, clearInterval*/

/*jshint node:true*/
/**
* @author pmeijer / https://github.com/pmeijer
*/
Expand All @@ -16,8 +16,11 @@ var requirejs = require('requirejs'),
executorClient,
server,
nodeWorkerProcess,
jobScriptName = process.platform.indexOf('win') > -1 ? 'script.cmd' : 'script.sh',
serverBaseUrl;



describe('NodeWorker', function () {
'use strict';

Expand Down Expand Up @@ -94,16 +97,18 @@ describe('NodeWorker', function () {
});
});

it('createJob with cmd exit and args 0 should succeed', function (done) {
it('createJob with cmd node -h should succeed', function (done) {
var executorConfig = {
cmd: 'exit',
args: ['0'],
cmd: 'node',
args: ['-h'],
resultArtifacts: [ { name: 'all', resultPatterns: [] } ]
},
killCnt = 0,
artifact = blobClient.createArtifact('execFiles');

artifact.addFile('executor_config.json', JSON.stringify(executorConfig), function (err, hash) {
artifact = blobClient.createArtifact('execFiles'),
filesToAdd = {
'executor_config.json': JSON.stringify(executorConfig)
};
//filesToAdd[jobScriptName] = 'exit /b 0';
artifact.addFiles(filesToAdd, function (err, hashes) {
if (err) {
done(err);
return;
Expand All @@ -120,31 +125,21 @@ describe('NodeWorker', function () {
return;
}
intervalId = setInterval(function(){
executorClient.getWorkersInfo(function (err, res) {
console.log(res);
});
executorClient.getInfo(jobInfo.hash, function (err, res) {
if (err) {
done(err);
return;
}
killCnt += 1;
if (killCnt > 15) {
done('Job Never finished!');
return;
}

if (res.status === 'CREATED' || res.status === 'RUNNING') {
// The job is still running..
return;
}

clearInterval(intervalId);
should.equal(jobInfo, 'SUCCESS');
should.equal(res.status, 'SUCCESS');
done();
});
}, 100);

});
});
});
Expand Down

0 comments on commit ca0442a

Please sign in to comment.