@zukhruf/testing 0.3.37 → 0.3.39
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 +41 -37
- package/dist/databases/clickhouse.d.ts +3 -4
- package/dist/databases/clickhouse.d.ts.map +1 -1
- package/dist/databases/clickhouse.js +5 -5
- package/dist/databases/clickhouse.js.map +1 -1
- package/dist/databases/database.d.ts +2 -4
- package/dist/databases/database.d.ts.map +1 -1
- package/dist/databases/mysql-family-server.d.ts +1 -1
- package/dist/databases/mysql-family-server.d.ts.map +1 -1
- package/dist/databases/mysql-family-server.js +8 -6
- package/dist/databases/mysql-family-server.js.map +1 -1
- package/dist/databases/postgres.d.ts +1 -1
- package/dist/databases/postgres.d.ts.map +1 -1
- package/dist/databases/postgres.js +14 -6
- package/dist/databases/postgres.js.map +1 -1
- package/dist/databases/sqlserver.d.ts +1 -1
- package/dist/databases/sqlserver.d.ts.map +1 -1
- package/dist/databases/sqlserver.js +6 -7
- package/dist/databases/sqlserver.js.map +1 -1
- package/dist/databases/succeeded.d.ts +7 -0
- package/dist/databases/succeeded.d.ts.map +1 -0
- package/dist/databases/succeeded.js +11 -0
- package/dist/databases/succeeded.js.map +1 -0
- package/dist/docker/{docker.d.ts → fixtures.d.ts} +31 -25
- package/dist/docker/fixtures.d.ts.map +1 -0
- package/dist/docker/fixtures.js +265 -0
- package/dist/docker/fixtures.js.map +1 -0
- package/dist/docker/host.d.ts +3 -10
- package/dist/docker/host.d.ts.map +1 -1
- package/dist/docker/host.js +21 -41
- package/dist/docker/host.js.map +1 -1
- package/dist/docker/index.d.ts +2 -3
- package/dist/docker/index.d.ts.map +1 -1
- package/dist/docker/index.js +2 -3
- package/dist/docker/index.js.map +1 -1
- package/dist/docker/service-container.d.ts +20 -0
- package/dist/docker/service-container.d.ts.map +1 -0
- package/dist/docker/service-container.js +30 -0
- package/dist/docker/service-container.js.map +1 -0
- package/dist/scripts/run-cleanup.js +1 -1
- package/dist/scripts/run-cleanup.js.map +1 -1
- package/package.json +2 -2
- package/dist/docker/container.d.ts +0 -30
- package/dist/docker/container.d.ts.map +0 -1
- package/dist/docker/container.js +0 -53
- package/dist/docker/container.js.map +0 -1
- package/dist/docker/docker.d.ts.map +0 -1
- package/dist/docker/docker.js +0 -263
- package/dist/docker/docker.js.map +0 -1
- package/dist/docker/volume.d.ts +0 -9
- package/dist/docker/volume.d.ts.map +0 -1
- package/dist/docker/volume.js +0 -13
- package/dist/docker/volume.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Docker, type Environment, type ExecResult, type OwnedContainer, type OwnedVolume } from '@zukhruf/docker';
|
|
2
2
|
import { DockerDirectory } from './directory.ts';
|
|
3
|
-
import
|
|
4
|
-
import { DockerVolume } from './volume.ts';
|
|
3
|
+
import { ServiceContainer } from './service-container.ts';
|
|
5
4
|
/** Marks a server that `reuse()` shares across processes and runs. */
|
|
6
5
|
export declare const SHARED_SERVER_LABEL = "dev.zukhruf.testing.shared";
|
|
6
|
+
/** The fingerprint of a shared server's configuration. */
|
|
7
|
+
export declare const CONFIG_LABEL = "dev.zukhruf.testing.config";
|
|
7
8
|
/** A volume or a path on the engine's host, mounted into a container. */
|
|
8
9
|
export interface Mount {
|
|
9
10
|
/** A volume's name, or an absolute path on the engine's host. */
|
|
@@ -21,8 +22,10 @@ export interface ContainerOptions {
|
|
|
21
22
|
env?: Record<string, string>;
|
|
22
23
|
labels?: Record<string, string> | undefined;
|
|
23
24
|
mounts?: Mount[];
|
|
25
|
+
/** `<path>[:<options>]`, as `docker run --tmpfs` takes it. */
|
|
24
26
|
tmpfs?: string[];
|
|
25
27
|
ipcHost?: boolean;
|
|
28
|
+
/** A size in the Docker CLI's binary units, such as `512m` or `1g`. */
|
|
26
29
|
memory?: string;
|
|
27
30
|
cpus?: number;
|
|
28
31
|
memorySwappiness?: number;
|
|
@@ -31,16 +34,21 @@ export interface ServiceOptions extends ContainerOptions {
|
|
|
31
34
|
/** The container's port that answers on 127.0.0.1 of this machine. */
|
|
32
35
|
internalPort: number;
|
|
33
36
|
/** Runs on every acquisition. Throw until ready, using timebox for polling. */
|
|
34
|
-
healthy?: (
|
|
37
|
+
healthy?: (service: ServiceContainer) => unknown;
|
|
35
38
|
}
|
|
36
|
-
export interface
|
|
37
|
-
/** The
|
|
38
|
-
|
|
39
|
+
export interface DockerFixturesOptions {
|
|
40
|
+
/** The environment of this process, such as `process.env`: it selects the engine and the run. */
|
|
41
|
+
environment: Environment;
|
|
39
42
|
}
|
|
40
|
-
/**
|
|
41
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Container fixtures on the engine that `environment` selects. The engine is
|
|
45
|
+
* connected on the first acquisition and kept: handles keep the engine they
|
|
46
|
+
* were made on. Docker owns cross-process coordination; this instance holds
|
|
47
|
+
* no server cache.
|
|
48
|
+
*/
|
|
49
|
+
export declare class DockerFixtures {
|
|
42
50
|
#private;
|
|
43
|
-
constructor({
|
|
51
|
+
constructor({ environment }: DockerFixturesOptions);
|
|
44
52
|
/**
|
|
45
53
|
* Defaults for disposable test containers, including external launchers.
|
|
46
54
|
* A launcher creates with these labels and no acquisition of this class:
|
|
@@ -53,26 +61,24 @@ export declare class Docker {
|
|
|
53
61
|
};
|
|
54
62
|
labels: Record<string, string>;
|
|
55
63
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}>;
|
|
64
|
+
/** The client of the engine that this instance's handles are on. */
|
|
65
|
+
client(): Promise<Docker>;
|
|
66
|
+
/** A fixture directory on the engine's host. */
|
|
60
67
|
directory(): Promise<DockerDirectory>;
|
|
61
68
|
/** Creates a named volume. Its run's cleanup removes it if this process dies first. */
|
|
62
|
-
volume(): Promise<
|
|
63
|
-
readonly command: DockerCommand;
|
|
64
|
-
isAvailable(): Promise<boolean>;
|
|
69
|
+
volume(): Promise<OwnedVolume>;
|
|
65
70
|
/** Starts a container this process owns. It stays after it stops, until disposal removes it. */
|
|
66
|
-
start(options: ContainerOptions): Promise<
|
|
67
|
-
/** Starts a dedicated server. Failure or disposal
|
|
71
|
+
start(options: ContainerOptions): Promise<OwnedContainer>;
|
|
72
|
+
/** Starts a dedicated server. Failure or disposal removes it. */
|
|
68
73
|
serve(options: ServiceOptions): Promise<ServiceContainer>;
|
|
69
74
|
/**
|
|
70
|
-
* Reuse one server per configuration on this
|
|
71
|
-
* Docker reserves the name atomically. Readiness failure leaves it
|
|
72
|
-
*
|
|
75
|
+
* Reuse one server per configuration on this engine, across processes and
|
|
76
|
+
* runs. Docker reserves the name atomically. Readiness failure leaves it
|
|
77
|
+
* running. Disposal closes only the forward; the server keeps running for
|
|
78
|
+
* its other users.
|
|
73
79
|
*/
|
|
74
80
|
reuse(options: ServiceOptions): Promise<ServiceContainer>;
|
|
75
|
-
/** Runs a container to completion and
|
|
76
|
-
run(options: ContainerOptions): Promise<
|
|
81
|
+
/** Runs a container to completion and gives its output and exit code. The container is removed afterwards. */
|
|
82
|
+
run(options: ContainerOptions): Promise<ExecResult>;
|
|
77
83
|
}
|
|
78
|
-
//# sourceMappingURL=
|
|
84
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/docker/fixtures.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,MAAM,EAEN,KAAK,WAAW,EAChB,KAAK,UAAU,EAEf,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,+BAA+B,CAAC;AAChE,0DAA0D;AAC1D,eAAO,MAAM,YAAY,+BAA+B,CAAC;AAEzD,yEAAyE;AACzE,MAAM,WAAW,KAAK;IACpB,iEAAiE;IACjE,MAAM,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;IAED,oEAAoE;IAC9D,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,gDAAgD;IAC1C,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;IAI3C,uFAAuF;IACjF,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC;IAQpC,gGAAgG;IAC1F,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IAS/D,iEAAiE;IAC3D,KAAK,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkB/D;;;;;OAKG;IACG,KAAK,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA+B/D,8GAA8G;IACxG,GAAG,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;CAwJ1D"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import pMemoize from 'p-memoize';
|
|
3
|
+
import { ConnectionFailedError, Docker, ImageNotFoundError, } from '@zukhruf/docker';
|
|
4
|
+
import { DockerDirectory } from "./directory.js";
|
|
5
|
+
import { DockerHost } from "./host.js";
|
|
6
|
+
import { ServiceContainer } from "./service-container.js";
|
|
7
|
+
import { TestRun } from "./test-run.js";
|
|
8
|
+
/** Marks a server that `reuse()` shares across processes and runs. */
|
|
9
|
+
export const SHARED_SERVER_LABEL = 'dev.zukhruf.testing.shared';
|
|
10
|
+
/** The fingerprint of a shared server's configuration. */
|
|
11
|
+
export const CONFIG_LABEL = 'dev.zukhruf.testing.config';
|
|
12
|
+
const units = {
|
|
13
|
+
b: 1,
|
|
14
|
+
k: 1024,
|
|
15
|
+
m: 1024 ** 2,
|
|
16
|
+
g: 1024 ** 3,
|
|
17
|
+
t: 1024 ** 4,
|
|
18
|
+
p: 1024 ** 5,
|
|
19
|
+
};
|
|
20
|
+
/** Bytes of a size such as `1g`, in the binary units of the Docker CLI's `--memory`. */
|
|
21
|
+
function bytes(size) {
|
|
22
|
+
const match = /^(\d+(?:\.\d+)?)\s?([bkmgtp])?i?b?$/i.exec(size);
|
|
23
|
+
if (!match?.[1])
|
|
24
|
+
throw new Error(`Invalid memory size: ${size}`);
|
|
25
|
+
return Math.trunc(Number(match[1]) * (units[match[2]?.toLowerCase() ?? 'b'] ?? 1));
|
|
26
|
+
}
|
|
27
|
+
const byKey = ([a], [b]) => {
|
|
28
|
+
if (a < b)
|
|
29
|
+
return -1;
|
|
30
|
+
if (a > b)
|
|
31
|
+
return 1;
|
|
32
|
+
return 0;
|
|
33
|
+
};
|
|
34
|
+
const generatedName = (image) => `test-${image.replace(/[^a-zA-Z0-9_.-]/g, '-')}-${randomUUID()}`;
|
|
35
|
+
/**
|
|
36
|
+
* Container fixtures on the engine that `environment` selects. The engine is
|
|
37
|
+
* connected on the first acquisition and kept: handles keep the engine they
|
|
38
|
+
* were made on. Docker owns cross-process coordination; this instance holds
|
|
39
|
+
* no server cache.
|
|
40
|
+
*/
|
|
41
|
+
export class DockerFixtures {
|
|
42
|
+
#environment;
|
|
43
|
+
#run;
|
|
44
|
+
#engine = pMemoize(async () => {
|
|
45
|
+
this.#run?.recordThisProcess();
|
|
46
|
+
const client = await Docker.connect({
|
|
47
|
+
environment: this.#environment,
|
|
48
|
+
}).catch((error) => {
|
|
49
|
+
if (error instanceof ConnectionFailedError)
|
|
50
|
+
throw new Error('Docker is required for container-backed tests', {
|
|
51
|
+
cause: error,
|
|
52
|
+
});
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
return { client, host: new DockerHost(client.host, this.#run) };
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
await client[Symbol.asyncDispose]();
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
constructor({ environment }) {
|
|
64
|
+
this.#environment = environment;
|
|
65
|
+
this.#run = TestRun.fromEnvironment(environment);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Defaults for disposable test containers, including external launchers.
|
|
69
|
+
* A launcher creates with these labels and no acquisition of this class:
|
|
70
|
+
* the read records this process, so the global teardown sweeps the run.
|
|
71
|
+
*/
|
|
72
|
+
get defaults() {
|
|
73
|
+
this.#run?.recordThisProcess();
|
|
74
|
+
return {
|
|
75
|
+
resources: { memory: '1g', cpus: 1 },
|
|
76
|
+
labels: this.#run?.labels ?? {},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** The client of the engine that this instance's handles are on. */
|
|
80
|
+
async client() {
|
|
81
|
+
return (await this.#engine()).client;
|
|
82
|
+
}
|
|
83
|
+
/** A fixture directory on the engine's host. */
|
|
84
|
+
async directory() {
|
|
85
|
+
return DockerDirectory.create((await this.#engine()).host, this.#run);
|
|
86
|
+
}
|
|
87
|
+
/** Creates a named volume. Its run's cleanup removes it if this process dies first. */
|
|
88
|
+
async volume() {
|
|
89
|
+
const { client } = await this.#engine();
|
|
90
|
+
return client.volumes.create({
|
|
91
|
+
Name: `zukhruf-testing-${randomUUID()}`,
|
|
92
|
+
Labels: this.defaults.labels,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** Starts a container this process owns. It stays after it stops, until disposal removes it. */
|
|
96
|
+
async start(options) {
|
|
97
|
+
const engine = await this.#engine();
|
|
98
|
+
const container = await this.#create(engine, this.#owned(options), {
|
|
99
|
+
name: options.name ?? generatedName(options.image),
|
|
100
|
+
});
|
|
101
|
+
await this.#startOrRemove(container);
|
|
102
|
+
return container;
|
|
103
|
+
}
|
|
104
|
+
/** Starts a dedicated server. Failure or disposal removes it. */
|
|
105
|
+
async serve(options) {
|
|
106
|
+
const engine = await this.#engine();
|
|
107
|
+
const owned = this.#owned(options);
|
|
108
|
+
const container = await this.#create(engine, this.#published(owned, options.internalPort), { name: options.name ?? generatedName(options.image) });
|
|
109
|
+
const remove = () => container.remove({ force: true, v: true });
|
|
110
|
+
await this.#startOrRemove(container);
|
|
111
|
+
try {
|
|
112
|
+
return await this.#ready(engine, container, options, remove);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
await remove().catch(() => { });
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Reuse one server per configuration on this engine, across processes and
|
|
121
|
+
* runs. Docker reserves the name atomically. Readiness failure leaves it
|
|
122
|
+
* running. Disposal closes only the forward; the server keeps running for
|
|
123
|
+
* its other users.
|
|
124
|
+
*/
|
|
125
|
+
async reuse(options) {
|
|
126
|
+
const engine = await this.#engine();
|
|
127
|
+
const fingerprint = this.#fingerprint(options);
|
|
128
|
+
const name = options.name ?? `zukhruf-testing-${fingerprint}`;
|
|
129
|
+
const body = this.#published(this.#body({
|
|
130
|
+
...options,
|
|
131
|
+
labels: {
|
|
132
|
+
...options.labels,
|
|
133
|
+
[SHARED_SERVER_LABEL]: '1',
|
|
134
|
+
[CONFIG_LABEL]: fingerprint,
|
|
135
|
+
},
|
|
136
|
+
}), options.internalPort);
|
|
137
|
+
const { container } = await this.#creating(engine, () => engine.client.containers.createOrGet(body, { name }));
|
|
138
|
+
const inspected = await container.inspect();
|
|
139
|
+
const labels = inspected.Config?.Labels;
|
|
140
|
+
if (labels?.[SHARED_SERVER_LABEL] !== '1' ||
|
|
141
|
+
labels[CONFIG_LABEL] !== fingerprint)
|
|
142
|
+
throw new Error(`Container ${name} does not match the shared test configuration`);
|
|
143
|
+
if (inspected.State?.Status !== 'running')
|
|
144
|
+
await container.start();
|
|
145
|
+
return this.#ready(engine, container, options, undefined);
|
|
146
|
+
}
|
|
147
|
+
/** Runs a container to completion and gives its output and exit code. The container is removed afterwards. */
|
|
148
|
+
async run(options) {
|
|
149
|
+
const engine = await this.#engine();
|
|
150
|
+
const body = this.#owned(options);
|
|
151
|
+
return this.#creating(engine, () => engine.client.containers.run(body, {
|
|
152
|
+
name: options.name ?? generatedName(options.image),
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
async #create(engine, body, { name }) {
|
|
156
|
+
return this.#creating(engine, () => engine.client.containers.create(body, { name }));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Runs `create` under a creating record, and pulls a missing image before
|
|
160
|
+
* a second try, as `docker run` does.
|
|
161
|
+
*/
|
|
162
|
+
async #creating(engine, create) {
|
|
163
|
+
await using _creating = await this.#run?.recordCreating();
|
|
164
|
+
try {
|
|
165
|
+
return await create();
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (!(error instanceof ImageNotFoundError))
|
|
169
|
+
throw error;
|
|
170
|
+
await engine.client.images.pull(error.image);
|
|
171
|
+
return await create();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async #startOrRemove(container) {
|
|
175
|
+
try {
|
|
176
|
+
await container.start();
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
await container.remove({ force: true, v: true }).catch(() => { });
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async #ready(engine, container, { internalPort, healthy }, remove) {
|
|
184
|
+
const published = await container.port(internalPort);
|
|
185
|
+
if (!published)
|
|
186
|
+
throw new Error(`Container ${container.id} publishes no port for ${internalPort}`);
|
|
187
|
+
const connection = await engine.host.forward(published.port);
|
|
188
|
+
const service = new ServiceContainer(container, connection.port, connection.close, remove);
|
|
189
|
+
try {
|
|
190
|
+
await healthy?.(service);
|
|
191
|
+
return service;
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
await service.disconnect();
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/** The body of a container this process owns: it carries the run's labels. */
|
|
199
|
+
#owned(options) {
|
|
200
|
+
return this.#body({
|
|
201
|
+
...options,
|
|
202
|
+
labels: { ...options.labels, ...this.defaults.labels },
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/** Publishes `internalPort` on 127.0.0.1 of the engine's host; the engine removes the container when it stops. */
|
|
206
|
+
#published(body, internalPort) {
|
|
207
|
+
const port = `${internalPort}/tcp`;
|
|
208
|
+
return {
|
|
209
|
+
...body,
|
|
210
|
+
ExposedPorts: { [port]: {} },
|
|
211
|
+
HostConfig: {
|
|
212
|
+
...body.HostConfig,
|
|
213
|
+
AutoRemove: true,
|
|
214
|
+
PortBindings: { [port]: [{ HostIp: '127.0.0.1', HostPort: '' }] },
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
#body(options) {
|
|
219
|
+
const { resources } = this.defaults;
|
|
220
|
+
const hostConfig = {
|
|
221
|
+
Binds: (options.mounts ?? []).map(({ source, target, readOnly }) => `${source}:${target}${readOnly ? ':ro' : ''}`),
|
|
222
|
+
Tmpfs: Object.fromEntries((options.tmpfs ?? []).map((spec) => {
|
|
223
|
+
const separator = spec.indexOf(':');
|
|
224
|
+
return separator === -1
|
|
225
|
+
? [spec, '']
|
|
226
|
+
: [spec.slice(0, separator), spec.slice(separator + 1)];
|
|
227
|
+
})),
|
|
228
|
+
Memory: bytes(options.memory ?? resources.memory),
|
|
229
|
+
NanoCpus: Math.round((options.cpus ?? resources.cpus) * 1e9),
|
|
230
|
+
...(options.ipcHost ? { IpcMode: 'host' } : {}),
|
|
231
|
+
...(options.memorySwappiness === undefined
|
|
232
|
+
? {}
|
|
233
|
+
: { MemorySwappiness: options.memorySwappiness }),
|
|
234
|
+
};
|
|
235
|
+
return {
|
|
236
|
+
Image: options.image,
|
|
237
|
+
...(options.command ? { Cmd: options.command } : {}),
|
|
238
|
+
...(options.hostname ? { Hostname: options.hostname } : {}),
|
|
239
|
+
Labels: options.labels ?? {},
|
|
240
|
+
Env: Object.entries(options.env ?? {}).map(([key, value]) => `${key}=${value}`),
|
|
241
|
+
HostConfig: hostConfig,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
#fingerprint(options) {
|
|
245
|
+
const { resources } = this.defaults;
|
|
246
|
+
return createHash('sha256')
|
|
247
|
+
.update(JSON.stringify({
|
|
248
|
+
transportVersion: 3,
|
|
249
|
+
memory: options.memory ?? resources.memory,
|
|
250
|
+
cpus: options.cpus ?? resources.cpus,
|
|
251
|
+
image: options.image,
|
|
252
|
+
command: options.command ?? [],
|
|
253
|
+
hostname: options.hostname,
|
|
254
|
+
internalPort: options.internalPort,
|
|
255
|
+
env: Object.entries(options.env ?? {}).sort(byKey),
|
|
256
|
+
labels: Object.entries(options.labels ?? {}).sort(byKey),
|
|
257
|
+
mounts: options.mounts ?? [],
|
|
258
|
+
tmpfs: options.tmpfs ?? [],
|
|
259
|
+
ipcHost: Boolean(options.ipcHost),
|
|
260
|
+
memorySwappiness: options.memorySwappiness,
|
|
261
|
+
}))
|
|
262
|
+
.digest('hex');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/docker/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,qBAAqB,EAErB,MAAM,EAIN,kBAAkB,GAGnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,sEAAsE;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AAChE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,4BAA4B,CAAC;AA+CzD,MAAM,KAAK,GAA2B;IACpC,CAAC,EAAE,CAAC;IACJ,CA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AAU;SACvB,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,OAAuB;QAClC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QACpC,OAAO,UAAU,CAAC,QAAQ,CAAC;aACxB,MAAM,CACL,IAAI,CAAC,SAAS,CAAC;YACb,gBAAgB,EAAE,CAAC;YACnB,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM;YAC1C,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI;YACpC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;YAClD,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;YACxD,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;YAC5B,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;YAC1B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;YACjC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;SAC3C,CAAC,CACH;aACA,MAAM,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;CACF"}
|
package/dist/docker/host.d.ts
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import { type Result } from 'nano-spawn';
|
|
2
2
|
import { type TestRun } from './test-run.ts';
|
|
3
3
|
export declare const quote: (value: string) => string;
|
|
4
|
-
/** How long one Docker CLI call may take before this process stops it. */
|
|
5
|
-
export declare const DOCKER_COMMAND_TIMEOUT = 240000;
|
|
6
4
|
/** How long one command in the SSH engine's remote shell may take. */
|
|
7
5
|
export declare const SHELL_TIMEOUT = 30000;
|
|
8
|
-
/** The environment that points the Docker CLI at `endpoint`, whatever context is selected. */
|
|
9
|
-
export declare const dockerEnvironment: (endpoint: string) => Record<string, string | undefined>;
|
|
10
6
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* has a process record while it runs.
|
|
7
|
+
* The endpoint of an engine, for what the Engine API does not do: a shell
|
|
8
|
+
* on the host of an SSH engine and port forwards from it. With a run, each
|
|
9
|
+
* command it starts has a process record while it runs.
|
|
14
10
|
*/
|
|
15
11
|
export declare class DockerHost {
|
|
16
12
|
#private;
|
|
17
13
|
readonly endpoint: string;
|
|
18
14
|
constructor(endpoint: string, run: TestRun | undefined);
|
|
19
|
-
/** The engine the Docker CLI selects. A run gets this process's process record. */
|
|
20
|
-
static resolve(run: TestRun | undefined): Promise<DockerHost>;
|
|
21
15
|
get remote(): boolean;
|
|
22
|
-
readonly command: (args: string[]) => Promise<Result>;
|
|
23
16
|
sshArgs(options?: string[]): string[];
|
|
24
17
|
shell(script: string, input?: string): Promise<Result>;
|
|
25
18
|
forward(port: number): Promise<{
|
|
@@ -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,OAAO,EAAiB,MAAM,eAAe,CAAC;AAE5D,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,MACC,CAAC;AAExC,
|
|
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,OAAO,EAAiB,MAAM,eAAe,CAAC;AAE5D,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,OAAO,GAAG,SAAS;IAUtD,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;CAkJzD"}
|
package/dist/docker/host.js
CHANGED
|
@@ -6,21 +6,31 @@ import command, { SubprocessError, } from 'nano-spawn';
|
|
|
6
6
|
import { timebox } from "../async/timebox.js";
|
|
7
7
|
import { forwardPrefix } from "./test-run.js";
|
|
8
8
|
export const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
9
|
-
/** How long one Docker CLI call may take before this process stops it. */
|
|
10
|
-
export const DOCKER_COMMAND_TIMEOUT = 240_000;
|
|
11
9
|
/** How long one command in the SSH engine's remote shell may take. */
|
|
12
10
|
export const SHELL_TIMEOUT = 30_000;
|
|
13
|
-
/** The environment that points the Docker CLI at `endpoint`, whatever context is selected. */
|
|
14
|
-
export const dockerEnvironment = (endpoint) => ({
|
|
15
|
-
DOCKER_CONTEXT: undefined,
|
|
16
|
-
DOCKER_HOST: endpoint,
|
|
17
|
-
});
|
|
18
11
|
/** Local Unix sockets, Docker Desktop's named pipe on Windows, and SSH engines. A `tcp://` engine may be on another machine. */
|
|
19
12
|
const supportedEndpoints = ['unix://', 'npipe://', 'ssh://'];
|
|
20
13
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
14
|
+
* A command this process started. A killed process leaves its commands
|
|
15
|
+
* running; their process records keep its run until they end.
|
|
16
|
+
*/
|
|
17
|
+
async function recorded(run, subprocess) {
|
|
18
|
+
if (!run)
|
|
19
|
+
return subprocess;
|
|
20
|
+
// Awaited below; a command that fails while its record is written must
|
|
21
|
+
// not count as an unhandled rejection.
|
|
22
|
+
subprocess.catch(() => { });
|
|
23
|
+
const { pid } = await subprocess.nodeChildProcess;
|
|
24
|
+
// Node leaves pid undefined when the spawn failed: no process to record.
|
|
25
|
+
if (pid === undefined)
|
|
26
|
+
return subprocess;
|
|
27
|
+
await using _record = await run.recordProcess(pid);
|
|
28
|
+
return await subprocess;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The endpoint of an engine, for what the Engine API does not do: a shell
|
|
32
|
+
* on the host of an SSH engine and port forwards from it. With a run, each
|
|
33
|
+
* command it starts has a process record while it runs.
|
|
24
34
|
*/
|
|
25
35
|
export class DockerHost {
|
|
26
36
|
endpoint;
|
|
@@ -32,39 +42,9 @@ export class DockerHost {
|
|
|
32
42
|
this.endpoint = endpoint;
|
|
33
43
|
this.#run = run;
|
|
34
44
|
}
|
|
35
|
-
/** The engine the Docker CLI selects. A run gets this process's process record. */
|
|
36
|
-
static async resolve(run) {
|
|
37
|
-
const { stdout } = await command('docker', [
|
|
38
|
-
'context',
|
|
39
|
-
'inspect',
|
|
40
|
-
'--format',
|
|
41
|
-
'{{.Endpoints.docker.Host}}',
|
|
42
|
-
]);
|
|
43
|
-
const host = new DockerHost(stdout.trim(), run);
|
|
44
|
-
await run?.recordProcess(process.pid);
|
|
45
|
-
return host;
|
|
46
|
-
}
|
|
47
45
|
get remote() {
|
|
48
46
|
return this.endpoint.startsWith('ssh://');
|
|
49
47
|
}
|
|
50
|
-
command = (args) => this.#recorded(command('docker', args, {
|
|
51
|
-
env: dockerEnvironment(this.endpoint),
|
|
52
|
-
timeout: DOCKER_COMMAND_TIMEOUT,
|
|
53
|
-
}));
|
|
54
|
-
/** A killed process leaves its commands running; their records keep its run until they end. */
|
|
55
|
-
async #recorded(subprocess) {
|
|
56
|
-
if (!this.#run)
|
|
57
|
-
return subprocess;
|
|
58
|
-
// Awaited below; a command that fails while its record is written must
|
|
59
|
-
// not count as an unhandled rejection.
|
|
60
|
-
subprocess.catch(() => { });
|
|
61
|
-
const { pid } = await subprocess.nodeChildProcess;
|
|
62
|
-
// Node leaves pid undefined when the spawn failed: no process to record.
|
|
63
|
-
if (pid === undefined)
|
|
64
|
-
return subprocess;
|
|
65
|
-
await using _record = await this.#run.recordProcess(pid);
|
|
66
|
-
return await subprocess;
|
|
67
|
-
}
|
|
68
48
|
sshArgs(options = []) {
|
|
69
49
|
const url = new URL(this.endpoint);
|
|
70
50
|
// Pass the original hostname to OpenSSH: ~/.ssh/config, jump hosts, keys,
|
|
@@ -86,7 +66,7 @@ export class DockerHost {
|
|
|
86
66
|
];
|
|
87
67
|
}
|
|
88
68
|
shell(script, input) {
|
|
89
|
-
return this.#
|
|
69
|
+
return recorded(this.#run, command('ssh', [...this.sshArgs(), script], {
|
|
90
70
|
stdin: input === undefined ? 'ignore' : { string: input },
|
|
91
71
|
timeout: SHELL_TIMEOUT,
|
|
92
72
|
}));
|
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;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,OAAO,EAAE,EAGd,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EA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G,MAAM,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,6 +1,5 @@
|
|
|
1
|
-
export { Container, type DockerCommand, ServiceContainer, } from './container.ts';
|
|
2
1
|
export { DockerDirectory } from './directory.ts';
|
|
3
|
-
export { type ContainerOptions,
|
|
2
|
+
export { type ContainerOptions, DockerFixtures, type DockerFixturesOptions, type Mount, type ServiceOptions, } from './fixtures.ts';
|
|
3
|
+
export { ServiceContainer } from './service-container.ts';
|
|
4
4
|
export { TestRun } from './test-run.ts';
|
|
5
|
-
export { DockerVolume } from './volume.ts';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docker/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,KAAK,gBAAgB,EACrB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,KAAK,EACV,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/docker/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { Container, ServiceContainer, } from "./container.js";
|
|
2
1
|
export { DockerDirectory } from "./directory.js";
|
|
3
|
-
export {
|
|
2
|
+
export { DockerFixtures, } from "./fixtures.js";
|
|
3
|
+
export { ServiceContainer } from "./service-container.js";
|
|
4
4
|
export { TestRun } from "./test-run.js";
|
|
5
|
-
export { DockerVolume } from "./volume.js";
|
|
6
5
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAEL,cAAc,GAIf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Container } from '@zukhruf/docker';
|
|
2
|
+
/**
|
|
3
|
+
* A container whose port answers on 127.0.0.1 of this machine, through an SSH
|
|
4
|
+
* forward when the engine is remote. Disposal closes the forward. A dedicated
|
|
5
|
+
* server's disposal also removes its container; a shared server's leaves it
|
|
6
|
+
* running for its other users.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ServiceContainer implements AsyncDisposable {
|
|
9
|
+
#private;
|
|
10
|
+
readonly container: Container;
|
|
11
|
+
readonly host = "127.0.0.1";
|
|
12
|
+
readonly port: number;
|
|
13
|
+
/** Closes the forward and leaves the container running for its other users. */
|
|
14
|
+
readonly disconnect: () => Promise<void>;
|
|
15
|
+
constructor(container: Container, port: number, disconnect: () => Promise<void>, remove: (() => Promise<void>) | undefined);
|
|
16
|
+
/** Removes a dedicated server's container, then closes the forward; when both fail, a SuppressedError holds both. */
|
|
17
|
+
cleanup(): Promise<void>;
|
|
18
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=service-container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-container.d.ts","sourceRoot":"","sources":["../../src/docker/service-container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;GAKG;AACH,qBAAa,gBAAiB,YAAW,eAAe;;IACtD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;gBAIvC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC/B,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS;IAQ3C,qHAAqH;IAC/G,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A container whose port answers on 127.0.0.1 of this machine, through an SSH
|
|
3
|
+
* forward when the engine is remote. Disposal closes the forward. A dedicated
|
|
4
|
+
* server's disposal also removes its container; a shared server's leaves it
|
|
5
|
+
* running for its other users.
|
|
6
|
+
*/
|
|
7
|
+
export class ServiceContainer {
|
|
8
|
+
container;
|
|
9
|
+
host = '127.0.0.1';
|
|
10
|
+
port;
|
|
11
|
+
/** Closes the forward and leaves the container running for its other users. */
|
|
12
|
+
disconnect;
|
|
13
|
+
#remove;
|
|
14
|
+
constructor(container, port, disconnect, remove) {
|
|
15
|
+
this.container = container;
|
|
16
|
+
this.port = port;
|
|
17
|
+
this.disconnect = disconnect;
|
|
18
|
+
this.#remove = remove;
|
|
19
|
+
}
|
|
20
|
+
/** Removes a dedicated server's container, then closes the forward; when both fail, a SuppressedError holds both. */
|
|
21
|
+
async cleanup() {
|
|
22
|
+
await using forward = new AsyncDisposableStack();
|
|
23
|
+
forward.defer(this.disconnect);
|
|
24
|
+
await this.#remove?.();
|
|
25
|
+
}
|
|
26
|
+
[Symbol.asyncDispose]() {
|
|
27
|
+
return this.cleanup();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=service-container.js.map
|