fix: fix internal measurements handling
[poolifier.git] / tests / pools / abstract / abstract-pool.test.js
index 32f5bbeefa611bad7d32967d4701f99ebefd6cdd..da870774b1bd66ee74d8fa8513dfd67e98cb429b 100644 (file)
@@ -11,6 +11,7 @@ const {
 } = require('../../../lib')
 const { CircularArray } = require('../../../lib/circular-array')
 const { Queue } = require('../../../lib/queue')
+const { version } = require('../../../package.json')
 
 describe('Abstract pool test suite', () => {
   const numberOfWorkers = 2
@@ -393,6 +394,7 @@ describe('Abstract pool test suite', () => {
       './tests/worker-files/thread/testWorker.js'
     )
     expect(pool.info).toStrictEqual({
+      version,
       type: PoolTypes.fixed,
       worker: WorkerTypes.thread,
       minSize: numberOfWorkers,
@@ -406,9 +408,6 @@ describe('Abstract pool test suite', () => {
       maxQueuedTasks: 0,
       failedTasks: 0
     })
-    for (const workerNode of pool.workerNodes) {
-      console.log('thread:workerNode.info', workerNode.info)
-    }
     await pool.destroy()
     pool = new DynamicClusterPool(
       numberOfWorkers,
@@ -416,6 +415,7 @@ describe('Abstract pool test suite', () => {
       './tests/worker-files/cluster/testWorker.js'
     )
     expect(pool.info).toStrictEqual({
+      version,
       type: PoolTypes.dynamic,
       worker: WorkerTypes.cluster,
       minSize: numberOfWorkers,
@@ -429,9 +429,6 @@ describe('Abstract pool test suite', () => {
       maxQueuedTasks: 0,
       failedTasks: 0
     })
-    for (const workerNode of pool.workerNodes) {
-      console.log('cluster:workerNode.info', workerNode.info)
-    }
     await pool.destroy()
   })
 
@@ -465,31 +462,18 @@ describe('Abstract pool test suite', () => {
           failed: 0
         },
         runTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         waitTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         elu: {
           idle: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
           },
           active: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
-          },
-          utilization: 0
+          }
         }
       })
     }
@@ -530,31 +514,18 @@ describe('Abstract pool test suite', () => {
           failed: 0
         },
         runTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         waitTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         elu: {
           idle: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
           },
           active: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
-          },
-          utilization: 0
+          }
         }
       })
     }
@@ -569,31 +540,18 @@ describe('Abstract pool test suite', () => {
           failed: 0
         },
         runTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         waitTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         elu: {
           idle: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
           },
           active: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
-          },
-          utilization: 0
+          }
         }
       })
     }
@@ -622,31 +580,18 @@ describe('Abstract pool test suite', () => {
           failed: 0
         },
         runTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         waitTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         elu: {
           idle: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
           },
           active: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
-          },
-          utilization: 0
+          }
         }
       })
       expect(workerNode.usage.tasks.executed).toBeGreaterThan(0)
@@ -663,31 +608,18 @@ describe('Abstract pool test suite', () => {
           failed: 0
         },
         runTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         waitTime: {
-          aggregate: 0,
-          average: 0,
-          median: 0,
           history: expect.any(CircularArray)
         },
         elu: {
           idle: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
           },
           active: {
-            aggregate: 0,
-            average: 0,
-            median: 0,
             history: expect.any(CircularArray)
-          },
-          utilization: 0
+          }
         }
       })
       expect(workerNode.usage.runTime.history.length).toBe(0)
@@ -717,6 +649,7 @@ describe('Abstract pool test suite', () => {
     // So in total numberOfWorkers * 2 times for a loop submitting up to numberOfWorkers * 2 tasks to the dynamic pool with min = max = numberOfWorkers.
     expect(poolFull).toBe(numberOfWorkers * 2)
     expect(poolInfo).toStrictEqual({
+      version,
       type: PoolTypes.dynamic,
       worker: WorkerTypes.thread,
       minSize: expect.any(Number),
@@ -753,6 +686,7 @@ describe('Abstract pool test suite', () => {
     // So in total numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the fixed pool.
     expect(poolBusy).toBe(numberOfWorkers + 1)
     expect(poolInfo).toStrictEqual({
+      version,
       type: PoolTypes.fixed,
       worker: WorkerTypes.thread,
       minSize: expect.any(Number),