Skip to content

Commit b085009

Browse files
committed
Dropping use of _.values to iterate for waking workers
1 parent ef33a9a commit b085009

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

features/parallel_custom_assign.feature

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ Feature: Running scenarios in parallel with custom assignment
9494
function step_def(name, delay) {
9595
return function(scenario, cb) {
9696
if (worker == null) worker = name;
97-
expect(worker).to.eq(name)
98-
expect(scenario).to.eq(++processed)
97+
if (processed !== 3) {
98+
expect(worker).to.eq(name)
99+
expect(scenario).to.eq(++processed)
100+
} else {
101+
// Scenario 3 might get picked up by B as both are ready at this point
102+
expect(scenario).to.eq(processed++)
103+
}
99104
setTimeout(cb, delay)
100105
}
101106
}
@@ -114,6 +119,10 @@ Feature: Running scenarios in parallel with custom assignment
114119
Scenario: 2
115120
Given scenario complex 2
116121
122+
@complex
123+
Scenario: 3
124+
Given scenario complex 3
125+
117126
@simple
118127
Scenario: 4
119128
Given scenario simple 1

src/runtime/parallel/coordinator.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default class Coordinator {
101101
this.saveDefinitionIdMapping(message.supportCodeIds)
102102
} else if (message.ready) {
103103
worker.state = WorkerState.idle
104-
this.awakenWorkers()
104+
this.awakenWorkers(worker)
105105
} else if (doesHaveValue(message.jsonEnvelope)) {
106106
const envelope = messages.Envelope.fromObject(
107107
JSON.parse(message.jsonEnvelope)
@@ -158,17 +158,16 @@ export default class Coordinator {
158158
}
159159
}
160160

161-
awakenWorkers(): void {
162-
const workers = _.values(this.workers)
163-
_.each(workers, (worker): boolean => {
161+
awakenWorkers(triggeringWorker: IWorker): void {
162+
_.each(this.workers, (worker): boolean => {
164163
if (worker.state === WorkerState.idle) {
165164
this.giveWork(worker)
166165
}
167166
return worker.state !== WorkerState.idle
168167
})
169168

170169
if (_.isEmpty(this.inProgressPickles) && this.pickleIds.length > 0) {
171-
this.giveWork(workers[0], true)
170+
this.giveWork(triggeringWorker, true)
172171
this.idleInterventions++
173172
}
174173
}

0 commit comments

Comments
 (0)