Skip to content

Commit

Permalink
fix: produce job to streaming platform only when started run (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
NivLipetz authored Feb 7, 2021
1 parent b2bdb4e commit f8e43db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
25 changes: 13 additions & 12 deletions src/jobs/models/jobManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ module.exports.createJob = async (job) => {
}
logger.info(`Job ${jobId} deployed successfully`);
const jobResponse = createResponse(jobId, job, report);
const streamingResource = {
job_id: jobResponse.id,
job_type: jobResponse.type,
...jobResponse
};
streamingManager.produce({}, STREAMING_EVENT_TYPES.JOB_CREATED, streamingResource);
if (job.run_immediately) {
produceJobToStreamingPlatform(jobResponse);
}

return jobResponse;
} catch (error) {
Expand Down Expand Up @@ -289,12 +286,7 @@ function addCron(job, cronExpression, configData) {
}
const report = await runJob(job, configData);
const jobResponse = createResponse(job.id, job, report);
const streamingResource = {
job_id: jobResponse.id,
job_type: jobResponse.type,
...jobResponse
};
streamingManager.produce({}, STREAMING_EVENT_TYPES.JOB_CREATED, streamingResource);
produceJobToStreamingPlatform(jobResponse);
}, function () {
logger.info(`Job: ${job.id} completed.`);
}, true);
Expand Down Expand Up @@ -378,3 +370,12 @@ async function runJob(job, configData) {
}
return report;
}

function produceJobToStreamingPlatform(jobResponse) {
const streamingResource = {
job_id: jobResponse.id,
job_type: jobResponse.type,
...jobResponse
};
streamingManager.produce({}, STREAMING_EVENT_TYPES.JOB_CREATED, streamingResource);
}
2 changes: 1 addition & 1 deletion tests/integration-tests-with-streaming/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ echo Running integration tests with "$DATABASE_TYPE" db and "$JOB_PLATFORM" inte
source $CURR_DIR/tests/configurations/"$DATABASE_TYPE"Configuration.sh
source $CURR_DIR/tests/configurations/"$JOB_PLATFORM"Configuration.sh
source $CURR_DIR/tests/configurations/"$STREAMING_PLATFORM"Configuration.sh
node_modules/.bin/_mocha $CURR_DIR/tests/integration-tests-with-streaming --recursive --timeout=30000 --retries=2 --exit
node_modules/.bin/_mocha $CURR_DIR/tests/integration-tests-with-streaming --recursive --timeout=40000 --retries=2 --exit
2 changes: 1 addition & 1 deletion tests/integration-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ fi
echo Running integration tests with "$DATABASE_TYPE" db and "$JOB_PLATFORM" integration
source $CURR_DIR/tests/configurations/"$DATABASE_TYPE"Configuration.sh
source $CURR_DIR/tests/configurations/"$JOB_PLATFORM"Configuration.sh
node_modules/.bin/_mocha $CURR_DIR/tests/integration-tests --recursive --timeout=30000 --retries=2 --exit
node_modules/.bin/_mocha $CURR_DIR/tests/integration-tests --recursive --timeout=40000 --retries=2 --exit

0 comments on commit f8e43db

Please sign in to comment.