X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fthread%2Ffixed.test.mjs;h=a7c4a48f73a4252414b2323db4a2b5e4ac9383c9;hb=6f6222f96758d59647d5666e22cd3ebd19c94e9c;hp=3969c83ad7464c728d7df33dd092673c16384734;hpb=229e9e73566ed1960ba5be0534fb3aa2eeb115eb;p=poolifier.git diff --git a/tests/pools/thread/fixed.test.mjs b/tests/pools/thread/fixed.test.mjs index 3969c83a..a7c4a48f 100644 --- a/tests/pools/thread/fixed.test.mjs +++ b/tests/pools/thread/fixed.test.mjs @@ -130,6 +130,7 @@ describe('Fixed thread pool test suite', () => { expect(workerNode.usage.tasks.maxQueued).toBe( maxMultiplier - queuePool.opts.tasksQueueOptions.concurrency ) + expect(workerNode.usage.tasks.sequentiallyStolen).toBe(0) expect(workerNode.usage.tasks.stolen).toBe(0) } expect(queuePool.info.executedTasks).toBe(0) @@ -157,6 +158,12 @@ describe('Fixed thread pool test suite', () => { expect(workerNode.usage.tasks.maxQueued).toBe( maxMultiplier - queuePool.opts.tasksQueueOptions.concurrency ) + expect(workerNode.usage.tasks.sequentiallyStolen).toBeGreaterThanOrEqual( + 0 + ) + expect(workerNode.usage.tasks.sequentiallyStolen).toBeLessThanOrEqual( + numberOfThreads * maxMultiplier + ) expect(workerNode.usage.tasks.stolen).toBeGreaterThanOrEqual(0) expect(workerNode.usage.tasks.stolen).toBeLessThanOrEqual( numberOfThreads * maxMultiplier @@ -202,8 +209,9 @@ describe('Fixed thread pool test suite', () => { error = e } expect(result).toStrictEqual({ ok: 1 }) - expect(error).toStrictEqual( - new TypeError('Found invalid object in transferList') + expect(error).toBeInstanceOf(Error) + expect(error.message).toMatch( + /Found invalid (object|value) in transferList/ ) }) @@ -292,6 +300,8 @@ describe('Fixed thread pool test suite', () => { await pool.destroy() const numberOfExitEvents = await exitPromise expect(pool.started).toBe(false) + expect(pool.readyEventEmitted).toBe(false) + expect(pool.emitter.eventNames()).toStrictEqual([]) expect(pool.workerNodes.length).toBe(0) expect(numberOfExitEvents).toBe(numberOfThreads) expect(poolDestroy).toBe(1) @@ -338,9 +348,9 @@ describe('Fixed thread pool test suite', () => { await pool.destroy() }) - it('Verify that a pool with zero worker fails', async () => { + it('Verify that a pool with zero worker fails', () => { expect( () => new FixedThreadPool(0, './tests/worker-files/thread/testWorker.mjs') - ).toThrowError('Cannot instantiate a fixed pool with zero worker') + ).toThrow('Cannot instantiate a fixed pool with zero worker') }) })