Skip to content

Commit

Permalink
fix: job-started streaming message missing job_id (#561)
Browse files Browse the repository at this point in the history
* fix: job-started streaming message missing job_id

* test: add streaming manager assertions for job-created event
  • Loading branch information
NivLipetz committed Feb 7, 2021
1 parent 8c5d5ed commit b2bdb4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/jobs/models/jobManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ module.exports.createJob = async (job) => {
}
logger.info(`Job ${jobId} deployed successfully`);
const jobResponse = createResponse(jobId, job, report);
streamingManager.produce({}, STREAMING_EVENT_TYPES.JOB_CREATED, jobResponse);
const streamingResource = {
job_id: jobResponse.id,
job_type: jobResponse.type,
...jobResponse
};
streamingManager.produce({}, STREAMING_EVENT_TYPES.JOB_CREATED, streamingResource);

return jobResponse;
} catch (error) {
Expand Down Expand Up @@ -284,7 +289,12 @@ function addCron(job, cronExpression, configData) {
}
const report = await runJob(job, configData);
const jobResponse = createResponse(job.id, job, report);
streamingManager.produce({}, STREAMING_EVENT_TYPES.JOB_CREATED, jobResponse);
const streamingResource = {
job_id: jobResponse.id,
job_type: jobResponse.type,
...jobResponse
};
streamingManager.produce({}, STREAMING_EVENT_TYPES.JOB_CREATED, streamingResource);
}, function () {
logger.info(`Job: ${job.id} completed.`);
}, true);
Expand Down
6 changes: 6 additions & 0 deletions tests/integration-tests-with-streaming/dockerFullFlow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ describe('Create job specific docker tests', async function () {
should(valuePublished.event).eql('job-created');
should(valuePublished.resource).containEql({
test_id: testId,
job_id: jobId,
report_id: reportId,
job_type: 'load_test',
arrival_rate: 2,
notes: 'streaming notes',
duration: 1
Expand Down Expand Up @@ -156,7 +158,9 @@ describe('Create job specific docker tests', async function () {
should(valuePublished.event).eql('job-created');
should(valuePublished.resource).containEql({
test_id: testId,
job_id: jobId,
report_id: reportId,
job_type: 'load_test',
arrival_rate: 2,
notes: 'streaming notes',
duration: 1
Expand Down Expand Up @@ -215,7 +219,9 @@ describe('Create job specific docker tests', async function () {
should(valuePublished.event).eql('job-created');
should(valuePublished.resource).containEql({
test_id: testId,
job_id: jobId,
report_id: reportId,
job_type: 'load_test',
arrival_rate: 2,
notes: 'streaming notes',
duration: 1
Expand Down

0 comments on commit b2bdb4e

Please sign in to comment.