X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fcluster%2Fdynamic.test.js;h=6d2bccadc1f2ae9bce01904443bb475b56ccb6a6;hb=4a581fcdc17b63ec445ce2b8b85a80ffe4961159;hp=33a5ab8c013bac7bb4d114fa4dda0c9cfff1153b;hpb=f06e48d8e14dcfe3277bd16b1bd2463136af13e6;p=poolifier.git diff --git a/tests/pools/cluster/dynamic.test.js b/tests/pools/cluster/dynamic.test.js index 33a5ab8c..6d2bccad 100644 --- a/tests/pools/cluster/dynamic.test.js +++ b/tests/pools/cluster/dynamic.test.js @@ -1,5 +1,5 @@ const { expect } = require('expect') -const { DynamicClusterPool, PoolEvents } = require('../../../lib/index') +const { DynamicClusterPool, PoolEvents } = require('../../../lib') const { WorkerFunctions } = require('../../test-types') const TestUtils = require('../../test-utils') @@ -19,11 +19,11 @@ describe('Dynamic cluster pool test suite', () => { let result = await pool.execute({ function: WorkerFunctions.fibonacci }) - expect(result).toBe(false) + expect(result).toBe(121393) result = await pool.execute({ function: WorkerFunctions.factorial }) - expect(result).toBe(false) + expect(result).toBe(9.33262154439441e157) }) it('Verify that new workers are created when required, max size is not exceeded and that after a while new workers will die', async () => { @@ -66,7 +66,7 @@ describe('Dynamic cluster pool test suite', () => { it('Validation of inputs test', () => { expect(() => new DynamicClusterPool(min)).toThrowError( - new Error('Please specify a file with a worker implementation') + 'Please specify a file with a worker implementation' ) }) @@ -100,6 +100,11 @@ describe('Dynamic cluster pool test suite', () => { expect(longRunningPool.workerNodes.length).toBe(max) await TestUtils.waitExits(longRunningPool, max - min) expect(longRunningPool.workerNodes.length).toBe(min) + expect( + longRunningPool.workerChoiceStrategyContext.workerChoiceStrategies.get( + longRunningPool.workerChoiceStrategyContext.workerChoiceStrategy + ).nextWorkerNodeId + ).toBeLessThan(longRunningPool.workerNodes.length) // We need to clean up the resources after our test await longRunningPool.destroy() })