Skip to content

Commit

Permalink
Merge pull request #2799 from kensipe/v1.10.5a
Browse files Browse the repository at this point in the history
  • Loading branch information
MatApple authored Mar 1, 2018
2 parents 7d86edd + e16e570 commit a947b78
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/js/utils/JobUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,27 @@ const JobUtil = {
Object.assign(spec.run, { docker });
}

// default values for id and policy
let scheduleId = "default";
let schedulePolicy = "ALLOW";
// preserve id and concurrencyPolicy
if (Array.isArray(spec.schedules) && spec.schedules.length > 0) {
scheduleId = spec.schedules[0].id;
schedulePolicy = spec.schedules[0].concurrencyPolicy;
}

// Reset schedules
spec.schedules = [];

// Only transfer schedule if checkbox is set, and create job with reasonable
// defaults
if (!schedule || schedule.runOnSchedule) {
const {
id = "default",
id = scheduleId,
enabled = true,
cron,
timezone,
concurrencyPolicy = "ALLOW",
concurrencyPolicy = schedulePolicy,
startingDeadlineSeconds
} = schedule || {};

Expand Down
45 changes: 44 additions & 1 deletion src/js/utils/__tests__/JobUtil-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,50 @@ describe("JobUtil", function() {
]);
});

it("should remove schedule if deactivated", function() {
it("job schedule maintains id and policy", function() {
const job = JobUtil.createJobFromFormModel({
general: { id: "test", cmd: "sleep 1000;" },
schedule: {
id: "fluffy",
cron: "* * * * *",
enabled: true,
concurrencyPolicy: "FORBID",
runOnSchedule: true
}
});

expect(job.getSchedules()).toEqual([
{
id: "fluffy",
cron: "* * * * *",
enabled: true,
concurrencyPolicy: "FORBID"
}
]);
});

it("job schedule defaults concurrencyPolicy if not provided", function() {
const job = JobUtil.createJobFromFormModel({
general: { id: "test", cmd: "sleep 1000;" },
schedule: {
id: "fluffy",
cron: "* * * * *",
enabled: true,
runOnSchedule: true
}
});

expect(job.getSchedules()).toEqual([
{
id: "fluffy",
cron: "* * * * *",
enabled: true,
concurrencyPolicy: "ALLOW"
}
]);
});

it("removes schedule if deactivated", function() {
const job = JobUtil.createJobFromFormModel({
general: { id: "test", cmd: "sleep 1000;" },
schedule: {
Expand Down

0 comments on commit a947b78

Please sign in to comment.