testcontainers 8.10.1 → 8.11.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/dist/docker/docker-client.d.ts +1 -1
- package/dist/docker/docker-client.js +8 -1
- package/dist/docker/functions/container/create-container.js +1 -1
- package/dist/docker/functions/container/get-container.js +2 -2
- package/dist/docker/functions/container/list-containers.js +1 -1
- package/dist/docker/functions/demux-stream.js +1 -1
- package/dist/docker/functions/get-info.js +1 -1
- package/dist/docker/functions/image/build-image.js +1 -1
- package/dist/docker/functions/image/list-images.js +1 -1
- package/dist/docker/functions/image/pull-image.js +1 -1
- package/dist/docker/functions/network/connect-network.js +1 -1
- package/dist/docker/functions/network/create-network.js +1 -1
- package/dist/docker/functions/network/remove-network.js +1 -1
- package/dist/docker-compose-environment/docker-compose-environment.js +2 -2
- package/dist/generic-container/generic-container.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/modules/nats/nats-container.d.ts +55 -0
- package/dist/modules/nats/nats-container.js +98 -0
- package/dist/port-forwarder.js +1 -1
- package/package.json +3 -2
|
@@ -153,4 +153,11 @@ const findGateway = (dockerode) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
153
153
|
});
|
|
154
154
|
const findDefaultGateway = (dockerode) => __awaiter(void 0, void 0, void 0, function* () { return (0, run_in_container_1.runInContainer)(dockerode, "alpine:3.14", ["sh", "-c", "ip route|awk '/default/ { print $3 }'"]); });
|
|
155
155
|
const isInContainer = () => (0, fs_1.existsSync)("/.dockerenv");
|
|
156
|
-
|
|
156
|
+
let _dockerClient;
|
|
157
|
+
const dockerClient = () => {
|
|
158
|
+
if (!_dockerClient) {
|
|
159
|
+
_dockerClient = getDockerClient();
|
|
160
|
+
}
|
|
161
|
+
return _dockerClient;
|
|
162
|
+
};
|
|
163
|
+
exports.dockerClient = dockerClient;
|
|
@@ -17,7 +17,7 @@ const create_labels_1 = require("../create-labels");
|
|
|
17
17
|
const createContainer = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
try {
|
|
19
19
|
logger_1.log.info(`Creating container for image: ${options.imageName}`);
|
|
20
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
20
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
21
21
|
return yield dockerode.createContainer({
|
|
22
22
|
name: options.name,
|
|
23
23
|
User: options.user,
|
|
@@ -15,7 +15,7 @@ const logger_1 = require("../../../logger");
|
|
|
15
15
|
const labels_1 = require("../../../labels");
|
|
16
16
|
const getContainerById = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
18
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
19
19
|
return dockerode.getContainer(id);
|
|
20
20
|
}
|
|
21
21
|
catch (err) {
|
|
@@ -26,7 +26,7 @@ const getContainerById = (id) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
26
26
|
exports.getContainerById = getContainerById;
|
|
27
27
|
const getContainerByHash = (hash) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
try {
|
|
29
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
29
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
30
30
|
const containers = yield dockerode.listContainers({
|
|
31
31
|
limit: 1,
|
|
32
32
|
filters: {
|
|
@@ -14,7 +14,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
14
14
|
const logger_1 = require("../../../logger");
|
|
15
15
|
const listContainers = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
17
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
18
18
|
return yield dockerode.listContainers();
|
|
19
19
|
}
|
|
20
20
|
catch (err) {
|
|
@@ -16,7 +16,7 @@ const docker_client_1 = require("../docker-client");
|
|
|
16
16
|
const demuxStream = (stream) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
18
|
const demuxedStream = new stream_1.PassThrough({ autoDestroy: true, encoding: "utf-8" });
|
|
19
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
19
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
20
20
|
dockerode.modem.demuxStream(stream, demuxedStream, demuxedStream);
|
|
21
21
|
stream.on("end", () => demuxedStream.end());
|
|
22
22
|
demuxedStream.on("close", () => {
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getDockerInfo = void 0;
|
|
13
13
|
const docker_client_1 = require("../docker-client");
|
|
14
14
|
const getDockerInfo = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
15
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
16
16
|
const info = yield dockerode.info();
|
|
17
17
|
return {
|
|
18
18
|
serverVersion: info.ServerVersion,
|
|
@@ -36,7 +36,7 @@ const buildImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
39
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
40
40
|
return new Promise((resolve) => dockerode
|
|
41
41
|
.buildImage(tarStream, {
|
|
42
42
|
dockerfile: options.dockerfileName,
|
|
@@ -15,7 +15,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
15
15
|
const logger_1 = require("../../../logger");
|
|
16
16
|
const listImages = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
18
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
19
19
|
const images = yield dockerode.listImages();
|
|
20
20
|
return images.reduce((dockerImageNames, image) => {
|
|
21
21
|
var _a;
|
|
@@ -21,7 +21,7 @@ const pullImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
logger_1.log.info(`Pulling image: ${options.imageName}`);
|
|
24
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
24
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
25
25
|
const stream = yield dockerode.pull(options.imageName.toString(), { authconfig: options.authConfig });
|
|
26
26
|
yield new pull_stream_parser_1.PullStreamParser(options.imageName, logger_1.log).consume(stream);
|
|
27
27
|
}
|
|
@@ -15,7 +15,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
15
15
|
const connectNetwork = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
17
|
logger_1.log.info(`Connecting container ${options.containerId} to network ${options.networkId}`);
|
|
18
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
18
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
19
19
|
const network = dockerode.getNetwork(options.networkId);
|
|
20
20
|
yield network.connect({ Container: options.containerId, EndpointConfig: { Aliases: options.networkAliases } });
|
|
21
21
|
}
|
|
@@ -16,7 +16,7 @@ const create_labels_1 = require("../create-labels");
|
|
|
16
16
|
const createNetwork = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
18
|
logger_1.log.info(`Creating network ${options.name}`);
|
|
19
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
19
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
20
20
|
const network = yield dockerode.createNetwork({
|
|
21
21
|
Name: options.name,
|
|
22
22
|
CheckDuplicate: options.checkDuplicate,
|
|
@@ -15,7 +15,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
15
15
|
const removeNetwork = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
17
|
logger_1.log.info(`Removing network ${id}`);
|
|
18
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
18
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
19
19
|
const network = dockerode.getNetwork(id);
|
|
20
20
|
const { message } = yield network.remove();
|
|
21
21
|
if (message) {
|
|
@@ -119,7 +119,7 @@ class DockerComposeEnvironment {
|
|
|
119
119
|
}
|
|
120
120
|
throw err;
|
|
121
121
|
}
|
|
122
|
-
return new started_generic_container_1.StartedGenericContainer(container, (yield docker_client_1.dockerClient).host, inspectResult, boundPorts, containerName);
|
|
122
|
+
return new started_generic_container_1.StartedGenericContainer(container, (yield (0, docker_client_1.dockerClient)()).host, inspectResult, boundPorts, containerName);
|
|
123
123
|
})))).reduce((map, startedGenericContainer) => {
|
|
124
124
|
const containerName = startedGenericContainer.getName();
|
|
125
125
|
return Object.assign(Object.assign({}, map), { [containerName]: startedGenericContainer });
|
|
@@ -130,7 +130,7 @@ class DockerComposeEnvironment {
|
|
|
130
130
|
}
|
|
131
131
|
waitForContainer(container, containerName, boundPorts) {
|
|
132
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
const waitStrategy = this.getWaitStrategy((yield docker_client_1.dockerClient).host, container, containerName);
|
|
133
|
+
const waitStrategy = this.getWaitStrategy((yield (0, docker_client_1.dockerClient)()).host, container, containerName);
|
|
134
134
|
yield waitStrategy.withStartupTimeout(this.startupTimeout).waitUntilReady(container, boundPorts);
|
|
135
135
|
});
|
|
136
136
|
}
|
|
@@ -119,7 +119,7 @@ class GenericContainer {
|
|
|
119
119
|
const inspectResult = yield (0, inspect_container_1.inspectContainer)(startedContainer);
|
|
120
120
|
const boundPorts = bound_ports_1.BoundPorts.fromInspectResult(inspectResult).filter(this.ports);
|
|
121
121
|
yield this.waitForContainer(startedContainer, boundPorts);
|
|
122
|
-
return new started_generic_container_1.StartedGenericContainer(startedContainer, (yield docker_client_1.dockerClient).host, inspectResult, boundPorts, inspectResult.name);
|
|
122
|
+
return new started_generic_container_1.StartedGenericContainer(startedContainer, (yield (0, docker_client_1.dockerClient)()).host, inspectResult, boundPorts, inspectResult.name);
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
startContainer(createContainerOptions) {
|
|
@@ -156,7 +156,7 @@ class GenericContainer {
|
|
|
156
156
|
const inspectResult = yield (0, inspect_container_1.inspectContainer)(container);
|
|
157
157
|
const boundPorts = bound_ports_1.BoundPorts.fromInspectResult(inspectResult).filter(this.ports);
|
|
158
158
|
yield this.waitForContainer(container, boundPorts);
|
|
159
|
-
const startedContainer = new started_generic_container_1.StartedGenericContainer(container, (yield docker_client_1.dockerClient).host, inspectResult, boundPorts, inspectResult.name);
|
|
159
|
+
const startedContainer = new started_generic_container_1.StartedGenericContainer(container, (yield (0, docker_client_1.dockerClient)()).host, inspectResult, boundPorts, inspectResult.name);
|
|
160
160
|
if (this.postStart) {
|
|
161
161
|
yield this.postStart(startedContainer, inspectResult, boundPorts);
|
|
162
162
|
}
|
|
@@ -263,7 +263,7 @@ class GenericContainer {
|
|
|
263
263
|
waitForContainer(container, boundPorts) {
|
|
264
264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
265
265
|
logger_1.log.debug(`Waiting for container to be ready: ${container.id}`);
|
|
266
|
-
const waitStrategy = this.getWaitStrategy((yield docker_client_1.dockerClient).host, container);
|
|
266
|
+
const waitStrategy = this.getWaitStrategy((yield (0, docker_client_1.dockerClient)()).host, container);
|
|
267
267
|
try {
|
|
268
268
|
yield waitStrategy.withStartupTimeout(this.startupTimeout).waitUntilReady(container, boundPorts);
|
|
269
269
|
logger_1.log.info("Container is ready");
|
package/dist/index.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { Neo4jContainer, StartedNeo4jContainer } from "./modules/neo4j/neo4j-con
|
|
|
15
15
|
export { ArangoDBContainer, StartedArangoContainer } from "./modules/arangodb/arangodb-container";
|
|
16
16
|
export { ElasticsearchContainer, StartedElasticsearchContainer } from "./modules/elasticsearch/elasticsearch-container";
|
|
17
17
|
export { MySqlContainer, StartedMySqlContainer } from "./modules/mysql/mysql-container";
|
|
18
|
+
export { NatsContainer, StartedNatsContainer, NatsConnectionOptions, NatsTlsOptions, } from "./modules/nats/nats-container";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StartedMySqlContainer = exports.MySqlContainer = exports.StartedElasticsearchContainer = exports.ElasticsearchContainer = exports.StartedArangoContainer = exports.ArangoDBContainer = exports.StartedNeo4jContainer = exports.Neo4jContainer = exports.StartedKafkaContainer = exports.KafkaContainer = exports.StartedPostgreSqlContainer = exports.PostgreSqlContainer = exports.AlwaysPullPolicy = exports.DefaultPullPolicy = exports.Wait = exports.StoppedNetwork = exports.StartedNetwork = exports.Network = exports.DownedDockerComposeEnvironment = exports.StoppedDockerComposeEnvironment = exports.StartedDockerComposeEnvironment = exports.DockerComposeEnvironment = exports.TestContainers = exports.GenericContainerBuilder = exports.GenericContainer = void 0;
|
|
3
|
+
exports.StartedNatsContainer = exports.NatsContainer = exports.StartedMySqlContainer = exports.MySqlContainer = exports.StartedElasticsearchContainer = exports.ElasticsearchContainer = exports.StartedArangoContainer = exports.ArangoDBContainer = exports.StartedNeo4jContainer = exports.Neo4jContainer = exports.StartedKafkaContainer = exports.KafkaContainer = exports.StartedPostgreSqlContainer = exports.PostgreSqlContainer = exports.AlwaysPullPolicy = exports.DefaultPullPolicy = exports.Wait = exports.StoppedNetwork = exports.StartedNetwork = exports.Network = exports.DownedDockerComposeEnvironment = exports.StoppedDockerComposeEnvironment = exports.StartedDockerComposeEnvironment = exports.DockerComposeEnvironment = exports.TestContainers = exports.GenericContainerBuilder = exports.GenericContainer = void 0;
|
|
4
4
|
var generic_container_1 = require("./generic-container/generic-container");
|
|
5
5
|
Object.defineProperty(exports, "GenericContainer", { enumerable: true, get: function () { return generic_container_1.GenericContainer; } });
|
|
6
6
|
var generic_container_builder_1 = require("./generic-container/generic-container-builder");
|
|
@@ -42,3 +42,6 @@ Object.defineProperty(exports, "StartedElasticsearchContainer", { enumerable: tr
|
|
|
42
42
|
var mysql_container_1 = require("./modules/mysql/mysql-container");
|
|
43
43
|
Object.defineProperty(exports, "MySqlContainer", { enumerable: true, get: function () { return mysql_container_1.MySqlContainer; } });
|
|
44
44
|
Object.defineProperty(exports, "StartedMySqlContainer", { enumerable: true, get: function () { return mysql_container_1.StartedMySqlContainer; } });
|
|
45
|
+
var nats_container_1 = require("./modules/nats/nats-container");
|
|
46
|
+
Object.defineProperty(exports, "NatsContainer", { enumerable: true, get: function () { return nats_container_1.NatsContainer; } });
|
|
47
|
+
Object.defineProperty(exports, "StartedNatsContainer", { enumerable: true, get: function () { return nats_container_1.StartedNatsContainer; } });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { GenericContainer } from "../../generic-container/generic-container";
|
|
2
|
+
import { StartedTestContainer } from "../../test-container";
|
|
3
|
+
import { AbstractStartedContainer } from "../abstract-started-container";
|
|
4
|
+
export declare class NatsContainer extends GenericContainer {
|
|
5
|
+
private args;
|
|
6
|
+
constructor(image?: string);
|
|
7
|
+
withUser(user: string): this;
|
|
8
|
+
withPass(pass: string): this;
|
|
9
|
+
withArg(name: string, value: string): this;
|
|
10
|
+
private static ensureDashInFrontOfArgumentName;
|
|
11
|
+
start(): Promise<StartedNatsContainer>;
|
|
12
|
+
private getUser;
|
|
13
|
+
private getPass;
|
|
14
|
+
}
|
|
15
|
+
export declare class StartedNatsContainer extends AbstractStartedContainer {
|
|
16
|
+
readonly username: string;
|
|
17
|
+
readonly password: string;
|
|
18
|
+
private readonly connectionOptions;
|
|
19
|
+
constructor(startedTestContainer: StartedTestContainer, username: string, password: string);
|
|
20
|
+
getConnectionOptions(): NatsConnectionOptions;
|
|
21
|
+
}
|
|
22
|
+
export interface NatsConnectionOptions {
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
maxPingOut?: number;
|
|
25
|
+
maxReconnectAttempts?: number;
|
|
26
|
+
name?: string;
|
|
27
|
+
noEcho?: boolean;
|
|
28
|
+
noRandomize?: boolean;
|
|
29
|
+
pass?: string;
|
|
30
|
+
pedantic?: boolean;
|
|
31
|
+
pingInterval?: number;
|
|
32
|
+
port?: number;
|
|
33
|
+
reconnect?: boolean;
|
|
34
|
+
reconnectDelayHandler?: () => number;
|
|
35
|
+
reconnectJitter?: number;
|
|
36
|
+
reconnectJitterTLS?: number;
|
|
37
|
+
reconnectTimeWait?: number;
|
|
38
|
+
servers?: Array<string> | string;
|
|
39
|
+
timeout?: number;
|
|
40
|
+
tls?: NatsTlsOptions;
|
|
41
|
+
token?: string;
|
|
42
|
+
user?: string;
|
|
43
|
+
verbose?: boolean;
|
|
44
|
+
waitOnFirstConnect?: boolean;
|
|
45
|
+
ignoreClusterUpdates?: boolean;
|
|
46
|
+
inboxPrefix?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface NatsTlsOptions {
|
|
49
|
+
certFile?: string;
|
|
50
|
+
cert?: string;
|
|
51
|
+
caFile?: string;
|
|
52
|
+
ca?: string;
|
|
53
|
+
keyFile?: string;
|
|
54
|
+
key?: string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StartedNatsContainer = exports.NatsContainer = void 0;
|
|
13
|
+
const generic_container_1 = require("../../generic-container/generic-container");
|
|
14
|
+
const uuid_1 = require("../../uuid");
|
|
15
|
+
const abstract_started_container_1 = require("../abstract-started-container");
|
|
16
|
+
const wait_1 = require("../../wait");
|
|
17
|
+
const CLIENT_PORT = 4222;
|
|
18
|
+
const ROUTING_PORT_FOR_CLUSTERING = 6222;
|
|
19
|
+
const HTTP_MANAGEMENT_PORT = 8222;
|
|
20
|
+
const USER_ARGUMENT_KEY = "--user";
|
|
21
|
+
const PASS_ARGUMENT_KEY = "--pass";
|
|
22
|
+
class NatsContainer extends generic_container_1.GenericContainer {
|
|
23
|
+
constructor(image = "nats:2.8-alpine") {
|
|
24
|
+
super(image);
|
|
25
|
+
this.args = {};
|
|
26
|
+
this.args[USER_ARGUMENT_KEY] = new uuid_1.RandomUuid().nextUuid();
|
|
27
|
+
this.args[PASS_ARGUMENT_KEY] = new uuid_1.RandomUuid().nextUuid();
|
|
28
|
+
}
|
|
29
|
+
withUser(user) {
|
|
30
|
+
this.args[USER_ARGUMENT_KEY] = user;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
withPass(pass) {
|
|
34
|
+
this.args[PASS_ARGUMENT_KEY] = pass;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
withArg(name, value) {
|
|
38
|
+
name = NatsContainer.ensureDashInFrontOfArgumentName(name);
|
|
39
|
+
this.args[name] = value;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
static ensureDashInFrontOfArgumentName(name) {
|
|
43
|
+
if (name.startsWith("--") || name.startsWith("-")) {
|
|
44
|
+
return name;
|
|
45
|
+
}
|
|
46
|
+
if (name.length == 1) {
|
|
47
|
+
return "-" + name;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return "--" + name;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
start() {
|
|
54
|
+
const _super = Object.create(null, {
|
|
55
|
+
start: { get: () => super.start }
|
|
56
|
+
});
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
function buildCmdsFromArgs(args) {
|
|
59
|
+
const result = [];
|
|
60
|
+
result.push("nats-server");
|
|
61
|
+
for (const argsKey in args) {
|
|
62
|
+
result.push(argsKey);
|
|
63
|
+
result.push(args[argsKey]);
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
this.withCmd(buildCmdsFromArgs(this.args))
|
|
68
|
+
.withExposedPorts(...(this.hasExposedPorts ? this.ports : [CLIENT_PORT, ROUTING_PORT_FOR_CLUSTERING, HTTP_MANAGEMENT_PORT]))
|
|
69
|
+
.withWaitStrategy(wait_1.Wait.forLogMessage(new RegExp(".*Server is ready.*")))
|
|
70
|
+
.withStartupTimeout(120000);
|
|
71
|
+
return new StartedNatsContainer(yield _super.start.call(this), this.getUser(), this.getPass());
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getUser() {
|
|
75
|
+
return this.args[USER_ARGUMENT_KEY];
|
|
76
|
+
}
|
|
77
|
+
getPass() {
|
|
78
|
+
return this.args[PASS_ARGUMENT_KEY];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.NatsContainer = NatsContainer;
|
|
82
|
+
class StartedNatsContainer extends abstract_started_container_1.AbstractStartedContainer {
|
|
83
|
+
constructor(startedTestContainer, username, password) {
|
|
84
|
+
super(startedTestContainer);
|
|
85
|
+
this.username = username;
|
|
86
|
+
this.password = password;
|
|
87
|
+
const port = startedTestContainer.getMappedPort(CLIENT_PORT);
|
|
88
|
+
this.connectionOptions = {
|
|
89
|
+
servers: `${this.startedTestContainer.getHost()}:${port}`,
|
|
90
|
+
user: this.username,
|
|
91
|
+
pass: this.password,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
getConnectionOptions() {
|
|
95
|
+
return this.connectionOptions;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.StartedNatsContainer = StartedNatsContainer;
|
package/dist/port-forwarder.js
CHANGED
|
@@ -69,7 +69,7 @@ class PortForwarderInstance {
|
|
|
69
69
|
`echo "${username}:$PASSWORD" | chpasswd && /usr/sbin/sshd -D -o PermitRootLogin=yes -o AddressFamily=inet -o GatewayPorts=yes`,
|
|
70
70
|
])
|
|
71
71
|
.start();
|
|
72
|
-
const host = (yield docker_client_1.dockerClient).host;
|
|
72
|
+
const host = (yield (0, docker_client_1.dockerClient)()).host;
|
|
73
73
|
const port = container.getMappedPort(22);
|
|
74
74
|
logger_1.log.debug(`Connecting to Port Forwarder on ${host}:${port}`);
|
|
75
75
|
const connection = yield (0, ssh_remote_port_forward_1.createSshConnection)({ host, port, username, password });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testcontainers",
|
|
3
3
|
"author": "Cristian Greco",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.11.1",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"keywords": [
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
"ts-jest": "^27.1.4",
|
|
75
75
|
"ts-node": "^10.7.0",
|
|
76
76
|
"typescript": "^4.6.3",
|
|
77
|
-
"wait-for-expect": "^3.0.2"
|
|
77
|
+
"wait-for-expect": "^3.0.2",
|
|
78
|
+
"nats": "^2.7.1"
|
|
78
79
|
},
|
|
79
80
|
"lint-staged": {
|
|
80
81
|
"src/**/*.ts": [
|