X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fselection-strategies%2Fselection-strategies.test.js;h=a2365a5d777c77cbe3ffe56fd7ebc4065fdf04e5;hb=e1ffb94fcac39a7459c47edaa086a7729a1dec44;hp=39895b213ff6baf1e88167827ac8cb0f717002b1;hpb=10fcfaf49c0b6d6f0e1d137eeba1e9d805c9a815;p=poolifier.git diff --git a/tests/pools/selection-strategies/selection-strategies.test.js b/tests/pools/selection-strategies/selection-strategies.test.js index 39895b21..a2365a5d 100644 --- a/tests/pools/selection-strategies/selection-strategies.test.js +++ b/tests/pools/selection-strategies/selection-strategies.test.js @@ -6,6 +6,9 @@ const { } = require('../../../lib/index') describe('Selection strategies test suite', () => { + const min = 0 + const max = 3 + it('Verify that WorkerChoiceStrategies enumeration provides string values', () => { expect(WorkerChoiceStrategies.ROUND_ROBIN).toBe('ROUND_ROBIN') expect(WorkerChoiceStrategies.LESS_RECENTLY_USED).toBe('LESS_RECENTLY_USED') @@ -16,8 +19,6 @@ describe('Selection strategies test suite', () => { }) it('Verify ROUND_ROBIN strategy is the default at pool creation', async () => { - const min = 0 - const max = 3 const pool = new DynamicThreadPool( min, max, @@ -31,8 +32,6 @@ describe('Selection strategies test suite', () => { }) it('Verify ROUND_ROBIN strategy can be set after pool creation', async () => { - const min = 0 - const max = 3 const pool = new DynamicThreadPool( min, max, @@ -47,8 +46,6 @@ describe('Selection strategies test suite', () => { }) it('Verify ROUND_ROBIN strategy default tasks usage statistics requirements', async () => { - const min = 0 - const max = 3 let pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js' @@ -73,7 +70,6 @@ describe('Selection strategies test suite', () => { }) it('Verify ROUND_ROBIN strategy can be run in a fixed pool', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js', @@ -85,7 +81,7 @@ describe('Selection strategies test suite', () => { // TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose` const promises = [] for (let i = 0; i < max * 2; i++) { - promises.push(pool.execute({ test: 'test' })) + promises.push(pool.execute()) } await Promise.all(promises) // We need to clean up the resources after our test @@ -93,8 +89,6 @@ describe('Selection strategies test suite', () => { }) it('Verify ROUND_ROBIN strategy can be run in a dynamic pool', async () => { - const min = 0 - const max = 3 const pool = new DynamicThreadPool( min, max, @@ -107,7 +101,7 @@ describe('Selection strategies test suite', () => { // TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose` const promises = [] for (let i = 0; i < max * 2; i++) { - promises.push(pool.execute({ test: 'test' })) + promises.push(pool.execute()) } await Promise.all(promises) // We need to clean up the resources after our test @@ -115,7 +109,6 @@ describe('Selection strategies test suite', () => { }) it('Verify LESS_RECENTLY_USED strategy is taken at pool creation', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js', @@ -129,7 +122,6 @@ describe('Selection strategies test suite', () => { }) it('Verify LESS_RECENTLY_USED strategy can be set after pool creation', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js' @@ -143,8 +135,6 @@ describe('Selection strategies test suite', () => { }) it('Verify LESS_RECENTLY_USED strategy default tasks usage statistics requirements', async () => { - const min = 0 - const max = 3 let pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js' @@ -169,7 +159,6 @@ describe('Selection strategies test suite', () => { }) it('Verify LESS_RECENTLY_USED strategy can be run in a fixed pool', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js', @@ -178,7 +167,7 @@ describe('Selection strategies test suite', () => { // TODO: Create a better test to cover `LessRecentlyUsedWorkerChoiceStrategy#choose` const promises = [] for (let i = 0; i < max * 2; i++) { - promises.push(pool.execute({ test: 'test' })) + promises.push(pool.execute()) } await Promise.all(promises) // We need to clean up the resources after our test @@ -186,8 +175,6 @@ describe('Selection strategies test suite', () => { }) it('Verify LESS_RECENTLY_USED strategy can be run in a dynamic pool', async () => { - const min = 0 - const max = 3 const pool = new DynamicThreadPool( min, max, @@ -197,7 +184,7 @@ describe('Selection strategies test suite', () => { // TODO: Create a better test to cover `LessRecentlyUsedWorkerChoiceStrategy#choose` const promises = [] for (let i = 0; i < max * 2; i++) { - promises.push(pool.execute({ test: 'test' })) + promises.push(pool.execute()) } await Promise.all(promises) // We need to clean up the resources after our test @@ -205,7 +192,6 @@ describe('Selection strategies test suite', () => { }) it('Verify FAIR_SHARE strategy is taken at pool creation', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js', @@ -219,7 +205,6 @@ describe('Selection strategies test suite', () => { }) it('Verify FAIR_SHARE strategy can be set after pool creation', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js' @@ -233,8 +218,6 @@ describe('Selection strategies test suite', () => { }) it('Verify FAIR_SHARE strategy default tasks usage statistics requirements', async () => { - const min = 0 - const max = 3 let pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js' @@ -259,7 +242,6 @@ describe('Selection strategies test suite', () => { }) it('Verify FAIR_SHARE strategy can be run in a fixed pool', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js', @@ -268,7 +250,7 @@ describe('Selection strategies test suite', () => { // TODO: Create a better test to cover `FairShareChoiceStrategy#choose` const promises = [] for (let i = 0; i < max * 2; i++) { - promises.push(pool.execute({ test: 'test' })) + promises.push(pool.execute()) } await Promise.all(promises) // We need to clean up the resources after our test @@ -276,8 +258,6 @@ describe('Selection strategies test suite', () => { }) it('Verify FAIR_SHARE strategy can be run in a dynamic pool', async () => { - const min = 0 - const max = 3 const pool = new DynamicThreadPool( min, max, @@ -287,7 +267,7 @@ describe('Selection strategies test suite', () => { // TODO: Create a better test to cover `FairShareChoiceStrategy#choose` const promises = [] for (let i = 0; i < max * 2; i++) { - promises.push(pool.execute({ test: 'test' })) + promises.push(pool.execute()) } await Promise.all(promises) // We need to clean up the resources after our test @@ -295,7 +275,6 @@ describe('Selection strategies test suite', () => { }) it('Verify WEIGHTED_ROUND_ROBIN strategy is taken at pool creation', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js', @@ -309,7 +288,6 @@ describe('Selection strategies test suite', () => { }) it('Verify WEIGHTED_ROUND_ROBIN strategy can be set after pool creation', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js' @@ -323,8 +301,6 @@ describe('Selection strategies test suite', () => { }) it('Verify WEIGHTED_ROUND_ROBIN strategy default tasks usage statistics requirements', async () => { - const min = 0 - const max = 3 let pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js' @@ -349,7 +325,6 @@ describe('Selection strategies test suite', () => { }) it('Verify WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => { - const max = 3 const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.js', @@ -358,7 +333,7 @@ describe('Selection strategies test suite', () => { // TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose` const promises = [] for (let i = 0; i < max * 2; i++) { - promises.push(pool.execute({ test: 'test' })) + promises.push(pool.execute()) } await Promise.all(promises) // We need to clean up the resources after our test @@ -366,8 +341,6 @@ describe('Selection strategies test suite', () => { }) it('Verify WEIGHTED_ROUND_ROBIN strategy can be run in a dynamic pool', async () => { - const min = 0 - const max = 3 const pool = new DynamicThreadPool( min, max, @@ -377,7 +350,7 @@ describe('Selection strategies test suite', () => { // TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose` const promises = [] for (let i = 0; i < max * 2; i++) { - promises.push(pool.execute({ test: 'test' })) + promises.push(pool.execute()) } await Promise.all(promises) // We need to clean up the resources after our test @@ -385,8 +358,6 @@ describe('Selection strategies test suite', () => { }) it('Verify unknown strategies throw error', () => { - const min = 1 - const max = 3 expect( () => new DynamicThreadPool(