}
await pool.destroy()
})
+
+ it('Verify sendKillMessageToWorker()', async () => {
+ const pool = new DynamicClusterPool(
+ Math.floor(numberOfWorkers / 2),
+ numberOfWorkers,
+ './tests/worker-files/cluster/testWorker.js'
+ )
+ const workerNodeKey = 0
+ await expect(
+ pool.sendKillMessageToWorker(
+ workerNodeKey,
+ pool.workerNodes[workerNodeKey].info.id
+ )
+ ).resolves.toBeUndefined()
+ await pool.destroy()
+ })
})
it('Verify destroyWorkerNode()', async () => {
const workerFilePath = './tests/worker-files/cluster/testWorker.js'
const pool = new FixedClusterPool(numberOfWorkers, workerFilePath)
+ const workerNodeKey = 0
let disconnectEvent = 0
- pool.workerNodes[0].worker.on('disconnect', () => {
+ pool.workerNodes[workerNodeKey].worker.on('disconnect', () => {
++disconnectEvent
})
let exitEvent = 0
- pool.workerNodes[0].worker.on('exit', () => {
+ pool.workerNodes[workerNodeKey].worker.on('exit', () => {
++exitEvent
})
- let error
- try {
- await pool.destroyWorkerNode(0)
- } catch (e) {
- error = e
- }
- expect(error).toBeUndefined()
+ await expect(pool.destroyWorkerNode(workerNodeKey)).resolves.toBeUndefined()
expect(disconnectEvent).toBe(1)
expect(exitEvent).toBe(1)
expect(pool.workerNodes.length).toBe(numberOfWorkers - 1)
it('Verify destroyWorkerNode()', async () => {
const workerFilePath = './tests/worker-files/thread/testWorker.js'
const pool = new FixedThreadPool(numberOfThreads, workerFilePath)
+ const workerNodeKey = 0
let exitEvent = 0
- pool.workerNodes[0].worker.on('exit', () => {
+ pool.workerNodes[workerNodeKey].worker.on('exit', () => {
++exitEvent
})
- let error
- try {
- await pool.destroyWorkerNode(0)
- } catch (e) {
- error = e
- }
- expect(error).toBeUndefined()
+ await expect(pool.destroyWorkerNode(workerNodeKey)).resolves.toBeUndefined()
expect(exitEvent).toBe(1)
expect(pool.workerNodes.length).toBe(numberOfThreads - 1)
await pool.destroy()