---
[poolifier.git] / tests / pools / cluster / fixed.test.mjs
index fa609cf357a8ac6763f2848c2102a5a47ffd6a0c..0397c797d53a547d1cf560c4520de2cadfafdd1e 100644 (file)
@@ -1,3 +1,5 @@
+import cluster from 'node:cluster'
+
 import { expect } from 'expect'
 
 import { FixedClusterPool, PoolEvents } from '../../../lib/index.cjs'
@@ -68,7 +70,7 @@ describe('Fixed cluster pool test suite', () => {
     let result = await pool.execute({
       function: TaskFunctions.fibonacci
     })
-    expect(result).toBe(75025)
+    expect(result).toBe(354224848179262000000)
     result = await pool.execute({
       function: TaskFunctions.factorial
     })
@@ -285,6 +287,10 @@ describe('Fixed cluster pool test suite', () => {
     let pool = new FixedClusterPool(numberOfWorkers, workerFilePath)
     expect(pool.opts.env).toBeUndefined()
     expect(pool.opts.settings).toBeUndefined()
+    expect(cluster.settings).toMatchObject({
+      exec: workerFilePath,
+      silent: false
+    })
     await pool.destroy()
     pool = new FixedClusterPool(numberOfWorkers, workerFilePath, {
       env: { TEST: 'test' },
@@ -295,7 +301,7 @@ describe('Fixed cluster pool test suite', () => {
       args: ['--use', 'http'],
       silent: true
     })
-    expect({ ...pool.opts.settings, exec: workerFilePath }).toStrictEqual({
+    expect(cluster.settings).toMatchObject({
       args: ['--use', 'http'],
       silent: true,
       exec: workerFilePath
@@ -327,7 +333,8 @@ describe('Fixed cluster pool test suite', () => {
     await expect(pool.destroyWorkerNode(workerNodeKey)).resolves.toBeUndefined()
     expect(disconnectEvent).toBe(1)
     expect(exitEvent).toBe(1)
-    expect(pool.workerNodes.length).toBe(numberOfWorkers - 1)
+    // Simulates an illegitimate worker node destroy and the minimum number of worker nodes is guaranteed
+    expect(pool.workerNodes.length).toBe(numberOfWorkers)
     await pool.destroy()
   })