@zukhruf/testing 0.3.45 → 0.3.47
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 +58 -48
- package/dist/databases/clickhouse.d.ts +2 -2
- package/dist/databases/clickhouse.d.ts.map +1 -1
- package/dist/databases/clickhouse.js +6 -5
- package/dist/databases/clickhouse.js.map +1 -1
- package/dist/databases/collector.d.ts +1 -2
- package/dist/databases/collector.d.ts.map +1 -1
- package/dist/databases/collector.js +2 -2
- package/dist/databases/collector.js.map +1 -1
- package/dist/databases/database.d.ts +2 -2
- package/dist/databases/database.d.ts.map +1 -1
- package/dist/databases/mysql-family-server.d.ts.map +1 -1
- package/dist/databases/mysql-family-server.js +14 -14
- package/dist/databases/mysql-family-server.js.map +1 -1
- package/dist/databases/postgres.d.ts.map +1 -1
- package/dist/databases/postgres.js +18 -15
- package/dist/databases/postgres.js.map +1 -1
- package/dist/databases/sqlserver.d.ts.map +1 -1
- package/dist/databases/sqlserver.js +19 -16
- package/dist/databases/sqlserver.js.map +1 -1
- package/dist/docker/directory.d.ts +2 -2
- package/dist/docker/directory.d.ts.map +1 -1
- package/dist/docker/directory.js +3 -3
- package/dist/docker/directory.js.map +1 -1
- package/dist/docker/engine-lease.d.ts +36 -0
- package/dist/docker/engine-lease.d.ts.map +1 -0
- package/dist/docker/engine-lease.js +141 -0
- package/dist/docker/engine-lease.js.map +1 -0
- package/dist/docker/host.d.ts +2 -2
- package/dist/docker/host.d.ts.map +1 -1
- package/dist/docker/host.js +5 -5
- package/dist/docker/host.js.map +1 -1
- package/dist/docker/index.d.ts +1 -2
- package/dist/docker/index.d.ts.map +1 -1
- package/dist/docker/index.js +1 -2
- package/dist/docker/index.js.map +1 -1
- package/dist/docker/{test-run.d.ts → run-records.d.ts} +22 -16
- package/dist/docker/run-records.d.ts.map +1 -0
- package/dist/docker/{test-run.js → run-records.js} +22 -27
- package/dist/docker/run-records.js.map +1 -0
- package/dist/docker/{fixtures.d.ts → testbed.d.ts} +26 -42
- package/dist/docker/testbed.d.ts.map +1 -0
- package/dist/docker/{fixtures.js → testbed.js} +108 -106
- package/dist/docker/testbed.js.map +1 -0
- package/dist/scripts/docker-global-setup.js +11 -10
- package/dist/scripts/docker-global-setup.js.map +1 -1
- package/dist/scripts/run-cleanup.d.ts.map +1 -1
- package/dist/scripts/run-cleanup.js +85 -18
- package/dist/scripts/run-cleanup.js.map +1 -1
- package/package.json +2 -2
- package/dist/docker/fixtures.d.ts.map +0 -1
- package/dist/docker/fixtures.js.map +0 -1
- package/dist/docker/test-run.d.ts.map +0 -1
- package/dist/docker/test-run.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DockerHost } from './host.ts';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ProcessRun } from './run-records.ts';
|
|
3
3
|
/** A disposable fixture directory on the selected daemon's host filesystem. */
|
|
4
4
|
export declare class DockerDirectory implements AsyncDisposable {
|
|
5
5
|
#private;
|
|
6
6
|
readonly path: string;
|
|
7
7
|
readonly host: DockerHost;
|
|
8
8
|
private constructor();
|
|
9
|
-
static create(host: DockerHost, run:
|
|
9
|
+
static create(host: DockerHost, run: ProcessRun | undefined): Promise<DockerDirectory>;
|
|
10
10
|
private resolve;
|
|
11
11
|
mkdir(name: string): Promise<void>;
|
|
12
12
|
writeFile(name: string, content: string, mode?: number): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/docker/directory.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAS,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/docker/directory.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAS,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAEpE,+EAA+E;AAC/E,qBAAa,eAAgB,YAAW,eAAe;;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAG1B,OAAO;WAUM,MAAM,CACjB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,UAAU,GAAG,SAAS,GAC1B,OAAO,CAAC,eAAe,CAAC;IAS3B,OAAO,CAAC,OAAO;IAMT,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAarE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWvC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpD,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAM7C"}
|
package/dist/docker/directory.js
CHANGED
|
@@ -3,7 +3,7 @@ import { chmod, mkdir, readFile, rm, symlink, writeFile, } from 'node:fs/promise
|
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join, posix } from 'node:path';
|
|
5
5
|
import { DockerHost, quote } from "./host.js";
|
|
6
|
-
import { directoryPrefix } from "./
|
|
6
|
+
import { directoryPrefix } from "./run-records.js";
|
|
7
7
|
/** A disposable fixture directory on the selected daemon's host filesystem. */
|
|
8
8
|
export class DockerDirectory {
|
|
9
9
|
path;
|
|
@@ -15,9 +15,9 @@ export class DockerDirectory {
|
|
|
15
15
|
this.#record = record;
|
|
16
16
|
}
|
|
17
17
|
static async create(host, run) {
|
|
18
|
-
const name = `${directoryPrefix(run)}${randomUUID()}`;
|
|
18
|
+
const name = `${directoryPrefix(run?.id)}${randomUUID()}`;
|
|
19
19
|
const path = host.remote ? `/tmp/${name}` : join(tmpdir(), name);
|
|
20
|
-
const record = await run?.record('directory', path);
|
|
20
|
+
const record = await run?.records.record('directory', path);
|
|
21
21
|
if (host.remote)
|
|
22
22
|
await host.shell(`mkdir -m 700 -- ${quote(path)}`);
|
|
23
23
|
else
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/docker/directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,EAAE,EACF,OAAO,EACP,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/docker/directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,EAAE,EACF,OAAO,EACP,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAmB,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE,+EAA+E;AAC/E,MAAM,OAAO,eAAe;IACjB,IAAI,CAAS;IACb,IAAI,CAA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,CAAC,IAAY,EAAE,IAAY;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM;YAClB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;YAClE,MAAM,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAAY;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM;YAClB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;YAC/D,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM;YAClB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;YACpD,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3D,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type CancelOptions, type Docker } from '@zukhruf/docker';
|
|
2
|
+
/** The kind of a lease: `process` for a test process that reuses shared servers, `sweep` for a teardown that removes them. */
|
|
3
|
+
export declare const LEASE_LABEL = "dev.zukhruf.testing.lease";
|
|
4
|
+
/** The smallest image with `cat`. A missing image is pulled by the caller. */
|
|
5
|
+
export declare const LEASE_IMAGE = "busybox:1.37.0";
|
|
6
|
+
/** The name of the sweep lease of `version` on an engine. */
|
|
7
|
+
export declare function sweepLeaseName(version: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* A lease on one engine (Gray & Cheriton): a container that runs `cat` on
|
|
10
|
+
* the standard input of the attach of its holder. When the holder process
|
|
11
|
+
* exits for any reason, the attach closes, `cat` exits and the engine
|
|
12
|
+
* removes the container. The attach does not keep the holder running.
|
|
13
|
+
*/
|
|
14
|
+
export declare class EngineLease implements AsyncDisposable {
|
|
15
|
+
#private;
|
|
16
|
+
private constructor();
|
|
17
|
+
/** Resolves when the attach ends: the lease is gone. */
|
|
18
|
+
closed(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates, attaches to and starts a lease. Gives undefined when another
|
|
21
|
+
* holder has `name`, or when a waiter removed the lease before its start.
|
|
22
|
+
* A missing image rejects with ImageNotFoundError.
|
|
23
|
+
*/
|
|
24
|
+
static take(docker: Docker, labels: Record<string, string>, options?: CancelOptions & {
|
|
25
|
+
name?: string;
|
|
26
|
+
}): Promise<EngineLease | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves when the lease named `name` is gone. A `running` lease can have
|
|
29
|
+
* a live holder, so the wait goes on. A lease that stays `created` for
|
|
30
|
+
* PATIENCE, or that ended, has no holder: the waiter removes it.
|
|
31
|
+
*/
|
|
32
|
+
static gone(docker: Docker, name: string, cancel?: CancelOptions): Promise<void>;
|
|
33
|
+
/** Ends the lease: the removal ends its attach. */
|
|
34
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=engine-lease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-lease.d.ts","sourceRoot":"","sources":["../../src/docker/engine-lease.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAKlB,KAAK,MAAM,EAGZ,MAAM,iBAAiB,CAAC;AAEzB,8HAA8H;AAC9H,eAAO,MAAM,WAAW,8BAA8B,CAAC;AAEvD,8EAA8E;AAC9E,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAQ5C,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AA2BD;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,eAAe;;IAIjD,OAAO;IAKP,wDAAwD;IAClD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;;;OAIG;WACU,IAAI,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,OAAO,GAAE,aAAa,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO,GAC9C,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAgCnC;;;;OAIG;WACU,IAAI,CACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,aAAkB,GACzB,OAAO,CAAC,IAAI,CAAC;IAoBhB,mDAAmD;IAC7C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7C"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { ContainerNotFoundError, ContainerRunningError, NameConflictError, } from '@zukhruf/docker';
|
|
3
|
+
/** The kind of a lease: `process` for a test process that reuses shared servers, `sweep` for a teardown that removes them. */
|
|
4
|
+
export const LEASE_LABEL = 'dev.zukhruf.testing.lease';
|
|
5
|
+
/** The smallest image with `cat`. A missing image is pulled by the caller. */
|
|
6
|
+
export const LEASE_IMAGE = 'busybox:1.37.0';
|
|
7
|
+
/** The time a `created` lease gets to start before a waiter removes it, and between two looks of a waiter. */
|
|
8
|
+
const PATIENCE = 5_000;
|
|
9
|
+
/** The states of a lease that ended: no holder can have it. */
|
|
10
|
+
const endedStates = new Set(['exited', 'dead']);
|
|
11
|
+
/** The name of the sweep lease of `version` on an engine. */
|
|
12
|
+
export function sweepLeaseName(version) {
|
|
13
|
+
return `zukhruf-testing-sweep-${createHash('sha256').update(version).digest('hex')}`;
|
|
14
|
+
}
|
|
15
|
+
/** The state of the container, or undefined when it is gone. */
|
|
16
|
+
async function stateOf(container, cancel) {
|
|
17
|
+
try {
|
|
18
|
+
return (await container.inspect(cancel)).State?.Status;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof ContainerNotFoundError)
|
|
22
|
+
return undefined;
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Removes the lease without force: the engine lets only one of this removal and the start of a `created` lease succeed. */
|
|
27
|
+
async function removeUnlessRunning(lease, cancel) {
|
|
28
|
+
try {
|
|
29
|
+
await lease.remove({ force: false, ...cancel });
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (!(error instanceof ContainerRunningError))
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A lease on one engine (Gray & Cheriton): a container that runs `cat` on
|
|
38
|
+
* the standard input of the attach of its holder. When the holder process
|
|
39
|
+
* exits for any reason, the attach closes, `cat` exits and the engine
|
|
40
|
+
* removes the container. The attach does not keep the holder running.
|
|
41
|
+
*/
|
|
42
|
+
export class EngineLease {
|
|
43
|
+
#container;
|
|
44
|
+
#attach;
|
|
45
|
+
constructor(container, attach) {
|
|
46
|
+
this.#container = container;
|
|
47
|
+
this.#attach = attach;
|
|
48
|
+
}
|
|
49
|
+
/** Resolves when the attach ends: the lease is gone. */
|
|
50
|
+
async closed() {
|
|
51
|
+
await this.#attach.exitCode.catch(() => { });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates, attaches to and starts a lease. Gives undefined when another
|
|
55
|
+
* holder has `name`, or when a waiter removed the lease before its start.
|
|
56
|
+
* A missing image rejects with ImageNotFoundError.
|
|
57
|
+
*/
|
|
58
|
+
static async take(docker, labels, options = {}) {
|
|
59
|
+
let container;
|
|
60
|
+
try {
|
|
61
|
+
container = await docker.containers.create({
|
|
62
|
+
Image: LEASE_IMAGE,
|
|
63
|
+
Entrypoint: ['cat'],
|
|
64
|
+
Cmd: [],
|
|
65
|
+
OpenStdin: true,
|
|
66
|
+
StdinOnce: true,
|
|
67
|
+
AttachStdin: true,
|
|
68
|
+
Labels: labels,
|
|
69
|
+
HostConfig: { AutoRemove: true },
|
|
70
|
+
}, options);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error instanceof NameConflictError)
|
|
74
|
+
return undefined;
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
// The attach comes before the start, so the lease never runs without it.
|
|
79
|
+
const attach = await container.attach({ stdin: true, ref: false });
|
|
80
|
+
await container.start();
|
|
81
|
+
return new EngineLease(container, attach);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error instanceof ContainerNotFoundError)
|
|
85
|
+
return undefined;
|
|
86
|
+
await container.remove({ force: true }).catch(() => { });
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resolves when the lease named `name` is gone. A `running` lease can have
|
|
92
|
+
* a live holder, so the wait goes on. A lease that stays `created` for
|
|
93
|
+
* PATIENCE, or that ended, has no holder: the waiter removes it.
|
|
94
|
+
*/
|
|
95
|
+
static async gone(docker, name, cancel = {}) {
|
|
96
|
+
const lease = await docker.containers.find(name, cancel);
|
|
97
|
+
if (lease === undefined)
|
|
98
|
+
return;
|
|
99
|
+
let state = await stateOf(lease, cancel);
|
|
100
|
+
for (;;) {
|
|
101
|
+
if (state === undefined)
|
|
102
|
+
return;
|
|
103
|
+
if (endedStates.has(state)) {
|
|
104
|
+
await removeUnlessRunning(lease, cancel);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const seen = state;
|
|
108
|
+
if (await removedWithin(lease, cancel))
|
|
109
|
+
return;
|
|
110
|
+
state = await stateOf(lease, cancel);
|
|
111
|
+
if (seen === 'created' && state === 'created') {
|
|
112
|
+
await removeUnlessRunning(lease, cancel);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Ends the lease: the removal ends its attach. */
|
|
118
|
+
async [Symbol.asyncDispose]() {
|
|
119
|
+
await this.#container.remove({ force: true });
|
|
120
|
+
await this.closed();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** True when the lease is gone within PATIENCE, false when it is still there. */
|
|
124
|
+
async function removedWithin(lease, { signal }) {
|
|
125
|
+
const patience = AbortSignal.timeout(PATIENCE);
|
|
126
|
+
try {
|
|
127
|
+
await lease.wait({
|
|
128
|
+
condition: 'removed',
|
|
129
|
+
signal: signal === undefined ? patience : AbortSignal.any([signal, patience]),
|
|
130
|
+
});
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (error instanceof ContainerNotFoundError)
|
|
135
|
+
return true;
|
|
136
|
+
if (signal?.aborted || !patience.aborted)
|
|
137
|
+
throw error;
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=engine-lease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-lease.js","sourceRoot":"","sources":["../../src/docker/engine-lease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAGL,sBAAsB,EAEtB,qBAAqB,EAErB,iBAAiB,GAElB,MAAM,iBAAiB,CAAC;AAEzB,8HAA8H;AAC9H,MAAM,CA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zB,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,IAAI,CAAC;YACf,SAAS,EAAE,SAAS;YACpB,MAAM,EACJ,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;SACxE,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,sBAAsB;YAAE,OAAO,IAAI,CAAC;QACzD,IAAI,MAAM,EAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO;YAAE,MAAM,KAAK,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/docker/host.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Result } from 'nano-spawn';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ProcessRun } from './run-records.ts';
|
|
3
3
|
export declare const quote: (value: string) => string;
|
|
4
4
|
/** How long one command in the SSH engine's remote shell may take. */
|
|
5
5
|
export declare const SHELL_TIMEOUT = 30000;
|
|
@@ -11,7 +11,7 @@ export declare const SHELL_TIMEOUT = 30000;
|
|
|
11
11
|
export declare class DockerHost {
|
|
12
12
|
#private;
|
|
13
13
|
readonly endpoint: string;
|
|
14
|
-
constructor(endpoint: string, run:
|
|
14
|
+
constructor(endpoint: string, run: ProcessRun | undefined);
|
|
15
15
|
get remote(): boolean;
|
|
16
16
|
sshArgs(options?: string[]): string[];
|
|
17
17
|
shell(script: string, input?: string): Promise<Result>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/docker/host.ts"],"names":[],"mappings":"AAKA,OAAgB,EACd,KAAK,MAAM,EAGZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/docker/host.ts"],"names":[],"mappings":"AAKA,OAAgB,EACd,KAAK,MAAM,EAGZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,kBAAkB,CAAC;AAElE,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,MACC,CAAC;AAExC,sEAAsE;AACtE,eAAO,MAAM,aAAa,QAAS,CAAC;AAwBpC;;;;GAIG;AACH,qBAAa,UAAU;;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAGd,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,SAAS;IAUzD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,OAAO,CAAC,OAAO,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE;IAqBzC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhD,OAAO,CACX,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;CAmJzD"}
|
package/dist/docker/host.js
CHANGED
|
@@ -4,7 +4,7 @@ import { connect, createServer } from 'node:net';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import command, { SubprocessError, } from 'nano-spawn';
|
|
6
6
|
import { timebox } from "../async/timebox.js";
|
|
7
|
-
import { forwardPrefix } from "./
|
|
7
|
+
import { forwardPrefix } from "./run-records.js";
|
|
8
8
|
export const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
9
9
|
/** How long one command in the SSH engine's remote shell may take. */
|
|
10
10
|
export const SHELL_TIMEOUT = 30_000;
|
|
@@ -24,7 +24,7 @@ async function recorded(run, subprocess) {
|
|
|
24
24
|
// Node leaves pid undefined when the spawn failed: no process to record.
|
|
25
25
|
if (pid === undefined)
|
|
26
26
|
return subprocess;
|
|
27
|
-
await using _record = await run.recordProcess(pid);
|
|
27
|
+
await using _record = await run.records.recordProcess(pid);
|
|
28
28
|
return await subprocess;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -80,9 +80,9 @@ export class DockerHost {
|
|
|
80
80
|
try {
|
|
81
81
|
// Keep the Unix socket path below macOS's 104-byte limit. The private
|
|
82
82
|
// directory and ownership record also cover workers killed mid-test.
|
|
83
|
-
const directory = resources.use(await mkdtempDisposable(forwardPrefix(run)));
|
|
83
|
+
const directory = resources.use(await mkdtempDisposable(forwardPrefix(run?.id)));
|
|
84
84
|
if (run)
|
|
85
|
-
resources.use(await run.record('forward', directory.path));
|
|
85
|
+
resources.use(await run.records.record('forward', directory.path));
|
|
86
86
|
const path = join(directory.path, 's');
|
|
87
87
|
const sockets = new Set();
|
|
88
88
|
const server = createServer((socket) => {
|
|
@@ -140,7 +140,7 @@ export class DockerHost {
|
|
|
140
140
|
const child = await ssh.nodeChildProcess;
|
|
141
141
|
// Disposed after ssh has stopped.
|
|
142
142
|
if (run && child.pid !== undefined)
|
|
143
|
-
resources.use(await run.recordProcess(child.pid));
|
|
143
|
+
resources.use(await run.records.recordProcess(child.pid));
|
|
144
144
|
resources.defer(async () => {
|
|
145
145
|
child.stdin.end();
|
|
146
146
|
const deadline = setTimeout(() => child.kill('SIGKILL'), 1_000);
|
package/dist/docker/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/docker/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAe,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC9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M,IAAI,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,mCAAmC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAC1D,EAAE,KAAK,EAAE,OAAO,EAAE,CACnB,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;YAC9B,MAAM,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAChC,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;gBACzC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAClE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,EAAE,CAAC;YACd,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
package/dist/docker/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { DockerDirectory } from './directory.ts';
|
|
2
|
-
export {
|
|
2
|
+
export { DockerTestbed, type DockerTestbedOptions, type ServiceOptions, } from './testbed.ts';
|
|
3
3
|
export { ServiceContainer } from './service-container.ts';
|
|
4
|
-
export { TestRun } from './test-run.ts';
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/docker/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { DockerDirectory } from "./directory.js";
|
|
2
|
-
export {
|
|
2
|
+
export { DockerTestbed, } from "./testbed.js";
|
|
3
3
|
export { ServiceContainer } from "./service-container.js";
|
|
4
|
-
export { TestRun } from "./test-run.js";
|
|
5
4
|
//# sourceMappingURL=index.js.map
|
package/dist/docker/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -5,21 +5,14 @@ export declare const TEST_RUN_DIRECTORY = "ZUKHRUF_TESTING_RUN_DIR";
|
|
|
5
5
|
/** The label that ties a container or volume to the run that created it. */
|
|
6
6
|
export declare const TEST_RUN_LABEL = "dev.zukhruf.testing.run";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* The records of one `node --test` invocation with the Docker global setup,
|
|
9
|
+
* in the run's directory. While a recorded process lives, or a record of a
|
|
10
|
+
* path remains, the global teardown, or the recovery of a later run, keeps
|
|
11
|
+
* the run and removes what a killed process left.
|
|
12
12
|
*/
|
|
13
|
-
export declare class
|
|
14
|
-
readonly id: string;
|
|
13
|
+
export declare class RunRecords {
|
|
15
14
|
readonly directory: string;
|
|
16
|
-
constructor(
|
|
17
|
-
/**
|
|
18
|
-
* The run the global setup started this process in, read from the
|
|
19
|
-
* environment the host passes (`process.env`). Undefined outside a run.
|
|
20
|
-
*/
|
|
21
|
-
static fromEnvironment(environment: Readonly<Record<string, string | undefined>>): TestRun | undefined;
|
|
22
|
-
get labels(): Record<string, string>;
|
|
15
|
+
constructor(directory: string);
|
|
23
16
|
/**
|
|
24
17
|
* Writes a process record for `pid`, a test process or a command it
|
|
25
18
|
* started. While a recorded process lives, the run's records stay.
|
|
@@ -46,8 +39,21 @@ export declare class TestRun {
|
|
|
46
39
|
*/
|
|
47
40
|
record(kind: 'forward' | 'directory', path: string): Promise<AsyncDisposable>;
|
|
48
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The run this process belongs to: its id marks what the process creates,
|
|
44
|
+
* its records keep the run while the process lives.
|
|
45
|
+
*/
|
|
46
|
+
export type ProcessRun = {
|
|
47
|
+
id: string;
|
|
48
|
+
records: RunRecords;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The run the global setup started this process in, read from the
|
|
52
|
+
* environment the host passes (`process.env`). Undefined outside a run.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readRun(environment: Readonly<Record<string, string | undefined>>): ProcessRun | undefined;
|
|
49
55
|
/** The name prefix of a host directory that a run's test process created. */
|
|
50
|
-
export declare const directoryPrefix: (
|
|
56
|
+
export declare const directoryPrefix: (id: string | undefined) => string;
|
|
51
57
|
/** The path prefix of the private directory behind an SSH port forward. */
|
|
52
|
-
export declare const forwardPrefix: (
|
|
53
|
-
//# sourceMappingURL=
|
|
58
|
+
export declare const forwardPrefix: (id: string | undefined) => string;
|
|
59
|
+
//# sourceMappingURL=run-records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-records.d.ts","sourceRoot":"","sources":["../../src/docker/run-records.ts"],"names":[],"mappings":"AAKA,0EAA0E;AAC1E,eAAO,MAAM,WAAW,2BAA2B,CAAC;AACpD,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,4BAA4B,CAAC;AAC5D,4EAA4E;AAC5E,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAKxD;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,MAAM;IAI7B;;;;;OAKG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAM1D;;;;OAIG;IACH,iBAAiB,IAAI,IAAI;IASzB;;;;;OAKG;IACG,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC;IAMhD;;;OAGG;IACG,MAAM,CACV,IAAI,EAAE,SAAS,GAAG,WAAW,EAC7B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC;CAK5B;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,OAAO,CACrB,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACxD,UAAU,GAAG,SAAS,CASxB;AAED,6EAA6E;AAC7E,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,GAAG,SAAS,KAAG,MACf,CAAC;AAE3C,2EAA2E;AAC3E,eAAO,MAAM,aAAa,GAAI,IAAI,MAAM,GAAG,SAAS,KAAG,MACA,CAAC"}
|
|
@@ -11,34 +11,16 @@ export const TEST_RUN_LABEL = 'dev.zukhruf.testing.run';
|
|
|
11
11
|
/** The run directories that hold a process record of this process. */
|
|
12
12
|
const recordedRuns = new Set();
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* The records of one `node --test` invocation with the Docker global setup,
|
|
15
|
+
* in the run's directory. While a recorded process lives, or a record of a
|
|
16
|
+
* path remains, the global teardown, or the recovery of a later run, keeps
|
|
17
|
+
* the run and removes what a killed process left.
|
|
18
18
|
*/
|
|
19
|
-
export class
|
|
20
|
-
id;
|
|
19
|
+
export class RunRecords {
|
|
21
20
|
directory;
|
|
22
|
-
constructor(
|
|
23
|
-
this.id = id;
|
|
21
|
+
constructor(directory) {
|
|
24
22
|
this.directory = directory;
|
|
25
23
|
}
|
|
26
|
-
/**
|
|
27
|
-
* The run the global setup started this process in, read from the
|
|
28
|
-
* environment the host passes (`process.env`). Undefined outside a run.
|
|
29
|
-
*/
|
|
30
|
-
static fromEnvironment(environment) {
|
|
31
|
-
const id = environment[TEST_RUN_ID];
|
|
32
|
-
const directory = environment[TEST_RUN_DIRECTORY];
|
|
33
|
-
if (id === undefined && directory === undefined)
|
|
34
|
-
return undefined;
|
|
35
|
-
if (!id || !directory)
|
|
36
|
-
throw new Error(`The global setup sets ${TEST_RUN_ID} and ${TEST_RUN_DIRECTORY} together, but only one of them is set`);
|
|
37
|
-
return new TestRun(id, directory);
|
|
38
|
-
}
|
|
39
|
-
get labels() {
|
|
40
|
-
return { [TEST_RUN_LABEL]: this.id };
|
|
41
|
-
}
|
|
42
24
|
/**
|
|
43
25
|
* Writes a process record for `pid`, a test process or a command it
|
|
44
26
|
* started. While a recorded process lives, the run's records stay.
|
|
@@ -82,8 +64,21 @@ export class TestRun {
|
|
|
82
64
|
return { [Symbol.asyncDispose]: () => rm(file, { force: true }) };
|
|
83
65
|
}
|
|
84
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The run the global setup started this process in, read from the
|
|
69
|
+
* environment the host passes (`process.env`). Undefined outside a run.
|
|
70
|
+
*/
|
|
71
|
+
export function readRun(environment) {
|
|
72
|
+
const id = environment[TEST_RUN_ID];
|
|
73
|
+
const directory = environment[TEST_RUN_DIRECTORY];
|
|
74
|
+
if (id === undefined && directory === undefined)
|
|
75
|
+
return undefined;
|
|
76
|
+
if (!id || !directory)
|
|
77
|
+
throw new Error(`The global setup sets ${TEST_RUN_ID} and ${TEST_RUN_DIRECTORY} together, but only one of them is set`);
|
|
78
|
+
return { id, records: new RunRecords(directory) };
|
|
79
|
+
}
|
|
85
80
|
/** The name prefix of a host directory that a run's test process created. */
|
|
86
|
-
export const directoryPrefix = (
|
|
81
|
+
export const directoryPrefix = (id) => `zukhruf-testing-${id ?? 'standalone'}-`;
|
|
87
82
|
/** The path prefix of the private directory behind an SSH port forward. */
|
|
88
|
-
export const forwardPrefix = (
|
|
89
|
-
//# sourceMappingURL=
|
|
83
|
+
export const forwardPrefix = (id) => `/tmp/zukhruf-testing-forward-${id ?? 'standalone'}-`;
|
|
84
|
+
//# sourceMappingURL=run-records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-records.js","sourceRoot":"","sources":["../../src/docker/run-records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AACpD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC;AAC5D,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAExD,sEAAsE;AACtE,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACZ,SAAS,CAAS;IAE3B,YAAY,SAAiB;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;I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,IAAY;QAEZ,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,IAAI,UAAU,EAAE,OAAO,CAAC,CAAC;QAClE,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAChD,OAAO,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACpE,CAAC;CACF;AAQD;;;GAGG;AACH,MAAM,UAAU,OAAO,CACrB,WAAyD;IAEzD,MAAM,EAAE,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAClD,IAAI,EAAE,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAClE,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS;QACnB,MAAM,IAAI,KAAK,CACb,yBAAyB,WAAW,QAAQ,kBAAkB,wCAAwC,CACvG,CAAC;IACJ,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAsB,EAAU,EAAE,CAChE,mBAAmB,EAAE,IAAI,YAAY,GAAG,CAAC;AAE3C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAsB,EAAU,EAAE,CAC9D,gCAAgC,EAAE,IAAI,YAAY,GAAG,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Docker, type Environment, type ExecResult, type OwnedContainer, type OwnedVolume } from '@zukhruf/docker';
|
|
1
|
+
import { Docker, type EngineApi, type Environment, type ExecResult, type OwnedContainer, type OwnedVolume } from '@zukhruf/docker';
|
|
2
2
|
import { DockerDirectory } from './directory.ts';
|
|
3
3
|
import { ServiceContainer } from './service-container.ts';
|
|
4
4
|
/** Marks a server that `reuse()` shares across processes and runs. */
|
|
@@ -9,61 +9,38 @@ export declare const CONFIG_LABEL = "dev.zukhruf.testing.config";
|
|
|
9
9
|
export declare const VERSION_LABEL = "dev.zukhruf.testing.version";
|
|
10
10
|
/** The version of this package: `../../package.json` from `src/docker` and from `dist/docker`. */
|
|
11
11
|
export declare const PACKAGE_VERSION: string;
|
|
12
|
-
|
|
13
|
-
export interface Mount {
|
|
14
|
-
/** A volume's name, or an absolute path on the engine's host. */
|
|
15
|
-
source: string;
|
|
16
|
-
target: string;
|
|
17
|
-
readOnly?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface ContainerOptions {
|
|
20
|
-
image: string;
|
|
21
|
-
/** Replaces the image's command. */
|
|
22
|
-
command?: string[];
|
|
23
|
-
/** A dedicated container gets a generated name; a reused server's name comes from its configuration. */
|
|
24
|
-
name?: string;
|
|
25
|
-
hostname?: string;
|
|
26
|
-
env?: Record<string, string>;
|
|
27
|
-
labels?: Record<string, string> | undefined;
|
|
28
|
-
mounts?: Mount[];
|
|
29
|
-
/** `<path>[:<options>]`, as `docker run --tmpfs` takes it. */
|
|
30
|
-
tmpfs?: string[];
|
|
31
|
-
ipcHost?: boolean;
|
|
32
|
-
/** A size in the Docker CLI's binary units, such as `512m` or `1g`. */
|
|
33
|
-
memory?: string;
|
|
34
|
-
cpus?: number;
|
|
35
|
-
memorySwappiness?: number;
|
|
36
|
-
}
|
|
37
|
-
export interface ServiceOptions extends ContainerOptions {
|
|
12
|
+
export interface ServiceOptions {
|
|
38
13
|
/** The container's port that answers on 127.0.0.1 of this machine. */
|
|
39
14
|
internalPort: number;
|
|
15
|
+
/** Without it, the engine names a dedicated server; a shared server's name comes from its configuration. */
|
|
16
|
+
name?: string;
|
|
40
17
|
/** Runs on every acquisition. Throw until ready, using timebox for polling. */
|
|
41
18
|
healthy?: (service: ServiceContainer) => unknown;
|
|
42
19
|
}
|
|
43
|
-
export interface
|
|
20
|
+
export interface DockerTestbedOptions {
|
|
44
21
|
/** The environment of this process, such as `process.env`: it selects the engine and the run. */
|
|
45
22
|
environment: Environment;
|
|
46
23
|
}
|
|
47
24
|
/**
|
|
48
|
-
*
|
|
25
|
+
* A testbed of containers on the engine that `environment` selects. The engine is
|
|
49
26
|
* connected on the first acquisition and kept: handles keep the engine they
|
|
50
27
|
* were made on. Docker owns cross-process coordination; this instance holds
|
|
51
28
|
* no server cache.
|
|
52
29
|
*/
|
|
53
|
-
export declare class
|
|
30
|
+
export declare class DockerTestbed {
|
|
54
31
|
#private;
|
|
55
|
-
constructor({ environment }:
|
|
32
|
+
constructor({ environment }: DockerTestbedOptions);
|
|
56
33
|
/**
|
|
57
34
|
* Defaults for disposable test containers, including external launchers.
|
|
58
35
|
* A launcher creates with these labels and no acquisition of this class:
|
|
59
36
|
* the read records this process, so the global teardown sweeps the run.
|
|
60
37
|
*/
|
|
61
38
|
get defaults(): {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
Labels: Record<string, string>;
|
|
40
|
+
HostConfig: {
|
|
41
|
+
Memory: number;
|
|
42
|
+
NanoCpus: number;
|
|
65
43
|
};
|
|
66
|
-
labels: Record<string, string>;
|
|
67
44
|
};
|
|
68
45
|
/** The client of the engine that this instance's handles are on. */
|
|
69
46
|
client(): Promise<Docker>;
|
|
@@ -72,17 +49,24 @@ export declare class DockerFixtures {
|
|
|
72
49
|
/** Creates a named volume. Its run's cleanup removes it if this process dies first. */
|
|
73
50
|
volume(): Promise<OwnedVolume>;
|
|
74
51
|
/** Starts a container this process owns. It stays after it stops, until disposal removes it. */
|
|
75
|
-
start(
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
start(body: EngineApi.ContainerCreateRequest, options?: {
|
|
53
|
+
name?: string;
|
|
54
|
+
}): Promise<OwnedContainer>;
|
|
55
|
+
/**
|
|
56
|
+
* Starts a dedicated server. Failure or disposal removes it. A server that
|
|
57
|
+
* is not ready rejects with its container's output, read before the removal.
|
|
58
|
+
*/
|
|
59
|
+
serve(body: EngineApi.ContainerCreateRequest, options: ServiceOptions): Promise<ServiceContainer>;
|
|
78
60
|
/**
|
|
79
61
|
* Reuse one server per configuration on this engine, across processes and
|
|
80
62
|
* runs. Docker reserves the name atomically. Readiness failure leaves it
|
|
81
63
|
* running. Disposal closes only the forward; the server keeps running for
|
|
82
|
-
* its other users.
|
|
64
|
+
* its other users. The engine removes the server when it stops.
|
|
83
65
|
*/
|
|
84
|
-
reuse(options: ServiceOptions): Promise<ServiceContainer>;
|
|
66
|
+
reuse(body: EngineApi.ContainerCreateRequest, options: ServiceOptions): Promise<ServiceContainer>;
|
|
85
67
|
/** Runs a container to completion and gives its output and exit code. The container is removed afterwards. */
|
|
86
|
-
run(
|
|
68
|
+
run(body: EngineApi.ContainerCreateRequest, options?: {
|
|
69
|
+
name?: string;
|
|
70
|
+
}): Promise<ExecResult>;
|
|
87
71
|
}
|
|
88
|
-
//# sourceMappingURL=
|
|
72
|
+
//# sourceMappingURL=testbed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testbed.d.ts","sourceRoot":"","sources":["../../src/docker/testbed.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,MAAM,EACN,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EAEf,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,+BAA+B,CAAC;AAChE,0DAA0D;AAC1D,eAAO,MAAM,YAAY,+BAA+B,CAAC;AACzD,8EAA8E;AAC9E,eAAO,MAAM,aAAa,gCAAgC,CA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