-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block until job canceled (local compute). Fixes #1743
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
describe('local compute', function() { | ||
const assert = require('assert'); | ||
const testFixture = require('../../../../../globals'); | ||
const GeneratedFiles = testFixture.requirejs('deepforge/plugin/GeneratedFiles'); | ||
const Compute = testFixture.requirejs('deepforge/compute/index'); | ||
const BlobClient = require('webgme-engine/src/server/middleware/blob/BlobClientWithFSBackend'); | ||
const gmeConfig = testFixture.getGmeConfig(); | ||
const blobClient = new BlobClient(gmeConfig, testFixture.logger); | ||
const backend = Compute.getBackend('local'); | ||
const client = backend.getClient(testFixture.logger, blobClient); | ||
const utils = testFixture.requirejs('deepforge/utils'); | ||
|
||
describe('cancelJob', function() { | ||
let jobInfo; | ||
|
||
beforeEach(async () => { | ||
const jobHash = await getJobHash('sleep', '10'); | ||
const deferred = utils.defer(); | ||
client.on('update', (hash, status) => { | ||
if (hash === jobHash && status === client.RUNNING) { | ||
deferred.resolve(); | ||
} | ||
}); | ||
|
||
jobInfo = await client.createJob(jobHash); | ||
await deferred.promise; | ||
}); | ||
|
||
it('should block until canceled', async function() { | ||
await client.cancelJob(jobInfo); | ||
const status = await client.getStatus(jobInfo); | ||
assert.equal(status, client.CANCELED); | ||
}); | ||
}); | ||
|
||
async function getJobHash(cmd) { | ||
const config = { | ||
cmd, args: Array.prototype.slice.call(arguments, 1), | ||
}; | ||
const files = new GeneratedFiles(blobClient); | ||
files.addFile('executor_config.json', JSON.stringify(config)); | ||
return await files.save(); | ||
} | ||
}); | ||
|