@impz/testing 7.4.0 → 7.5.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 +83 -66
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -21758,6 +21758,69 @@ function parseTailnetNamesConfig(env, dataDir, isOnTailnet) {
|
|
|
21758
21758
|
};
|
|
21759
21759
|
}
|
|
21760
21760
|
|
|
21761
|
+
// packages/daemon/src/platform/errors/impd-error.ts
|
|
21762
|
+
class ImpdError extends Error {
|
|
21763
|
+
name = "ImpdError";
|
|
21764
|
+
code;
|
|
21765
|
+
status;
|
|
21766
|
+
data;
|
|
21767
|
+
constructor(code, options) {
|
|
21768
|
+
super(options.message, buildErrorOptions(options.cause));
|
|
21769
|
+
this.code = code;
|
|
21770
|
+
this.status = options.status;
|
|
21771
|
+
this.data = options.data;
|
|
21772
|
+
}
|
|
21773
|
+
}
|
|
21774
|
+
function isImpdError(error, code) {
|
|
21775
|
+
return error instanceof ImpdError && error.code === code;
|
|
21776
|
+
}
|
|
21777
|
+
function buildErrorOptions(cause) {
|
|
21778
|
+
return cause === undefined ? undefined : { cause };
|
|
21779
|
+
}
|
|
21780
|
+
|
|
21781
|
+
// packages/daemon/src/vm/vmm/elastic-memory.ts
|
|
21782
|
+
var MAX_GROWTH_FACTOR = 4;
|
|
21783
|
+
var SLOT_MIB = 128;
|
|
21784
|
+
var BLOCK_MIB = 2;
|
|
21785
|
+
var ONLINE_MOVABLE_ARG = "memhp_default_state=online_movable";
|
|
21786
|
+
var GROW_STEP_MIB = 256;
|
|
21787
|
+
var LOW_FLOOR_MIB = 128;
|
|
21788
|
+
var LOW_FRACTION = 0.15;
|
|
21789
|
+
var STRUCT_PAGE_MIB_PER_GIB = 16;
|
|
21790
|
+
function getRegionMib(memoryMib, maxMemoryMib) {
|
|
21791
|
+
const growth = maxMemoryMib - memoryMib;
|
|
21792
|
+
return growth <= 0 ? 0 : Math.ceil(growth / SLOT_MIB) * SLOT_MIB;
|
|
21793
|
+
}
|
|
21794
|
+
function getLowMib(totalMib) {
|
|
21795
|
+
return Math.max(LOW_FLOOR_MIB, totalMib * LOW_FRACTION);
|
|
21796
|
+
}
|
|
21797
|
+
function getSpareTotalMib(usedMib) {
|
|
21798
|
+
return Math.max(usedMib + LOW_FLOOR_MIB + GROW_STEP_MIB, Math.ceil((usedMib + GROW_STEP_MIB) / (1 - LOW_FRACTION)));
|
|
21799
|
+
}
|
|
21800
|
+
function getStructPageMib(mib) {
|
|
21801
|
+
return Math.ceil(mib * STRUCT_PAGE_MIB_PER_GIB / 1024);
|
|
21802
|
+
}
|
|
21803
|
+
function resolveMaxMemoryMib(memoryMib, requested) {
|
|
21804
|
+
if (requested === undefined) {
|
|
21805
|
+
return memoryMib;
|
|
21806
|
+
}
|
|
21807
|
+
if (requested < memoryMib) {
|
|
21808
|
+
throw new ImpdError("BAD_REQUEST", {
|
|
21809
|
+
message: `the max memory (${String(requested)} MiB) is less than the memory (${String(memoryMib)} MiB)`
|
|
21810
|
+
});
|
|
21811
|
+
}
|
|
21812
|
+
const ceiling = memoryMib * MAX_GROWTH_FACTOR;
|
|
21813
|
+
if (requested > ceiling) {
|
|
21814
|
+
throw new ImpdError("BAD_REQUEST", {
|
|
21815
|
+
message: `the max memory (${String(requested)} MiB) is more than ${String(MAX_GROWTH_FACTOR)} \xD7 the memory (${String(ceiling)} MiB): memory the guest grows into cannot hold its kernel's own allocations, so raise the memory too`
|
|
21816
|
+
});
|
|
21817
|
+
}
|
|
21818
|
+
return requested;
|
|
21819
|
+
}
|
|
21820
|
+
function toWholeBlocks(mib) {
|
|
21821
|
+
return Math.ceil(mib / BLOCK_MIB) * BLOCK_MIB;
|
|
21822
|
+
}
|
|
21823
|
+
|
|
21761
21824
|
// packages/daemon/src/config.ts
|
|
21762
21825
|
var PortSchema3 = z54.coerce.number().pipe(z54.int().min(1).max(65535));
|
|
21763
21826
|
var CountSchema3 = z54.coerce.number().pipe(z54.int().positive());
|
|
@@ -21796,6 +21859,7 @@ var EnvSchema = z54.object({
|
|
|
21796
21859
|
IMP_DISK_RESERVE_GIB: CountSchema3.optional(),
|
|
21797
21860
|
IMP_BUILD_CONTEXT_MAX_MIB: CountSchema3.default(1024),
|
|
21798
21861
|
IMP_BUILD_MEMORY_MIB: CountSchema3.default(2048),
|
|
21862
|
+
IMP_BUILD_MAX_MEMORY_MIB: CountSchema3.optional(),
|
|
21799
21863
|
IMP_BUILD_DISK_GIB: CountSchema3.default(20),
|
|
21800
21864
|
IMP_BUILD_IMAGE_MAX_MIB: CountSchema3.default(8192),
|
|
21801
21865
|
IMP_BUILD_IMAGE_MAX_FILES: CountSchema3.default(1e6),
|
|
@@ -21964,6 +22028,7 @@ function loadConfig(env) {
|
|
|
21964
22028
|
buildContextMaxBytes: parsed.IMP_BUILD_CONTEXT_MAX_MIB * 1024 ** 2,
|
|
21965
22029
|
build: {
|
|
21966
22030
|
memoryMib: parsed.IMP_BUILD_MEMORY_MIB,
|
|
22031
|
+
maxMemoryMib: parseBuildMaxMemoryMib(parsed),
|
|
21967
22032
|
diskBytes: parsed.IMP_BUILD_DISK_GIB * 1024 ** 3,
|
|
21968
22033
|
imageMaxBytes: parsed.IMP_BUILD_IMAGE_MAX_MIB * 1024 ** 2,
|
|
21969
22034
|
imageMaxFiles: parsed.IMP_BUILD_IMAGE_MAX_FILES,
|
|
@@ -22025,6 +22090,20 @@ function parsePriorityRam(parsed) {
|
|
|
22025
22090
|
}
|
|
22026
22091
|
return { mib, patterns, ...ordinaryMib !== undefined && { ordinaryMib } };
|
|
22027
22092
|
}
|
|
22093
|
+
function parseBuildMaxMemoryMib(parsed) {
|
|
22094
|
+
const memoryMib = parsed.IMP_BUILD_MEMORY_MIB;
|
|
22095
|
+
const maxMemoryMib = parsed.IMP_BUILD_MAX_MEMORY_MIB;
|
|
22096
|
+
if (maxMemoryMib === undefined) {
|
|
22097
|
+
return null;
|
|
22098
|
+
}
|
|
22099
|
+
if (maxMemoryMib <= memoryMib) {
|
|
22100
|
+
throw new Error(`IMP_BUILD_MAX_MEMORY_MIB ${String(maxMemoryMib)} is not above the ${String(memoryMib)} MiB IMP_BUILD_MEMORY_MIB`);
|
|
22101
|
+
}
|
|
22102
|
+
if (maxMemoryMib > memoryMib * MAX_GROWTH_FACTOR) {
|
|
22103
|
+
throw new Error(`IMP_BUILD_MAX_MEMORY_MIB ${String(maxMemoryMib)} is more than ${String(MAX_GROWTH_FACTOR)} \xD7 the ${String(memoryMib)} MiB IMP_BUILD_MEMORY_MIB`);
|
|
22104
|
+
}
|
|
22105
|
+
return maxMemoryMib;
|
|
22106
|
+
}
|
|
22028
22107
|
function parseTestRegistry(parsed) {
|
|
22029
22108
|
const registry = parsed.IMP_BUILD_TEST_REGISTRY;
|
|
22030
22109
|
const caPath = parsed.IMP_BUILD_TEST_REGISTRY_CA;
|
|
@@ -22074,7 +22153,7 @@ import { join as join49 } from "path";
|
|
|
22074
22153
|
// packages/daemon/package.json
|
|
22075
22154
|
var package_default = {
|
|
22076
22155
|
name: "@impz/daemon",
|
|
22077
|
-
version: "7.
|
|
22156
|
+
version: "7.5.0",
|
|
22078
22157
|
private: true,
|
|
22079
22158
|
description: "impd: the imp host daemon",
|
|
22080
22159
|
type: "module",
|
|
@@ -23497,26 +23576,6 @@ class ImpClashError extends Error {
|
|
|
23497
23576
|
}
|
|
23498
23577
|
}
|
|
23499
23578
|
|
|
23500
|
-
// packages/daemon/src/platform/errors/impd-error.ts
|
|
23501
|
-
class ImpdError extends Error {
|
|
23502
|
-
name = "ImpdError";
|
|
23503
|
-
code;
|
|
23504
|
-
status;
|
|
23505
|
-
data;
|
|
23506
|
-
constructor(code, options) {
|
|
23507
|
-
super(options.message, buildErrorOptions(options.cause));
|
|
23508
|
-
this.code = code;
|
|
23509
|
-
this.status = options.status;
|
|
23510
|
-
this.data = options.data;
|
|
23511
|
-
}
|
|
23512
|
-
}
|
|
23513
|
-
function isImpdError(error, code) {
|
|
23514
|
-
return error instanceof ImpdError && error.code === code;
|
|
23515
|
-
}
|
|
23516
|
-
function buildErrorOptions(cause) {
|
|
23517
|
-
return cause === undefined ? undefined : { cause };
|
|
23518
|
-
}
|
|
23519
|
-
|
|
23520
23579
|
// packages/daemon/src/platform/errors/impd-errors.ts
|
|
23521
23580
|
function buildNotFoundError(kind, name) {
|
|
23522
23581
|
return new ImpdError("NOT_FOUND", {
|
|
@@ -40680,49 +40739,6 @@ function toApiError(error) {
|
|
|
40680
40739
|
// packages/daemon/src/imps/imps/imp-commands.ts
|
|
40681
40740
|
import { mkdirSync as mkdirSync12, rmSync as rmSync15 } from "fs";
|
|
40682
40741
|
|
|
40683
|
-
// packages/daemon/src/vm/vmm/elastic-memory.ts
|
|
40684
|
-
var MAX_GROWTH_FACTOR = 4;
|
|
40685
|
-
var SLOT_MIB = 128;
|
|
40686
|
-
var BLOCK_MIB = 2;
|
|
40687
|
-
var ONLINE_MOVABLE_ARG = "memhp_default_state=online_movable";
|
|
40688
|
-
var GROW_STEP_MIB = 256;
|
|
40689
|
-
var LOW_FLOOR_MIB = 128;
|
|
40690
|
-
var LOW_FRACTION = 0.15;
|
|
40691
|
-
var STRUCT_PAGE_MIB_PER_GIB = 16;
|
|
40692
|
-
function getRegionMib(memoryMib, maxMemoryMib) {
|
|
40693
|
-
const growth = maxMemoryMib - memoryMib;
|
|
40694
|
-
return growth <= 0 ? 0 : Math.ceil(growth / SLOT_MIB) * SLOT_MIB;
|
|
40695
|
-
}
|
|
40696
|
-
function getLowMib(totalMib) {
|
|
40697
|
-
return Math.max(LOW_FLOOR_MIB, totalMib * LOW_FRACTION);
|
|
40698
|
-
}
|
|
40699
|
-
function getSpareTotalMib(usedMib) {
|
|
40700
|
-
return Math.max(usedMib + LOW_FLOOR_MIB + GROW_STEP_MIB, Math.ceil((usedMib + GROW_STEP_MIB) / (1 - LOW_FRACTION)));
|
|
40701
|
-
}
|
|
40702
|
-
function getStructPageMib(mib) {
|
|
40703
|
-
return Math.ceil(mib * STRUCT_PAGE_MIB_PER_GIB / 1024);
|
|
40704
|
-
}
|
|
40705
|
-
function resolveMaxMemoryMib(memoryMib, requested) {
|
|
40706
|
-
if (requested === undefined) {
|
|
40707
|
-
return memoryMib;
|
|
40708
|
-
}
|
|
40709
|
-
if (requested < memoryMib) {
|
|
40710
|
-
throw new ImpdError("BAD_REQUEST", {
|
|
40711
|
-
message: `the max memory (${String(requested)} MiB) is less than the memory (${String(memoryMib)} MiB)`
|
|
40712
|
-
});
|
|
40713
|
-
}
|
|
40714
|
-
const ceiling = memoryMib * MAX_GROWTH_FACTOR;
|
|
40715
|
-
if (requested > ceiling) {
|
|
40716
|
-
throw new ImpdError("BAD_REQUEST", {
|
|
40717
|
-
message: `the max memory (${String(requested)} MiB) is more than ${String(MAX_GROWTH_FACTOR)} \xD7 the memory (${String(ceiling)} MiB): memory the guest grows into cannot hold its kernel's own allocations, so raise the memory too`
|
|
40718
|
-
});
|
|
40719
|
-
}
|
|
40720
|
-
return requested;
|
|
40721
|
-
}
|
|
40722
|
-
function toWholeBlocks(mib) {
|
|
40723
|
-
return Math.ceil(mib / BLOCK_MIB) * BLOCK_MIB;
|
|
40724
|
-
}
|
|
40725
|
-
|
|
40726
40742
|
// packages/daemon/src/imps/imps/cpu-limit.ts
|
|
40727
40743
|
var MIN_CPU_LIMIT = 0.1;
|
|
40728
40744
|
var DEFAULT_CPU_WEIGHT = 100;
|
|
@@ -50759,6 +50775,7 @@ function createBuilders(deps) {
|
|
|
50759
50775
|
name,
|
|
50760
50776
|
image: BUILDER_IMAGE,
|
|
50761
50777
|
memoryMib: deps.config.build.memoryMib,
|
|
50778
|
+
maxMemoryMib: deps.config.build.maxMemoryMib ?? undefined,
|
|
50762
50779
|
diskMib: Math.ceil(deps.config.build.diskBytes / 1024 ** 2),
|
|
50763
50780
|
policy: { mode: "public", allow: [] },
|
|
50764
50781
|
kind: "builder",
|
|
@@ -53556,7 +53573,7 @@ function createImageAdds(deps, writer) {
|
|
|
53556
53573
|
signal: options?.signal ?? new AbortController().signal
|
|
53557
53574
|
}),
|
|
53558
53575
|
ensureBuilderImage: loadBuilderImage,
|
|
53559
|
-
|
|
53576
|
+
addDefaultImage: async () => {
|
|
53560
53577
|
const images = await listImages(deps.db);
|
|
53561
53578
|
const seedRef = deps.seedRef === undefined ? SEED_REF : deps.seedRef;
|
|
53562
53579
|
if (seedRef !== null && images.every((image) => image.name === BUILDER_IMAGE)) {
|
|
@@ -60332,7 +60349,7 @@ async function startImpdParts(config, boundaries, plan) {
|
|
|
60332
60349
|
}
|
|
60333
60350
|
async function setupDefaultImage(config, images) {
|
|
60334
60351
|
try {
|
|
60335
|
-
await images.
|
|
60352
|
+
await images.addDefaultImage();
|
|
60336
60353
|
const existing = await images.listImages();
|
|
60337
60354
|
if (!existing.some((image) => image.name === config.defaultImage)) {
|
|
60338
60355
|
getImpdLogger("image").warning("no image named {defaultImage} (IMP_DEFAULT_IMAGE); impz new uses ubuntu until `impz image add <ref> --name {defaultImage}` adds it", { defaultImage: config.defaultImage });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@impz/testing",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.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": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ts-pattern": "^5.9.2",
|
|
43
43
|
"xstate": "^5.33.3",
|
|
44
44
|
"zod": "^4.6.7",
|
|
45
|
-
"@impz/client": "7.
|
|
45
|
+
"@impz/client": "7.5.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"bun": ">=1.4.3"
|