Skip to content

Commit 0c08be4

Browse files
committed
test(execution): stop the lease deadline override leaking between tests
- Add `IVM_LEASE_REDIS_DEADLINE_MS` to the harness env reset. It was absent, so a test that overrode it left the value in the module-scoped mock env for every later test in the file, quietly changing their fallback timing. - Drop the duplicate over-limit test and fold its extra assertion into the existing one; the two had identical setup and covered the same path.
1 parent b9e640c commit 0c08be4

1 file changed

Lines changed: 3 additions & 30 deletions

File tree

apps/sim/lib/execution/isolated-vm.test.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ const { mockSpawn, mockExecSync, mockEnv } = vi.hoisted(() => ({
185185
IVM_MAX_OWNER_WEIGHT: '5',
186186
IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER: '100',
187187
IVM_DISTRIBUTED_LEASE_MIN_TTL_MS: '1000',
188+
IVM_LEASE_REDIS_DEADLINE_MS: '1000',
188189
IVM_QUEUE_TIMEOUT_MS: '1000',
189190
IVM_MAX_FETCH_RESPONSE_BYTES: '',
190191
IVM_MAX_FETCH_RESPONSE_CHARS: '',
@@ -246,6 +247,7 @@ async function loadExecutionModule(options: {
246247
IVM_MAX_OWNER_WEIGHT: '5',
247248
IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER: '100',
248249
IVM_DISTRIBUTED_LEASE_MIN_TTL_MS: '1000',
250+
IVM_LEASE_REDIS_DEADLINE_MS: '1000',
249251
IVM_QUEUE_TIMEOUT_MS: '1000',
250252
IVM_MAX_FETCH_RESPONSE_BYTES: '',
251253
IVM_MAX_FETCH_RESPONSE_CHARS: '',
@@ -497,6 +499,7 @@ describe('isolated-vm scheduler', () => {
497499
})
498500

499501
expect(result.error?.message).toContain('Too many concurrent')
502+
expect(result.result).toBeNull()
500503
})
501504

502505
it('falls back to local limits when no Redis client is available', async () => {
@@ -651,36 +654,6 @@ describe('isolated-vm scheduler', () => {
651654
expect(result.error?.message).toContain('Too many concurrent')
652655
})
653656

654-
it('still rejects when Redis answers that the owner is over its lease limit', async () => {
655-
const { executeInIsolatedVM } = await loadExecutionModule({
656-
envOverrides: {
657-
IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER: '1',
658-
REDIS_URL: 'redis://localhost:6379',
659-
},
660-
spawns: [() => createReadyProc('ok')],
661-
redisEvalImpl: (...args: unknown[]) => {
662-
const script = String(args[0] ?? '')
663-
if (script.includes('ZREMRANGEBYSCORE')) {
664-
return 0
665-
}
666-
return 1
667-
},
668-
})
669-
670-
const result = await executeInIsolatedVM({
671-
code: 'return "ok"',
672-
params: {},
673-
envVars: {},
674-
contextVariables: {},
675-
timeoutMs: 100,
676-
requestId: 'req-10',
677-
ownerKey: 'user:over-limit',
678-
})
679-
680-
expect(result.error?.message).toContain('Too many concurrent')
681-
expect(result.result).toBeNull()
682-
})
683-
684657
it('reports cancellation when abort races a rejected distributed lease', async () => {
685658
let resolveLease!: (value: number) => void
686659
let markLeaseRequested!: () => void

0 commit comments

Comments
 (0)