dsh-ris-ide 1.8.0 → 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 +5 -3
- package/bin/risd.mjs +14 -17
- package/lib/client.js +400 -93
- 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/proxybridge-bundle.js +1 -1
- package/lib/proxybridge-health.js +206 -0
- package/lib/redirector.js +1181 -90
- package/lib/risd/lifecycle.js +9 -3
- package/lib/risd/server.js +762 -26
- package/lib/risd/ui.js +419 -98
- package/lib/risd-client.js +4 -1
- package/lib/startup.js +27 -7
- package/package.json +2 -2
- package/test/client-viewer.test.mjs +299 -120
- 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/proxybridge-health.test.mjs +116 -0
- package/test/redirector-bundle.test.mjs +21 -67
- package/test/redirector.test.mjs +395 -5
- package/test/risd-api.test.mjs +114 -17
- 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-restart.test.mjs +104 -0
- 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 +322 -4
- package/test/risd-write.test.mjs +2 -1
- package/test/startup-reconcile.test.mjs +44 -8
- package/test/proxy-restart.test.mjs +0 -37
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import test from 'node:test'
|
|
6
|
+
|
|
7
|
+
import { SIDE_FILES, collectProxyBridgeHealth, createHealthCache } from '../lib/proxybridge-health.js'
|
|
8
|
+
|
|
9
|
+
function seedBundle() {
|
|
10
|
+
const home = mkdtempSync(join(tmpdir(), 'pb-health-'))
|
|
11
|
+
const dir = join(home, 'proxybridge', 'bundle')
|
|
12
|
+
for (const files of Object.values(SIDE_FILES)) {
|
|
13
|
+
for (const relative of files) {
|
|
14
|
+
const path = join(dir, relative)
|
|
15
|
+
mkdirSync(join(path, '..'), { recursive: true })
|
|
16
|
+
writeFileSync(path, 'x')
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return home
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
test('both sides are healthy when every file exists and each CLI answers --version (m11828)', async () => {
|
|
23
|
+
const home = seedBundle()
|
|
24
|
+
const calls = []
|
|
25
|
+
try {
|
|
26
|
+
const health = await collectProxyBridgeHealth({
|
|
27
|
+
home,
|
|
28
|
+
engineRunning: true,
|
|
29
|
+
// Windows cannot launch an exe from the Linux filesystem: the probe targets the
|
|
30
|
+
// copy under %LOCALAPPDATA% (here a fake Windows path).
|
|
31
|
+
windowsExe: 'C:\\Users\\demo\\AppData\\Local\\dsh-ris-ide\\proxybridge\\windows\\ProxyBridge_CLI.exe',
|
|
32
|
+
run: async (command, args) => {
|
|
33
|
+
calls.push([command, args.at(-1) ?? ''])
|
|
34
|
+
return 'ProxyBridge 4.3.0\n'
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
assert.equal(health.ok, true)
|
|
38
|
+
assert.equal(health.installed, true)
|
|
39
|
+
assert.equal(health.sides.linux.version, '4.3.0')
|
|
40
|
+
assert.equal(health.sides.windows.version, '4.3.0')
|
|
41
|
+
assert.equal(health.engineRunning, true)
|
|
42
|
+
// Windows binaries cannot be launched straight from the Linux filesystem.
|
|
43
|
+
assert.ok(calls.some(([command]) => command === 'powershell.exe'))
|
|
44
|
+
} finally {
|
|
45
|
+
rmSync(home, { recursive: true, force: true })
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
test('a missing file or an unrunnable CLI is reported per side, not as a dead card', async () => {
|
|
50
|
+
const home = seedBundle()
|
|
51
|
+
try {
|
|
52
|
+
rmSync(join(home, 'proxybridge', 'bundle', 'windows', 'WinDivert.dll'))
|
|
53
|
+
const health = await collectProxyBridgeHealth({
|
|
54
|
+
home,
|
|
55
|
+
engineRunning: true,
|
|
56
|
+
windowsExe: 'C:\\fake\\ProxyBridge_CLI.exe',
|
|
57
|
+
run: async (command) => (command === 'powershell.exe' ? 'boom: missing DLL' : 'ProxyBridge 4.0.0'),
|
|
58
|
+
})
|
|
59
|
+
assert.equal(health.ok, false)
|
|
60
|
+
assert.equal(health.sides.linux.ok, true)
|
|
61
|
+
assert.equal(health.sides.windows.ok, false)
|
|
62
|
+
assert.ok(health.sides.windows.files.missing.includes('bundle/windows/WinDivert.dll'))
|
|
63
|
+
assert.match(health.sides.windows.checks.find((check) => check.id === 'runs').detail, /boom/)
|
|
64
|
+
} finally {
|
|
65
|
+
rmSync(home, { recursive: true, force: true })
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
test('a single-sided host is healthy, not broken (m12019)', async () => {
|
|
70
|
+
const home = seedBundle()
|
|
71
|
+
const run = async () => 'ProxyBridge 4.0.0'
|
|
72
|
+
try {
|
|
73
|
+
const linuxOnly = await collectProxyBridgeHealth({ home, engineRunning: true, linuxApplicable: true, windowsApplicable: false, run })
|
|
74
|
+
assert.equal(linuxOnly.ok, true, 'one side is enough')
|
|
75
|
+
assert.equal(linuxOnly.sides.windows.applicable, false)
|
|
76
|
+
assert.equal(linuxOnly.sides.windows.ok, true, 'a skipped side is neutral')
|
|
77
|
+
assert.match(linuxOnly.sides.windows.note, /没有 Windows 侧/)
|
|
78
|
+
|
|
79
|
+
const windowsOnly = await collectProxyBridgeHealth({ home, engineRunning: true, linuxApplicable: false, windowsApplicable: true, windowsExe: 'C:\\fake\\ProxyBridge_CLI.exe', run })
|
|
80
|
+
assert.equal(windowsOnly.ok, true)
|
|
81
|
+
assert.equal(windowsOnly.sides.linux.applicable, false)
|
|
82
|
+
|
|
83
|
+
// Installed, but the Windows copy has not been materialised yet (first start of
|
|
84
|
+
// the bridge prepares it): that is "not prepared", not "broken".
|
|
85
|
+
const notPrepared = await collectProxyBridgeHealth({ home, engineRunning: true, linuxApplicable: true, windowsApplicable: true, windowsPrepared: false, run })
|
|
86
|
+
assert.equal(notPrepared.ok, true)
|
|
87
|
+
assert.equal(notPrepared.sides.windows.skipped, true)
|
|
88
|
+
assert.match(notPrepared.sides.windows.note, /尚未复制/)
|
|
89
|
+
} finally {
|
|
90
|
+
rmSync(home, { recursive: true, force: true })
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('the health cache answers from memory unless forced', async () => {
|
|
95
|
+
const home = seedBundle()
|
|
96
|
+
let probes = 0
|
|
97
|
+
try {
|
|
98
|
+
const cache = createHealthCache()
|
|
99
|
+
const run = async () => { probes += 1; return 'ProxyBridge 4.0.0' }
|
|
100
|
+
const windowsExe = 'C:\\fake\\ProxyBridge_CLI.exe'
|
|
101
|
+
const first = await cache.get({ home, engineRunning: true, run, windowsExe })
|
|
102
|
+
assert.equal(first.cached, false)
|
|
103
|
+
const second = await cache.get({ home, engineRunning: true, run, windowsExe })
|
|
104
|
+
assert.equal(second.cached, true)
|
|
105
|
+
assert.equal(probes, 2, 'two sides probed once, then served from the cache')
|
|
106
|
+
// Applicability decides WHAT is probed, so a host shape with one side must not
|
|
107
|
+
// reuse the other shape's snapshot (review A4-P1-1).
|
|
108
|
+
const linuxOnly = await cache.get({ home, engineRunning: true, run })
|
|
109
|
+
assert.equal(linuxOnly.cached, false, 'a different applicability set is a cache miss')
|
|
110
|
+
assert.equal(probes, 3, 'with no Windows exe only the Linux side runs')
|
|
111
|
+
await cache.get({ home, engineRunning: true, force: true, run, windowsExe })
|
|
112
|
+
assert.equal(probes, 5, 'force re-probes both sides')
|
|
113
|
+
} finally {
|
|
114
|
+
rmSync(home, { recursive: true, force: true })
|
|
115
|
+
}
|
|
116
|
+
})
|
|
@@ -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 })
|