testcontainers 8.14.0 → 8.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docker/functions/container/exec-container.d.ts +7 -1
- package/dist/docker/functions/container/exec-container.js +3 -11
- package/dist/generic-container/started-generic-container.d.ts +2 -2
- package/dist/generic-container/started-generic-container.js +3 -2
- package/dist/port-check.js +1 -1
- package/dist/test-container.d.ts +6 -1
- package/package.json +1 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { Command, ExecResult } from "../../types";
|
|
2
2
|
import Dockerode from "dockerode";
|
|
3
|
-
|
|
3
|
+
declare type ExecContainerOptions = {
|
|
4
|
+
tty: boolean;
|
|
5
|
+
stdin: boolean;
|
|
6
|
+
detach: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const execContainer: (container: Dockerode.Container, command: Command[], options: ExecContainerOptions) => Promise<ExecResult>;
|
|
9
|
+
export {};
|
|
@@ -11,14 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.execContainer = void 0;
|
|
13
13
|
const logger_1 = require("../../../logger");
|
|
14
|
-
const execContainer = (container, command) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const execContainer = (container, command, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
try {
|
|
16
16
|
const exec = yield container.exec({
|
|
17
17
|
Cmd: command,
|
|
18
18
|
AttachStdout: true,
|
|
19
19
|
AttachStderr: true,
|
|
20
20
|
});
|
|
21
|
-
const stream = yield startExec(exec);
|
|
21
|
+
const stream = yield startExec(exec, options);
|
|
22
22
|
const chunks = [];
|
|
23
23
|
stream.on("data", (chunk) => chunks.push(chunk));
|
|
24
24
|
const exitCode = yield waitForExec(exec);
|
|
@@ -31,16 +31,8 @@ const execContainer = (container, command) => __awaiter(void 0, void 0, void 0,
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
exports.execContainer = execContainer;
|
|
34
|
-
const startExec = (exec) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const startExec = (exec, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
35
|
try {
|
|
36
|
-
const options = {
|
|
37
|
-
Detach: false,
|
|
38
|
-
Tty: true,
|
|
39
|
-
stream: true,
|
|
40
|
-
stdin: true,
|
|
41
|
-
stdout: true,
|
|
42
|
-
stderr: true,
|
|
43
|
-
};
|
|
44
36
|
const stream = yield exec.start(options);
|
|
45
37
|
stream.setEncoding("utf-8");
|
|
46
38
|
return stream;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { RestartOptions, StartedTestContainer, StopOptions, StoppedTestContainer } from "../test-container";
|
|
2
|
+
import { RestartOptions, StartedTestContainer, StopOptions, ExecOptions, StoppedTestContainer } from "../test-container";
|
|
3
3
|
import Dockerode from "dockerode";
|
|
4
4
|
import { Command, ContainerName, ExecResult, Host, Id as ContainerId, Labels } from "../docker/types";
|
|
5
5
|
import { InspectResult } from "../docker/functions/container/inspect-container";
|
|
@@ -27,6 +27,6 @@ export declare class StartedGenericContainer implements StartedTestContainer {
|
|
|
27
27
|
getNetworkNames(): string[];
|
|
28
28
|
getNetworkId(networkName: string): string;
|
|
29
29
|
getIpAddress(networkName: string): string;
|
|
30
|
-
exec(command: Command[]): Promise<ExecResult>;
|
|
30
|
+
exec(command: Command[], options?: Partial<ExecOptions>): Promise<ExecResult>;
|
|
31
31
|
logs(): Promise<Readable>;
|
|
32
32
|
}
|
|
@@ -96,8 +96,9 @@ class StartedGenericContainer {
|
|
|
96
96
|
getIpAddress(networkName) {
|
|
97
97
|
return this.inspectResult.networkSettings[networkName].ipAddress;
|
|
98
98
|
}
|
|
99
|
-
exec(command) {
|
|
100
|
-
|
|
99
|
+
exec(command, options = {}) {
|
|
100
|
+
const resolvedOptions = Object.assign({ stdin: true, detach: false, tty: true }, options);
|
|
101
|
+
return (0, exec_container_1.execContainer)(this.container, command, resolvedOptions);
|
|
101
102
|
}
|
|
102
103
|
logs() {
|
|
103
104
|
return (0, container_logs_1.containerLogs)(this.container);
|
package/dist/port-check.js
CHANGED
|
@@ -52,7 +52,7 @@ class InternalPortCheck {
|
|
|
52
52
|
["/bin/sh", "-c", `nc -vz -w 1 localhost ${port}`],
|
|
53
53
|
["/bin/bash", "-c", `</dev/tcp/localhost/${port}`],
|
|
54
54
|
];
|
|
55
|
-
const commandResults = yield Promise.all(commands.map((command) => (0, exec_container_1.execContainer)(this.container, command)));
|
|
55
|
+
const commandResults = yield Promise.all(commands.map((command) => (0, exec_container_1.execContainer)(this.container, command, { stdin: true, detach: false, tty: true })));
|
|
56
56
|
const isBound = commandResults.some((result) => result.exitCode === 0);
|
|
57
57
|
if (!isBound) {
|
|
58
58
|
const shellExists = commandResults.some((result) => result.exitCode !== 126);
|
package/dist/test-container.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export interface StopOptions {
|
|
|
30
30
|
timeout: number;
|
|
31
31
|
removeVolumes: boolean;
|
|
32
32
|
}
|
|
33
|
+
export interface ExecOptions {
|
|
34
|
+
tty: boolean;
|
|
35
|
+
detach: boolean;
|
|
36
|
+
stdin: boolean;
|
|
37
|
+
}
|
|
33
38
|
export interface StartedTestContainer {
|
|
34
39
|
stop(options?: Partial<StopOptions>): Promise<StoppedTestContainer>;
|
|
35
40
|
restart(options?: Partial<RestartOptions>): Promise<void>;
|
|
@@ -41,7 +46,7 @@ export interface StartedTestContainer {
|
|
|
41
46
|
getNetworkNames(): string[];
|
|
42
47
|
getNetworkId(networkName: string): string;
|
|
43
48
|
getIpAddress(networkName: string): string;
|
|
44
|
-
exec(command: Command[]): Promise<ExecResult>;
|
|
49
|
+
exec(command: Command[], options?: Partial<ExecOptions>): Promise<ExecResult>;
|
|
45
50
|
logs(): Promise<Readable>;
|
|
46
51
|
}
|
|
47
52
|
export interface StoppedTestContainer {
|