X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fthread%2Fdynamic.test.js;h=9cba566f916abccdd380b38a0795a5502992a933;hb=008a75fe80f29ce358a78eb8df64c70ebe3e64d3;hp=2e3a849257befecc2e3564518c099d2fa267005d;hpb=330c983e06cc9711c66fcd0f1bb419e80453c77f;p=poolifier.git diff --git a/tests/pools/thread/dynamic.test.js b/tests/pools/thread/dynamic.test.js index 2e3a8492..9cba566f 100644 --- a/tests/pools/thread/dynamic.test.js +++ b/tests/pools/thread/dynamic.test.js @@ -21,13 +21,13 @@ describe('Dynamic thread pool test suite', () => { it('Verify that new workers are created when required, max size is not exceeded and that after a while new workers will die', async () => { const promises = [] - let busy = 0 - pool.emitter.on('busy', () => busy++) + let poolBusy = 0 + pool.emitter.on('busy', () => poolBusy++) for (let i = 0; i < max * 2; i++) { promises.push(pool.execute({ test: 'test' })) } expect(pool.workers.length).toBe(max) - expect(busy > 1).toBeTruthy() + expect(poolBusy).toBe(max + 1) const res = await TestUtils.waitExits(pool, max - min) expect(res).toBe(max - min) }) @@ -72,6 +72,7 @@ describe('Dynamic thread pool test suite', () => { './tests/worker-files/thread/testWorker.js' ) const res = await pool1.execute({ test: 'test' }) + expect(res).toBeDefined() expect(res).toBeFalsy() // We need to clean up the resources after our test await pool1.destroy() @@ -84,7 +85,8 @@ describe('Dynamic thread pool test suite', () => { './tests/worker-files/thread/longRunningWorkerHardBehavior.js', { errorHandler: e => console.error(e), - onlineHandler: () => console.log('worker is online') + onlineHandler: () => console.log('long running worker is online'), + exitHandler: () => console.log('long running worker exited') } ) expect(longRunningPool.workers.length).toBe(min) @@ -105,7 +107,8 @@ describe('Dynamic thread pool test suite', () => { './tests/worker-files/thread/longRunningWorkerSoftBehavior.js', { errorHandler: e => console.error(e), - onlineHandler: () => console.log('worker is online') + onlineHandler: () => console.log('long running worker is online'), + exitHandler: () => console.log('long running worker exited') } ) expect(longRunningPool.workers.length).toBe(min)