Skip to content

Commit

Permalink
fix: continue to attempt scheduling tasks that breach concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Dec 3, 2020
1 parent 3e33b8e commit 6d209a5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/factories/createPlanton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const createPlanton = (configuration: PlantonConfiguration): Planton => {
const activeTaskInstructions = await getActiveTaskInstructions(inputTask.name);

if (activeTaskInstructions.length >= concurrency) {
break;
continue;
}

let taskInstructions: TaskInstruction[];
Expand Down
28 changes: 28 additions & 0 deletions test/planton/factories/createPlanton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,31 @@ test('scheduler executions are evenly distributed', async (t) => {

await planton.terminate();
});

test('continues to attempt scheduling tasks that breach concurrency', async (t) => {
const getActiveTaskInstructions = sinon
.stub()
.returns(['1']);

const planton = createPlanton({
getActiveTaskInstructions,
tasks: [
{
concurrency: 1,
delay: () => {
return 10;
},
name: 'foo',
schedule: () => {
throw new Error('Should not be called.');
},
},
],
});

await delay(100);

t.true(getActiveTaskInstructions.callCount > 3);

await planton.terminate();
});

0 comments on commit 6d209a5

Please sign in to comment.