@impz/testing 6.6.0 → 6.7.0
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/dist/index.js +54 -38
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -18923,12 +18923,12 @@ var BACKUP_TREE = {
|
|
|
18923
18923
|
buildImageDir: (digest) => join("images", toDigestHex(digest))
|
|
18924
18924
|
};
|
|
18925
18925
|
|
|
18926
|
-
// packages/daemon/
|
|
18926
|
+
// packages/daemon/src/test-utils/start-test-impd.ts
|
|
18927
18927
|
import { copyFileSync as copyFileSync5, mkdirSync as mkdirSync31, mkdtempSync, writeFileSync as writeFileSync16 } from "fs";
|
|
18928
18928
|
import { rm as rm2 } from "fs/promises";
|
|
18929
18929
|
import { tmpdir } from "os";
|
|
18930
18930
|
|
|
18931
|
-
// packages/test-utils/
|
|
18931
|
+
// packages/shared/src/test-utils/claim-free-ports.ts
|
|
18932
18932
|
import { onTestFinished } from "bun:test";
|
|
18933
18933
|
import { randomInt } from "crypto";
|
|
18934
18934
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -18991,7 +18991,7 @@ function readBusyPorts() {
|
|
|
18991
18991
|
return busy;
|
|
18992
18992
|
}
|
|
18993
18993
|
|
|
18994
|
-
// packages/daemon/
|
|
18994
|
+
// packages/daemon/src/test-utils/start-test-impd.ts
|
|
18995
18995
|
import { createORPCClient as createORPCClient2 } from "@orpc/client";
|
|
18996
18996
|
import { RPCLink } from "@orpc/client/fetch";
|
|
18997
18997
|
import invariant7 from "tiny-invariant";
|
|
@@ -19011,6 +19011,10 @@ function formatBytes(bytes) {
|
|
|
19011
19011
|
const digits = unit === 0 || value >= 100 ? 0 : 1;
|
|
19012
19012
|
return `${value.toFixed(digits)} ${UNITS[unit] ?? "B"}`;
|
|
19013
19013
|
}
|
|
19014
|
+
// packages/shared/src/get-error-message.ts
|
|
19015
|
+
function getErrorMessage(error) {
|
|
19016
|
+
return error instanceof Error ? error.message : String(error);
|
|
19017
|
+
}
|
|
19014
19018
|
// packages/shared/src/merge-bytes.ts
|
|
19015
19019
|
function mergeBytes(chunks) {
|
|
19016
19020
|
const merged = new Uint8Array(chunks.reduce((sum, chunk) => sum + chunk.byteLength, 0));
|
|
@@ -19234,11 +19238,6 @@ import { randomBytes } from "crypto";
|
|
|
19234
19238
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
19235
19239
|
import { dirname, join as join2 } from "path";
|
|
19236
19240
|
|
|
19237
|
-
// packages/daemon/src/platform/process/get-error-message.ts
|
|
19238
|
-
function getErrorMessage(error) {
|
|
19239
|
-
return error instanceof Error ? error.message : String(error);
|
|
19240
|
-
}
|
|
19241
|
-
|
|
19242
19241
|
// packages/daemon/src/platform/process/get-impd-logger.ts
|
|
19243
19242
|
import { getLogger } from "@logtape/logtape";
|
|
19244
19243
|
function getImpdLogger(area) {
|
|
@@ -21972,7 +21971,7 @@ import { join as join48 } from "path";
|
|
|
21972
21971
|
// packages/daemon/package.json
|
|
21973
21972
|
var package_default = {
|
|
21974
21973
|
name: "@impz/daemon",
|
|
21975
|
-
version: "6.
|
|
21974
|
+
version: "6.7.0",
|
|
21976
21975
|
private: true,
|
|
21977
21976
|
description: "impd: the imp host daemon",
|
|
21978
21977
|
type: "module",
|
|
@@ -21980,13 +21979,9 @@ var package_default = {
|
|
|
21980
21979
|
".": "./src/index.ts",
|
|
21981
21980
|
"./read-text": "./src/platform/process/read-text.ts",
|
|
21982
21981
|
"./real-clock": "./src/platform/process/real-clock.ts",
|
|
21983
|
-
"./
|
|
21984
|
-
"./
|
|
21985
|
-
"./
|
|
21986
|
-
"./testing/pebble-images": "./testing/network/pebble-images.ts",
|
|
21987
|
-
"./testing/start-stub-agent": "./testing/vm/start-stub-agent.ts",
|
|
21988
|
-
"./testing/start-test-impd": "./testing/start-test-impd.ts",
|
|
21989
|
-
"./testing/test-token": "./testing/test-token.ts",
|
|
21982
|
+
"./test-utils": "./src/test-utils/index.ts",
|
|
21983
|
+
"./test-utils/data-layout": "./src/vm/storage/data-layout.ts",
|
|
21984
|
+
"./test-utils/*": "./src/test-utils/*.ts",
|
|
21990
21985
|
"./package.json": "./package.json"
|
|
21991
21986
|
},
|
|
21992
21987
|
dependencies: {
|
|
@@ -22029,7 +22024,8 @@ var package_default = {
|
|
|
22029
22024
|
},
|
|
22030
22025
|
devDependencies: {
|
|
22031
22026
|
"@faker-js/faker": "catalog:",
|
|
22032
|
-
"@impz/
|
|
22027
|
+
"@impz/cli": "workspace:*",
|
|
22028
|
+
"@impz/e2e-harness": "workspace:*",
|
|
22033
22029
|
"@modelcontextprotocol/client": "catalog:",
|
|
22034
22030
|
"@msw/data": "catalog:",
|
|
22035
22031
|
"@types/dns-packet": "catalog:",
|
|
@@ -26317,7 +26313,11 @@ async function sendAgentRequest(vsockPath, request, timeoutMs = 5000) {
|
|
|
26317
26313
|
const connection = await openAgentConnection(vsockPath, timeoutMs);
|
|
26318
26314
|
try {
|
|
26319
26315
|
sendRequestFrame(connection, request);
|
|
26320
|
-
const frame = await readFrameWithin(connection,
|
|
26316
|
+
const frame = await readFrameWithin(connection, {
|
|
26317
|
+
call: `${request.op} response`,
|
|
26318
|
+
vsockPath,
|
|
26319
|
+
timeoutMs
|
|
26320
|
+
});
|
|
26321
26321
|
if (frame?.type !== FRAME_TYPES.response) {
|
|
26322
26322
|
throw new Error(`agent ${request.op}: no response`);
|
|
26323
26323
|
}
|
|
@@ -26379,8 +26379,8 @@ async function sendThaw(vsockPath) {
|
|
|
26379
26379
|
const response = await sendAgentRequest(vsockPath, { op: "thaw" });
|
|
26380
26380
|
decodeAgentMessage(OKSchema, response);
|
|
26381
26381
|
}
|
|
26382
|
-
function readFrameWithin(connection,
|
|
26383
|
-
return requireWithin(connection.next(), timeoutMs, () => new Error(`agent
|
|
26382
|
+
function readFrameWithin(connection, wait) {
|
|
26383
|
+
return requireWithin(connection.next(), wait.timeoutMs, () => new Error(`agent at ${wait.vsockPath} sent no ${wait.call} within ${String(wait.timeoutMs)} ms`));
|
|
26384
26384
|
}
|
|
26385
26385
|
|
|
26386
26386
|
// packages/daemon/src/imps/imps/consistent-disk.ts
|
|
@@ -33480,7 +33480,11 @@ async function openStream(vsockPath, request, startTimeoutMs) {
|
|
|
33480
33480
|
let output;
|
|
33481
33481
|
try {
|
|
33482
33482
|
sendRequestFrame(connection, request);
|
|
33483
|
-
const first = await readFrameWithin(connection,
|
|
33483
|
+
const first = await readFrameWithin(connection, {
|
|
33484
|
+
call: `${request.op} start`,
|
|
33485
|
+
vsockPath,
|
|
33486
|
+
timeoutMs: startTimeoutMs
|
|
33487
|
+
});
|
|
33484
33488
|
if (first === null) {
|
|
33485
33489
|
throw new Error("agent closed the exec connection before the process started");
|
|
33486
33490
|
}
|
|
@@ -41333,7 +41337,11 @@ async function openRelayStream(vsockPath, request, feature, answerTimeoutMs) {
|
|
|
41333
41337
|
const connection = await openAgentConnection(vsockPath);
|
|
41334
41338
|
try {
|
|
41335
41339
|
sendRequestFrame(connection, request);
|
|
41336
|
-
const answer = await readFrameWithin(connection,
|
|
41340
|
+
const answer = await readFrameWithin(connection, {
|
|
41341
|
+
call: `${request.op} answer`,
|
|
41342
|
+
vsockPath,
|
|
41343
|
+
timeoutMs: answerTimeoutMs
|
|
41344
|
+
});
|
|
41337
41345
|
if (answer?.type !== FRAME_TYPES.response) {
|
|
41338
41346
|
throw new Error(`agent closed the ${request.op} connection before it answered`);
|
|
41339
41347
|
}
|
|
@@ -41379,12 +41387,16 @@ function buildListenRequest(spec) {
|
|
|
41379
41387
|
}
|
|
41380
41388
|
return { op: "listen", network: "tcp", address: `127.0.0.1:${String(spec.port)}` };
|
|
41381
41389
|
}
|
|
41382
|
-
async function openListener(vsockPath, spec) {
|
|
41390
|
+
async function openListener(vsockPath, spec, answerTimeoutMs = ANSWER_TIMEOUT_MS) {
|
|
41383
41391
|
const feature = spec.network === "ssh-agent" ? "agent-forwarding" : "reverse-forward";
|
|
41384
41392
|
const connection = await openAgentConnection(vsockPath);
|
|
41385
41393
|
try {
|
|
41386
41394
|
sendRequestFrame(connection, buildListenRequest(spec));
|
|
41387
|
-
const answer = await readFrameWithin(connection,
|
|
41395
|
+
const answer = await readFrameWithin(connection, {
|
|
41396
|
+
call: "listener answer",
|
|
41397
|
+
vsockPath,
|
|
41398
|
+
timeoutMs: answerTimeoutMs
|
|
41399
|
+
});
|
|
41388
41400
|
if (answer?.type !== FRAME_TYPES.response) {
|
|
41389
41401
|
throw new Error("agent closed the listen connection before it answered");
|
|
41390
41402
|
}
|
|
@@ -42286,7 +42298,7 @@ async function sendServicesRestart(vsockPath, service) {
|
|
|
42286
42298
|
const response = await sendAgentRequest(vsockPath, { op: "services.restart", service }, STOP_TIMEOUT_MS).catch(handleUnknownOp("services"));
|
|
42287
42299
|
decodeAgentMessage(OKSchema, response);
|
|
42288
42300
|
}
|
|
42289
|
-
async function openServiceLogStream(vsockPath, request) {
|
|
42301
|
+
async function openServiceLogStream(vsockPath, request, startTimeoutMs = LOGS_START_TIMEOUT_MS) {
|
|
42290
42302
|
const connection = await openAgentConnection(vsockPath);
|
|
42291
42303
|
try {
|
|
42292
42304
|
sendRequestFrame(connection, {
|
|
@@ -42296,7 +42308,11 @@ async function openServiceLogStream(vsockPath, request) {
|
|
|
42296
42308
|
follow: request.follow,
|
|
42297
42309
|
...request.cursor !== undefined && { cursor: request.cursor }
|
|
42298
42310
|
});
|
|
42299
|
-
const first = await readFrameWithin(connection,
|
|
42311
|
+
const first = await readFrameWithin(connection, {
|
|
42312
|
+
call: "services.logs start",
|
|
42313
|
+
vsockPath,
|
|
42314
|
+
timeoutMs: startTimeoutMs
|
|
42315
|
+
});
|
|
42300
42316
|
if (first === null) {
|
|
42301
42317
|
throw new Error("agent closed the log connection before it answered");
|
|
42302
42318
|
}
|
|
@@ -58516,12 +58532,12 @@ async function setupDefaultImage(config, images) {
|
|
|
58516
58532
|
}
|
|
58517
58533
|
}
|
|
58518
58534
|
|
|
58519
|
-
// packages/daemon/
|
|
58535
|
+
// packages/daemon/src/test-utils/network/read-no-tailscale.ts
|
|
58520
58536
|
function readNoTailscale() {
|
|
58521
58537
|
return Promise.resolve({ state: null, hostname: null, dnsName: null, ip: null, ips: [] });
|
|
58522
58538
|
}
|
|
58523
58539
|
|
|
58524
|
-
// packages/daemon/
|
|
58540
|
+
// packages/daemon/src/test-utils/platform/build-stub-ticker-timer.ts
|
|
58525
58541
|
function buildStubTickerTimer() {
|
|
58526
58542
|
const pending = new Map;
|
|
58527
58543
|
const holdRun = (label, run, durationMs) => {
|
|
@@ -58547,12 +58563,12 @@ function buildStubTickerTimer() {
|
|
|
58547
58563
|
};
|
|
58548
58564
|
}
|
|
58549
58565
|
|
|
58550
|
-
// packages/daemon/
|
|
58566
|
+
// packages/daemon/src/test-utils/platform/format-run-prefix.ts
|
|
58551
58567
|
function formatRunPrefix(owner) {
|
|
58552
58568
|
return `pid${String(owner.pid)}-ns${owner.namespace}-`;
|
|
58553
58569
|
}
|
|
58554
58570
|
|
|
58555
|
-
// packages/daemon/
|
|
58571
|
+
// packages/daemon/src/test-utils/platform/open-migrated-copy.ts
|
|
58556
58572
|
import { Database as Database4 } from "bun:sqlite";
|
|
58557
58573
|
var TEMPLATE = {};
|
|
58558
58574
|
function openMigratedCopy() {
|
|
@@ -58567,14 +58583,14 @@ async function serializeMigratedDatabase() {
|
|
|
58567
58583
|
return bytes;
|
|
58568
58584
|
}
|
|
58569
58585
|
|
|
58570
|
-
// packages/daemon/
|
|
58586
|
+
// packages/daemon/src/test-utils/platform/pick-impd-port.ts
|
|
58571
58587
|
var FIRST_PORT = 10100;
|
|
58572
58588
|
var PORT_SPAN = 9900;
|
|
58573
58589
|
function pickImpdPort(draw) {
|
|
58574
58590
|
return FIRST_PORT + Math.floor(draw * PORT_SPAN);
|
|
58575
58591
|
}
|
|
58576
58592
|
|
|
58577
|
-
// packages/daemon/
|
|
58593
|
+
// packages/daemon/src/test-utils/platform/read-run-owner.ts
|
|
58578
58594
|
import { readlinkSync as readlinkSync2 } from "fs";
|
|
58579
58595
|
function readRunOwner() {
|
|
58580
58596
|
return {
|
|
@@ -58583,7 +58599,7 @@ function readRunOwner() {
|
|
|
58583
58599
|
};
|
|
58584
58600
|
}
|
|
58585
58601
|
|
|
58586
|
-
// packages/daemon/
|
|
58602
|
+
// packages/daemon/src/test-utils/platform/start-impd-log-capture.ts
|
|
58587
58603
|
import { resetSync } from "@logtape/logtape";
|
|
58588
58604
|
|
|
58589
58605
|
// packages/daemon/src/platform/process/setup-logging.ts
|
|
@@ -58616,7 +58632,7 @@ function renderLogLine(record) {
|
|
|
58616
58632
|
`;
|
|
58617
58633
|
}
|
|
58618
58634
|
|
|
58619
|
-
// packages/daemon/
|
|
58635
|
+
// packages/daemon/src/test-utils/platform/start-impd-log-capture.ts
|
|
58620
58636
|
var listeners = new Set;
|
|
58621
58637
|
function startImpdLogCapture(onLine) {
|
|
58622
58638
|
if (listeners.size === 0) {
|
|
@@ -58634,10 +58650,10 @@ function startImpdLogCapture(onLine) {
|
|
|
58634
58650
|
};
|
|
58635
58651
|
}
|
|
58636
58652
|
|
|
58637
|
-
// packages/daemon/
|
|
58653
|
+
// packages/daemon/src/test-utils/test-token.ts
|
|
58638
58654
|
var TEST_TOKEN = "test-token";
|
|
58639
58655
|
|
|
58640
|
-
// packages/daemon/
|
|
58656
|
+
// packages/daemon/src/test-utils/vm/build-stub-vmm.ts
|
|
58641
58657
|
import { existsSync as existsSync33, mkdirSync as mkdirSync30, renameSync as renameSync8, writeFileSync as writeFileSync15 } from "fs";
|
|
58642
58658
|
var STUB_AGENT_VERSION = "0.1.0";
|
|
58643
58659
|
var IMPD_OWNER = { uid: process.getuid?.() ?? 0, cgroup: null };
|
|
@@ -59041,7 +59057,7 @@ log tail`);
|
|
|
59041
59057
|
};
|
|
59042
59058
|
}
|
|
59043
59059
|
|
|
59044
|
-
// packages/daemon/
|
|
59060
|
+
// packages/daemon/src/test-utils/start-test-impd.ts
|
|
59045
59061
|
var FAKE_VM_RAM_MIB = 300;
|
|
59046
59062
|
var FAKE_VM_RSS_MIB = 340;
|
|
59047
59063
|
var TEST_DRIVE = "d1".repeat(32);
|
|
@@ -59384,7 +59400,7 @@ function buildTestIdentity(dataDir, drive) {
|
|
|
59384
59400
|
import { randomBytes as randomBytes12 } from "crypto";
|
|
59385
59401
|
import { Duplex } from "stream";
|
|
59386
59402
|
|
|
59387
|
-
// packages/daemon/
|
|
59403
|
+
// packages/daemon/src/test-utils/vm/start-stub-agent.ts
|
|
59388
59404
|
import { onTestFinished as onTestFinished2 } from "bun:test";
|
|
59389
59405
|
import { mkdirSync as mkdirSync32 } from "fs";
|
|
59390
59406
|
import { createServer as createServer3 } from "net";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@impz/testing",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"description": "A real impd on stand-ins, for Bun tests of code that drives impd through @impz/client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"ts-pattern": "^5.9.2",
|
|
44
44
|
"xstate": "^5.33.3",
|
|
45
45
|
"zod": "^4.6.7",
|
|
46
|
-
"@impz/client": "6.
|
|
46
|
+
"@impz/client": "6.7.0"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"bun": ">=1.4.3"
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@opentelemetry/exporter-metrics-otlp-proto": "^0.300.0",
|
|
53
53
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.300.0",
|
|
54
|
-
"@opentelemetry/resources": "^
|
|
55
|
-
"@opentelemetry/sdk-metrics": "^
|
|
54
|
+
"@opentelemetry/resources": "^3.0.0",
|
|
55
|
+
"@opentelemetry/sdk-metrics": "^3.0.0",
|
|
56
56
|
"@opentelemetry/sdk-trace-base": "^2.12.0",
|
|
57
57
|
"acme-client": "^5.4.0"
|
|
58
58
|
},
|