docs: add changelog entry for IWRR worker choice strategy
[poolifier.git] / tests / pools / cluster / fixed.test.js
index 34c066100aff925579f80a8876c03a4b4d81e695..ac5d1fda6943a67651ea521e924cfcf8283a20c3 100644 (file)
@@ -89,8 +89,8 @@ describe('Fixed cluster pool test suite', () => {
   })
 
   it('Verify that tasks queuing is working', async () => {
-    const maxMultiplier = 10
     const promises = new Set()
+    const maxMultiplier = 2
     for (let i = 0; i < numberOfWorkers * maxMultiplier; i++) {
       promises.add(queuePool.execute())
     }
@@ -110,9 +110,9 @@ describe('Fixed cluster pool test suite', () => {
     for (const workerNode of queuePool.workerNodes) {
       expect(workerNode.tasksUsage.running).toBe(0)
       expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+      expect(workerNode.tasksUsage.run).toBeLessThanOrEqual(maxMultiplier)
       expect(workerNode.tasksQueue.size).toBe(0)
     }
-    promises.clear()
   })
 
   it('Verify that is possible to have a worker that return undefined', async () => {
@@ -137,6 +137,11 @@ describe('Fixed cluster pool test suite', () => {
     expect(inError).toBeDefined()
     expect(typeof inError === 'string').toBe(true)
     expect(inError).toBe('Error Message from ClusterWorker')
+    expect(
+      errorPool.workerNodes.some(
+        workerNode => workerNode.tasksUsage.error === 1
+      )
+    ).toBe(true)
   })
 
   it('Verify that error handling is working properly:async', async () => {
@@ -150,6 +155,11 @@ describe('Fixed cluster pool test suite', () => {
     expect(inError).toBeDefined()
     expect(typeof inError === 'string').toBe(true)
     expect(inError).toBe('Error Message from ClusterWorker:async')
+    expect(
+      asyncErrorPool.workerNodes.some(
+        workerNode => workerNode.tasksUsage.error === 1
+      )
+    ).toBe(true)
   })
 
   it('Verify that async function is working properly', async () => {