@zukhruf/testing 0.8.14 → 0.8.15
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 +15 -8
- package/dist/docker/engine-lease.d.ts +4 -2
- package/dist/docker/engine-lease.d.ts.map +1 -1
- package/dist/docker/engine-lease.js +5 -4
- package/dist/docker/engine-lease.js.map +1 -1
- package/dist/docker/testbed.d.ts +8 -13
- package/dist/docker/testbed.d.ts.map +1 -1
- package/dist/docker/testbed.js +31 -50
- package/dist/docker/testbed.js.map +1 -1
- package/dist/scripts/docker-cleanup-worker.js +1 -1
- package/dist/scripts/docker-cleanup-worker.js.map +1 -1
- package/dist/scripts/run-cleanup.d.ts +5 -4
- package/dist/scripts/run-cleanup.d.ts.map +1 -1
- package/dist/scripts/run-cleanup.js +55 -52
- package/dist/scripts/run-cleanup.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ test('a holder in another container', async () => {
|
|
|
99
99
|
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
100
100
|
| `start(body, { name? })` | A container this process owns. It stays after it stops, so its logs remain, until disposal removes it. | `OwnedContainer` |
|
|
101
101
|
| `serve(body, { internalPort, name?, healthy? })` | A dedicated server whose `internalPort` answers on `127.0.0.1` of this machine. Failure or disposal removes it. | `ServiceContainer` |
|
|
102
|
-
| `reuse(body, { internalPort, name?, healthy? })` | One server per
|
|
102
|
+
| `reuse(body, { internalPort, name?, healthy? })` | One server per request on the engine, shared across processes, runs and versions of this package. | `ServiceContainer` |
|
|
103
103
|
| `run(body, { name? })` | A container that runs to completion. It gives the output and the exit code, and removes the container. A non-zero exit code does not throw. | `ExecResult` |
|
|
104
104
|
| `volume()` | A named volume. | `OwnedVolume` |
|
|
105
105
|
| `directory()` | A directory on the engine's host, for bind mounts. It has `mkdir`, `writeFile`, `readFile`, `chmod` and `symlink`. | `DockerDirectory` |
|
|
@@ -122,20 +122,27 @@ A dedicated server is not ready when `healthy` throws, or when its container exi
|
|
|
122
122
|
|
|
123
123
|
### Shared servers
|
|
124
124
|
|
|
125
|
-
`reuse(body, options)` finds the server for this
|
|
125
|
+
`reuse(body, options)` finds the server for this request, or creates it. The request is the body after the testbed adds its defaults and the published port, and the `internalPort`. The order of the keys and the order of the `Env` entries do not select a different server. Docker reserves the name atomically, so concurrent processes attach to the same container. Different images, passwords, environments or labels select separate servers. The version of `@zukhruf/testing` does not: projects on different versions that send the same request share one server. A readiness failure leaves the shared server running for diagnosis. Dispose a reused server only after all its users finish: disposal stops it for every caller.
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
The name of a shared server is `zukhruf-testing-<fingerprint>`, and its label `dev.zukhruf.testing.server` holds the fingerprint. The fingerprint is a hash of the request. At the end of a run that used Docker, the global teardown removes each shared server on its engine that is older than its time to live (TTL) of 7 days, from its `Created` time. It keeps a server while a test process uses it ([ADR 0019](./docs/adr/0019-a-shared-servers-name-comes-from-its-request-and-the-global-teardown-removes-it-after-a-ttl.md)). Each test process that calls `reuse()` holds a process lease for each shared server that it uses: a small `busybox` container that runs `cat` on the input of an attach. When the process exits, also when it is killed, the attach closes and the engine removes the lease. The attach does not keep the process running. Before the teardown removes a server, it takes the sweep lease of that server, and then it looks for a process lease of that server. A test process takes its process lease, and then it looks for the sweep lease of its server. When that sweep lease exists, `reuse()` waits until the sweep ends, and then finds or creates its server ([ADR 0014](./docs/adr/0014-a-test-process-holds-a-process-lease-and-the-global-teardown-keeps-the-shared-servers-of-a-version-that-has-one.md)).
|
|
128
128
|
|
|
129
|
-
The teardown
|
|
129
|
+
The teardown checks the servers only at the end of a run that used Docker. An engine that no run uses keeps its servers.
|
|
130
130
|
|
|
131
|
-
When you change your own body
|
|
131
|
+
When you change your own body, the old server stays until its TTL ends. A newer image behind the same tag does not change the request. To use the newer image now, stop the server:
|
|
132
132
|
|
|
133
133
|
```sh
|
|
134
|
-
docker ps -a --filter label=dev.zukhruf.testing.
|
|
134
|
+
docker ps -a --filter label=dev.zukhruf.testing.server
|
|
135
135
|
docker stop <container-id>
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
The engine removes a server when it stops, so stopping also removes it.
|
|
138
|
+
The engine removes a server when it stops, so stopping also removes it.
|
|
139
|
+
|
|
140
|
+
Versions of this package before ADR 0019 used the label `dev.zukhruf.testing.shared=1`. This version does not see their servers. After each project on that engine uses this version, stop them one time:
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
docker ps -a --filter label=dev.zukhruf.testing.shared=1
|
|
144
|
+
docker stop <container-id>
|
|
145
|
+
```
|
|
139
146
|
|
|
140
147
|
A shared server starts on the first `database()` call that needs it. When that call is in a test, the time limit of the test also counts the start of the server. Each fixture sets a time limit for the start, its readiness bound: Postgres 60 s, MySQL and MariaDB 90 s, SQL Server 180 s. When the server does not answer in that time, the call fails with "Container … was not ready" and the output of the container. The default time limit of `@zukhruf/nx/test` is 240 s: the slowest readiness bound plus 60 s for the test (see [the test area](../nx/README.md#what-the-test-target-runs)). When you change a readiness bound, change that default with it.
|
|
141
148
|
|
|
@@ -163,7 +170,7 @@ node --test --test-force-exit --test-global-setup=src/testing/docker-global-setu
|
|
|
163
170
|
|
|
164
171
|
The global setup sets `ZUKHRUF_TESTING_RUN_ID` and `ZUKHRUF_TESTING_RUN_DIR` for the test processes. A `DockerTestbed` reads them from its `environment` and labels what it creates with the run. It records SSH forwards and host directories in the run's directory. It also writes a process record for its test process, and for each SSH command that it starts, while that command runs. While it asks the engine to create a container, it writes a creating record. In a run, `database()` puts the run's id in the name of each database that it creates on a shared server: `test_<run id>_<16 hex>`.
|
|
165
172
|
|
|
166
|
-
The global teardown removes the labeled containers with their anonymous volumes, the labeled volumes and the recorded paths. On each running shared server of `Postgres`, `Mysql`, `Mariadb` and `SqlServer`, it drops the databases whose name has the run's id ([ADR 0011](./docs/adr/0011-the-run-id-in-a-databases-name-is-its-owner-reference-and-one-collector-for-each-kind-drops-a-dead-runs-databases.md)). Each list and each drop on a server has the time limit of one request to the engine, 240 s. When a shared server does not answer in that time, the global teardown keeps the run's databases on that server and continues. Recovery does the same. It skips a kind whose driver the project did not install. It
|
|
173
|
+
The global teardown removes the labeled containers with their anonymous volumes, the labeled volumes and the recorded paths. On each running shared server of `Postgres`, `Mysql`, `Mariadb` and `SqlServer`, it drops the databases whose name has the run's id ([ADR 0011](./docs/adr/0011-the-run-id-in-a-databases-name-is-its-owner-reference-and-one-collector-for-each-kind-drops-a-dead-runs-databases.md)). Each list and each drop on a server has the time limit of one request to the engine, 240 s. When a shared server does not answer in that time, the global teardown keeps the run's databases on that server and continues. Recovery does the same. It skips a kind whose driver the project did not install. It removes each shared server that is older than its TTL, unless a test process holds a process lease for it (see [Shared servers](#shared-servers)). When the engine does not remove one of these servers, the teardown keeps it and continues, and a later teardown removes it. The teardown is synchronous, because Node does not wait for an asynchronous teardown under `--test-force-exit`. When every recorded process has ended, the teardown deletes the run's records. A recorded process that still runs can still create a container. The engine can also finish a create after the test process that sent it was killed. Then the teardown keeps the records, and a later run removes what is left after that process ends. Recovery keeps the records for 240 s after a create that a killed test process started, and sweeps the run again at each start in that time.
|
|
167
174
|
|
|
168
175
|
If cleanup fails, for example because the engine is unreachable, the global teardown prints the error, keeps the run's records, and sets exit code 1. The next run on the same engine removes what the run left, from any project of this user. This is recovery. Recovery does not touch a run while its runner or one of its recorded processes lives. The records are in `$XDG_STATE_HOME/zukhruf-testing/docker-runs` (`~/.local/state/zukhruf-testing/docker-runs` by default). Do not delete a record to hide a cleanup failure.
|
|
169
176
|
|
|
@@ -2,10 +2,12 @@ import { type Clock } from '@zukhruf/async';
|
|
|
2
2
|
import { type CancelOptions, type Docker } from '@zukhruf/docker';
|
|
3
3
|
/** The kind of a lease: `process` for a test process that reuses shared servers, `sweep` for a teardown that removes them. */
|
|
4
4
|
export declare const LEASE_LABEL = "dev.zukhruf.testing.lease";
|
|
5
|
+
/** The fingerprint of the shared server that a lease is for (ADR 0019). */
|
|
6
|
+
export declare const LEASED_SERVER_LABEL = "dev.zukhruf.testing.lease.server";
|
|
5
7
|
/** The smallest image with `cat`. A missing image is pulled by the caller. */
|
|
6
8
|
export declare const LEASE_IMAGE = "busybox:1.37.0";
|
|
7
|
-
/** The name of the sweep lease of `
|
|
8
|
-
export declare function sweepLeaseName(
|
|
9
|
+
/** The name of the sweep lease of the shared server of `fingerprint` on an engine. */
|
|
10
|
+
export declare function sweepLeaseName(fingerprint: string): string;
|
|
9
11
|
/**
|
|
10
12
|
* A lease on one engine (Gray & Cheriton): a container that runs `cat` on
|
|
11
13
|
* the standard input of the attach of its holder. When the holder process
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-lease.d.ts","sourceRoot":"","sources":["../../src/docker/engine-lease.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine-lease.d.ts","sourceRoot":"","sources":["../../src/docker/engine-lease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAW,MAAM,gBAAgB,CAAC;AACrD,OAAO,EACL,KAAK,aAAa,EAKlB,KAAK,MAAM,EAGZ,MAAM,iBAAiB,CAAC;AAEzB,8HAA8H;AAC9H,eAAO,MAAM,WAAW,8BAA8B,CAAC;AAEvD,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,qCAAqC,CAAC;AAEtE,8EAA8E;AAC9E,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAQ5C,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1D;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,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,EAAE,aAAa,GAAG;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,GACrD,OAAO,CAAC,IAAI,CAAC;IAoBhB,mDAAmD;IAC7C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7C"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { hash } from 'node:crypto';
|
|
2
1
|
import { timeout } from '@zukhruf/async';
|
|
3
2
|
import { ContainerNotFoundError, ContainerRunningError, NameConflictError, } from '@zukhruf/docker';
|
|
4
3
|
/** The kind of a lease: `process` for a test process that reuses shared servers, `sweep` for a teardown that removes them. */
|
|
5
4
|
export const LEASE_LABEL = 'dev.zukhruf.testing.lease';
|
|
5
|
+
/** The fingerprint of the shared server that a lease is for (ADR 0019). */
|
|
6
|
+
export const LEASED_SERVER_LABEL = 'dev.zukhruf.testing.lease.server';
|
|
6
7
|
/** The smallest image with `cat`. A missing image is pulled by the caller. */
|
|
7
8
|
export const LEASE_IMAGE = 'busybox:1.37.0';
|
|
8
9
|
/** The time a `created` lease gets to start before a waiter removes it, and between two looks of a waiter. */
|
|
9
10
|
const PATIENCE = 5_000;
|
|
10
11
|
/** The states of a lease that ended: no holder can have it. */
|
|
11
12
|
const endedStates = new Set(['exited', 'dead']);
|
|
12
|
-
/** The name of the sweep lease of `
|
|
13
|
-
export function sweepLeaseName(
|
|
14
|
-
return `zukhruf-testing-sweep-${
|
|
13
|
+
/** The name of the sweep lease of the shared server of `fingerprint` on an engine. */
|
|
14
|
+
export function sweepLeaseName(fingerprint) {
|
|
15
|
+
return `zukhruf-testing-sweep-${fingerprint}`;
|
|
15
16
|
}
|
|
16
17
|
/** The state of the container, or undefined when it is gone. */
|
|
17
18
|
async function stateOf(container, cancel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-lease.js","sourceRoot":"","sources":["../../src/docker/engine-lease.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"engine-lease.js","sourceRoot":"","sources":["../../src/docker/engine-lease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAGL,sBAAsB,EAEtB,qBAAqB,EAErB,iBAAiB,GAElB,MAAM,iBAAiB,CAAC;AAEzB,8HAA8H;AAC9H,MAAM,CAAC,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAEvD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AAEtE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAE5C,8GAA8G;AAC9G,MAAM,QAAQ,GAAG,KAAK,CAAC;AAEvB,+DAA+D;AAC/D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhD,sFAAsF;AACtF,MAAM,UAAU,cAAc,CAAC,WAAmB;IAChD,OAAO,yBAAyB,WAAW,EAAE,CAAC;AAChD,CAAC;AAED,gEAAgE;AAChE,KAAK,UAAU,OAAO,CACpB,SAAoB,EACpB,MAAqB;IAErB,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,sBAAsB;YAAE,OAAO,SAAS,CAAC;QAC9D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,4HAA4H;AAC5H,KAAK,UAAU,mBAAmB,CAChC,KAAgB,EAChB,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K,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC9C,MAAM,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBACzC,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;CACF;AAED,iFAAiF;AACjF,KAAK,UAAU,aAAa,CAC1B,KAAgB,EAChB,EAAE,MAAM,EAAiB,EACzB,KAAY;IAEZ,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9C,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,IAAI,CAAC;YACf,SAAS,EAAE,SAAS;YACpB,MAAM,EACJ,MAAM,KAAK,SAAS;gBAClB,CAAC,CAAC,QAAQ,CAAC,MAAM;gBACjB,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;SACjD,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,MAAM,CAAC,OAAO;YAAE,MAAM,KAAK,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/docker/testbed.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
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
|
-
/** Marks a server that `reuse()` shares across processes and runs. */
|
|
5
|
-
export declare const
|
|
6
|
-
/** The fingerprint of a shared server's configuration. */
|
|
7
|
-
export declare const CONFIG_LABEL = "dev.zukhruf.testing.config";
|
|
8
|
-
/** The version of this package that a shared server belongs to (ADR 0012). */
|
|
9
|
-
export declare const VERSION_LABEL = "dev.zukhruf.testing.version";
|
|
10
|
-
/** The version of this package: `../../package.json` from `src/docker` and from `dist/docker`. */
|
|
11
|
-
export declare const PACKAGE_VERSION: string;
|
|
4
|
+
/** Marks a server that `reuse()` shares across processes and runs. Its value is the fingerprint of the server's request (ADR 0019). */
|
|
5
|
+
export declare const SERVER_LABEL = "dev.zukhruf.testing.server";
|
|
12
6
|
export interface ServiceOptions {
|
|
13
7
|
/** The container's port that answers on 127.0.0.1 of this machine. */
|
|
14
8
|
internalPort: number;
|
|
15
|
-
/** Without it, the engine names a dedicated server; a shared server's name comes from its
|
|
9
|
+
/** Without it, the engine names a dedicated server; a shared server's name comes from its request. */
|
|
16
10
|
name?: string;
|
|
17
11
|
/** Runs on every acquisition. Throw until ready, using timebox for polling. */
|
|
18
12
|
healthy?: (service: ServiceContainer) => unknown;
|
|
@@ -58,10 +52,11 @@ export declare class DockerTestbed {
|
|
|
58
52
|
*/
|
|
59
53
|
serve(body: EngineApi.ContainerCreateRequest, options: ServiceOptions): Promise<ServiceContainer>;
|
|
60
54
|
/**
|
|
61
|
-
* Reuse one server per
|
|
62
|
-
*
|
|
63
|
-
* running. Disposal closes only the forward; the server
|
|
64
|
-
* its other users. The engine removes the server when it
|
|
55
|
+
* Reuse one server per request on this engine, across processes, runs and
|
|
56
|
+
* versions of this package. Docker reserves the name atomically. Readiness
|
|
57
|
+
* failure leaves it running. Disposal closes only the forward; the server
|
|
58
|
+
* keeps running for its other users. The engine removes the server when it
|
|
59
|
+
* stops.
|
|
65
60
|
*/
|
|
66
61
|
reuse(body: EngineApi.ContainerCreateRequest, options: ServiceOptions): Promise<ServiceContainer>;
|
|
67
62
|
/** Runs a container to completion and gives its output and exit code. The container is removed afterwards. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testbed.d.ts","sourceRoot":"","sources":["../../src/docker/testbed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testbed.d.ts","sourceRoot":"","sources":["../../src/docker/testbed.ts"],"names":[],"mappings":"AAIA,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;AASjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,uIAAuI;AACvI,eAAO,MAAM,YAAY,+BAA+B,CAAC;AAEzD,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC;IACrB,sGAAsG;IACtG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC;CAClD;AAED,MAAM,WAAW,oBAAoB;IACnC,iGAAiG;IACjG,WAAW,EAAE,WAAW,CAAC;CAC1B;AAwCD;;;;;GAKG;AACH,qBAAa,aAAa;;gBAuBZ,EAAE,WAAW,EAAE,EAAE,oBAAoB;IAKjD;;;;OAIG;IACH,IAAI,QAAQ,IAAI;QACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B,UAAU,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;KAClD,CAMA;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,CACT,IAAI,EAAE,SAAS,CAAC,sBAAsB,EACtC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAC1B,OAAO,CAAC,cAAc,CAAC;IAS1B;;;OAGG;IACG,KAAK,CACT,IAAI,EAAE,SAAS,CAAC,sBAAsB,EACtC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,gBAAgB,CAAC;IAuB5B;;;;;;OAMG;IACG,KAAK,CACT,IAAI,EAAE,SAAS,CAAC,sBAAsB,EACtC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,gBAAgB,CAAC;IAsC5B,8GAA8G;IACxG,GAAG,CACP,IAAI,EAAE,SAAS,CAAC,sBAAsB,EACtC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAC1B,OAAO,CAAC,UAAU,CAAC;CAkHvB"}
|
package/dist/docker/testbed.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { hash, randomUUID } from 'node:crypto';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
2
|
import pMemoize from 'p-memoize';
|
|
4
3
|
import { ConnectionFailedError, Docker, ImageNotFoundError, } from '@zukhruf/docker';
|
|
5
4
|
import { DockerDirectory } from "./directory.js";
|
|
6
|
-
import { EngineLease, LEASE_LABEL, sweepLeaseName } from "./engine-lease.js";
|
|
5
|
+
import { EngineLease, LEASED_SERVER_LABEL, LEASE_LABEL, sweepLeaseName, } from "./engine-lease.js";
|
|
7
6
|
import { DockerHost } from "./host.js";
|
|
8
7
|
import { TEST_RUN_LABEL, readRun } from "./run-records.js";
|
|
9
8
|
import { ServiceContainer } from "./service-container.js";
|
|
10
|
-
/** Marks a server that `reuse()` shares across processes and runs. */
|
|
11
|
-
export const
|
|
12
|
-
/** The fingerprint of a shared server's configuration. */
|
|
13
|
-
export const CONFIG_LABEL = 'dev.zukhruf.testing.config';
|
|
14
|
-
/** The version of this package that a shared server belongs to (ADR 0012). */
|
|
15
|
-
export const VERSION_LABEL = 'dev.zukhruf.testing.version';
|
|
16
|
-
/** The version of this package: `../../package.json` from `src/docker` and from `dist/docker`. */
|
|
17
|
-
export const { version: PACKAGE_VERSION } = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
9
|
+
/** Marks a server that `reuse()` shares across processes and runs. Its value is the fingerprint of the server's request (ADR 0019). */
|
|
10
|
+
export const SERVER_LABEL = 'dev.zukhruf.testing.server';
|
|
18
11
|
/** The default resources: they protect a shared engine, such as an SSH engine that runs real applications. */
|
|
19
12
|
const RESOURCES = { Memory: 1024 ** 3, NanoCpus: 1e9 };
|
|
20
13
|
/**
|
|
21
|
-
* The process lease of this process
|
|
22
|
-
* One process builds many testbeds, so the
|
|
23
|
-
* lease whose attach ended is taken again by
|
|
14
|
+
* The process lease of this process for each shared server, by the engine's
|
|
15
|
+
* host and the server's fingerprint. One process builds many testbeds, so the
|
|
16
|
+
* lease belongs to the module. A lease whose attach ended is taken again by
|
|
17
|
+
* the next reuse() of that server.
|
|
24
18
|
*/
|
|
25
19
|
const processLeases = new Map();
|
|
26
20
|
const byKey = ([a], [b]) => {
|
|
@@ -134,46 +128,33 @@ export class DockerTestbed {
|
|
|
134
128
|
}
|
|
135
129
|
}
|
|
136
130
|
/**
|
|
137
|
-
* Reuse one server per
|
|
138
|
-
*
|
|
139
|
-
* running. Disposal closes only the forward; the server
|
|
140
|
-
* its other users. The engine removes the server when it
|
|
131
|
+
* Reuse one server per request on this engine, across processes, runs and
|
|
132
|
+
* versions of this package. Docker reserves the name atomically. Readiness
|
|
133
|
+
* failure leaves it running. Disposal closes only the forward; the server
|
|
134
|
+
* keeps running for its other users. The engine removes the server when it
|
|
135
|
+
* stops.
|
|
141
136
|
*/
|
|
142
137
|
async reuse(body, options) {
|
|
143
138
|
const engine = await this.#engine();
|
|
139
|
+
const published = this.#published({ ...body, HostConfig: { ...RESOURCES, ...body.HostConfig } }, options.internalPort);
|
|
140
|
+
const request = {
|
|
141
|
+
...published,
|
|
142
|
+
HostConfig: { ...published.HostConfig, AutoRemove: true },
|
|
143
|
+
};
|
|
144
|
+
const fingerprint = hash('sha256', JSON.stringify(canonical({ internalPort: options.internalPort, request })));
|
|
144
145
|
// Publish this process's lease, then read the sweep lease (ADR 0014).
|
|
145
|
-
await this.#processLease(engine);
|
|
146
|
-
await EngineLease.gone(engine.client, sweepLeaseName(
|
|
146
|
+
await this.#processLease(engine, fingerprint);
|
|
147
|
+
await EngineLease.gone(engine.client, sweepLeaseName(fingerprint), {
|
|
147
148
|
clock: globalThis,
|
|
148
149
|
});
|
|
149
|
-
const configured = {
|
|
150
|
-
...body,
|
|
151
|
-
HostConfig: { ...RESOURCES, ...body.HostConfig },
|
|
152
|
-
};
|
|
153
|
-
const fingerprint = hash('sha256', JSON.stringify(canonical({
|
|
154
|
-
version: PACKAGE_VERSION,
|
|
155
|
-
internalPort: options.internalPort,
|
|
156
|
-
body: configured,
|
|
157
|
-
})));
|
|
158
150
|
const name = options.name ?? `zukhruf-testing-${fingerprint}`;
|
|
159
|
-
const published = this.#published({
|
|
160
|
-
...configured,
|
|
161
|
-
Labels: {
|
|
162
|
-
...configured.Labels,
|
|
163
|
-
[SHARED_SERVER_LABEL]: '1',
|
|
164
|
-
[CONFIG_LABEL]: fingerprint,
|
|
165
|
-
[VERSION_LABEL]: PACKAGE_VERSION,
|
|
166
|
-
},
|
|
167
|
-
}, options.internalPort);
|
|
168
151
|
const shared = {
|
|
169
|
-
...
|
|
170
|
-
|
|
152
|
+
...request,
|
|
153
|
+
Labels: { ...request.Labels, [SERVER_LABEL]: fingerprint },
|
|
171
154
|
};
|
|
172
155
|
const { container } = await this.#creating(engine, () => engine.client.containers.createOrGet(shared, { name }));
|
|
173
156
|
const inspected = await container.inspect();
|
|
174
|
-
|
|
175
|
-
if (labels?.[SHARED_SERVER_LABEL] !== '1' ||
|
|
176
|
-
labels[CONFIG_LABEL] !== fingerprint)
|
|
157
|
+
if (inspected.Config?.Labels?.[SERVER_LABEL] !== fingerprint)
|
|
177
158
|
throw new Error(`Container ${name} does not match the shared test configuration`);
|
|
178
159
|
if (inspected.State?.Status !== 'running')
|
|
179
160
|
await container.start();
|
|
@@ -185,26 +166,26 @@ export class DockerTestbed {
|
|
|
185
166
|
const owned = this.#owned(body);
|
|
186
167
|
return this.#creating(engine, () => engine.client.containers.run(owned, options));
|
|
187
168
|
}
|
|
188
|
-
/** The process lease of this process
|
|
189
|
-
async #processLease(engine) {
|
|
190
|
-
const
|
|
191
|
-
const taken = processLeases.get(
|
|
169
|
+
/** The process lease of this process for the shared server of `fingerprint`: a sweep keeps that server while it runs. */
|
|
170
|
+
async #processLease(engine, fingerprint) {
|
|
171
|
+
const key = `${engine.client.host} ${fingerprint}`;
|
|
172
|
+
const taken = processLeases.get(key);
|
|
192
173
|
if (taken !== undefined)
|
|
193
174
|
return taken;
|
|
194
175
|
const taking = this.#creating(engine, async () => {
|
|
195
176
|
const lease = await EngineLease.take(engine.client, {
|
|
196
177
|
...this.defaults.Labels,
|
|
197
178
|
[LEASE_LABEL]: 'process',
|
|
198
|
-
[
|
|
179
|
+
[LEASED_SERVER_LABEL]: fingerprint,
|
|
199
180
|
});
|
|
200
181
|
if (lease === undefined)
|
|
201
182
|
throw new Error('The engine removed the process lease before its start');
|
|
202
183
|
return lease;
|
|
203
184
|
});
|
|
204
|
-
processLeases.set(
|
|
185
|
+
processLeases.set(key, taking);
|
|
205
186
|
const forget = () => {
|
|
206
|
-
if (processLeases.get(
|
|
207
|
-
processLeases.delete(
|
|
187
|
+
if (processLeases.get(key) === taking)
|
|
188
|
+
processLeases.delete(key);
|
|
208
189
|
};
|
|
209
190
|
taking.then((lease) => lease.closed().then(forget), forget);
|
|
210
191
|
return taking;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testbed.js","sourceRoot":"","sources":["../../src/docker/testbed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"testbed.js","sourceRoot":"","sources":["../../src/docker/testbed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE/C,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,EACL,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAmB,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,uIAAuI;AACvI,MAAM,CAAC,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAsBzD,8GAA8G;AAC9G,MAAM,SAAS,GAAG,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAgC,CAAC;AAE9D,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAoB,EAAE,CAAC,CAAC,CAAoB,EAAU,EAAE;IACvE,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,6GAA6G;AAC7G,SAAS,SAAS,CAAC,KAAc,EAAE,G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AAM,OAAO,CAAC,UAAU,EAAE,CAAC;YAC3B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,uHAAuH;IACvH,MAAM,CACJ,IAAsC;QAEtC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7C,OAAO;YACL,GAAG,IAAI;YACP,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE;YACrC,UAAU,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE;SAClD,CAAC;IACJ,CAAC;IAED,kEAAkE;IAClE,UAAU,CACR,IAAsC,EACtC,YAAoB;QAEpB,MAAM,IAAI,GAAG,GAAG,YAAY,MAAM,CAAC;QACnC,OAAO;YACL,GAAG,IAAI;YACP,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE;YAC5B,UAAU,EAAE;gBACV,GAAG,IAAI,CAAC,UAAU;gBAClB,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE;aAClE;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -11,7 +11,7 @@ async function sweep() {
|
|
|
11
11
|
// Imported here, so that a module that fails to load is an outcome too:
|
|
12
12
|
// the teardown would otherwise wait until its timeout.
|
|
13
13
|
const { connectAndCleanup } = await import("./run-cleanup.js");
|
|
14
|
-
await connectAndCleanup(run, directory);
|
|
14
|
+
await connectAndCleanup(run, directory, globalThis);
|
|
15
15
|
return { ok: true };
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker-cleanup-worker.js","sourceRoot":"","sources":["../../src/scripts/docker-cleanup-worker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MA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KAAK,CAAC;gBAC7D,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC;aACvB;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;AAChC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;AACpC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WallClock } from '@zukhruf/async';
|
|
1
2
|
import { Docker } from '@zukhruf/docker';
|
|
2
3
|
/** How long one Engine API call of the cleanup may take. */
|
|
3
4
|
export declare const ENGINE_CALL_TIMEOUT = 240000;
|
|
@@ -13,9 +14,9 @@ export interface Run {
|
|
|
13
14
|
*/
|
|
14
15
|
export declare function cleanup(engine: Docker, previous: Run, directory: string): Promise<void>;
|
|
15
16
|
/**
|
|
16
|
-
* Connects to the run's engine, cleans the run, removes the shared
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Connects to the run's engine, cleans the run, removes the expired shared
|
|
18
|
+
* servers, and ends the connection. Only the global teardown calls it, for a
|
|
19
|
+
* run that used Docker.
|
|
19
20
|
*/
|
|
20
|
-
export declare function connectAndCleanup(previous: Run, directory: string): Promise<void>;
|
|
21
|
+
export declare function connectAndCleanup(previous: Run, directory: string, clock: WallClock): Promise<void>;
|
|
21
22
|
//# sourceMappingURL=run-cleanup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cleanup.d.ts","sourceRoot":"","sources":["../../src/scripts/run-cleanup.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,MAAM,EAEP,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-cleanup.d.ts","sourceRoot":"","sources":["../../src/scripts/run-cleanup.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAGL,MAAM,EAEP,MAAM,iBAAiB,CAAC;AAuBzB,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAE3C,gDAAgD;AAChD,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AA8HD;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAgDf;AAwGD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -12,10 +12,10 @@ import { join } from 'node:path';
|
|
|
12
12
|
import { promisify } from 'node:util';
|
|
13
13
|
import { ContainerNotFoundError, Docker, ImageNotFoundError, } from '@zukhruf/docker';
|
|
14
14
|
import { KIND_LABEL, ownedBy, } from "../databases/collector.js";
|
|
15
|
-
import { EngineLease, LEASE_IMAGE, LEASE_LABEL, sweepLeaseName, } from "../docker/engine-lease.js";
|
|
15
|
+
import { EngineLease, LEASED_SERVER_LABEL, LEASE_IMAGE, LEASE_LABEL, sweepLeaseName, } from "../docker/engine-lease.js";
|
|
16
16
|
import { DockerHost, SHELL_TIMEOUT, quote } from "../docker/host.js";
|
|
17
17
|
import { TEST_RUN_LABEL, directoryPrefix, forwardPrefix, } from "../docker/run-records.js";
|
|
18
|
-
import {
|
|
18
|
+
import { SERVER_LABEL } from "../docker/testbed.js";
|
|
19
19
|
/** How long one Engine API call of the cleanup may take. */
|
|
20
20
|
export const ENGINE_CALL_TIMEOUT = 240_000;
|
|
21
21
|
const execute = promisify(execFile);
|
|
@@ -65,7 +65,7 @@ const running = async (container) => (await container.inspect().catch(() => unde
|
|
|
65
65
|
*/
|
|
66
66
|
async function dropDatabases(engine, host, runId, signal) {
|
|
67
67
|
for (const summary of await engine.containers.list({
|
|
68
|
-
filters: { label: [
|
|
68
|
+
filters: { label: [SERVER_LABEL, KIND_LABEL] },
|
|
69
69
|
signal: signal(),
|
|
70
70
|
})) {
|
|
71
71
|
const kind = summary.Labels?.[KIND_LABEL];
|
|
@@ -139,7 +139,7 @@ export async function cleanup(engine, previous, directory) {
|
|
|
139
139
|
filters,
|
|
140
140
|
signal: signal(),
|
|
141
141
|
})) {
|
|
142
|
-
if (summary.Labels?.[
|
|
142
|
+
if (summary.Labels?.[SERVER_LABEL] !== undefined)
|
|
143
143
|
continue;
|
|
144
144
|
const container = await engine.containers.find(summary.Id, {
|
|
145
145
|
signal: signal(),
|
|
@@ -178,20 +178,22 @@ export async function cleanup(engine, previous, directory) {
|
|
|
178
178
|
}
|
|
179
179
|
/** The tries of a teardown to take a sweep lease that another holder has. */
|
|
180
180
|
const SWEEP_LEASE_TRIES = 3;
|
|
181
|
-
/** How long a teardown waits for the sweep lease of one
|
|
181
|
+
/** How long a teardown waits for the sweep lease of one server that another holder has. */
|
|
182
182
|
const SWEEP_LEASE_WAIT = 30_000;
|
|
183
|
+
/** The age from which a teardown removes a shared server that no process lease holds (ADR 0019). */
|
|
184
|
+
const SERVER_TTL = 7 * 24 * 60 * 60 * 1000;
|
|
183
185
|
/**
|
|
184
|
-
* Takes the sweep lease of `
|
|
186
|
+
* Takes the sweep lease of `fingerprint`, and pulls its image when the engine
|
|
185
187
|
* does not have it. When the name is taken, it waits until that lease is
|
|
186
188
|
* gone, as a test process does, and tries again: a teardown killed before
|
|
187
189
|
* the start of its lease leaves it created, and the wait removes it. Gives
|
|
188
190
|
* undefined when each try found the name taken, or when the wait took
|
|
189
|
-
* longer than SWEEP_LEASE_WAIT: the
|
|
190
|
-
*
|
|
191
|
+
* longer than SWEEP_LEASE_WAIT: the server stays for a later teardown, and
|
|
192
|
+
* another teardown's sweep never fails this run.
|
|
191
193
|
*/
|
|
192
|
-
async function takeSweepLease(engine,
|
|
193
|
-
const name = sweepLeaseName(
|
|
194
|
-
const take = () => EngineLease.take(engine, { [LEASE_LABEL]: 'sweep', [
|
|
194
|
+
async function takeSweepLease(engine, fingerprint, signal, clock) {
|
|
195
|
+
const name = sweepLeaseName(fingerprint);
|
|
196
|
+
const take = () => EngineLease.take(engine, { [LEASE_LABEL]: 'sweep', [LEASED_SERVER_LABEL]: fingerprint }, { name, signal: signal() });
|
|
195
197
|
const wait = AbortSignal.timeout(SWEEP_LEASE_WAIT);
|
|
196
198
|
for (let tries = 0; tries < SWEEP_LEASE_TRIES; tries += 1) {
|
|
197
199
|
let lease;
|
|
@@ -207,7 +209,7 @@ async function takeSweepLease(engine, version, signal) {
|
|
|
207
209
|
if (lease !== undefined)
|
|
208
210
|
return lease;
|
|
209
211
|
try {
|
|
210
|
-
await EngineLease.gone(engine, name, { signal: wait, clock
|
|
212
|
+
await EngineLease.gone(engine, name, { signal: wait, clock });
|
|
211
213
|
}
|
|
212
214
|
catch (error) {
|
|
213
215
|
if (wait.aborted)
|
|
@@ -218,60 +220,61 @@ async function takeSweepLease(engine, version, signal) {
|
|
|
218
220
|
return undefined;
|
|
219
221
|
}
|
|
220
222
|
/**
|
|
221
|
-
* Removes each shared server
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* for process leases after it. A server with no version label has no lease.
|
|
223
|
+
* Removes each shared server that is older than SERVER_TTL, unless a test
|
|
224
|
+
* process holds a process lease for it (ADR 0019). The sweep lease of the
|
|
225
|
+
* server comes first, and the look for process leases after it (ADR 0014).
|
|
225
226
|
* A removal that fails keeps the server, and the teardown goes on.
|
|
226
227
|
*/
|
|
227
|
-
async function
|
|
228
|
+
async function removeExpiredServers(engine, clock) {
|
|
228
229
|
const signal = () => AbortSignal.timeout(ENGINE_CALL_TIMEOUT);
|
|
229
|
-
const
|
|
230
|
+
const expiry = (clock.Date.now() - SERVER_TTL) / 1000;
|
|
231
|
+
const servers = await engine.containers.list({
|
|
230
232
|
all: true,
|
|
231
|
-
filters: { label: [
|
|
233
|
+
filters: { label: [SERVER_LABEL] },
|
|
232
234
|
signal: signal(),
|
|
233
|
-
})
|
|
234
|
-
for (const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
235
|
+
});
|
|
236
|
+
for (const { Id, Created, Labels } of servers) {
|
|
237
|
+
// The filter and the engine give both; the Engine API types mark each field optional.
|
|
238
|
+
const fingerprint = Labels?.[SERVER_LABEL];
|
|
239
|
+
if (fingerprint === undefined || Created === undefined || Created > expiry)
|
|
240
|
+
continue;
|
|
241
|
+
// Other teardowns held the sweep lease on each try.
|
|
242
|
+
await using lease = await takeSweepLease(engine, fingerprint, signal, clock);
|
|
243
|
+
if (lease === undefined)
|
|
244
|
+
continue;
|
|
245
|
+
const holders = await engine.containers.list({
|
|
246
|
+
filters: {
|
|
247
|
+
label: [
|
|
248
|
+
`${LEASE_LABEL}=process`,
|
|
249
|
+
`${LEASED_SERVER_LABEL}=${fingerprint}`,
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
signal: signal(),
|
|
253
|
+
});
|
|
254
|
+
if (holders.length > 0)
|
|
255
|
+
continue;
|
|
256
|
+
// Another run's teardown can remove it first.
|
|
257
|
+
const container = await engine.containers.find(Id, { signal: signal() });
|
|
258
|
+
// A server that the engine does not remove stays for a later teardown:
|
|
259
|
+
// the sweep never fails this run.
|
|
260
|
+
await container
|
|
261
|
+
?.remove({ force: true, v: true, signal: signal() })
|
|
262
|
+
.catch(() => { });
|
|
260
263
|
}
|
|
261
264
|
}
|
|
262
265
|
/**
|
|
263
|
-
* Connects to the run's engine, cleans the run, removes the shared
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
+
* Connects to the run's engine, cleans the run, removes the expired shared
|
|
267
|
+
* servers, and ends the connection. Only the global teardown calls it, for a
|
|
268
|
+
* run that used Docker.
|
|
266
269
|
*/
|
|
267
|
-
export async function connectAndCleanup(previous, directory) {
|
|
270
|
+
export async function connectAndCleanup(previous, directory, clock) {
|
|
268
271
|
// Disposal ends the connection, and with it the ssh child of an SSH engine.
|
|
269
272
|
await using engine = await Docker.connect({
|
|
270
|
-
clock
|
|
273
|
+
clock,
|
|
271
274
|
host: previous.endpoint,
|
|
272
275
|
signal: AbortSignal.timeout(ENGINE_CALL_TIMEOUT),
|
|
273
276
|
});
|
|
274
277
|
await cleanup(engine, previous, directory);
|
|
275
|
-
await
|
|
278
|
+
await removeExpiredServers(engine, clock);
|
|
276
279
|
}
|
|
277
280
|
//# sourceMappingURL=run-cleanup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cleanup.js","sourceRoot":"","sources":["../../src/scripts/run-cleanup.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"run-cleanup.js","sourceRoot":"","sources":["../../src/scripts/run-cleanup.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,OAAO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C;QACH,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,SAAS;QACjC,8CAA8C;QAC9C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACzE,uEAAuE;QACvE,kCAAkC;QAClC,MAAM,SAAS;YACb,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;aACnD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAa,EACb,SAAiB,EACjB,KAAgB;IAEhB,4EAA4E;IAC5E,YAAY,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACxC,KAAK;QACL,IAAI,EAAE,QAAQ,CAAC,QAAQ;QACvB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC;KACjD,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC3C,MAAM,oBAAoB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/testing",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.15",
|
|
4
4
|
"description": "Disposable fixtures for integration tests: Docker containers, database servers, SQLite and DuckDB databases, HTTP servers, streams, temporary directories and intercepted requests. Node's global setup and teardown remove what a killed test run left behind.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -141,6 +141,7 @@
|
|
|
141
141
|
"devDependencies": {
|
|
142
142
|
"@duckdb/node-api": "^1.5.5-r.3",
|
|
143
143
|
"@google-cloud/bigquery": "^8.3.1",
|
|
144
|
+
"@sinonjs/fake-timers": "15.4.0",
|
|
144
145
|
"@types/mssql": "^12.3.0",
|
|
145
146
|
"@types/pg": "^8.23.1",
|
|
146
147
|
"mariadb": "^3.5.4",
|
|
@@ -150,8 +151,8 @@
|
|
|
150
151
|
"pg": "^8.23.1"
|
|
151
152
|
},
|
|
152
153
|
"dependencies": {
|
|
153
|
-
"@zukhruf/async": "^0.8.
|
|
154
|
-
"@zukhruf/docker": "^0.8.
|
|
154
|
+
"@zukhruf/async": "^0.8.15",
|
|
155
|
+
"@zukhruf/docker": "^0.8.15",
|
|
155
156
|
"nano-spawn": "^2.1.0",
|
|
156
157
|
"p-memoize": "^8.0.0",
|
|
157
158
|
"p-retry": "^8.0.1"
|