mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 10:08:13 +00:00
* test: exercise runtime request routing with deterministic socket deadlines * test: isolate local status and await redaction stream completion --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
101 lines
3.0 KiB
TypeScript
101 lines
3.0 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { RemoteRuntimeClientError } from '../../shared/remote-runtime-client-error'
|
|
import type { PairedRuntimeConnection } from '../../shared/paired-runtime-connection'
|
|
import { orchestrationMutationRecoveryError } from '../orchestration-mutation-recovery'
|
|
|
|
const { sendRemoteRuntimeRequest, sendRemoteRuntimeRequestWithStatusPreflight } = vi.hoisted(
|
|
() => ({
|
|
sendRemoteRuntimeRequest: vi.fn(),
|
|
sendRemoteRuntimeRequestWithStatusPreflight: vi.fn()
|
|
})
|
|
)
|
|
|
|
vi.mock('../../shared/remote-runtime-client', () => ({
|
|
sendRemoteRuntimeRequest,
|
|
sendRemoteRuntimeRequestWithStatusPreflight
|
|
}))
|
|
|
|
import {
|
|
sendWebSocketRequest,
|
|
sendWebSocketRequestWithStatusPreflight
|
|
} from './websocket-transport'
|
|
|
|
const pairing = {
|
|
endpoint: 'ws://127.0.0.1:1',
|
|
hostPublicKeyB64: Buffer.from(new Uint8Array(32).fill(1)).toString('base64'),
|
|
credential: { kind: 'token', deviceToken: 'token' }
|
|
} satisfies PairedRuntimeConnection
|
|
|
|
describe('CLI WebSocket transport error identity', () => {
|
|
it('preserves recovery data from one-shot transport errors', async () => {
|
|
sendRemoteRuntimeRequest.mockRejectedValueOnce(
|
|
new RemoteRuntimeClientError('runtime_timeout', 'timed out', {
|
|
data: {
|
|
orchestrationRequestId: 'request_1',
|
|
dispatchId: 'dispatch_1',
|
|
originalCommand: ['orca', 'orchestration', 'worker-start', '--task', 'task_1']
|
|
}
|
|
})
|
|
)
|
|
|
|
try {
|
|
await sendWebSocketRequest(pairing, 'orchestration.workerStart', {}, 100)
|
|
throw new Error('expected transport failure')
|
|
} catch (error) {
|
|
expect(error).toMatchObject({
|
|
code: 'runtime_timeout',
|
|
data: {
|
|
orchestrationRequestId: 'request_1',
|
|
dispatchId: 'dispatch_1',
|
|
originalCommand: ['orca', 'orchestration', 'worker-start', '--task', 'task_1']
|
|
}
|
|
})
|
|
expect(orchestrationMutationRecoveryError(error)).toMatchObject({
|
|
data: {
|
|
recovery: {
|
|
dispatchId: 'dispatch_1',
|
|
queryCommand: [
|
|
'orca',
|
|
'orchestration',
|
|
'worker-show',
|
|
'--dispatch',
|
|
'dispatch_1',
|
|
'--json'
|
|
],
|
|
retryCommand: [
|
|
'orca',
|
|
'orchestration',
|
|
'worker-start',
|
|
'--task',
|
|
'task_1',
|
|
'--retry-request',
|
|
'request_1'
|
|
]
|
|
}
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
it('preserves recovery data through status-preflight transport errors', async () => {
|
|
sendRemoteRuntimeRequestWithStatusPreflight.mockRejectedValueOnce(
|
|
new RemoteRuntimeClientError('runtime_timeout', 'timed out', {
|
|
data: { orchestrationRequestId: 'request_2' }
|
|
})
|
|
)
|
|
|
|
await expect(
|
|
sendWebSocketRequestWithStatusPreflight(
|
|
pairing,
|
|
'orchestration.workerStart',
|
|
{},
|
|
100,
|
|
() => {}
|
|
)
|
|
).rejects.toMatchObject({
|
|
code: 'runtime_timeout',
|
|
data: { orchestrationRequestId: 'request_2' }
|
|
})
|
|
})
|
|
})
|