refactor(tasks): simplify admission configuration

This commit is contained in:
pku-xht
2026-08-11 17:12:53 +08:00
parent 9d173f8333
commit c98a4d0949
6 changed files with 58 additions and 36 deletions

View File

@@ -25,7 +25,7 @@ describe('tasks-local through a real Loader composition', () => {
await writeFile(configPath, [
"- name: '@deepseek-ai/dsh-tasks-local'",
' config:',
' maxConcurrentTasksPerOwner: 2',
' maxConcurrentTasksPerOwner: 1',
'',
].join('\n'))
@@ -47,6 +47,20 @@ describe('tasks-local through a real Loader composition', () => {
await context.loader.await()
expect(context.tasks).toBeInstanceOf(LocalTaskService)
expect((context.tasks as LocalTaskService).config.maxConcurrentTasksPerOwner).toBe(2)
context.tasks.attachController('loader-test')
let settle!: (outcome: { status: 'killed' }) => void
context.tasks.start({
kind: 'bash',
label: 'hold loader slot',
run: () => ({
cancel: () => { settle({ status: 'killed' }) },
done: new Promise((resolve) => { settle = resolve }),
}),
})
expect(() => context!.tasks.start({
kind: 'bash',
label: 'blocked loader task',
run: () => ({ cancel: () => {}, done: Promise.resolve({ status: 'completed' }) }),
})).toThrow('(limit: 1)')
})
})