dsh-ris-ide 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/client.js +311 -72
- package/lib/debug/vendor/README.md +14 -0
- package/lib/debug/vendor/jdwp/client.js +9 -4
- package/lib/debug/vendor/src/jdwp/client.ts +12 -5
- package/lib/index.js +794 -48
- package/lib/redirector.js +42 -2
- package/lib/risd/lifecycle.js +9 -3
- package/lib/risd/server.js +308 -13
- package/lib/risd/ui.js +149 -112
- package/lib/risd-client.js +4 -1
- package/lib/startup.js +27 -7
- package/package.json +2 -2
- package/test/client-viewer.test.mjs +188 -95
- package/test/clipboard.test.mjs +259 -0
- package/test/debug-engine.test.mjs +3 -1
- package/test/dsh-origin.test.mjs +4 -11
- package/test/dsh-window-refresh.test.mjs +166 -1
- package/test/harness.test.mjs +1 -1
- package/test/helpers/cmd.mjs +29 -0
- package/test/helpers/tgz.mjs +71 -0
- package/test/host-search.test.mjs +18 -11
- package/test/host-tail.test.mjs +119 -24
- package/test/proxy-route.test.mjs +61 -0
- package/test/proxy-window.test.mjs +5 -0
- package/test/proxy.test.mjs +13 -1
- package/test/proxybridge-bundle.test.mjs +1 -59
- package/test/redirector-bundle.test.mjs +21 -67
- package/test/redirector.test.mjs +41 -4
- package/test/risd-api.test.mjs +81 -28
- package/test/risd-bridge-degrade.test.mjs +3 -29
- package/test/risd-engine.test.mjs +13 -50
- package/test/risd-entry.test.mjs +0 -37
- package/test/risd-follow-start.test.mjs +101 -0
- package/test/risd-git.test.mjs +7 -5
- package/test/risd-handoff.test.mjs +6 -50
- package/test/risd-helpers.mjs +150 -3
- package/test/risd-host-p2.test.mjs +2 -30
- package/test/risd-lifecycle.test.mjs +25 -0
- package/test/risd-programs.test.mjs +4 -34
- package/test/risd-review-p2.test.mjs +0 -13
- package/test/risd-shutdown.test.mjs +5 -38
- package/test/risd-teardown.test.mjs +8 -27
- package/test/risd-ui.test.mjs +169 -13
- package/test/risd-write.test.mjs +2 -1
- package/test/startup-reconcile.test.mjs +44 -8
- package/test/proxy-restart.test.mjs +0 -39
|
@@ -14,8 +14,8 @@ import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync,
|
|
|
14
14
|
import { tmpdir } from 'node:os'
|
|
15
15
|
import { join } from 'node:path'
|
|
16
16
|
import test from 'node:test'
|
|
17
|
-
import { gzipSync } from 'node:zlib'
|
|
18
17
|
|
|
18
|
+
import { fileContent, fetchServing, makeTgz } from './helpers/tgz.mjs'
|
|
19
19
|
import { DEFAULT_BUNDLE_URL, bundleLayout, installDir, installFromTgz, isInstalled } from '../lib/proxybridge-bundle.js'
|
|
20
20
|
|
|
21
21
|
const home = mkdtempSync(join(tmpdir(), 'ris-redirector-home-'))
|
|
@@ -36,42 +36,6 @@ const {
|
|
|
36
36
|
const BUNDLE = bundleLayout()
|
|
37
37
|
const WINDOWS_FILES = ['ProxyBridge_CLI.exe', 'ProxyBridgeCore.dll', 'WinDivert.dll', 'WinDivert64.sys']
|
|
38
38
|
const LICENCES = ['NOTICE.md', 'LICENSE-ProxyBridge.txt']
|
|
39
|
-
const fileContent = (rel) => `fixture bytes for ${rel}\n`
|
|
40
|
-
|
|
41
|
-
/** Octal field: width-1 digits + NUL, as ustar spells numbers. */
|
|
42
|
-
const octalField = (value, width) => `${value.toString(8).padStart(width - 1, '0')}\0`
|
|
43
|
-
|
|
44
|
-
function tarHeader(name, size, { mode = 0o644 } = {}) {
|
|
45
|
-
const header = Buffer.alloc(512, 0)
|
|
46
|
-
Buffer.from(name, 'utf8').copy(header, 0)
|
|
47
|
-
header.write(octalField(mode, 8), 100, 'ascii')
|
|
48
|
-
header.write(octalField(0, 8), 108, 'ascii')
|
|
49
|
-
header.write(octalField(0, 8), 116, 'ascii')
|
|
50
|
-
header.write(octalField(size, 12), 124, 'ascii')
|
|
51
|
-
header.write(octalField(0, 12), 136, 'ascii')
|
|
52
|
-
header.write(' ', 148, 'ascii')
|
|
53
|
-
header.write('0', 156, 'ascii')
|
|
54
|
-
header.write('ustar\0', 257, 'ascii')
|
|
55
|
-
header.write('00', 263, 'ascii')
|
|
56
|
-
let sum = 0
|
|
57
|
-
for (const byte of header) sum += byte
|
|
58
|
-
header.write(`${sum.toString(8).padStart(6, '0')}\0 `, 148, 'ascii')
|
|
59
|
-
return header
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** Build a real `.tgz` from `{name, content, mode}` entries. */
|
|
63
|
-
function makeTgz(entries) {
|
|
64
|
-
const chunks = []
|
|
65
|
-
for (const entry of entries) {
|
|
66
|
-
const content = Buffer.from(entry.content)
|
|
67
|
-
chunks.push(tarHeader(entry.name, content.length, entry))
|
|
68
|
-
chunks.push(content)
|
|
69
|
-
const pad = (512 - (content.length % 512)) % 512
|
|
70
|
-
if (pad > 0) chunks.push(Buffer.alloc(pad))
|
|
71
|
-
}
|
|
72
|
-
chunks.push(Buffer.alloc(1024))
|
|
73
|
-
return gzipSync(Buffer.concat(chunks))
|
|
74
|
-
}
|
|
75
39
|
|
|
76
40
|
const bundleTgz = () => makeTgz(BUNDLE.map((rel) => ({
|
|
77
41
|
name: rel,
|
|
@@ -79,20 +43,6 @@ const bundleTgz = () => makeTgz(BUNDLE.map((rel) => ({
|
|
|
79
43
|
mode: /\.(exe|dll|sys|so)$|ProxyBridge$/.test(rel) === true ? 0o755 : 0o644,
|
|
80
44
|
})))
|
|
81
45
|
|
|
82
|
-
/** `fetch` stand-in serving one body; records every URL it was asked for. */
|
|
83
|
-
function fetchServing(body) {
|
|
84
|
-
const calls = { urls: [] }
|
|
85
|
-
const impl = async (url) => {
|
|
86
|
-
calls.urls.push(String(url))
|
|
87
|
-
return {
|
|
88
|
-
ok: true,
|
|
89
|
-
status: 200,
|
|
90
|
-
arrayBuffer: async () => body.buffer.slice(body.byteOffset, body.byteOffset + body.length),
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return { impl, calls }
|
|
94
|
-
}
|
|
95
|
-
|
|
96
46
|
const installFixture = () => {
|
|
97
47
|
// A fresh machine starts with no cache; every test proves its own precondition.
|
|
98
48
|
rmSync(join(home, 'proxybridge'), { recursive: true, force: true })
|
|
@@ -277,7 +227,11 @@ test('a failed materialisation is not cached: the next call retries', () => {
|
|
|
277
227
|
}
|
|
278
228
|
})
|
|
279
229
|
|
|
280
|
-
test('ensureBundleReady
|
|
230
|
+
test('ensureBundleReady is a thin wrapper over the bundle install', async () => {
|
|
231
|
+
// The download/cache/failure semantics themselves are covered by the bundle
|
|
232
|
+
// module tests; here we pin only what this wrapper owns: it downloads into the
|
|
233
|
+
// machine-level proxy home, forwards the machine settings, maps the outcome for
|
|
234
|
+
// the dialog (fromCache/url/error/hint) and never throws.
|
|
281
235
|
rmSync(join(home, 'proxybridge'), { recursive: true, force: true })
|
|
282
236
|
__test.clearProbeCaches()
|
|
283
237
|
delete process.env.DSH_RIS_IDE_PROXYBRIDGE_URL
|
|
@@ -285,38 +239,38 @@ test('ensureBundleReady downloads into the proxy home and reuses the cache', asy
|
|
|
285
239
|
const first = await ensureBundleReady({ fetchImpl: impl })
|
|
286
240
|
assert.equal(first.ok, true)
|
|
287
241
|
assert.equal(first.fromCache, false)
|
|
288
|
-
assert.equal(first.dir, installDir(home))
|
|
242
|
+
assert.equal(first.dir, installDir(home), 'the download lands in proxyHomeDir(), not a caller path')
|
|
289
243
|
assert.equal(first.url, DEFAULT_BUNDLE_URL)
|
|
290
244
|
assert.equal(isInstalled(installDir(home)), true)
|
|
291
245
|
const second = await ensureBundleReady({ fetchImpl: impl })
|
|
292
246
|
assert.equal(second.ok, true)
|
|
293
247
|
assert.equal(second.fromCache, true, 'the cache must be reused without another request')
|
|
248
|
+
assert.equal(second.dir, first.dir)
|
|
294
249
|
assert.equal(calls.urls.length, 1)
|
|
295
|
-
})
|
|
296
250
|
|
|
297
|
-
|
|
251
|
+
// A failed download is a value, not a throw, and the wrapper passes the bundle
|
|
252
|
+
// error/hint through to the dialog.
|
|
298
253
|
rmSync(join(home, 'proxybridge'), { recursive: true, force: true })
|
|
299
254
|
__test.clearProbeCaches()
|
|
300
255
|
const failing = async () => ({ ok: false, status: 502, arrayBuffer: async () => new ArrayBuffer(0) })
|
|
301
|
-
const
|
|
302
|
-
assert.equal(
|
|
303
|
-
assert.match(String(
|
|
304
|
-
assert.match(String(
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
256
|
+
const failed = await ensureBundleReady({ fetchImpl: failing })
|
|
257
|
+
assert.equal(failed.ok, false)
|
|
258
|
+
assert.match(String(failed.error), /HTTP 502/)
|
|
259
|
+
assert.match(String(failed.hint), /检查网络/)
|
|
260
|
+
|
|
261
|
+
// The wrapper reads settings.json and forwards it, but URL resolution lives only
|
|
262
|
+
// in `resolveBundleUrls` (env → settings → mirrors), so redirector-side and
|
|
263
|
+
// daemon-side installs agree (review A3-P2-1).
|
|
308
264
|
rmSync(join(home, 'proxybridge'), { recursive: true, force: true })
|
|
309
265
|
__test.clearProbeCaches()
|
|
310
266
|
const settingsPath = join(home, 'settings.json')
|
|
311
267
|
writeFileSync(settingsPath, JSON.stringify({ proxybridgeUrl: 'https://mirror.example/ris-proxy.tgz' }))
|
|
312
268
|
process.env.DSH_RIS_IDE_PROXYBRIDGE_URL = 'https://env.example/ris-proxy.tgz'
|
|
313
|
-
const
|
|
269
|
+
const envFetch = fetchServing(bundleTgz())
|
|
314
270
|
try {
|
|
315
|
-
const result = await ensureBundleReady({ fetchImpl: impl })
|
|
271
|
+
const result = await ensureBundleReady({ fetchImpl: envFetch.impl })
|
|
316
272
|
assert.equal(result.ok, true)
|
|
317
|
-
|
|
318
|
-
// so redirector-side and daemon-side installs agree (review A3-P2-1).
|
|
319
|
-
assert.deepEqual(calls.urls, ['https://env.example/ris-proxy.tgz'])
|
|
273
|
+
assert.deepEqual(envFetch.calls.urls, ['https://env.example/ris-proxy.tgz'])
|
|
320
274
|
} finally {
|
|
321
275
|
delete process.env.DSH_RIS_IDE_PROXYBRIDGE_URL
|
|
322
276
|
rmSync(settingsPath, { force: true })
|
package/test/redirector.test.mjs
CHANGED
|
@@ -10,13 +10,43 @@ import assert from 'node:assert/strict'
|
|
|
10
10
|
import { chmodSync, existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync, mkdirSync } from 'node:fs'
|
|
11
11
|
import { tmpdir } from 'node:os'
|
|
12
12
|
import { join } from 'node:path'
|
|
13
|
-
import test from 'node:test'
|
|
13
|
+
import test, { after } from 'node:test'
|
|
14
|
+
|
|
15
|
+
import { engineSide } from '../lib/proxy.js'
|
|
16
|
+
import { HAS_WSLPATH, skipWithout } from './helpers/cmd.mjs'
|
|
14
17
|
|
|
15
18
|
const home = mkdtempSync(join(tmpdir(), 'ris-redirector-home-'))
|
|
16
19
|
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
17
20
|
|
|
21
|
+
// `spawnDetachedText` unrefs its timeout and its child on purpose (a launcher that
|
|
22
|
+
// outlives its caller must not hold the daemon open). Those handles can be the ONLY
|
|
23
|
+
// thing a waiting test has, and on node 20/22 the test runner keeps no handle of its
|
|
24
|
+
// own: the loop runs dry, the pending `await` never settles and every later test in
|
|
25
|
+
// the file is cancelled with "Promise resolution is still pending but the event loop
|
|
26
|
+
// has already resolved". node 24 happens to keep the runner referenced, which is why
|
|
27
|
+
// this only failed in CI. Hold ONE referenced timer for the file; the after hook
|
|
28
|
+
// releases it so the runner can still exit.
|
|
29
|
+
const keepLoopAlive = setInterval(() => { /* keep the loop referenced (see above) */ }, 1000)
|
|
30
|
+
after(() => clearInterval(keepLoopAlive))
|
|
31
|
+
|
|
18
32
|
const { __test } = await import('../lib/redirector.js')
|
|
19
33
|
|
|
34
|
+
/**
|
|
35
|
+
* CI runs this suite on a plain Linux host (a k8s pod): no WSL, no `wslpath`, no
|
|
36
|
+
* Windows side — so `windowsPathOf` cannot answer there and the two watchdog
|
|
37
|
+
* tests could only ever run on a developer's WSL machine. On such a host we
|
|
38
|
+
* inject the mapping the WSL box would have produced; production still asks
|
|
39
|
+
* `wslpath` (`test/redirector.test.mjs` is the only caller of this seam).
|
|
40
|
+
*/
|
|
41
|
+
const WSL_DISTRO = 'Ubuntu'
|
|
42
|
+
if (engineSide() !== 'wsl') {
|
|
43
|
+
__test.setWindowsPathTranslator((path) => {
|
|
44
|
+
const text = String(path)
|
|
45
|
+
if (text.startsWith('/') !== true) return ''
|
|
46
|
+
return `\\\\wsl.localhost\\${WSL_DISTRO}${text.replace(/\//g, '\\')}`
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
20
50
|
/**
|
|
21
51
|
* Every probe that could reach the real Windows side is stubbed for the whole
|
|
22
52
|
* file. A test run must never enumerate, kill or elevate the user's actual
|
|
@@ -31,7 +61,7 @@ const BASE_HOOKS = {
|
|
|
31
61
|
taskkill: () => 'ERROR: Access is denied.',
|
|
32
62
|
}
|
|
33
63
|
__test.setProbeHooks(BASE_HOOKS)
|
|
34
|
-
process.on('exit', () => __test.resetProbeHooks())
|
|
64
|
+
process.on('exit', () => { __test.resetProbeHooks(); __test.setWindowsPathTranslator(null) })
|
|
35
65
|
/** Use one extra stub for a single test, then fall back to the safe defaults. */
|
|
36
66
|
const useHooks = (hooks) => {
|
|
37
67
|
__test.resetProbeHooks()
|
|
@@ -66,6 +96,10 @@ test('a Windows command line never carries a WSL-only /mnt path', async () => {
|
|
|
66
96
|
cliPath: '/mnt/x/Program Files/ProxyBridge/ProxyBridge_CLI.exe',
|
|
67
97
|
profilePath: profile,
|
|
68
98
|
platform: 'win32',
|
|
99
|
+
// The translation rule is what is under test here, not whether THIS machine
|
|
100
|
+
// has a Windows side: on a plain-Linux CI host `engineSide()` is 'linux' and
|
|
101
|
+
// the default gate would keep `/mnt` in the command line.
|
|
102
|
+
translate: true,
|
|
69
103
|
})
|
|
70
104
|
assert.equal(plan.display.includes('/mnt/'), false, 'no mnt path may survive in the Windows command')
|
|
71
105
|
assert.ok(plan.display.includes('X:\\Program Files'), 'the executable must be spelled the Windows way')
|
|
@@ -298,7 +332,10 @@ test('the old single pid file is migrated to the side it names (M1)', () => {
|
|
|
298
332
|
__test.clearRedirectorPid()
|
|
299
333
|
})
|
|
300
334
|
|
|
301
|
-
|
|
335
|
+
// 纯 Linux(Jenkins 裸镜像)用上面的接缝;WSL 上必须真有 wslpath 才能算 Windows 路径。
|
|
336
|
+
const WINDOWS_SIDE = engineSide() !== 'wsl' || HAS_WSLPATH
|
|
337
|
+
|
|
338
|
+
test('the parked-service state has ONE path shared by writer and watchdog (B2)', { skip: skipWithout(WINDOWS_SIDE, 'wslpath') }, async () => {
|
|
302
339
|
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
303
340
|
const mod = await import('../lib/redirector.js')
|
|
304
341
|
const canonical = __test.serviceStatePath()
|
|
@@ -541,7 +578,7 @@ test('the heartbeat ages out and the stop signals round-trip', async () => {
|
|
|
541
578
|
}
|
|
542
579
|
})
|
|
543
580
|
|
|
544
|
-
test('the elevated watchdog script carries the rules it needs to tear down', async () => {
|
|
581
|
+
test('the elevated watchdog script carries the rules it needs to tear down', { skip: skipWithout(WINDOWS_SIDE, 'wslpath') }, async () => {
|
|
545
582
|
const tmpHome = mkdtempSync(join(tmpdir(), 'wd-'))
|
|
546
583
|
process.env.DSH_RIS_IDE_PROXY_HOME = tmpHome
|
|
547
584
|
const mod = await import('../lib/redirector.js')
|
package/test/risd-api.test.mjs
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import assert from 'node:assert/strict'
|
|
11
11
|
import test from 'node:test'
|
|
12
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
12
|
+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
13
|
+
import { createServer } from 'node:http'
|
|
13
14
|
import { join } from 'node:path'
|
|
14
15
|
import { tmpdir } from 'node:os'
|
|
15
16
|
import { createHash } from 'node:crypto'
|
|
16
17
|
import { gzipSync } from 'node:zlib'
|
|
17
18
|
import { RISD_API_VERSION, risdStatePath } from '../lib/risd/state.js'
|
|
18
|
-
import { successorArgs } from '../lib/risd/server.js'
|
|
19
19
|
import { bundleLayout } from '../lib/proxybridge-bundle.js'
|
|
20
20
|
import { readProxyConfig } from '../lib/proxy.js'
|
|
21
21
|
import { risdConfigRevision } from '../lib/risd/view.js'
|
|
@@ -191,18 +191,21 @@ test('the payload is the whole table: rows it leaves out are retired (m10585)',
|
|
|
191
191
|
}), null, 2)}\n`, { mode: 0o600 })
|
|
192
192
|
const view = await (await call(state, `/v1/proxy?cwd=${encodeURIComponent(ws)}`)).json()
|
|
193
193
|
const userRule = view.rules.find((rule) => rule.id === 'r1')
|
|
194
|
+
// A row the stored table never had proves the upsert direction too (it used to
|
|
195
|
+
// live in a separate test, risd-api:'a sent row is upserted…').
|
|
196
|
+
const newRow = { id: 'kept-1', program: 'java', hosts: '10.0.0.*', ports: '*', enabled: true, source: 'yds' }
|
|
194
197
|
const saved = await call(state, '/v1/proxy', {
|
|
195
198
|
method: 'POST',
|
|
196
199
|
body: {
|
|
197
200
|
cwd: ws,
|
|
198
|
-
config: { socks: view.socks, listenPort: view.listenPort, rules: [userRule] },
|
|
201
|
+
config: { socks: view.socks, listenPort: view.listenPort, rules: [userRule, newRow] },
|
|
199
202
|
revision: view.revision,
|
|
200
203
|
},
|
|
201
204
|
})
|
|
202
205
|
assert.equal(saved.status, 200)
|
|
203
206
|
const after = await (await call(state, `/v1/proxy?cwd=${encodeURIComponent(ws)}`)).json()
|
|
204
|
-
assert.deepEqual(after.rules.map((rule) => rule.id).sort(), ['r1'],
|
|
205
|
-
'only the rows in the payload survive')
|
|
207
|
+
assert.deepEqual(after.rules.map((rule) => rule.id).sort(), ['kept-1', 'r1'],
|
|
208
|
+
'the sent row is inserted, and only the rows in the payload survive')
|
|
206
209
|
})
|
|
207
210
|
|
|
208
211
|
test('the ping route probes the configured SOCKS upstream and honours overrides', async (t) => {
|
|
@@ -271,10 +274,6 @@ test('the ProxyBridge bundle card reports status and rejects a bad upload', asyn
|
|
|
271
274
|
// A forced probe while stopped still must not spawn anything (nothing to judge).
|
|
272
275
|
const forced = await (await call(state, '/v1/proxybridge/health?force=1')).json()
|
|
273
276
|
assert.equal(forced.checked, false)
|
|
274
|
-
// The reconciler probes the bridge only when there is something to reconcile:
|
|
275
|
-
// a stopped engine with no pid file must not spawn PowerShell on every poll.
|
|
276
|
-
assert.match(readFileSync(new URL('../lib/risd/server.js', import.meta.url), 'utf8'), /engineStopped === true && hasBridgePidFiles\(\) !== true\) return/)
|
|
277
|
-
|
|
278
277
|
// A non-tar body is answered with a reason, not a crash or a half-installed dir.
|
|
279
278
|
const bad = await fetch(`${state.url}/v1/proxybridge/upload`, {
|
|
280
279
|
method: 'POST',
|
|
@@ -409,17 +408,76 @@ test('/v1/dsh drops unusable `at` values and counts them (review A3-P2-6)', asyn
|
|
|
409
408
|
assert.equal(body.dropped, 3, 'every unusable timestamp is reported, not silently pruned')
|
|
410
409
|
})
|
|
411
410
|
|
|
412
|
-
test('
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
411
|
+
test('/v1/dsh probes a live host when no usable snapshot exists (m00186)', async (t) => {
|
|
412
|
+
// The daemon cannot read dsh's own API (its launch token lives in dsh's memory), so
|
|
413
|
+
// the plugin advertises one `instances/dsh-<pid>.json` per running host. When the
|
|
414
|
+
// shared document is missing or unusable, the daemon must ask that host directly
|
|
415
|
+
// instead of concluding "dsh is not running".
|
|
416
|
+
const home = makeHome('risd-dsh-probe-')
|
|
417
|
+
const saved = process.env.DSH_RIS_IDE_PROXY_HOME
|
|
418
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
419
|
+
t.after(() => {
|
|
420
|
+
if (saved === undefined) delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
421
|
+
else process.env.DSH_RIS_IDE_PROXY_HOME = saved
|
|
422
|
+
removeHome(home)
|
|
419
423
|
})
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
424
|
+
const plugin = createServer((req, res) => {
|
|
425
|
+
if (req.url !== '/dsh-ris-ide/workspaces') {
|
|
426
|
+
res.writeHead(404)
|
|
427
|
+
res.end()
|
|
428
|
+
return
|
|
429
|
+
}
|
|
430
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
431
|
+
res.end(JSON.stringify({
|
|
432
|
+
ok: true,
|
|
433
|
+
url: `http://127.0.0.1:${plugin.address().port}`,
|
|
434
|
+
at: new Date().toISOString(),
|
|
435
|
+
workspaces: [{ cwd: '/tmp/ws-probe', title: 'probed', sessionId: 's-probe', active: true }],
|
|
436
|
+
}))
|
|
437
|
+
})
|
|
438
|
+
await new Promise((resolve) => plugin.listen(0, '127.0.0.1', resolve))
|
|
439
|
+
t.after(() => new Promise((resolve) => plugin.close(resolve)))
|
|
440
|
+
const origin = `http://127.0.0.1:${plugin.address().port}`
|
|
441
|
+
mkdirSync(join(home, 'instances'), { recursive: true })
|
|
442
|
+
writeFileSync(join(home, 'instances', 'dsh-424242.json'), `${JSON.stringify({
|
|
443
|
+
pid: 424242,
|
|
444
|
+
url: origin,
|
|
445
|
+
at: new Date().toISOString(),
|
|
446
|
+
})}\n`)
|
|
447
|
+
const daemon = await startRisdProcess({ home, env: { DSH_RIS_IDE_PROXY_HOME: home } })
|
|
448
|
+
t.after(() => daemon.stop())
|
|
449
|
+
const body = await (await call(daemon.state, '/v1/dsh')).json()
|
|
450
|
+
assert.equal(body.available, true, 'a live instance file is enough to find the host')
|
|
451
|
+
assert.equal(body.url, origin)
|
|
452
|
+
assert.deepEqual(body.windows.map((row) => [row.cwd, row.title, row.sessionId, row.source, row.active]), [
|
|
453
|
+
['/tmp/ws-probe', 'probed', 's-probe', 'workspace', true],
|
|
454
|
+
])
|
|
455
|
+
assert.equal(body.knownWorkspaces, 1)
|
|
456
|
+
})
|
|
457
|
+
|
|
458
|
+
test('/v1/dsh names how many workspaces it found when no origin is usable (m00186)', async (t) => {
|
|
459
|
+
// "dsh is not running" and "dsh reported workspaces but no origin to embed" are
|
|
460
|
+
// different answers: the page can only show the count in the second case.
|
|
461
|
+
const home = makeHome('risd-dsh-known-')
|
|
462
|
+
const saved = process.env.DSH_RIS_IDE_PROXY_HOME
|
|
463
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
464
|
+
t.after(() => {
|
|
465
|
+
if (saved === undefined) delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
466
|
+
else process.env.DSH_RIS_IDE_PROXY_HOME = saved
|
|
467
|
+
removeHome(home)
|
|
468
|
+
})
|
|
469
|
+
const daemon = await startRisdProcess({ home, env: { DSH_RIS_IDE_PROXY_HOME: home } })
|
|
470
|
+
t.after(() => daemon.stop())
|
|
471
|
+
writeFileSync(join(home, 'dsh-window.json'), `${JSON.stringify({
|
|
472
|
+
windows: [],
|
|
473
|
+
workspaces: [{ cwd: '/tmp/ws-a', title: 'alpha' }, { cwd: '/tmp/ws-b', title: 'beta' }],
|
|
474
|
+
at: new Date().toISOString(),
|
|
475
|
+
})}\n`)
|
|
476
|
+
const body = await (await call(daemon.state, '/v1/dsh')).json()
|
|
477
|
+
assert.equal(body.available, false)
|
|
478
|
+
assert.deepEqual(body.windows, [])
|
|
479
|
+
assert.equal(body.knownWorkspaces, 2)
|
|
480
|
+
assert.match(String(body.reason), /已发现 2 个 dsh 工作区/)
|
|
423
481
|
})
|
|
424
482
|
|
|
425
483
|
test('an upload whose digest is not the pinned one is rejected (review B-P0-1)', async (t) => {
|
|
@@ -491,14 +549,6 @@ test('a restart request hands over to a successor that waits for this pid (m1142
|
|
|
491
549
|
assert.match(server, /spawnRestartSuccessor\(actualPort\)\n\s*if \(onShutdown !== null\) onShutdown\(true\)/, 'the restart path spawns the successor with the live port then hands off')
|
|
492
550
|
// A4-P2-6: the successor keeps the port this daemon actually bound; A4-P2-5: it
|
|
493
551
|
// also carries the predecessor identity so a reused pid is not waited on.
|
|
494
|
-
const argv = successorArgs({ pid: 4321, port: 11082, startTime: '987654' })
|
|
495
|
-
assert.equal(argv[1], 'serve')
|
|
496
|
-
assert.deepEqual(argv.slice(2, 4), ['--wait-pid', '4321'])
|
|
497
|
-
assert.deepEqual(argv.slice(argv.indexOf('--port'), argv.indexOf('--port') + 2), ['--port', '11082'])
|
|
498
|
-
assert.deepEqual(argv.slice(argv.indexOf('--wait-start'), argv.indexOf('--wait-start') + 2), ['--wait-start', '987654'])
|
|
499
|
-
const noPort = successorArgs({ pid: 7, port: 0, startTime: '' })
|
|
500
|
-
assert.equal(noPort.includes('--port'), false, 'port 0 means "let the OS choose", never --port 0')
|
|
501
|
-
assert.equal(noPort.includes('--wait-start'), false)
|
|
502
552
|
const cli = readFileSync(new URL('../bin/risd.mjs', import.meta.url), 'utf8')
|
|
503
553
|
assert.match(cli, /arg === '--wait-pid'/, 'the CLI understands --wait-pid')
|
|
504
554
|
assert.match(cli, /arg === '--wait-start'/, 'the CLI understands the pid identity hint')
|
|
@@ -507,7 +557,10 @@ test('a restart request hands over to a successor that waits for this pid (m1142
|
|
|
507
557
|
|
|
508
558
|
test('the daemon only prompts on a user-initiated start and files elevation state per side (review B-P0-2/B-P1-1)', async () => {
|
|
509
559
|
const source = readFileSync(new URL('../lib/risd/server.js', import.meta.url), 'utf8')
|
|
510
|
-
assert.match(source, /const
|
|
560
|
+
assert.match(source, /const interactive = parsed\.interactive === true/, 'the flag is opt-in: saving rules and dsh starting never ask for a password')
|
|
561
|
+
assert.match(source, /const redirector = await serializeBridge\(\(\) => startRedirectors\(\{ interactive \}\)\)/)
|
|
562
|
+
const plugin = readFileSync(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
563
|
+
assert.match(plugin, /const interactive = body\.interactive === true/, 'the plugin forwards the explicit-click flag')
|
|
511
564
|
const reconcile = source.indexOf('startRedirectors({ sides: missing, interactive: false })')
|
|
512
565
|
assert.ok(reconcile > 0, 'the reconciler starts without an interactive prompt')
|
|
513
566
|
assert.match(source, /linux: readElevationState\('local', \{ home \}\)/, 'the elevation file is named after the side that writes it')
|
|
@@ -12,8 +12,8 @@ import { createServer } from 'node:http'
|
|
|
12
12
|
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
13
13
|
import { tmpdir } from 'node:os'
|
|
14
14
|
import { join } from 'node:path'
|
|
15
|
-
import { Readable } from 'node:stream'
|
|
16
15
|
import test from 'node:test'
|
|
16
|
+
import { fakeReq, fakeRes, risdBridge } from './risd-helpers.mjs'
|
|
17
17
|
|
|
18
18
|
const home = mkdtempSync(join(tmpdir(), 'risd-degrade-'))
|
|
19
19
|
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
@@ -21,24 +21,6 @@ process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
|
21
21
|
const { __test } = await import('../lib/index.js')
|
|
22
22
|
const { RISD_API_VERSION } = await import('../lib/risd/state.js')
|
|
23
23
|
|
|
24
|
-
function fakeRes() {
|
|
25
|
-
return {
|
|
26
|
-
status: 0,
|
|
27
|
-
chunks: [],
|
|
28
|
-
writeHead(status) { this.status = status },
|
|
29
|
-
write(chunk) { this.chunks.push(String(chunk)); return true },
|
|
30
|
-
end(chunk) { if (chunk !== undefined) this.chunks.push(String(chunk)) },
|
|
31
|
-
json() { return JSON.parse(this.chunks.join('')) },
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function fakeReq(method, url, body) {
|
|
35
|
-
const chunks = body === undefined ? [] : [Buffer.from(JSON.stringify(body))]
|
|
36
|
-
const req = Readable.from(chunks)
|
|
37
|
-
req.method = method
|
|
38
|
-
req.url = url
|
|
39
|
-
req.headers = { host: '127.0.0.1:3080', 'content-type': 'application/json' }
|
|
40
|
-
return req
|
|
41
|
-
}
|
|
42
24
|
|
|
43
25
|
const workspace = mkdtempSync(join(tmpdir(), 'risd-degrade-ws-'))
|
|
44
26
|
const ctx = { sessions: { get: () => ({ header: { cwd: workspace } }) } }
|
|
@@ -50,15 +32,7 @@ test.after(() => {
|
|
|
50
32
|
})
|
|
51
33
|
|
|
52
34
|
test('a failed read keeps the lease, marks the bridge degraded and answers locally', async () => {
|
|
53
|
-
const bridge = {
|
|
54
|
-
mode: 'auto',
|
|
55
|
-
state: { url: 'http://127.0.0.1:9', token: 'x', apiVersion: RISD_API_VERSION, port: 9 },
|
|
56
|
-
leaseId: 'lease-x',
|
|
57
|
-
pending: null,
|
|
58
|
-
warnedAt: 0,
|
|
59
|
-
degraded: false,
|
|
60
|
-
lastProbeAt: Date.now(),
|
|
61
|
-
}
|
|
35
|
+
const bridge = risdBridge({ url: 'http://127.0.0.1:9', token: 'x' })
|
|
62
36
|
__test.setRisdBridge(bridge)
|
|
63
37
|
const res = fakeRes()
|
|
64
38
|
await __test.serveProxy(ctx, fakeReq('GET', '/dsh-ris-ide/proxy?sessionId=s1'), res)
|
|
@@ -86,7 +60,7 @@ test('a write refuses to go local while the daemon still answers health', async
|
|
|
86
60
|
version: '1.8.0', startedAt: new Date().toISOString(), home,
|
|
87
61
|
url: `http://127.0.0.1:${port}`,
|
|
88
62
|
}, null, 2)}\n`, { mode: 0o600 })
|
|
89
|
-
const bridge = {
|
|
63
|
+
const bridge = risdBridge({ degraded: true })
|
|
90
64
|
__test.setRisdBridge(bridge)
|
|
91
65
|
const before = readFileSync(join(home, 'proxy.json'), 'utf8')
|
|
92
66
|
const res = fakeRes()
|
|
@@ -7,48 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import assert from 'node:assert/strict'
|
|
9
9
|
import test from 'node:test'
|
|
10
|
-
import { existsSync, mkdtempSync, rmSync
|
|
10
|
+
import { existsSync, mkdtempSync, rmSync } from 'node:fs'
|
|
11
11
|
import { tmpdir } from 'node:os'
|
|
12
12
|
import { join } from 'node:path'
|
|
13
|
-
import {
|
|
14
|
-
import { makeHome, removeHome,
|
|
15
|
-
|
|
16
|
-
function pickPort() {
|
|
17
|
-
return 20000 + Math.floor(Math.random() * 20000)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function writeEngineFixture(home, port) {
|
|
21
|
-
const config = {
|
|
22
|
-
socks: { host: '127.0.0.1', port: 1, dbPort: 0, redisPort: 0 },
|
|
23
|
-
listenPort: port,
|
|
24
|
-
rules: [
|
|
25
|
-
{
|
|
26
|
-
id: 'rule-1',
|
|
27
|
-
program: 'java',
|
|
28
|
-
hosts: ['127.0.0.1'],
|
|
29
|
-
ports: ['443'],
|
|
30
|
-
enabled: true,
|
|
31
|
-
shadow: false,
|
|
32
|
-
source: 'user',
|
|
33
|
-
workspace: home,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
}
|
|
37
|
-
writeFileSync(join(home, 'proxy.json'), JSON.stringify(config, null, 2))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function headers(state) {
|
|
41
|
-
return { authorization: `Bearer ${state.token}`, 'x-risd-api-version': String(RISD_API_VERSION), 'content-type': 'application/json' }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function waitFor(fn, timeoutMs = 8000) {
|
|
45
|
-
const deadline = Date.now() + timeoutMs
|
|
46
|
-
while (Date.now() < deadline) {
|
|
47
|
-
if (await fn()) return true
|
|
48
|
-
await sleep(120)
|
|
49
|
-
}
|
|
50
|
-
return false
|
|
51
|
-
}
|
|
13
|
+
import { risdStatePath } from '../lib/risd/state.js'
|
|
14
|
+
import { makeHome, pickPort, removeHome, risdHeaders, startRisdProcess, waitFor, writeEngineFixture } from './risd-helpers.mjs'
|
|
52
15
|
|
|
53
16
|
test('the daemon starts/stops the engine and reports one pid everywhere', async (t) => {
|
|
54
17
|
const home = makeHome('risd-engine-')
|
|
@@ -56,7 +19,7 @@ test('the daemon starts/stops the engine and reports one pid everywhere', async
|
|
|
56
19
|
writeEngineFixture(home, pickPort())
|
|
57
20
|
const daemon = await startRisdProcess({ home, env: { DSH_RIS_IDE_PROXY_HOME: home } })
|
|
58
21
|
t.after(async () => {
|
|
59
|
-
await fetch(`${daemon.state.url}/v1/engine`, { method: 'POST', headers:
|
|
22
|
+
await fetch(`${daemon.state.url}/v1/engine`, { method: 'POST', headers: risdHeaders(daemon.state), body: JSON.stringify({ action: 'stop', cwd }) }).catch(() => {})
|
|
60
23
|
await daemon.stop()
|
|
61
24
|
removeHome(home)
|
|
62
25
|
rmSync(cwd, { recursive: true, force: true })
|
|
@@ -64,7 +27,7 @@ test('the daemon starts/stops the engine and reports one pid everywhere', async
|
|
|
64
27
|
|
|
65
28
|
const started = await fetch(`${daemon.state.url}/v1/engine`, {
|
|
66
29
|
method: 'POST',
|
|
67
|
-
headers:
|
|
30
|
+
headers: risdHeaders(daemon.state),
|
|
68
31
|
body: JSON.stringify({ action: 'start', cwd }),
|
|
69
32
|
})
|
|
70
33
|
const startBody = await started.json()
|
|
@@ -75,7 +38,7 @@ test('the daemon starts/stops the engine and reports one pid everywhere', async
|
|
|
75
38
|
assert.equal(Number.isInteger(pid) && pid > 0, true)
|
|
76
39
|
assert.equal(existsSync(join(home, 'proxy.pid')), true, 'the daemon must own the pidfile')
|
|
77
40
|
|
|
78
|
-
const read = await (await fetch(`${daemon.state.url}/v1/engine?cwd=${encodeURIComponent(cwd)}`, { headers:
|
|
41
|
+
const read = await (await fetch(`${daemon.state.url}/v1/engine?cwd=${encodeURIComponent(cwd)}`, { headers: risdHeaders(daemon.state) })).json()
|
|
79
42
|
assert.equal(read.engine.owned, true)
|
|
80
43
|
assert.equal(read.engine.running, true)
|
|
81
44
|
assert.equal(read.engine.pid, pid)
|
|
@@ -86,14 +49,14 @@ test('the daemon starts/stops the engine and reports one pid everywhere', async
|
|
|
86
49
|
|
|
87
50
|
const stopped = await (await fetch(`${daemon.state.url}/v1/engine`, {
|
|
88
51
|
method: 'POST',
|
|
89
|
-
headers:
|
|
52
|
+
headers: risdHeaders(daemon.state),
|
|
90
53
|
body: JSON.stringify({ action: 'stop', cwd }),
|
|
91
54
|
})).json()
|
|
92
55
|
assert.equal(stopped.ok, true)
|
|
93
56
|
assert.equal(stopped.result.stopped, true)
|
|
94
57
|
assert.equal(await waitFor(() => !existsSync(join(home, 'proxy.pid'))), true)
|
|
95
58
|
|
|
96
|
-
const after = await (await fetch(`${daemon.state.url}/v1/engine?cwd=${encodeURIComponent(cwd)}`, { headers:
|
|
59
|
+
const after = await (await fetch(`${daemon.state.url}/v1/engine?cwd=${encodeURIComponent(cwd)}`, { headers: risdHeaders(daemon.state) })).json()
|
|
97
60
|
assert.equal(after.engine.running, false)
|
|
98
61
|
assert.equal(after.engine.owned, false)
|
|
99
62
|
})
|
|
@@ -104,15 +67,15 @@ test('engine requests are validated and serialized', async (t) => {
|
|
|
104
67
|
writeEngineFixture(home, pickPort())
|
|
105
68
|
const daemon = await startRisdProcess({ home, env: { DSH_RIS_IDE_PROXY_HOME: home } })
|
|
106
69
|
t.after(async () => {
|
|
107
|
-
await fetch(`${daemon.state.url}/v1/engine`, { method: 'POST', headers:
|
|
70
|
+
await fetch(`${daemon.state.url}/v1/engine`, { method: 'POST', headers: risdHeaders(daemon.state), body: JSON.stringify({ action: 'stop', cwd }) }).catch(() => {})
|
|
108
71
|
await daemon.stop()
|
|
109
72
|
removeHome(home)
|
|
110
73
|
rmSync(cwd, { recursive: true, force: true })
|
|
111
74
|
})
|
|
112
75
|
|
|
113
|
-
const bad = await fetch(`${daemon.state.url}/v1/engine`, { method: 'POST', headers:
|
|
76
|
+
const bad = await fetch(`${daemon.state.url}/v1/engine`, { method: 'POST', headers: risdHeaders(daemon.state), body: JSON.stringify({ action: 'restart', cwd }) })
|
|
114
77
|
assert.equal(bad.status, 400)
|
|
115
|
-
const relative = await fetch(`${daemon.state.url}/v1/engine`, { method: 'POST', headers:
|
|
78
|
+
const relative = await fetch(`${daemon.state.url}/v1/engine`, { method: 'POST', headers: risdHeaders(daemon.state), body: JSON.stringify({ action: 'start', cwd: 'relative/path' }) })
|
|
116
79
|
assert.equal(relative.status, 400)
|
|
117
80
|
const noAuth = await fetch(`${daemon.state.url}/v1/engine?cwd=/tmp/ws`)
|
|
118
81
|
assert.equal(noAuth.status, 401)
|
|
@@ -120,13 +83,13 @@ test('engine requests are validated and serialized', async (t) => {
|
|
|
120
83
|
// Two concurrent presses: both answer, one engine, no duplicate listeners.
|
|
121
84
|
const [a, b] = await Promise.all(['start', 'start'].map((action) => fetch(`${daemon.state.url}/v1/engine`, {
|
|
122
85
|
method: 'POST',
|
|
123
|
-
headers:
|
|
86
|
+
headers: risdHeaders(daemon.state),
|
|
124
87
|
body: JSON.stringify({ action, cwd }),
|
|
125
88
|
}).then((res) => res.json())))
|
|
126
89
|
assert.equal(a.ok && b.ok, true)
|
|
127
90
|
const first = a.result.pid || b.result.pid
|
|
128
91
|
assert.equal(Number.isInteger(first) && first > 0, true)
|
|
129
|
-
const status = await (await fetch(`${daemon.state.url}/v1/status?cwd=${encodeURIComponent(cwd)}`, { headers:
|
|
92
|
+
const status = await (await fetch(`${daemon.state.url}/v1/status?cwd=${encodeURIComponent(cwd)}`, { headers: risdHeaders(daemon.state) })).json()
|
|
130
93
|
assert.equal(status.running, true)
|
|
131
94
|
assert.equal(status.pid, first)
|
|
132
95
|
})
|
package/test/risd-entry.test.mjs
CHANGED
|
@@ -13,34 +13,12 @@ const host = readFileSync(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
|
13
13
|
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
|
|
14
14
|
const bin = readFileSync(new URL('../bin/risd.mjs', import.meta.url), 'utf8')
|
|
15
15
|
|
|
16
|
-
test('both IDE entry points open the risd page, with the window as fallback', () => {
|
|
17
|
-
assert.match(client, /async function openRisdPage\(scope, fallback\)/, 'one shared opener')
|
|
18
|
-
// Header ⧉ and the sidebar console ⧉ both go through it.
|
|
19
|
-
assert.equal((client.match(/await openRisdPage\(/g) ?? []).length, 2, 'two entry points')
|
|
20
|
-
// The page lives on the daemon origin and is reused by tab name.
|
|
21
|
-
assert.match(client, /window\.open\(target, 'dsh-risd-ui'\)/)
|
|
22
|
-
// The entry point preselects the workspace but does not switch the tab anymore
|
|
23
|
-
// (m11345): the maintenance page keeps whatever tab the user was on.
|
|
24
|
-
assert.match(client, /\?cwd=' \+ encodeURIComponent\(cwd\) : ''/)
|
|
25
|
-
assert.doesNotMatch(client, /'tab=ide' \+/)
|
|
26
|
-
assert.match(client, /target = risd\.url \+ '\/ui' \+ query/)
|
|
27
|
-
// Without a daemon (daemonMode=off) the old standalone window still works.
|
|
28
|
-
assert.ok((client.match(/openStandaloneWindow\(/g) ?? []).length >= 2, 'fallbacks stay in place')
|
|
29
|
-
})
|
|
30
|
-
|
|
31
16
|
test('the host view reports the daemon page address', () => {
|
|
32
17
|
// proxyView (daemonMode=off ⇒ available:false) and mergeRisdView both carry it.
|
|
33
18
|
assert.equal((host.match(/risd: risdBridge !== null && risdBridge\.state !== null/g) ?? []).length, 2)
|
|
34
19
|
assert.match(host, /url: risdBridge\.state\.url, port: risdBridge\.state\.port/)
|
|
35
20
|
})
|
|
36
21
|
|
|
37
|
-
test('neither console carries a proxy button any more', () => {
|
|
38
|
-
assert.doesNotMatch(client, /consoleConfigActions\.push\(button\('🌐'/, 'console 🌐 removed')
|
|
39
|
-
// The sidebar's compact bar lost its 🌐 too: rules live on the risd page.
|
|
40
|
-
assert.doesNotMatch(client, /data-action': 'compact-proxy'/)
|
|
41
|
-
assert.doesNotMatch(client, /compactProxyOpen/)
|
|
42
|
-
})
|
|
43
|
-
|
|
44
22
|
test('the CLI is `risd`, exposed through package.json', () => {
|
|
45
23
|
assert.deepEqual(pkg.bin, { risd: 'bin/risd.mjs' })
|
|
46
24
|
assert.match(bin, /^#!\/usr\/bin\/env node/)
|
|
@@ -101,18 +79,3 @@ test('an api-version mismatch is a "restart dsh" answer, not a failed start (C-P
|
|
|
101
79
|
// The forward path maps it to design §7.1's 503 instead of reusing the 409 branch.
|
|
102
80
|
assert.match(host, /new TailError\('risd-upgrade-required'[\s\S]{0,120}503\)/)
|
|
103
81
|
})
|
|
104
|
-
|
|
105
|
-
test('tools probe a half-dead daemon and say when they fell back to local (C-P2-2)', () => {
|
|
106
|
-
// A daemon that died between two tool calls used to look healthy forever: every
|
|
107
|
-
// call then paid a 2 s timeout and ran locally without a word.
|
|
108
|
-
assert.match(host, /const health = await risdHealth\(bridge\.state\)\.catch\(\(\) => null\)/)
|
|
109
|
-
assert.match(host, /if \(Date\.now\(\) - \(bridge\.lastProbeAt \?\? 0\) < 5000\) return bridge\.state/)
|
|
110
|
-
assert.match(host, /if \(healed === null\) warnDaemonFallback\(\)/)
|
|
111
|
-
assert.match(host, /不在 daemon 的托管范围内(停 daemon 不会停它)/)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
test('a transport failure on a proxy action says "retry", not "500" (C-P2-8)', () => {
|
|
115
|
-
assert.match(host, /if \(call\.status === 0 \|\| call\.body === null\) \{/)
|
|
116
|
-
assert.match(host, /new TailError\('risd-unavailable'[\s\S]{0,200}503\)/)
|
|
117
|
-
assert.match(host, /void risdBridgeState\(cwd\)\.catch\(\(\) => \{\}\)/)
|
|
118
|
-
})
|