refactor(orcad): every snapshot state op fits the gateway exec budget in shell; the state lock sends its script once (#30744)

* refactor(orcad): every snapshot state op fits the gateway exec budget in shell; the state lock sends its script once

* test(orcad): a restore that stops part way reports FAILED and reruns from the archive
This commit is contained in:
Neil
2026-10-19 07:54:34 -07:00
committed by GitHub
parent 8ff19bc126
commit 43abe329c5
6 changed files with 139 additions and 140 deletions
@@ -87,7 +87,7 @@ describe.skipIf(process.platform === 'win32')(
expect(conn.exec).toHaveBeenCalledTimes(1)
})
it('captures a snapshot through a gateway that truncates the plain command and merges stderr', async () => {
it('captures a snapshot whole through a gateway that cuts exec requests at 6 KiB and merges stderr', async () => {
const base = mkdtempSync(join(tmpdir(), 'orcad-gateway-capture-'))
try {
const root = join(base, '.orca')
@@ -100,20 +100,11 @@ describe.skipIf(process.platform === 'win32')(
snapshot,
join(base, '.orca-remote')
)
// The command embeds the temp path ~40 times, so its size varies by OS; pick a cut the
// plain form always exceeds and the compressed form always fits.
const plainBytes = Buffer.byteLength(
wrapRemoteCommandForPosixShell(command, { compress: false })
)
const compressedBytes = Buffer.byteLength(
wrapRemoteCommandForPosixShell(command, { compress: true })
)
const gatewayLimitBytes = Math.min(
10 * 1024,
Math.floor((plainBytes + compressedBytes) / 2)
)
expect(plainBytes).toBeGreaterThan(gatewayLimitBytes)
expect(compressedBytes).toBeLessThan(gatewayLimitBytes)
// Under the byte budget, so even uncompressed nothing is cut.
const gatewayLimitBytes = 6 * 1024
expect(
Buffer.byteLength(wrapRemoteCommandForPosixShell(command, { compress: false }))
).toBeLessThan(gatewayLimitBytes)
const output = await execCommand(host({ gatewayLimitBytes }), command)