testcontainers 8.16.0 → 9.0.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/README.md +115 -78
- package/dist/bound-ports.d.ts +4 -4
- package/dist/docker/docker-client.d.ts +1 -2
- package/dist/docker/functions/container/container-logs.js +1 -6
- package/dist/docker/functions/container/create-container.d.ts +5 -5
- package/dist/docker/functions/container/create-container.js +5 -6
- package/dist/docker/functions/container/exec-container.d.ts +2 -2
- package/dist/docker/functions/container/get-container.d.ts +1 -2
- package/dist/docker/functions/container/inspect-container.d.ts +2 -2
- package/dist/docker/functions/create-labels.d.ts +1 -1
- package/dist/docker/functions/image/build-image.d.ts +2 -2
- package/dist/docker/functions/run-in-container.d.ts +1 -2
- package/dist/docker/types.d.ts +23 -22
- package/dist/docker-compose/default-docker-compose-options.d.ts +1 -1
- package/dist/docker-compose/default-docker-compose-options.js +2 -2
- package/dist/docker-compose/docker-compose-options.d.ts +2 -2
- package/dist/docker-compose/functions/docker-compose-up.d.ts +1 -1
- package/dist/docker-compose-environment/docker-compose-environment.d.ts +5 -5
- package/dist/docker-compose-environment/docker-compose-environment.js +11 -11
- package/dist/generic-container/generic-container-builder.d.ts +3 -3
- package/dist/generic-container/generic-container-builder.js +2 -2
- package/dist/generic-container/generic-container.d.ts +16 -17
- package/dist/generic-container/generic-container.js +31 -27
- package/dist/generic-container/started-generic-container.d.ts +7 -8
- package/dist/modules/abstract-started-container.d.ts +6 -7
- package/dist/modules/arangodb/arangodb-container.js +2 -2
- package/dist/modules/elasticsearch/elasticsearch-container.js +2 -2
- package/dist/modules/kafka/kafka-container.d.ts +4 -5
- package/dist/modules/kafka/kafka-container.js +41 -34
- package/dist/modules/mongodb/mongodb-container.js +1 -1
- package/dist/modules/mysql/mysql-container.d.ts +1 -2
- package/dist/modules/mysql/mysql-container.js +7 -5
- package/dist/modules/nats/nats-container.d.ts +1 -1
- package/dist/modules/nats/nats-container.js +2 -2
- package/dist/modules/neo4j/neo4j-container.js +10 -4
- package/dist/modules/postgresql/postgresql-container.d.ts +1 -2
- package/dist/modules/postgresql/postgresql-container.js +5 -3
- package/dist/port-binder.d.ts +1 -2
- package/dist/port-check.d.ts +4 -6
- package/dist/port-forwarder.d.ts +1 -2
- package/dist/port-forwarder.js +2 -2
- package/dist/port-generator.d.ts +4 -5
- package/dist/port.d.ts +3 -5
- package/dist/reaper.js +1 -1
- package/dist/test-container.d.ts +16 -14
- package/dist/test-containers.d.ts +1 -2
- package/package.json +29 -25
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WaitStrategy } from "../wait-strategy";
|
|
2
2
|
import { Uuid } from "../uuid";
|
|
3
|
-
import {
|
|
3
|
+
import { Environment } from "../docker/types";
|
|
4
4
|
import { StartedDockerComposeEnvironment } from "./started-docker-compose-environment";
|
|
5
5
|
export declare class DockerComposeEnvironment {
|
|
6
6
|
private readonly composeFilePath;
|
|
@@ -8,15 +8,15 @@ export declare class DockerComposeEnvironment {
|
|
|
8
8
|
private projectName;
|
|
9
9
|
private build;
|
|
10
10
|
private recreate;
|
|
11
|
-
private
|
|
11
|
+
private environmentFile;
|
|
12
12
|
private profiles;
|
|
13
|
-
private
|
|
13
|
+
private environment;
|
|
14
14
|
private waitStrategy;
|
|
15
15
|
private startupTimeout;
|
|
16
16
|
constructor(composeFilePath: string, composeFiles: string | string[], uuid?: Uuid);
|
|
17
17
|
withBuild(): this;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
withEnvironment(environment: Environment): this;
|
|
19
|
+
withEnvironmentFile(environmentFile: string): this;
|
|
20
20
|
withProfiles(...profiles: string[]): this;
|
|
21
21
|
withNoRecreate(): this;
|
|
22
22
|
withWaitStrategy(containerName: string, waitStrategy: WaitStrategy): this;
|
|
@@ -30,9 +30,9 @@ class DockerComposeEnvironment {
|
|
|
30
30
|
constructor(composeFilePath, composeFiles, uuid = new uuid_1.RandomUuid()) {
|
|
31
31
|
this.build = false;
|
|
32
32
|
this.recreate = true;
|
|
33
|
-
this.
|
|
33
|
+
this.environmentFile = "";
|
|
34
34
|
this.profiles = [];
|
|
35
|
-
this.
|
|
35
|
+
this.environment = {};
|
|
36
36
|
this.waitStrategy = {};
|
|
37
37
|
this.startupTimeout = 60000;
|
|
38
38
|
this.composeFilePath = composeFilePath;
|
|
@@ -43,16 +43,16 @@ class DockerComposeEnvironment {
|
|
|
43
43
|
this.build = true;
|
|
44
44
|
return this;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
this.
|
|
46
|
+
withEnvironment(environment) {
|
|
47
|
+
this.environment = Object.assign(Object.assign({}, this.environment), environment);
|
|
48
48
|
return this;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
this.
|
|
50
|
+
withEnvironmentFile(environmentFile) {
|
|
51
|
+
this.environmentFile = environmentFile;
|
|
52
52
|
return this;
|
|
53
53
|
}
|
|
54
54
|
withProfiles(...profiles) {
|
|
55
|
-
this.profiles = profiles;
|
|
55
|
+
this.profiles = [...this.profiles, ...profiles];
|
|
56
56
|
return this;
|
|
57
57
|
}
|
|
58
58
|
withNoRecreate() {
|
|
@@ -85,11 +85,11 @@ class DockerComposeEnvironment {
|
|
|
85
85
|
commandOptions.push("--no-recreate");
|
|
86
86
|
}
|
|
87
87
|
const composeOptions = [];
|
|
88
|
-
if (this.
|
|
89
|
-
composeOptions.push("--env-file", this.
|
|
88
|
+
if (this.environmentFile) {
|
|
89
|
+
composeOptions.push("--env-file", this.environmentFile);
|
|
90
90
|
}
|
|
91
91
|
this.profiles.forEach((profile) => composeOptions.push("--profile", profile));
|
|
92
|
-
yield (0, docker_compose_up_1.dockerComposeUp)(Object.assign(Object.assign({}, options), { commandOptions, composeOptions,
|
|
92
|
+
yield (0, docker_compose_up_1.dockerComposeUp)(Object.assign(Object.assign({}, options), { commandOptions, composeOptions, environment: this.environment }), services);
|
|
93
93
|
const startedContainers = (yield (0, list_containers_1.listContainers)()).filter((container) => container.Labels["com.docker.compose.project"] === this.projectName);
|
|
94
94
|
const startedContainerNames = startedContainers.reduce((containerNames, startedContainer) => [
|
|
95
95
|
...containerNames,
|
|
@@ -125,7 +125,7 @@ class DockerComposeEnvironment {
|
|
|
125
125
|
return Object.assign(Object.assign({}, map), { [containerName]: startedGenericContainer });
|
|
126
126
|
}, {});
|
|
127
127
|
logger_1.log.info(`DockerCompose environment started: ${Object.keys(startedGenericContainers).join(", ")}`);
|
|
128
|
-
return new started_docker_compose_environment_1.StartedDockerComposeEnvironment(startedGenericContainers, Object.assign(Object.assign({}, options), { composeOptions,
|
|
128
|
+
return new started_docker_compose_environment_1.StartedDockerComposeEnvironment(startedGenericContainers, Object.assign(Object.assign({}, options), { composeOptions, environment: this.environment }));
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
waitForContainer(container, containerName, boundPorts) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuildArgs } from "../docker/types";
|
|
2
2
|
import { PullPolicy } from "../pull-policy";
|
|
3
3
|
import { Uuid } from "../uuid";
|
|
4
4
|
import { GenericContainer } from "./generic-container";
|
|
@@ -9,8 +9,8 @@ export declare class GenericContainerBuilder {
|
|
|
9
9
|
private buildArgs;
|
|
10
10
|
private pullPolicy;
|
|
11
11
|
private cache;
|
|
12
|
-
constructor(context:
|
|
13
|
-
|
|
12
|
+
constructor(context: string, dockerfileName: string, uuid?: Uuid);
|
|
13
|
+
withBuildArgs(buildArgs: BuildArgs): GenericContainerBuilder;
|
|
14
14
|
withPullPolicy(pullPolicy: PullPolicy): this;
|
|
15
15
|
withCache(cache: boolean): this;
|
|
16
16
|
build(image?: string): Promise<GenericContainer>;
|
|
@@ -34,8 +34,8 @@ class GenericContainerBuilder {
|
|
|
34
34
|
this.pullPolicy = new pull_policy_1.DefaultPullPolicy();
|
|
35
35
|
this.cache = true;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
this.buildArgs
|
|
37
|
+
withBuildArgs(buildArgs) {
|
|
38
|
+
this.buildArgs = buildArgs;
|
|
39
39
|
return this;
|
|
40
40
|
}
|
|
41
41
|
withPullPolicy(pullPolicy) {
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import archiver from "archiver";
|
|
3
2
|
import { BoundPorts } from "../bound-ports";
|
|
4
3
|
import { PortWithOptionalBinding } from "../port";
|
|
5
4
|
import { PullPolicy } from "../pull-policy";
|
|
6
5
|
import { StartedTestContainer, TestContainer } from "../test-container";
|
|
7
6
|
import { WaitStrategy } from "../wait-strategy";
|
|
8
|
-
import {
|
|
9
|
-
import { BindMode, BindMount, BuildContext, Command, ContainerName, Dir, Env, EnvKey, EnvValue, ExtraHost, HealthCheck, NetworkMode, TmpFs, Labels, Ulimits } from "../docker/types";
|
|
7
|
+
import { BindMount, ContentToCopy, Environment, ExtraHost, FileToCopy, HealthCheck, Labels, TmpFs, Ulimits } from "../docker/types";
|
|
10
8
|
import { InspectResult } from "../docker/functions/container/inspect-container";
|
|
11
9
|
import { GenericContainerBuilder } from "./generic-container-builder";
|
|
10
|
+
import { StartedNetwork } from "../network";
|
|
12
11
|
export declare class GenericContainer implements TestContainer {
|
|
13
12
|
readonly image: string;
|
|
14
|
-
static fromDockerfile(context:
|
|
13
|
+
static fromDockerfile(context: string, dockerfileName?: string): GenericContainerBuilder;
|
|
15
14
|
private readonly imageName;
|
|
16
|
-
protected
|
|
17
|
-
protected networkMode?:
|
|
15
|
+
protected environment: Environment;
|
|
16
|
+
protected networkMode?: string;
|
|
18
17
|
protected networkAliases: string[];
|
|
19
18
|
protected ports: PortWithOptionalBinding[];
|
|
20
|
-
protected
|
|
19
|
+
protected command: string[];
|
|
21
20
|
protected entrypoint?: string[];
|
|
22
21
|
protected bindMounts: BindMount[];
|
|
23
|
-
protected name?:
|
|
22
|
+
protected name?: string;
|
|
24
23
|
protected labels: Labels;
|
|
25
24
|
protected tmpFs: TmpFs;
|
|
26
25
|
protected healthCheck?: HealthCheck;
|
|
@@ -44,21 +43,21 @@ export declare class GenericContainer implements TestContainer {
|
|
|
44
43
|
private startContainer;
|
|
45
44
|
protected postStart?(container: StartedTestContainer, inspectResult: InspectResult, boundPorts: BoundPorts): Promise<void>;
|
|
46
45
|
protected get hasExposedPorts(): boolean;
|
|
47
|
-
|
|
46
|
+
withCommand(command: string[]): this;
|
|
48
47
|
withEntrypoint(entrypoint: string[]): this;
|
|
49
|
-
withName(name:
|
|
48
|
+
withName(name: string): this;
|
|
50
49
|
withLabels(labels: Labels): this;
|
|
51
|
-
|
|
50
|
+
withEnvironment(environment: Environment): this;
|
|
52
51
|
withTmpFs(tmpFs: TmpFs): this;
|
|
53
52
|
withUlimits(ulimits: Ulimits): this;
|
|
54
53
|
withAddedCapabilities(...capabilities: string[]): this;
|
|
55
54
|
withDroppedCapabilities(...capabilities: string[]): this;
|
|
56
|
-
|
|
55
|
+
withNetwork(network: StartedNetwork): this;
|
|
56
|
+
withNetworkMode(networkMode: string): this;
|
|
57
57
|
withNetworkAliases(...networkAliases: string[]): this;
|
|
58
|
-
withExtraHosts(
|
|
58
|
+
withExtraHosts(extraHosts: ExtraHost[]): this;
|
|
59
59
|
withExposedPorts(...ports: PortWithOptionalBinding[]): this;
|
|
60
|
-
|
|
61
|
-
withBindMount(source: Dir, target: Dir, bindMode?: BindMode): this;
|
|
60
|
+
withBindMounts(bindMounts: BindMount[]): this;
|
|
62
61
|
withHealthCheck(healthCheck: HealthCheck): this;
|
|
63
62
|
withStartupTimeout(startupTimeout: number): this;
|
|
64
63
|
withWaitStrategy(waitStrategy: WaitStrategy): this;
|
|
@@ -68,8 +67,8 @@ export declare class GenericContainer implements TestContainer {
|
|
|
68
67
|
withReuse(): this;
|
|
69
68
|
withPullPolicy(pullPolicy: PullPolicy): this;
|
|
70
69
|
withIpcMode(ipcMode: string): this;
|
|
71
|
-
|
|
72
|
-
withCopyContentToContainer(
|
|
70
|
+
withCopyFilesToContainer(filesToCopy: FileToCopy[]): this;
|
|
71
|
+
withCopyContentToContainer(contentsToCopy: ContentToCopy[]): this;
|
|
73
72
|
protected getTarToCopy(): archiver.Archiver;
|
|
74
73
|
private waitForContainer;
|
|
75
74
|
private getWaitStrategy;
|
|
@@ -41,10 +41,10 @@ const labels_1 = require("../labels");
|
|
|
41
41
|
class GenericContainer {
|
|
42
42
|
constructor(image) {
|
|
43
43
|
this.image = image;
|
|
44
|
-
this.
|
|
44
|
+
this.environment = {};
|
|
45
45
|
this.networkAliases = [];
|
|
46
46
|
this.ports = [];
|
|
47
|
-
this.
|
|
47
|
+
this.command = [];
|
|
48
48
|
this.bindMounts = [];
|
|
49
49
|
this.labels = {};
|
|
50
50
|
this.tmpFs = {};
|
|
@@ -78,8 +78,8 @@ class GenericContainer {
|
|
|
78
78
|
}
|
|
79
79
|
const createContainerOptions = {
|
|
80
80
|
imageName: this.imageName,
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
environment: this.environment,
|
|
82
|
+
command: this.command,
|
|
83
83
|
entrypoint: this.entrypoint,
|
|
84
84
|
bindMounts: this.bindMounts,
|
|
85
85
|
tmpFs: this.tmpFs,
|
|
@@ -170,8 +170,8 @@ class GenericContainer {
|
|
|
170
170
|
get hasExposedPorts() {
|
|
171
171
|
return this.ports.length !== 0;
|
|
172
172
|
}
|
|
173
|
-
|
|
174
|
-
this.
|
|
173
|
+
withCommand(command) {
|
|
174
|
+
this.command = command;
|
|
175
175
|
return this;
|
|
176
176
|
}
|
|
177
177
|
withEntrypoint(entrypoint) {
|
|
@@ -183,27 +183,33 @@ class GenericContainer {
|
|
|
183
183
|
return this;
|
|
184
184
|
}
|
|
185
185
|
withLabels(labels) {
|
|
186
|
-
this.labels = Object.assign({}, labels);
|
|
186
|
+
this.labels = Object.assign(Object.assign({}, this.labels), labels);
|
|
187
187
|
return this;
|
|
188
188
|
}
|
|
189
|
-
|
|
190
|
-
this.
|
|
189
|
+
withEnvironment(environment) {
|
|
190
|
+
this.environment = Object.assign(Object.assign({}, this.environment), environment);
|
|
191
191
|
return this;
|
|
192
192
|
}
|
|
193
193
|
withTmpFs(tmpFs) {
|
|
194
|
-
this.tmpFs = tmpFs;
|
|
194
|
+
this.tmpFs = Object.assign(Object.assign({}, this.tmpFs), tmpFs);
|
|
195
195
|
return this;
|
|
196
196
|
}
|
|
197
197
|
withUlimits(ulimits) {
|
|
198
|
-
this.ulimits = ulimits;
|
|
198
|
+
this.ulimits = Object.assign(Object.assign({}, this.ulimits), ulimits);
|
|
199
199
|
return this;
|
|
200
200
|
}
|
|
201
201
|
withAddedCapabilities(...capabilities) {
|
|
202
|
-
|
|
202
|
+
var _a;
|
|
203
|
+
this.addedCapabilities = [...((_a = this.addedCapabilities) !== null && _a !== void 0 ? _a : []), ...capabilities];
|
|
203
204
|
return this;
|
|
204
205
|
}
|
|
205
206
|
withDroppedCapabilities(...capabilities) {
|
|
206
|
-
|
|
207
|
+
var _a;
|
|
208
|
+
this.droppedCapabilities = [...((_a = this.droppedCapabilities) !== null && _a !== void 0 ? _a : []), ...capabilities];
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
withNetwork(network) {
|
|
212
|
+
this.networkMode = network.getName();
|
|
207
213
|
return this;
|
|
208
214
|
}
|
|
209
215
|
withNetworkMode(networkMode) {
|
|
@@ -211,23 +217,19 @@ class GenericContainer {
|
|
|
211
217
|
return this;
|
|
212
218
|
}
|
|
213
219
|
withNetworkAliases(...networkAliases) {
|
|
214
|
-
this.networkAliases = networkAliases;
|
|
220
|
+
this.networkAliases = [...this.networkAliases, ...networkAliases];
|
|
215
221
|
return this;
|
|
216
222
|
}
|
|
217
|
-
withExtraHosts(
|
|
218
|
-
this.extraHosts.
|
|
223
|
+
withExtraHosts(extraHosts) {
|
|
224
|
+
this.extraHosts = [...this.extraHosts, ...extraHosts];
|
|
219
225
|
return this;
|
|
220
226
|
}
|
|
221
227
|
withExposedPorts(...ports) {
|
|
222
|
-
this.ports = ports;
|
|
223
|
-
return this;
|
|
224
|
-
}
|
|
225
|
-
addExposedPorts(...ports) {
|
|
226
|
-
this.ports.push(...ports);
|
|
228
|
+
this.ports = [...this.ports, ...ports];
|
|
227
229
|
return this;
|
|
228
230
|
}
|
|
229
|
-
|
|
230
|
-
this.bindMounts.
|
|
231
|
+
withBindMounts(bindMounts) {
|
|
232
|
+
this.bindMounts = bindMounts.map((bindMount) => (Object.assign({ mode: "rw" }, bindMount)));
|
|
231
233
|
return this;
|
|
232
234
|
}
|
|
233
235
|
withHealthCheck(healthCheck) {
|
|
@@ -266,12 +268,14 @@ class GenericContainer {
|
|
|
266
268
|
this.ipcMode = ipcMode;
|
|
267
269
|
return this;
|
|
268
270
|
}
|
|
269
|
-
|
|
270
|
-
this.getTarToCopy()
|
|
271
|
+
withCopyFilesToContainer(filesToCopy) {
|
|
272
|
+
const tar = this.getTarToCopy();
|
|
273
|
+
filesToCopy.forEach(({ source, target }) => tar.file(source, { name: target }));
|
|
271
274
|
return this;
|
|
272
275
|
}
|
|
273
|
-
withCopyContentToContainer(
|
|
274
|
-
this.getTarToCopy()
|
|
276
|
+
withCopyContentToContainer(contentsToCopy) {
|
|
277
|
+
const tar = this.getTarToCopy();
|
|
278
|
+
contentsToCopy.forEach(({ content, target }) => tar.append(content, { name: target }));
|
|
275
279
|
return this;
|
|
276
280
|
}
|
|
277
281
|
getTarToCopy() {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { RestartOptions, StartedTestContainer, StopOptions, ExecOptions, StoppedTestContainer } from "../test-container";
|
|
3
3
|
import Dockerode from "dockerode";
|
|
4
|
-
import {
|
|
4
|
+
import { ExecResult, Labels } from "../docker/types";
|
|
5
5
|
import { InspectResult } from "../docker/functions/container/inspect-container";
|
|
6
6
|
import { BoundPorts } from "../bound-ports";
|
|
7
|
-
import { Port } from "../port";
|
|
8
7
|
import { Readable } from "stream";
|
|
9
8
|
import { WaitStrategy } from "../wait-strategy";
|
|
10
9
|
export declare class StartedGenericContainer implements StartedTestContainer {
|
|
@@ -14,19 +13,19 @@ export declare class StartedGenericContainer implements StartedTestContainer {
|
|
|
14
13
|
private boundPorts;
|
|
15
14
|
private readonly name;
|
|
16
15
|
private readonly waitStrategy;
|
|
17
|
-
constructor(container: Dockerode.Container, host:
|
|
16
|
+
constructor(container: Dockerode.Container, host: string, inspectResult: InspectResult, boundPorts: BoundPorts, name: string, waitStrategy: WaitStrategy);
|
|
18
17
|
stop(options?: Partial<StopOptions>): Promise<StoppedTestContainer>;
|
|
19
18
|
restart(options?: Partial<RestartOptions>): Promise<void>;
|
|
20
19
|
private stopContainer;
|
|
21
20
|
private waitForContainer;
|
|
22
|
-
getHost():
|
|
23
|
-
getMappedPort(port:
|
|
24
|
-
getId():
|
|
25
|
-
getName():
|
|
21
|
+
getHost(): string;
|
|
22
|
+
getMappedPort(port: number): number;
|
|
23
|
+
getId(): string;
|
|
24
|
+
getName(): string;
|
|
26
25
|
getLabels(): Labels;
|
|
27
26
|
getNetworkNames(): string[];
|
|
28
27
|
getNetworkId(networkName: string): string;
|
|
29
28
|
getIpAddress(networkName: string): string;
|
|
30
|
-
exec(command:
|
|
29
|
+
exec(command: string[], options?: Partial<ExecOptions>): Promise<ExecResult>;
|
|
31
30
|
logs(): Promise<Readable>;
|
|
32
31
|
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { RestartOptions, StartedTestContainer, StopOptions, StoppedTestContainer } from "../test-container";
|
|
3
|
-
import {
|
|
4
|
-
import { ContainerName, Host, Id, Command, ExecResult, Labels } from "../docker/types";
|
|
3
|
+
import { ExecResult, Labels } from "../docker/types";
|
|
5
4
|
import { Readable } from "stream";
|
|
6
5
|
export declare class AbstractStartedContainer {
|
|
7
6
|
protected readonly startedTestContainer: StartedTestContainer;
|
|
8
7
|
constructor(startedTestContainer: StartedTestContainer);
|
|
9
8
|
stop(options?: Partial<StopOptions>): Promise<StoppedTestContainer>;
|
|
10
9
|
restart(options?: Partial<RestartOptions>): Promise<void>;
|
|
11
|
-
getHost():
|
|
12
|
-
getMappedPort(port:
|
|
13
|
-
getName():
|
|
10
|
+
getHost(): string;
|
|
11
|
+
getMappedPort(port: number): number;
|
|
12
|
+
getName(): string;
|
|
14
13
|
getLabels(): Labels;
|
|
15
|
-
getId():
|
|
14
|
+
getId(): string;
|
|
16
15
|
getNetworkNames(): string[];
|
|
17
16
|
getNetworkId(networkName: string): string;
|
|
18
17
|
getIpAddress(networkName: string): string;
|
|
19
|
-
exec(command:
|
|
18
|
+
exec(command: string[]): Promise<ExecResult>;
|
|
20
19
|
logs(): Promise<Readable>;
|
|
21
20
|
}
|
|
@@ -16,7 +16,7 @@ const abstract_started_container_1 = require("../abstract-started-container");
|
|
|
16
16
|
const ARANGODB_PORT = 8529;
|
|
17
17
|
const USERNAME = "root";
|
|
18
18
|
class ArangoDBContainer extends __1.GenericContainer {
|
|
19
|
-
constructor(image = "arangodb:3.
|
|
19
|
+
constructor(image = "arangodb:3.10.0", password = new uuid_1.RandomUuid().nextUuid()) {
|
|
20
20
|
super(image);
|
|
21
21
|
this.password = password;
|
|
22
22
|
}
|
|
@@ -31,7 +31,7 @@ class ArangoDBContainer extends __1.GenericContainer {
|
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [ARANGODB_PORT]))
|
|
33
33
|
.withWaitStrategy(__1.Wait.forLogMessage("Have fun!"))
|
|
34
|
-
.
|
|
34
|
+
.withEnvironment({ ARANGO_ROOT_PASSWORD: this.password })
|
|
35
35
|
.withStartupTimeout(120000);
|
|
36
36
|
return new StartedArangoContainer(yield _super.start.call(this), this.password);
|
|
37
37
|
});
|
|
@@ -14,7 +14,7 @@ const __1 = require("../..");
|
|
|
14
14
|
const abstract_started_container_1 = require("../abstract-started-container");
|
|
15
15
|
const ELASTIC_SEARCH_HTTP_PORT = 9200;
|
|
16
16
|
class ElasticsearchContainer extends __1.GenericContainer {
|
|
17
|
-
constructor(image = "
|
|
17
|
+
constructor(image = "elasticsearch:7.17.7") {
|
|
18
18
|
super(image);
|
|
19
19
|
}
|
|
20
20
|
start() {
|
|
@@ -23,7 +23,7 @@ class ElasticsearchContainer extends __1.GenericContainer {
|
|
|
23
23
|
});
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [ELASTIC_SEARCH_HTTP_PORT]))
|
|
26
|
-
.
|
|
26
|
+
.withEnvironment({ "discovery.type": "single-node" })
|
|
27
27
|
.withStartupTimeout(120000);
|
|
28
28
|
return new StartedElasticsearchContainer(yield _super.start.call(this));
|
|
29
29
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { GenericContainer } from "../../generic-container/generic-container";
|
|
2
2
|
import { BoundPorts } from "../../bound-ports";
|
|
3
|
-
import { Port } from "../../port";
|
|
4
3
|
import { StartedTestContainer } from "../..";
|
|
5
4
|
import { AbstractStartedContainer } from "../abstract-started-container";
|
|
6
|
-
import { Host } from "../../docker/types";
|
|
7
5
|
import { InspectResult } from "../../docker/functions/container/inspect-container";
|
|
8
|
-
|
|
6
|
+
import { Content } from "../../docker/types";
|
|
7
|
+
export declare const KAFKA_IMAGE = "confluentinc/cp-kafka:7.2.2";
|
|
9
8
|
interface SaslSslListenerOptions {
|
|
10
9
|
sasl: SaslOptions;
|
|
11
10
|
port: number;
|
|
@@ -21,7 +20,7 @@ interface User {
|
|
|
21
20
|
password: string;
|
|
22
21
|
}
|
|
23
22
|
interface PKCS12CertificateStore {
|
|
24
|
-
content:
|
|
23
|
+
content: Content;
|
|
25
24
|
passphrase: string;
|
|
26
25
|
}
|
|
27
26
|
export declare class KafkaContainer extends GenericContainer {
|
|
@@ -31,7 +30,7 @@ export declare class KafkaContainer extends GenericContainer {
|
|
|
31
30
|
private zooKeeperPort?;
|
|
32
31
|
private saslSslConfig?;
|
|
33
32
|
constructor(image?: string);
|
|
34
|
-
withZooKeeper(host:
|
|
33
|
+
withZooKeeper(host: string, port: number): this;
|
|
35
34
|
withSaslSslListener(options: SaslSslListenerOptions): this;
|
|
36
35
|
protected preStart(): Promise<void>;
|
|
37
36
|
start(): Promise<StartedKafkaContainer>;
|
|
@@ -16,23 +16,23 @@ const abstract_started_container_1 = require("../abstract-started-container");
|
|
|
16
16
|
const KAFKA_PORT = 9093;
|
|
17
17
|
const KAFKA_BROKER_PORT = 9092;
|
|
18
18
|
const DEFAULT_ZOOKEEPER_PORT = 2181;
|
|
19
|
-
exports.KAFKA_IMAGE = "confluentinc/cp-kafka:
|
|
19
|
+
exports.KAFKA_IMAGE = "confluentinc/cp-kafka:7.2.2";
|
|
20
20
|
class KafkaContainer extends generic_container_1.GenericContainer {
|
|
21
21
|
constructor(image = exports.KAFKA_IMAGE) {
|
|
22
22
|
super(image);
|
|
23
23
|
this.uuid = new uuid_1.RandomUuid();
|
|
24
24
|
this.isZooKeeperProvided = false;
|
|
25
|
-
this.withExposedPorts(KAFKA_PORT)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
this.withExposedPorts(KAFKA_PORT).withStartupTimeout(180000).withEnvironment({
|
|
26
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "BROKER:PLAINTEXT,PLAINTEXT:PLAINTEXT",
|
|
27
|
+
KAFKA_INTER_BROKER_LISTENER_NAME: "BROKER",
|
|
28
|
+
KAFKA_BROKER_ID: "1",
|
|
29
|
+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1",
|
|
30
|
+
KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS: "1",
|
|
31
|
+
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: "1",
|
|
32
|
+
KAFKA_LOG_FLUSH_INTERVAL_MESSAGES: "9223372036854775807",
|
|
33
|
+
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: "0",
|
|
34
|
+
KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE: "false",
|
|
35
|
+
});
|
|
36
36
|
}
|
|
37
37
|
withZooKeeper(host, port) {
|
|
38
38
|
this.isZooKeeperProvided = true;
|
|
@@ -47,7 +47,7 @@ class KafkaContainer extends generic_container_1.GenericContainer {
|
|
|
47
47
|
preStart() {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
const network = this.networkMode && this.networkAliases.length > 0 ? this.networkAliases[0] : "localhost";
|
|
50
|
-
this.
|
|
50
|
+
this.withEnvironment({ KAFKA_ADVERTISED_LISTENERS: `BROKER://${network}:${KAFKA_BROKER_PORT}` });
|
|
51
51
|
if (this.saslSslConfig) {
|
|
52
52
|
this.addPlaintextAndSecureListener(this.saslSslConfig);
|
|
53
53
|
}
|
|
@@ -56,13 +56,13 @@ class KafkaContainer extends generic_container_1.GenericContainer {
|
|
|
56
56
|
}
|
|
57
57
|
let command = "#!/bin/bash\n";
|
|
58
58
|
if (this.isZooKeeperProvided) {
|
|
59
|
-
this.
|
|
59
|
+
this.withEnvironment({ KAFKA_ZOOKEEPER_CONNECT: `${this.zooKeeperHost}:${this.zooKeeperPort}` });
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
this.zooKeeperHost = this.uuid.nextUuid();
|
|
63
63
|
this.zooKeeperPort = DEFAULT_ZOOKEEPER_PORT;
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
64
|
+
this.withExposedPorts(this.zooKeeperPort);
|
|
65
|
+
this.withEnvironment({ KAFKA_ZOOKEEPER_CONNECT: `localhost:${this.zooKeeperPort}` });
|
|
66
66
|
command += "echo 'clientPort=" + this.zooKeeperPort + "' > zookeeper.properties\n";
|
|
67
67
|
command += "echo 'dataDir=/var/lib/zookeeper/data' >> zookeeper.properties\n";
|
|
68
68
|
command += "echo 'dataLogDir=/var/lib/zookeeper/log' >> zookeeper.properties\n";
|
|
@@ -70,7 +70,7 @@ class KafkaContainer extends generic_container_1.GenericContainer {
|
|
|
70
70
|
}
|
|
71
71
|
command += "echo '' > /etc/confluent/docker/ensure \n";
|
|
72
72
|
command += "/etc/confluent/docker/run \n";
|
|
73
|
-
this.
|
|
73
|
+
this.withCommand(["sh", "-c", command]);
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
start() {
|
|
@@ -90,25 +90,32 @@ class KafkaContainer extends generic_container_1.GenericContainer {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
addPlaintextAndSecureListener({ port, sasl, keystore, truststore }) {
|
|
93
|
-
this.
|
|
94
|
-
.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
this.withEnvironment({
|
|
94
|
+
KAFKA_LISTENERS: `SECURE://0.0.0.0:${port},PLAINTEXT://0.0.0.0:${KAFKA_PORT},BROKER://0.0.0.0:${KAFKA_BROKER_PORT}`,
|
|
95
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "BROKER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SECURE:SASL_SSL",
|
|
96
|
+
KAFKA_SSL_PROTOCOL: "TLSv1.2",
|
|
97
|
+
KAFKA_SSL_KEYSTORE_LOCATION: "/etc/kafka/secrets/server.keystore.pfx",
|
|
98
|
+
KAFKA_SSL_KEYSTORE_PASSWORD: keystore.passphrase,
|
|
99
|
+
KAFKA_SSL_KEYSTORE_TYPE: "PKCS12",
|
|
100
|
+
KAFKA_SASL_ENABLED_MECHANISMS: sasl.mechanism,
|
|
101
|
+
[`KAFKA_LISTENER_NAME_SECURE_${sasl.mechanism}_SASL_JAAS_CONFIG`]: "org.apache.kafka.common.security.scram.ScramLoginModule required;",
|
|
102
|
+
})
|
|
103
|
+
.withCopyContentToContainer([{ content: keystore.content, target: "/etc/kafka/secrets/server.keystore.pfx" }])
|
|
104
|
+
.withExposedPorts(KAFKA_PORT, port);
|
|
103
105
|
if (truststore) {
|
|
104
|
-
this.withCopyContentToContainer(
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
.
|
|
106
|
+
this.withCopyContentToContainer([
|
|
107
|
+
{ content: truststore.content, target: "/etc/kafka/secrets/server.truststore.pfx" },
|
|
108
|
+
]).withEnvironment({
|
|
109
|
+
KAFKA_SSL_TRUSTSTORE_LOCATION: "/etc/kafka/secrets/server.truststore.pfx",
|
|
110
|
+
KAFKA_SSL_TRUSTSTORE_PASSWORD: truststore.passphrase,
|
|
111
|
+
KAFKA_SSL_TRUSTSTORE_TYPE: "PKCS12",
|
|
112
|
+
});
|
|
108
113
|
}
|
|
109
114
|
}
|
|
110
115
|
addPlaintextListener() {
|
|
111
|
-
this.
|
|
116
|
+
this.withEnvironment({
|
|
117
|
+
KAFKA_LISTENERS: `PLAINTEXT://0.0.0.0:${KAFKA_PORT},BROKER://0.0.0.0:${KAFKA_BROKER_PORT}`,
|
|
118
|
+
}).withExposedPorts(KAFKA_PORT);
|
|
112
119
|
}
|
|
113
120
|
updateAdvertisedListeners(container, inspectResult, boundPorts) {
|
|
114
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -125,7 +132,7 @@ class KafkaContainer extends generic_container_1.GenericContainer {
|
|
|
125
132
|
"--entity-type",
|
|
126
133
|
"brokers",
|
|
127
134
|
"--entity-name",
|
|
128
|
-
this.
|
|
135
|
+
this.environment["KAFKA_BROKER_ID"],
|
|
129
136
|
"--add-config",
|
|
130
137
|
`advertised.listeners=[${bootstrapServers},${brokerAdvertisedListener}]`,
|
|
131
138
|
]);
|
|
@@ -142,7 +149,7 @@ class KafkaContainer extends generic_container_1.GenericContainer {
|
|
|
142
149
|
// At the time of writing kafka-configs displays a warning stating that the 'zookeeper' flag is deprecated in favor of 'bootstrap-server'.
|
|
143
150
|
// Unfortunately, 'bootstrap-server' can only be used to set quotas and not to create a user.
|
|
144
151
|
"--zookeeper",
|
|
145
|
-
this.
|
|
152
|
+
this.environment["KAFKA_ZOOKEEPER_CONNECT"],
|
|
146
153
|
"--entity-type",
|
|
147
154
|
"users",
|
|
148
155
|
"--entity-name",
|
|
@@ -26,7 +26,7 @@ class MongoDBContainer extends generic_container_1.GenericContainer {
|
|
|
26
26
|
});
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
this.withExposedPorts(MONGODB_PORT)
|
|
29
|
-
.
|
|
29
|
+
.withCommand(["--replSet", "rs0"])
|
|
30
30
|
.withWaitStrategy(wait_1.Wait.forLogMessage(new RegExp(".*waiting for connections.*", "i")))
|
|
31
31
|
.withStartupTimeout(120000);
|
|
32
32
|
return new StartedMongoDBContainer(yield _super.start.call(this));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GenericContainer } from "../../generic-container/generic-container";
|
|
2
2
|
import { StartedTestContainer } from "../../test-container";
|
|
3
3
|
import { AbstractStartedContainer } from "../abstract-started-container";
|
|
4
|
-
import { Port } from "../../port";
|
|
5
4
|
export declare class MySqlContainer extends GenericContainer {
|
|
6
5
|
private database;
|
|
7
6
|
private username;
|
|
@@ -21,7 +20,7 @@ export declare class StartedMySqlContainer extends AbstractStartedContainer {
|
|
|
21
20
|
private readonly rootPassword;
|
|
22
21
|
private readonly port;
|
|
23
22
|
constructor(startedTestContainer: StartedTestContainer, database: string, username: string, userPassword: string, rootPassword: string);
|
|
24
|
-
getPort():
|
|
23
|
+
getPort(): number;
|
|
25
24
|
getDatabase(): string;
|
|
26
25
|
getUsername(): string;
|
|
27
26
|
getUserPassword(): string;
|