await Promise.all(
this.workerNodes.map(async (workerNode, workerNodeKey) => {
this.flushTasksQueue(workerNodeKey)
+ // FIXME: wait for tasks to be finished
await this.destroyWorker(workerNode.worker)
})
)
) {
// Kill message received from the worker: no new tasks are submitted to that worker for a while ( > maxInactiveTime)
this.flushTasksQueue(currentWorkerNodeKey)
+ // FIXME: wait for tasks to be finished
void (this.destroyWorker(workerCreated) as Promise<void>)
}
})
const { expect } = require('expect')
const { isPlainObject, median } = require('../lib/utils')
+const {
+ isKillBehavior,
+ KillBehaviors
+} = require('../lib/worker/worker-options')
describe('Utils test suite', () => {
it('Verify median computation', () => {
expect(isPlainObject({})).toBe(true)
expect(isPlainObject({ a: 1 })).toBe(true)
})
+
+ it('Verify isKillBehavior() behavior', () => {
+ expect(isKillBehavior(KillBehaviors.SOFT, KillBehaviors.SOFT)).toBe(true)
+ expect(isKillBehavior(KillBehaviors.SOFT, KillBehaviors.HARD)).toBe(false)
+ expect(isKillBehavior(KillBehaviors.HARD, KillBehaviors.HARD)).toBe(true)
+ expect(isKillBehavior(KillBehaviors.HARD, KillBehaviors.SOFT)).toBe(false)
+ expect(isKillBehavior(KillBehaviors.SOFT)).toBe(false)
+ expect(isKillBehavior(KillBehaviors.HARD)).toBe(false)
+ expect(isKillBehavior(KillBehaviors.HARD, null)).toBe(false)
+ expect(isKillBehavior(KillBehaviors.SOFT, 'unknown')).toBe(false)
+ })
})