mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-12 04:01:20 +00:00
test(code-runtime): allow measured worker initialization time
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, it, onTestFinished } from 'vitest'
|
||||
import { Context } from '@deepseek-ai/cordis'
|
||||
import { WorkerThreadCodeRuntime } from '@deepseek-ai/dsh-code-runtime-worker-thread'
|
||||
import type { Config } from '@deepseek-ai/dsh-code-runtime-worker-thread'
|
||||
@@ -185,12 +185,21 @@ describe('WorkerThreadCodeRuntime — budgets and containment (real workers)', (
|
||||
}, 15_000)
|
||||
|
||||
it('does not charge time spent awaiting a slow binding against the compute budget', async () => {
|
||||
// Keep the binding delay above the compute allowance while leaving enough
|
||||
// headroom for worker bootstrap on loaded CI hosts.
|
||||
const { runtime } = await setup({ computeMs: 1_000, maxWallMs: 30_000 })
|
||||
// Source-worker bootstrap consumes busy time before the binding can begin.
|
||||
// The idle delay must still exceed the entire compute allowance.
|
||||
const computeMs = 5_000
|
||||
const bindingDelayMs = computeMs + 1_500
|
||||
const { ctx, runtime } = await setup({ computeMs, maxWallMs: 30_000 })
|
||||
let bindingTimer: ReturnType<typeof setTimeout> | undefined
|
||||
onTestFinished(async () => {
|
||||
clearTimeout(bindingTimer)
|
||||
await ctx.fiber.dispose()
|
||||
})
|
||||
const result = await runtime.run({
|
||||
program: 'return await tools.slow({})',
|
||||
bindings: tools({ slow: () => new Promise(resolve => setTimeout(() => { resolve('slow-done') }, 1_500)) }),
|
||||
bindings: tools({ slow: () => new Promise((resolve) => {
|
||||
bindingTimer = setTimeout(() => { resolve('slow-done') }, bindingDelayMs)
|
||||
}) }),
|
||||
})
|
||||
expect(result.error).toBeUndefined()
|
||||
expect(result.value).toBe('slow-done')
|
||||
|
||||
Reference in New Issue
Block a user