Skip to content

Commit

Permalink
Merge pull request #537 from jsnoble/api_jobs_put
Browse files Browse the repository at this point in the history
fixed PUT /jobs/:job_id endpoint resolves #533
  • Loading branch information
godber authored Sep 13, 2017
2 parents beeb181 + 52cb6ac commit c599af0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
43 changes: 43 additions & 0 deletions integration-tests/spec/cases/cluster/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

var misc = require('../../misc')();
var wait = require('../../wait')();
var request = require('request');

module.exports = function() {
var teraslice = misc.teraslice();

describe('api endpoint', function() {

it('should update job specs', function(done) {
var job_spec = misc.newJob('generator');
var job_id;

teraslice.jobs.submit(job_spec)
.then(function(job) {
job_id = job.id();
expect(job_id).toBeDefined();

return job.waitForStatus('running')
.then(function() {
return job.spec();
})
.then(function(jobSpec) {
expect(jobSpec.workers).toEqual(3);
return job.put(`/jobs/${job_id}`, {workers: 2});
})
.then(function() {
return job.spec();
})
.then(function(jobSpec) {
expect(jobSpec.workers).toEqual(2);
return job.stop();
})

})
.catch(fail)
.finally(done);
});
});

};
1 change: 0 additions & 1 deletion integration-tests/spec/cases/cluster/job-state.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var _ = require('lodash');
var Promise = require('bluebird');
var misc = require('../../misc')();
var wait = require('../../wait')();
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/spec/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ describe('teraslice', function() {
process.exit(2)
})
});


require('./cases/cluster/api')();
require('./cases/cluster/job-state')();
require('./cases/data/id-reader')();
require('./cases/data/elasticsearch-bulk')();
Expand Down
5 changes: 1 addition & 4 deletions lib/cluster/services/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,7 @@ module.exports = function(context, cluster_service) {

// Updates the job but does not automatically start it.
function updateJob(job_id, job) {
return getJob(job_id)
.then(function(job) {
return job_store.update(job_id, job);
})
return job_store.update(job_id, job)
.catch(function(err) {
var errMsg = parseError(err);
logger.error(`could not updateJob`, errMsg)
Expand Down

0 comments on commit c599af0

Please sign in to comment.