-const numThreads = 10
-const maxTasks = 400
-const pool = new FixedThreadPool(
- numThreads,
- './tests/worker/thread/testWorker.js',
- {
- errorHandler: e => console.error(e),
- onlineHandler: () => console.log('worker is online')
- }
-)
-const emptyPool = new FixedThreadPool(1, './tests/worker/thread/emptyWorker.js')
-const echoPool = new FixedThreadPool(1, './tests/worker/thread/echoWorker.js')
-const errorPool = new FixedThreadPool(
- 1,
- './tests/worker/thread/errorWorker.js',
- {
- errorHandler: e => console.error(e),
- onlineHandler: () => console.log('worker is online')
- }
-)
-const asyncPool = new FixedThreadPool(
- 1,
- './tests/worker/thread/asyncWorker.js',
- { maxTasks: maxTasks }
-)
+const { WorkerFunctions } = require('../../test-types')
+const TestUtils = require('../../test-utils')
+
+describe('Fixed thread pool test suite', () => {
+ const numberOfThreads = 6
+ const pool = new FixedThreadPool(
+ numberOfThreads,
+ './tests/worker-files/thread/testWorker.js',
+ {
+ errorHandler: e => console.error(e)
+ }
+ )
+ const emptyPool = new FixedThreadPool(
+ numberOfThreads,
+ './tests/worker-files/thread/emptyWorker.js',
+ { exitHandler: () => console.log('empty pool worker exited') }
+ )
+ const echoPool = new FixedThreadPool(
+ numberOfThreads,
+ './tests/worker-files/thread/echoWorker.js'
+ )
+ const errorPool = new FixedThreadPool(
+ numberOfThreads,
+ './tests/worker-files/thread/errorWorker.js',
+ {
+ errorHandler: e => console.error(e)
+ }
+ )
+ const asyncErrorPool = new FixedThreadPool(
+ numberOfThreads,
+ './tests/worker-files/thread/asyncErrorWorker.js',
+ {
+ errorHandler: e => console.error(e)
+ }
+ )
+ const asyncPool = new FixedThreadPool(
+ numberOfThreads,
+ './tests/worker-files/thread/asyncWorker.js'
+ )
+
+ after('Destroy all pools', async () => {
+ // We need to clean up the resources after our test
+ await echoPool.destroy()
+ await asyncPool.destroy()
+ await errorPool.destroy()
+ await asyncErrorPool.destroy()
+ await emptyPool.destroy()
+ })