testcontainers 12.1.0 → 12.2.1
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/build/common/file-lock.js +3 -3
- package/build/common/hash.js +2 -2
- package/build/common/index.d.ts +2 -3
- package/build/common/index.js +2 -4
- package/build/common/retry.d.ts +1 -1
- package/build/common/uuid.js +2 -2
- package/build/container-runtime/auth/auths.d.ts +2 -2
- package/build/container-runtime/auth/cred-helpers.d.ts +1 -1
- package/build/container-runtime/auth/credential-provider.d.ts +2 -2
- package/build/container-runtime/auth/credential-provider.js +3 -3
- package/build/container-runtime/auth/creds-store.d.ts +2 -2
- package/build/container-runtime/auth/creds-store.js +1 -1
- package/build/container-runtime/auth/get-auth-config.d.ts +1 -1
- package/build/container-runtime/auth/get-auth-config.js +7 -7
- package/build/container-runtime/auth/registry-auth-locator.d.ts +1 -1
- package/build/container-runtime/auth/registry-matches.js +1 -1
- package/build/container-runtime/clients/client.d.ts +5 -5
- package/build/container-runtime/clients/compose/compose-client.d.ts +1 -1
- package/build/container-runtime/clients/compose/compose-client.js +1 -3
- package/build/container-runtime/clients/compose/default-compose-options.d.ts +2 -2
- package/build/container-runtime/clients/compose/default-compose-options.js +5 -3
- package/build/container-runtime/clients/compose/types.d.ts +3 -2
- package/build/container-runtime/clients/container/container-client.d.ts +5 -4
- package/build/container-runtime/clients/container/docker-container-client.d.ts +6 -5
- package/build/container-runtime/clients/container/docker-container-client.js +13 -9
- package/build/container-runtime/clients/container/types.d.ts +1 -3
- package/build/container-runtime/clients/image/docker-image-client.d.ts +4 -3
- package/build/container-runtime/clients/image/docker-image-client.js +11 -10
- package/build/container-runtime/clients/image/image-client.d.ts +2 -2
- package/build/container-runtime/clients/network/docker-network-client.d.ts +3 -2
- package/build/container-runtime/clients/network/network-client.d.ts +1 -1
- package/build/container-runtime/image-name.d.ts +2 -1
- package/build/container-runtime/image-name.js +23 -13
- package/build/container-runtime/index.d.ts +1 -1
- package/build/container-runtime/strategies/configuration-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/configuration-strategy.js +7 -7
- package/build/container-runtime/strategies/npipe-socket-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/rootless-unix-socket-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/rootless-unix-socket-strategy.js +9 -9
- package/build/container-runtime/strategies/strategy.d.ts +1 -1
- package/build/container-runtime/strategies/testcontainers-host-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/testcontainers-host-strategy.js +2 -2
- package/build/container-runtime/strategies/types.d.ts +1 -1
- package/build/container-runtime/strategies/unix-socket-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/unix-socket-strategy.js +2 -2
- package/build/container-runtime/strategies/utils/config.js +12 -12
- package/build/container-runtime/utils/attach-container.d.ts +2 -2
- package/build/container-runtime/utils/demux-stream.d.ts +2 -2
- package/build/container-runtime/utils/demux-stream.js +2 -2
- package/build/container-runtime/utils/image-exists.d.ts +2 -2
- package/build/container-runtime/utils/lookup-host-ips.d.ts +1 -1
- package/build/container-runtime/utils/lookup-host-ips.js +4 -4
- package/build/container-runtime/utils/pull-image.d.ts +2 -2
- package/build/container-runtime/utils/remote-container-runtime-socket-path.d.ts +1 -1
- package/build/container-runtime/utils/remote-container-runtime-socket-path.js +2 -2
- package/build/container-runtime/utils/resolve-host.d.ts +2 -2
- package/build/container-runtime/utils/resolve-host.js +4 -4
- package/build/container-runtime/utils/run-in-container.d.ts +1 -1
- package/build/container-runtime/utils/run-in-container.js +2 -1
- package/build/container-runtime/utils/start-container.d.ts +1 -1
- package/build/docker-compose-environment/docker-compose-environment.d.ts +5 -5
- package/build/docker-compose-environment/docker-compose-environment.js +18 -8
- package/build/docker-compose-environment/started-docker-compose-environment.d.ts +2 -2
- package/build/docker-compose-environment/stopped-docker-compose-environment.d.ts +1 -1
- package/build/generic-container/abstract-started-container.d.ts +3 -3
- package/build/generic-container/abstract-stopped-container.d.ts +1 -1
- package/build/generic-container/generic-container-builder.d.ts +3 -3
- package/build/generic-container/generic-container-builder.js +11 -6
- package/build/generic-container/generic-container.d.ts +9 -9
- package/build/generic-container/generic-container.js +22 -8
- package/build/generic-container/inspect-container-util-ports-exposed.d.ts +1 -1
- package/build/generic-container/inspect-container-util-ports-exposed.js +1 -1
- package/build/generic-container/started-generic-container.d.ts +6 -5
- package/build/generic-container/started-generic-container.js +19 -16
- package/build/generic-container/stopped-generic-container.d.ts +2 -2
- package/build/index.d.ts +4 -4
- package/build/index.js +3 -3
- package/build/network/network.d.ts +3 -3
- package/build/port-forwarder/port-forwarder.d.ts +2 -3
- package/build/port-forwarder/port-forwarder.js +25 -19
- package/build/reaper/reaper.d.ts +1 -1
- package/build/reaper/reaper.js +21 -19
- package/build/socat/socat-container.d.ts +0 -2
- package/build/socat/socat-container.js +0 -3
- package/build/test-container.d.ts +6 -6
- package/build/test-containers.js +2 -1
- package/build/types.d.ts +3 -4
- package/build/utils/bound-ports.d.ts +3 -3
- package/build/utils/bound-ports.js +2 -2
- package/build/utils/dockerfile-parser.d.ts +1 -1
- package/build/utils/dockerfile-parser.js +2 -2
- package/build/utils/labels.d.ts +0 -2
- package/build/utils/labels.js +5 -5
- package/build/utils/map-inspect-result.d.ts +2 -2
- package/build/utils/map-inspect-result.js +12 -13
- package/build/utils/pull-policy.d.ts +2 -1
- package/build/utils/pull-policy.js +9 -0
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/build/wait-strategies/composite-wait-strategy.d.ts +3 -3
- package/build/wait-strategies/composite-wait-strategy.js +3 -1
- package/build/wait-strategies/health-check-wait-strategy.d.ts +1 -1
- package/build/wait-strategies/host-port-wait-strategy.d.ts +2 -2
- package/build/wait-strategies/http-wait-strategy.d.ts +2 -2
- package/build/wait-strategies/http-wait-strategy.js +4 -7
- package/build/wait-strategies/log-wait-strategy.d.ts +3 -3
- package/build/wait-strategies/log-wait-strategy.js +1 -1
- package/build/wait-strategies/one-shot-startup-startegy.d.ts +2 -2
- package/build/wait-strategies/shell-wait-strategy.d.ts +1 -1
- package/build/wait-strategies/startup-check-strategy.d.ts +1 -2
- package/build/wait-strategies/startup-check-strategy.js +0 -3
- package/build/wait-strategies/utils/health-check.d.ts +2 -4
- package/build/wait-strategies/utils/health-check.js +4 -6
- package/build/wait-strategies/utils/port-check.d.ts +2 -2
- package/build/wait-strategies/utils/port-check.js +2 -2
- package/build/wait-strategies/utils/undici-response-parser.d.ts +1 -1
- package/build/wait-strategies/utils/undici-response-parser.js +2 -2
- package/build/wait-strategies/utils/wait-strategy-selector.d.ts +4 -4
- package/build/wait-strategies/wait-for-container.d.ts +4 -4
- package/build/wait-strategies/wait-strategy.d.ts +2 -2
- package/build/wait-strategies/wait.d.ts +3 -3
- package/build/wait-strategies/wait.js +1 -0
- package/package.json +3 -4
- package/build/common/streams.d.ts +0 -6
- package/build/common/streams.js +0 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDockerfileImages = getDockerfileImages;
|
|
4
|
-
const
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const container_runtime_1 = require("../container-runtime");
|
|
7
7
|
const buildArgRegex = /\${([^{]+)}/g;
|
|
@@ -17,7 +17,7 @@ async function getDockerfileImages(dockerfile, buildArgs) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
async function parseImages(dockerfile) {
|
|
20
|
-
return Array.from((await
|
|
20
|
+
return Array.from((await node_fs_1.promises.readFile(dockerfile, "utf8"))
|
|
21
21
|
.split(/\r?\n/)
|
|
22
22
|
.filter((line) => line.toUpperCase().startsWith("FROM"))
|
|
23
23
|
.map((line) => line.split(" ").filter(common_1.isNotEmptyString)[1])
|
package/build/utils/labels.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export declare const LABEL_TESTCONTAINERS = "org.testcontainers";
|
|
2
1
|
export declare const LABEL_TESTCONTAINERS_LANG = "org.testcontainers.lang";
|
|
3
|
-
export declare const LABEL_TESTCONTAINERS_VERSION = "org.testcontainers.version";
|
|
4
2
|
export declare const LABEL_TESTCONTAINERS_SESSION_ID = "org.testcontainers.session-id";
|
|
5
3
|
export declare const LABEL_TESTCONTAINERS_SSHD = "org.testcontainers.sshd";
|
|
6
4
|
export declare const LABEL_TESTCONTAINERS_CONTAINER_HASH = "org.testcontainers.container-hash";
|
package/build/utils/labels.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LABEL_TESTCONTAINERS_RYUK = exports.LABEL_TESTCONTAINERS_CONTAINER_HASH = exports.LABEL_TESTCONTAINERS_SSHD = exports.LABEL_TESTCONTAINERS_SESSION_ID = exports.
|
|
3
|
+
exports.LABEL_TESTCONTAINERS_RYUK = exports.LABEL_TESTCONTAINERS_CONTAINER_HASH = exports.LABEL_TESTCONTAINERS_SSHD = exports.LABEL_TESTCONTAINERS_SESSION_ID = exports.LABEL_TESTCONTAINERS_LANG = void 0;
|
|
4
4
|
exports.createLabels = createLabels;
|
|
5
5
|
const version_1 = require("../version");
|
|
6
|
-
|
|
6
|
+
const LABEL_TESTCONTAINERS = "org.testcontainers";
|
|
7
|
+
const LABEL_TESTCONTAINERS_VERSION = "org.testcontainers.version";
|
|
7
8
|
exports.LABEL_TESTCONTAINERS_LANG = "org.testcontainers.lang";
|
|
8
|
-
exports.LABEL_TESTCONTAINERS_VERSION = "org.testcontainers.version";
|
|
9
9
|
exports.LABEL_TESTCONTAINERS_SESSION_ID = "org.testcontainers.session-id";
|
|
10
10
|
exports.LABEL_TESTCONTAINERS_SSHD = "org.testcontainers.sshd";
|
|
11
11
|
exports.LABEL_TESTCONTAINERS_CONTAINER_HASH = "org.testcontainers.container-hash";
|
|
12
12
|
exports.LABEL_TESTCONTAINERS_RYUK = "org.testcontainers.ryuk";
|
|
13
13
|
function createLabels() {
|
|
14
14
|
return {
|
|
15
|
-
[
|
|
15
|
+
[LABEL_TESTCONTAINERS]: "true",
|
|
16
16
|
[exports.LABEL_TESTCONTAINERS_LANG]: "node",
|
|
17
|
-
[
|
|
17
|
+
[LABEL_TESTCONTAINERS_VERSION]: version_1.LIB_VERSION,
|
|
18
18
|
};
|
|
19
19
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ContainerInspectInfo } from "dockerode";
|
|
2
|
-
import { InspectResult } from "../types";
|
|
1
|
+
import type { ContainerInspectInfo } from "dockerode";
|
|
2
|
+
import type { InspectResult } from "../types";
|
|
3
3
|
export declare function mapInspectResult(inspectResult: ContainerInspectInfo): InspectResult;
|
|
@@ -20,19 +20,19 @@ function mapInspectResult(inspectResult) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
function mapPorts(inspectInfo) {
|
|
23
|
-
return Object.entries(inspectInfo.NetworkSettings.Ports)
|
|
23
|
+
return Object.fromEntries(Object.entries(inspectInfo.NetworkSettings.Ports)
|
|
24
24
|
.filter(([, hostPorts]) => hostPorts !== null)
|
|
25
25
|
.map(([containerPortAndProtocol, hostPorts]) => {
|
|
26
26
|
const [port, protocol] = containerPortAndProtocol.split("/");
|
|
27
|
-
const containerPort = parseInt(port);
|
|
28
|
-
return
|
|
29
|
-
|
|
27
|
+
const containerPort = parseInt(port, 10);
|
|
28
|
+
return [
|
|
29
|
+
`${containerPort}/${protocol}`,
|
|
30
|
+
hostPorts.map((hostPort) => ({
|
|
30
31
|
hostIp: hostPort.HostIp,
|
|
31
|
-
hostPort: parseInt(hostPort.HostPort),
|
|
32
|
+
hostPort: parseInt(hostPort.HostPort, 10),
|
|
32
33
|
})),
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
.reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
34
|
+
];
|
|
35
|
+
}));
|
|
36
36
|
}
|
|
37
37
|
function mapHealthCheckStatus(inspectResult) {
|
|
38
38
|
const status = (0, health_check_1.getHealthCheckStatusFromInspect)(inspectResult);
|
|
@@ -44,12 +44,11 @@ function mapHealthCheckStatus(inspectResult) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
function mapNetworkSettings(inspectResult) {
|
|
47
|
-
return Object.entries(inspectResult.NetworkSettings.Networks)
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
return Object.fromEntries(Object.entries(inspectResult.NetworkSettings.Networks).map(([networkName, network]) => [
|
|
48
|
+
networkName,
|
|
49
|
+
{
|
|
50
50
|
networkId: network.NetworkID,
|
|
51
51
|
ipAddress: network.IPAddress,
|
|
52
52
|
},
|
|
53
|
-
|
|
54
|
-
.reduce((prev, next) => ({ ...prev, ...next }), {});
|
|
53
|
+
]));
|
|
55
54
|
}
|
|
@@ -11,6 +11,12 @@ class AlwaysPullPolicy {
|
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
class NeverPullPolicy {
|
|
15
|
+
shouldPull() {
|
|
16
|
+
return "never";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// biome-ignore lint/complexity/noStaticOnlyClass: public API surface, kept as a class for backwards compatibility
|
|
14
20
|
class PullPolicy {
|
|
15
21
|
static defaultPolicy() {
|
|
16
22
|
return new DefaultPullPolicy();
|
|
@@ -18,5 +24,8 @@ class PullPolicy {
|
|
|
18
24
|
static alwaysPull() {
|
|
19
25
|
return new AlwaysPullPolicy();
|
|
20
26
|
}
|
|
27
|
+
static neverPull() {
|
|
28
|
+
return new NeverPullPolicy();
|
|
29
|
+
}
|
|
21
30
|
}
|
|
22
31
|
exports.PullPolicy = PullPolicy;
|
package/build/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "12.1
|
|
1
|
+
export declare const LIB_VERSION = "12.2.1";
|
package/build/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
2
|
-
import { BoundPorts } from "../utils/bound-ports";
|
|
3
|
-
import { AbstractWaitStrategy, WaitStrategy } from "./wait-strategy";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
|
+
import type { BoundPorts } from "../utils/bound-ports";
|
|
3
|
+
import { AbstractWaitStrategy, type WaitStrategy } from "./wait-strategy";
|
|
4
4
|
export declare class CompositeWaitStrategy extends AbstractWaitStrategy {
|
|
5
5
|
private readonly waitStrategies;
|
|
6
6
|
private deadline?;
|
|
@@ -37,7 +37,9 @@ class CompositeWaitStrategy extends wait_strategy_1.AbstractWaitStrategy {
|
|
|
37
37
|
withStartupTimeout(startupTimeoutMs) {
|
|
38
38
|
this.waitStrategies
|
|
39
39
|
.filter((waitStrategy) => !waitStrategy.isStartupTimeoutSet())
|
|
40
|
-
.forEach((waitStrategy) =>
|
|
40
|
+
.forEach((waitStrategy) => {
|
|
41
|
+
waitStrategy.withStartupTimeout(startupTimeoutMs);
|
|
42
|
+
});
|
|
41
43
|
return this;
|
|
42
44
|
}
|
|
43
45
|
withDeadline(deadline) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
2
|
import { AbstractWaitStrategy } from "./wait-strategy";
|
|
3
3
|
export declare class HealthCheckWaitStrategy extends AbstractWaitStrategy {
|
|
4
4
|
waitUntilReady(container: Dockerode.Container): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
2
|
-
import { BoundPorts } from "../utils/bound-ports";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
|
+
import type { BoundPorts } from "../utils/bound-ports";
|
|
3
3
|
import { AbstractWaitStrategy } from "./wait-strategy";
|
|
4
4
|
export declare class HostPortWaitStrategy extends AbstractWaitStrategy {
|
|
5
5
|
waitUntilReady(container: Dockerode.Container, boundPorts: BoundPorts): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
2
|
-
import { BoundPorts } from "../utils/bound-ports";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
|
+
import type { BoundPorts } from "../utils/bound-ports";
|
|
3
3
|
import { AbstractWaitStrategy } from "./wait-strategy";
|
|
4
4
|
export interface HttpWaitStrategyOptions {
|
|
5
5
|
abortOnContainerExit?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpWaitStrategy = void 0;
|
|
4
|
+
const consumers_1 = require("node:stream/consumers");
|
|
4
5
|
const undici_1 = require("undici");
|
|
5
6
|
const common_1 = require("../common");
|
|
6
7
|
const container_runtime_1 = require("../container-runtime");
|
|
@@ -126,17 +127,13 @@ class HttpWaitStrategy extends wait_strategy_1.AbstractWaitStrategy {
|
|
|
126
127
|
}
|
|
127
128
|
async handleContainerExit(container) {
|
|
128
129
|
const tail = 50;
|
|
129
|
-
const lastLogs = [];
|
|
130
130
|
const client = await (0, container_runtime_1.getContainerRuntimeClient)();
|
|
131
131
|
let message;
|
|
132
132
|
try {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
stream.on("data", (d) => lastLogs.push(d.trim())).on("end", res);
|
|
136
|
-
});
|
|
137
|
-
message = `Container exited during HTTP healthCheck, last ${tail} logs: ${lastLogs.join("\n")}`;
|
|
133
|
+
const lastLogs = await (0, consumers_1.text)(await client.container.logs(container, { tail }));
|
|
134
|
+
message = `Container exited during HTTP healthCheck, last ${tail} logs: ${lastLogs.trim()}`;
|
|
138
135
|
}
|
|
139
|
-
catch (
|
|
136
|
+
catch (_err) {
|
|
140
137
|
message = "Container exited during HTTP healthCheck, failed to get last logs";
|
|
141
138
|
}
|
|
142
139
|
common_1.log.error(message, { containerId: container.id });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
2
|
-
import { BoundPorts } from "../utils/bound-ports";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
|
+
import type { BoundPorts } from "../utils/bound-ports";
|
|
3
3
|
import { AbstractWaitStrategy } from "./wait-strategy";
|
|
4
4
|
export type Log = string;
|
|
5
5
|
export declare class LogWaitStrategy extends AbstractWaitStrategy {
|
|
6
6
|
private readonly message;
|
|
7
7
|
private readonly times;
|
|
8
8
|
constructor(message: Log | RegExp, times: number);
|
|
9
|
-
waitUntilReady(container: Dockerode.Container,
|
|
9
|
+
waitUntilReady(container: Dockerode.Container, _boundPorts: BoundPorts, startTime?: Date): Promise<void>;
|
|
10
10
|
}
|
|
@@ -16,7 +16,7 @@ class LogWaitStrategy extends wait_strategy_1.AbstractWaitStrategy {
|
|
|
16
16
|
this.message = message;
|
|
17
17
|
this.times = times;
|
|
18
18
|
}
|
|
19
|
-
async waitUntilReady(container,
|
|
19
|
+
async waitUntilReady(container, _boundPorts, startTime) {
|
|
20
20
|
common_1.log.debug(`Waiting for log message "${this.message}"...`, { containerId: container.id });
|
|
21
21
|
const client = await (0, container_runtime_1.getContainerRuntimeClient)();
|
|
22
22
|
const stream = await client.container.logs(container, { since: startTime ? startTime.getTime() / 1000 : 0 });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
2
|
-
import { StartupCheckStrategy, StartupStatus } from "./startup-check-strategy";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
|
+
import { StartupCheckStrategy, type StartupStatus } from "./startup-check-strategy";
|
|
3
3
|
export declare class OneShotStartupCheckStrategy extends StartupCheckStrategy {
|
|
4
4
|
DOCKER_TIMESTAMP_ZERO: string;
|
|
5
5
|
private isDockerTimestampNonEmpty;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
2
|
import { AbstractWaitStrategy } from "./wait-strategy";
|
|
3
3
|
export type StartupStatus = "PENDING" | "SUCCESS" | "FAIL";
|
|
4
4
|
export declare abstract class StartupCheckStrategy extends AbstractWaitStrategy {
|
|
5
|
-
constructor();
|
|
6
5
|
abstract checkStartupState(dockerClient: Dockerode, containerId: string): Promise<StartupStatus>;
|
|
7
6
|
waitUntilReady(container: Dockerode.Container): Promise<void>;
|
|
8
7
|
}
|
|
@@ -5,9 +5,6 @@ const common_1 = require("../common");
|
|
|
5
5
|
const container_runtime_1 = require("../container-runtime");
|
|
6
6
|
const wait_strategy_1 = require("./wait-strategy");
|
|
7
7
|
class StartupCheckStrategy extends wait_strategy_1.AbstractWaitStrategy {
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
}
|
|
11
8
|
async waitUntilReady(container) {
|
|
12
9
|
const client = await (0, container_runtime_1.getContainerRuntimeClient)();
|
|
13
10
|
const startupStatus = await new common_1.IntervalRetry(1000).retryUntil(async () => await this.checkStartupState(client.container.dockerode, container.id), (startupStatus) => startupStatus === "SUCCESS" || startupStatus === "FAIL", () => {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { ContainerInspectInfo, HealthConfig, ImageInspectInfo } from "dockerode";
|
|
2
|
-
import { HealthCheck, HealthCheckStatus } from "../../types";
|
|
1
|
+
import type { ContainerInspectInfo, HealthConfig, ImageInspectInfo } from "dockerode";
|
|
2
|
+
import type { HealthCheck, HealthCheckStatus } from "../../types";
|
|
3
3
|
type HealthCheckConfig = HealthConfig | HealthCheck;
|
|
4
4
|
type HealthCheckInspectInfo = ContainerInspectInfo | ImageInspectInfo;
|
|
5
|
-
export declare const isHealthCheckDisabled: (healthCheck: HealthCheckConfig | undefined) => boolean;
|
|
6
5
|
export declare const hasHealthCheck: (healthCheck: HealthCheckConfig | undefined) => boolean;
|
|
7
|
-
export declare const getHealthCheckConfig: (inspectResult: HealthCheckInspectInfo) => HealthConfig | undefined;
|
|
8
6
|
export declare const hasHealthCheckConfig: (inspectResult: HealthCheckInspectInfo) => boolean;
|
|
9
7
|
export declare const hasDisabledHealthCheckConfig: (inspectResult: HealthCheckInspectInfo) => boolean;
|
|
10
8
|
export declare const getHealthCheckStatusFromInspect: (inspectResult: ContainerInspectInfo) => HealthCheckStatus | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasHealthCheckStatus = exports.getHealthCheckStatusFromInspect = exports.hasDisabledHealthCheckConfig = exports.hasHealthCheckConfig = exports.
|
|
3
|
+
exports.hasHealthCheckStatus = exports.getHealthCheckStatusFromInspect = exports.hasDisabledHealthCheckConfig = exports.hasHealthCheckConfig = exports.hasHealthCheck = void 0;
|
|
4
4
|
const DISABLED_HEALTH_CHECK_TEST = "NONE";
|
|
5
5
|
const getHealthCheckTest = (healthCheck) => {
|
|
6
6
|
if ("test" in healthCheck) {
|
|
@@ -21,7 +21,6 @@ const isHealthCheckDisabled = (healthCheck) => {
|
|
|
21
21
|
}
|
|
22
22
|
return isDisabledHealthCheck(test);
|
|
23
23
|
};
|
|
24
|
-
exports.isHealthCheckDisabled = isHealthCheckDisabled;
|
|
25
24
|
const hasHealthCheck = (healthCheck) => {
|
|
26
25
|
if (healthCheck === undefined) {
|
|
27
26
|
return false;
|
|
@@ -30,7 +29,7 @@ const hasHealthCheck = (healthCheck) => {
|
|
|
30
29
|
if (test === undefined || test.length === 0) {
|
|
31
30
|
return false;
|
|
32
31
|
}
|
|
33
|
-
return !
|
|
32
|
+
return !isHealthCheckDisabled(healthCheck);
|
|
34
33
|
};
|
|
35
34
|
exports.hasHealthCheck = hasHealthCheck;
|
|
36
35
|
const getHealthCheckConfig = (inspectResult) => {
|
|
@@ -42,13 +41,12 @@ const getHealthCheckConfig = (inspectResult) => {
|
|
|
42
41
|
inspectWithHealthCheckConfig.Healthcheck ??
|
|
43
42
|
inspectWithHealthCheckConfig.HealthCheck);
|
|
44
43
|
};
|
|
45
|
-
exports.getHealthCheckConfig = getHealthCheckConfig;
|
|
46
44
|
const hasHealthCheckConfig = (inspectResult) => {
|
|
47
|
-
return (0, exports.hasHealthCheck)(
|
|
45
|
+
return (0, exports.hasHealthCheck)(getHealthCheckConfig(inspectResult));
|
|
48
46
|
};
|
|
49
47
|
exports.hasHealthCheckConfig = hasHealthCheckConfig;
|
|
50
48
|
const hasDisabledHealthCheckConfig = (inspectResult) => {
|
|
51
|
-
return
|
|
49
|
+
return isHealthCheckDisabled(getHealthCheckConfig(inspectResult));
|
|
52
50
|
};
|
|
53
51
|
exports.hasDisabledHealthCheckConfig = hasDisabledHealthCheckConfig;
|
|
54
52
|
const getHealthCheckStatusFromInspect = (inspectResult) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
2
|
-
import { ContainerRuntimeClient } from "../../container-runtime";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
|
+
import type { ContainerRuntimeClient } from "../../container-runtime";
|
|
3
3
|
export interface PortCheck {
|
|
4
4
|
isBound(port: number | string): Promise<boolean>;
|
|
5
5
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InternalPortCheck = exports.HostPortCheck = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_net_1 = require("node:net");
|
|
5
5
|
const common_1 = require("../../common");
|
|
6
6
|
class HostPortCheck {
|
|
7
7
|
client;
|
|
@@ -14,7 +14,7 @@ class HostPortCheck {
|
|
|
14
14
|
return Promise.resolve(true);
|
|
15
15
|
}
|
|
16
16
|
return new Promise((resolve) => {
|
|
17
|
-
const socket = new
|
|
17
|
+
const socket = new node_net_1.Socket();
|
|
18
18
|
const portNumber = typeof port === "string" ? parseInt(port.split("/")[0], 10) : port;
|
|
19
19
|
socket
|
|
20
20
|
.setTimeout(1000)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatcher } from "undici";
|
|
1
|
+
import type { Dispatcher } from "undici";
|
|
2
2
|
/**
|
|
3
3
|
* Converts an undici response to a fetch response.
|
|
4
4
|
* This is necessary because node's fetch does not support disabling SSL validation (https://github.com/orgs/nodejs/discussions/44038).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.undiciResponseToFetchResponse = undiciResponseToFetchResponse;
|
|
4
|
-
const
|
|
4
|
+
const node_stream_1 = require("node:stream");
|
|
5
5
|
/**
|
|
6
6
|
* Converts an undici response to a fetch response.
|
|
7
7
|
* This is necessary because node's fetch does not support disabling SSL validation (https://github.com/orgs/nodejs/discussions/44038).
|
|
@@ -25,6 +25,6 @@ function undiciResponseToFetchResponse(undiciResponse) {
|
|
|
25
25
|
}
|
|
26
26
|
const status = undiciResponse.statusCode;
|
|
27
27
|
const hasNullBody = status === 204 || status === 205 || status === 304;
|
|
28
|
-
const responseBody = hasNullBody ? null :
|
|
28
|
+
const responseBody = hasNullBody ? null : node_stream_1.Readable.toWeb(undiciResponse.body);
|
|
29
29
|
return new Response(responseBody, { status, headers });
|
|
30
30
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ContainerInspectInfo } from "dockerode";
|
|
2
|
-
import { ContainerRuntimeClient } from "../../container-runtime";
|
|
3
|
-
import { HealthCheck } from "../../types";
|
|
4
|
-
import { WaitStrategy } from "../wait-strategy";
|
|
1
|
+
import type { ContainerInspectInfo } from "dockerode";
|
|
2
|
+
import { type ContainerRuntimeClient } from "../../container-runtime";
|
|
3
|
+
import type { HealthCheck } from "../../types";
|
|
4
|
+
import type { WaitStrategy } from "../wait-strategy";
|
|
5
5
|
type WaitStrategySelectorOptions = {
|
|
6
6
|
client: ContainerRuntimeClient;
|
|
7
7
|
inspectResult: ContainerInspectInfo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Container } from "dockerode";
|
|
2
|
-
import { ContainerRuntimeClient } from "../container-runtime";
|
|
3
|
-
import { BoundPorts } from "../utils/bound-ports";
|
|
4
|
-
import { WaitStrategy } from "./wait-strategy";
|
|
1
|
+
import type { Container } from "dockerode";
|
|
2
|
+
import type { ContainerRuntimeClient } from "../container-runtime";
|
|
3
|
+
import type { BoundPorts } from "../utils/bound-ports";
|
|
4
|
+
import type { WaitStrategy } from "./wait-strategy";
|
|
5
5
|
export declare const waitForContainer: (client: ContainerRuntimeClient, container: Container, waitStrategy: WaitStrategy, boundPorts: BoundPorts, startTime?: Date) => Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Dockerode from "dockerode";
|
|
2
|
-
import { BoundPorts } from "../utils/bound-ports";
|
|
1
|
+
import type Dockerode from "dockerode";
|
|
2
|
+
import type { BoundPorts } from "../utils/bound-ports";
|
|
3
3
|
export interface WaitStrategy {
|
|
4
4
|
waitUntilReady(container: Dockerode.Container, boundPorts: BoundPorts, startTime?: Date): Promise<void>;
|
|
5
5
|
withStartupTimeout(startupTimeoutMs: number): WaitStrategy;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CompositeWaitStrategy } from "./composite-wait-strategy";
|
|
2
|
-
import { HttpWaitStrategy, HttpWaitStrategyOptions } from "./http-wait-strategy";
|
|
3
|
-
import { Log } from "./log-wait-strategy";
|
|
2
|
+
import { HttpWaitStrategy, type HttpWaitStrategyOptions } from "./http-wait-strategy";
|
|
3
|
+
import { type Log } from "./log-wait-strategy";
|
|
4
4
|
import { ShellWaitStrategy } from "./shell-wait-strategy";
|
|
5
|
-
import { WaitStrategy } from "./wait-strategy";
|
|
5
|
+
import type { WaitStrategy } from "./wait-strategy";
|
|
6
6
|
export declare class Wait {
|
|
7
7
|
static forAll(waitStrategies: WaitStrategy[]): CompositeWaitStrategy;
|
|
8
8
|
static forListeningPorts(): WaitStrategy;
|
|
@@ -8,6 +8,7 @@ const http_wait_strategy_1 = require("./http-wait-strategy");
|
|
|
8
8
|
const log_wait_strategy_1 = require("./log-wait-strategy");
|
|
9
9
|
const one_shot_startup_startegy_1 = require("./one-shot-startup-startegy");
|
|
10
10
|
const shell_wait_strategy_1 = require("./shell-wait-strategy");
|
|
11
|
+
// biome-ignore lint/complexity/noStaticOnlyClass: public API surface, kept as a class for backwards compatibility
|
|
11
12
|
class Wait {
|
|
12
13
|
static forAll(waitStrategies) {
|
|
13
14
|
return new composite_wait_strategy_1.CompositeWaitStrategy(waitStrategies);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testcontainers",
|
|
3
|
-
"version": "12.1
|
|
3
|
+
"version": "12.2.1",
|
|
4
4
|
"author": "Cristian Greco",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"async-lock": "^1.4.1",
|
|
37
37
|
"byline": "^5.0.0",
|
|
38
38
|
"debug": "^4.4.3",
|
|
39
|
-
"docker-compose": "^1.
|
|
39
|
+
"docker-compose": "^1.5.0",
|
|
40
40
|
"dockerode": "^5.0.1",
|
|
41
41
|
"get-port": "^5.1.1",
|
|
42
42
|
"proper-lockfile": "^4.1.2",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"ssh-remote-port-forward": "^1.0.4",
|
|
45
45
|
"tar-fs": "^3.1.3",
|
|
46
46
|
"tmp": "^0.2.7",
|
|
47
|
-
"undici": "^8.
|
|
47
|
+
"undici": "^8.11.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/archiver": "^7.0.0",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"@types/byline": "^4.2.36",
|
|
53
53
|
"@types/debug": "^4.1.13",
|
|
54
54
|
"@types/proper-lockfile": "^4.1.4",
|
|
55
|
-
"@types/properties-reader": "^2.1.3",
|
|
56
55
|
"@types/tar-fs": "^2.0.4",
|
|
57
56
|
"@types/tmp": "^0.2.6"
|
|
58
57
|
},
|
package/build/common/streams.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.streamToString = void 0;
|
|
4
|
-
const streamToString = async (stream, options = { trim: false }) => {
|
|
5
|
-
const chunks = [];
|
|
6
|
-
for await (const chunk of stream) {
|
|
7
|
-
chunks.push(Buffer.from(chunk));
|
|
8
|
-
}
|
|
9
|
-
const str = Buffer.concat(chunks).toString("utf-8");
|
|
10
|
-
return options.trim ? str.trim() : str;
|
|
11
|
-
};
|
|
12
|
-
exports.streamToString = streamToString;
|