diff --git a/gitnexus/test/unit/worker-pool-resilience.test.ts b/gitnexus/test/unit/worker-pool-resilience.test.ts index 2f8635630..2212ed080 100644 --- a/gitnexus/test/unit/worker-pool-resilience.test.ts +++ b/gitnexus/test/unit/worker-pool-resilience.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, vi, beforeEach } from 'vitest'; +import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'; import { EventEmitter } from 'node:events'; import path from 'node:path'; import { pathToFileURL } from 'node:url'; @@ -111,6 +111,14 @@ beforeEach(() => { workerUrl = pathToFileURL(workerPath) as URL; }); +afterEach(() => { + try { + fs.rmSync(tempDir, { recursive: true, force: true }); + } catch { + // best-effort cleanup — directory may already be gone if a test removed it + } +}); + describe('worker pool resilience', () => { it('seeds an empty quarantine on a fresh pool', () => { const pool = createWorkerPool(workerUrl, 1, { @@ -581,38 +589,3 @@ describe('resolveAutoPoolSize', () => { expect(Number.isInteger(resolveAutoPoolSize())).toBe(true); }); }); - -describe('worker pool option resolution', () => { - it('resolves maxRespawnsPerSlot from explicit options', () => { - const opts = resolveWorkerPoolOptions({ maxRespawnsPerSlot: 7 }, 4); - expect(opts.maxRespawnsPerSlot).toBe(7); - }); - - it('defaults consecutiveFailureThreshold to max(3, poolSize)', () => { - expect(resolveWorkerPoolOptions({}, 1).consecutiveFailureThreshold).toBe(3); - expect(resolveWorkerPoolOptions({}, 8).consecutiveFailureThreshold).toBe(8); - }); - - it('defaults maxCumulativeTimeoutMs to 5x subBatchIdleTimeoutMs', () => { - const opts = resolveWorkerPoolOptions({ subBatchIdleTimeoutMs: 1000 }, 1); - expect(opts.maxCumulativeTimeoutMs).toBe(5000); - }); - - it('reads GITNEXUS_WORKER_MAX_RESPAWNS_PER_SLOT env override', () => { - vi.stubEnv('GITNEXUS_WORKER_MAX_RESPAWNS_PER_SLOT', '2'); - try { - expect(resolveWorkerPoolOptions({}, 1).maxRespawnsPerSlot).toBe(2); - } finally { - vi.unstubAllEnvs(); - } - }); - - it('reads GITNEXUS_WORKER_CONSECUTIVE_FAILURE_THRESHOLD env override', () => { - vi.stubEnv('GITNEXUS_WORKER_CONSECUTIVE_FAILURE_THRESHOLD', '12'); - try { - expect(resolveWorkerPoolOptions({}, 1).consecutiveFailureThreshold).toBe(12); - } finally { - vi.unstubAllEnvs(); - } - }); -});