From c719859cee641746563db75ad6725911ec6f7c28 Mon Sep 17 00:00:00 2001 From: aardizio Date: Mon, 20 Jan 2020 00:00:26 +0100 Subject: [PATCH] Ligth number of threads --- tests/dynamic.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/dynamic.test.js b/tests/dynamic.test.js index 7c5eec12..3784c651 100644 --- a/tests/dynamic.test.js +++ b/tests/dynamic.test.js @@ -1,7 +1,7 @@ const expect = require('expect') const DynamicThreadPool = require('../lib/dynamic') const min = 1 -const max = 10 +const max = 3 const pool = new DynamicThreadPool(min, max, './tests/testWorker.js', { errorHandler: (e) => console.error(e), onlineHandler: () => console.log('worker is online') }) @@ -18,7 +18,7 @@ describe('Dynamic thread pool test suite ', () => { let closedThreads = 0 let fullPool = 0 pool.emitter.on('FullPool', () => fullPool++) - for (let i = 0; i < (max * 3); i++) { + for (let i = 0; i < (max * 2); i++) { promises.push(pool.execute({ test: 'test' })) } expect(pool.workers.length).toBe(max) @@ -28,7 +28,7 @@ describe('Dynamic thread pool test suite ', () => { }) }) expect(fullPool > 1).toBeTruthy() - await new Promise(resolve => setTimeout(resolve, 1000 * 2)) + await new Promise(resolve => setTimeout(resolve, 2000)) expect(closedThreads).toBe(max - min) }) @@ -40,7 +40,7 @@ describe('Dynamic thread pool test suite ', () => { }) }) pool.destroy() - await new Promise(resolve => setTimeout(resolve, 1000)) + await new Promise(resolve => setTimeout(resolve, 2000)) expect(closedThreads).toBe(min) }) -- 2.34.1