testcontainers 9.2.0 → 9.3.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/package.json +1 -1
- package/dist/src/bound-ports.d.ts +12 -0
- package/dist/src/bound-ports.js +50 -0
- package/dist/src/clock.d.ts +7 -0
- package/dist/src/clock.js +9 -0
- package/dist/src/docker/docker-client-config.d.ts +10 -0
- package/dist/src/docker/docker-client-config.js +66 -0
- package/dist/src/docker/docker-client.d.ts +24 -0
- package/dist/src/docker/docker-client.js +198 -0
- package/dist/src/docker/functions/container/attach-container.d.ts +3 -0
- package/dist/src/docker/functions/container/attach-container.js +25 -0
- package/dist/src/docker/functions/container/container-logs.d.ts +6 -0
- package/dist/src/docker/functions/container/container-logs.js +32 -0
- package/dist/src/docker/functions/container/create-container.d.ts +30 -0
- package/dist/src/docker/functions/container/create-container.js +114 -0
- package/dist/src/docker/functions/container/exec-container.d.ts +9 -0
- package/dist/src/docker/functions/container/exec-container.js +59 -0
- package/dist/src/docker/functions/container/get-container.d.ts +3 -0
- package/dist/src/docker/functions/container/get-container.js +49 -0
- package/dist/src/docker/functions/container/inspect-container.d.ts +19 -0
- package/dist/src/docker/functions/container/inspect-container.js +67 -0
- package/dist/src/docker/functions/container/list-containers.d.ts +2 -0
- package/dist/src/docker/functions/container/list-containers.js +25 -0
- package/dist/src/docker/functions/container/put-container-archive.d.ts +9 -0
- package/dist/src/docker/functions/container/put-container-archive.js +23 -0
- package/dist/src/docker/functions/container/remove-container.d.ts +5 -0
- package/dist/src/docker/functions/container/remove-container.js +23 -0
- package/dist/src/docker/functions/container/restart-container.d.ts +5 -0
- package/dist/src/docker/functions/container/restart-container.js +23 -0
- package/dist/src/docker/functions/container/start-container.d.ts +2 -0
- package/dist/src/docker/functions/container/start-container.js +23 -0
- package/dist/src/docker/functions/container/stop-container.d.ts +5 -0
- package/dist/src/docker/functions/container/stop-container.js +29 -0
- package/dist/src/docker/functions/create-labels.d.ts +3 -0
- package/dist/src/docker/functions/create-labels.js +17 -0
- package/dist/src/docker/functions/demux-stream.d.ts +3 -0
- package/dist/src/docker/functions/demux-stream.js +32 -0
- package/dist/src/docker/functions/get-info.d.ts +11 -0
- package/dist/src/docker/functions/get-info.js +38 -0
- package/dist/src/docker/functions/image/build-image.d.ts +13 -0
- package/dist/src/docker/functions/image/build-image.js +76 -0
- package/dist/src/docker/functions/image/image-exists.d.ts +3 -0
- package/dist/src/docker/functions/image/image-exists.js +34 -0
- package/dist/src/docker/functions/image/list-images.d.ts +3 -0
- package/dist/src/docker/functions/image/list-images.js +34 -0
- package/dist/src/docker/functions/image/pull-image.d.ts +7 -0
- package/dist/src/docker/functions/image/pull-image.js +41 -0
- package/dist/src/docker/functions/network/connect-network.d.ts +6 -0
- package/dist/src/docker/functions/network/connect-network.js +27 -0
- package/dist/src/docker/functions/network/create-network.d.ts +16 -0
- package/dist/src/docker/functions/network/create-network.js +38 -0
- package/dist/src/docker/functions/network/remove-network.d.ts +1 -0
- package/dist/src/docker/functions/network/remove-network.js +30 -0
- package/dist/src/docker/functions/run-in-container.d.ts +2 -0
- package/dist/src/docker/functions/run-in-container.js +39 -0
- package/dist/src/docker/get-remote-docker-unix-socket-path.d.ts +5 -0
- package/dist/src/docker/get-remote-docker-unix-socket-path.js +17 -0
- package/dist/src/docker/lookup-host-ips.d.ts +5 -0
- package/dist/src/docker/lookup-host-ips.js +26 -0
- package/dist/src/docker/pull-stream-parser.d.ts +11 -0
- package/dist/src/docker/pull-stream-parser.js +63 -0
- package/dist/src/docker/rootless-unix-socket-strategy.d.ts +16 -0
- package/dist/src/docker/rootless-unix-socket-strategy.js +69 -0
- package/dist/src/docker/session-id.d.ts +1 -0
- package/dist/src/docker/session-id.js +5 -0
- package/dist/src/docker/types.d.ts +79 -0
- package/dist/src/docker/types.js +2 -0
- package/dist/src/docker-compose/default-docker-compose-options.d.ts +3 -0
- package/dist/src/docker-compose/default-docker-compose-options.js +37 -0
- package/dist/src/docker-compose/docker-compose-options.d.ts +9 -0
- package/dist/src/docker-compose/docker-compose-options.js +2 -0
- package/dist/src/docker-compose/functions/container-name-resolver.d.ts +1 -0
- package/dist/src/docker-compose/functions/container-name-resolver.js +15 -0
- package/dist/src/docker-compose/functions/docker-compose-down.d.ts +3 -0
- package/dist/src/docker-compose/functions/docker-compose-down.js +39 -0
- package/dist/src/docker-compose/functions/docker-compose-stop.d.ts +2 -0
- package/dist/src/docker-compose/functions/docker-compose-stop.js +29 -0
- package/dist/src/docker-compose/functions/docker-compose-up.d.ts +2 -0
- package/dist/src/docker-compose/functions/docker-compose-up.js +41 -0
- package/dist/src/docker-compose-environment/docker-compose-environment.d.ts +25 -0
- package/dist/src/docker-compose-environment/docker-compose-environment.js +134 -0
- package/dist/src/docker-compose-environment/downed-docker-compose-environment.d.ts +2 -0
- package/dist/src/docker-compose-environment/downed-docker-compose-environment.js +6 -0
- package/dist/src/docker-compose-environment/started-docker-compose-environment.d.ts +15 -0
- package/dist/src/docker-compose-environment/started-docker-compose-environment.js +46 -0
- package/dist/src/docker-compose-environment/stopped-docker-compose-environment.d.ts +8 -0
- package/dist/src/docker-compose-environment/stopped-docker-compose-environment.js +27 -0
- package/dist/src/docker-image-name.d.ts +15 -0
- package/dist/src/docker-image-name.js +63 -0
- package/dist/src/dockerfile-parser.d.ts +3 -0
- package/dist/src/dockerfile-parser.js +39 -0
- package/dist/src/generic-container/generic-container-builder.d.ts +18 -0
- package/dist/src/generic-container/generic-container-builder.js +98 -0
- package/dist/src/generic-container/generic-container.d.ts +77 -0
- package/dist/src/generic-container/generic-container.js +312 -0
- package/dist/src/generic-container/started-generic-container.d.ts +31 -0
- package/dist/src/generic-container/started-generic-container.js +97 -0
- package/dist/src/generic-container/stopped-generic-container.d.ts +3 -0
- package/dist/src/generic-container/stopped-generic-container.js +6 -0
- package/dist/src/hash.d.ts +1 -0
- package/dist/src/hash.js +11 -0
- package/dist/src/http-wait-strategy.d.ts +27 -0
- package/dist/src/http-wait-strategy.js +113 -0
- package/dist/src/images.d.ts +2 -0
- package/dist/src/images.js +6 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.js +54 -0
- package/dist/src/labels.d.ts +5 -0
- package/dist/src/labels.js +8 -0
- package/dist/src/logger.d.ts +36 -0
- package/dist/src/logger.js +61 -0
- package/dist/src/modules/abstract-started-container.d.ts +21 -0
- package/dist/src/modules/abstract-started-container.js +59 -0
- package/dist/src/modules/arangodb/arangodb-container.d.ts +19 -0
- package/dist/src/modules/arangodb/arangodb-container.js +60 -0
- package/dist/src/modules/elasticsearch/elasticsearch-container.d.ts +12 -0
- package/dist/src/modules/elasticsearch/elasticsearch-container.js +43 -0
- package/dist/src/modules/kafka/kafka-container.d.ts +46 -0
- package/dist/src/modules/kafka/kafka-container.js +172 -0
- package/dist/src/modules/mongodb/mongodb-container.d.ts +19 -0
- package/dist/src/modules/mongodb/mongodb-container.js +85 -0
- package/dist/src/modules/mysql/mysql-container.d.ts +29 -0
- package/dist/src/modules/mysql/mysql-container.js +102 -0
- package/dist/src/modules/nats/nats-container.d.ts +55 -0
- package/dist/src/modules/nats/nats-container.js +97 -0
- package/dist/src/modules/neo4j/neo4j-container.d.ts +23 -0
- package/dist/src/modules/neo4j/neo4j-container.js +82 -0
- package/dist/src/modules/postgresql/postgresql-container.d.ts +28 -0
- package/dist/src/modules/postgresql/postgresql-container.js +87 -0
- package/dist/src/network.d.ts +17 -0
- package/dist/src/network.js +54 -0
- package/dist/src/port-check.d.ts +17 -0
- package/dist/src/port-check.js +84 -0
- package/dist/src/port-forwarder.d.ts +17 -0
- package/dist/src/port-forwarder.js +81 -0
- package/dist/src/port-generator.d.ts +15 -0
- package/dist/src/port-generator.js +51 -0
- package/dist/src/port.d.ts +10 -0
- package/dist/src/port.js +47 -0
- package/dist/src/pull-policy.d.ts +9 -0
- package/dist/src/pull-policy.js +15 -0
- package/dist/src/reaper.d.ts +14 -0
- package/dist/src/reaper.js +141 -0
- package/dist/src/registry-auth-locator/auths.d.ts +8 -0
- package/dist/src/registry-auth-locator/auths.js +56 -0
- package/dist/src/registry-auth-locator/cred-helpers.d.ts +6 -0
- package/dist/src/registry-auth-locator/cred-helpers.js +15 -0
- package/dist/src/registry-auth-locator/credential-provider.d.ts +10 -0
- package/dist/src/registry-auth-locator/credential-provider.js +83 -0
- package/dist/src/registry-auth-locator/creds-store.d.ts +6 -0
- package/dist/src/registry-auth-locator/creds-store.js +15 -0
- package/dist/src/registry-auth-locator/get-auth-config.d.ts +2 -0
- package/dist/src/registry-auth-locator/get-auth-config.js +65 -0
- package/dist/src/registry-auth-locator/registry-auth-locator.d.ts +6 -0
- package/dist/src/registry-auth-locator/registry-auth-locator.js +2 -0
- package/dist/src/registry-auth-locator/registry-matches.d.ts +1 -0
- package/dist/src/registry-auth-locator/registry-matches.js +5 -0
- package/dist/src/registry-auth-locator/types.d.ts +23 -0
- package/dist/src/registry-auth-locator/types.js +2 -0
- package/dist/src/retry-strategy.d.ts +17 -0
- package/dist/src/retry-strategy.js +46 -0
- package/dist/src/startup-check-strategy.d.ts +7 -0
- package/dist/src/startup-check-strategy.js +30 -0
- package/dist/src/stream-utils.d.ts +6 -0
- package/dist/src/stream-utils.js +46 -0
- package/dist/src/system-info.d.ts +17 -0
- package/dist/src/system-info.js +51 -0
- package/dist/src/test-container.d.ts +66 -0
- package/dist/src/test-container.js +2 -0
- package/dist/src/test-containers.d.ts +3 -0
- package/dist/src/test-containers.js +22 -0
- package/dist/src/type-guards.d.ts +1 -0
- package/dist/src/type-guards.js +7 -0
- package/dist/src/uuid.d.ts +6 -0
- package/dist/src/uuid.js +13 -0
- package/dist/src/wait-for-container.d.ts +4 -0
- package/dist/src/wait-for-container.js +34 -0
- package/dist/src/wait-strategy.d.ts +32 -0
- package/dist/src/wait-strategy.js +137 -0
- package/dist/src/wait.d.ts +7 -0
- package/dist/src/wait.js +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
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.StartedKafkaContainer = exports.KafkaContainer = exports.KAFKA_IMAGE = 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 KAFKA_PORT = 9093;
|
|
17
|
+
const KAFKA_BROKER_PORT = 9092;
|
|
18
|
+
const DEFAULT_ZOOKEEPER_PORT = 2181;
|
|
19
|
+
exports.KAFKA_IMAGE = "confluentinc/cp-kafka:7.2.2";
|
|
20
|
+
class KafkaContainer extends generic_container_1.GenericContainer {
|
|
21
|
+
constructor(image = exports.KAFKA_IMAGE) {
|
|
22
|
+
super(image);
|
|
23
|
+
this.uuid = new uuid_1.RandomUuid();
|
|
24
|
+
this.isZooKeeperProvided = false;
|
|
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
|
+
}
|
|
37
|
+
withZooKeeper(host, port) {
|
|
38
|
+
this.isZooKeeperProvided = true;
|
|
39
|
+
this.zooKeeperHost = host;
|
|
40
|
+
this.zooKeeperPort = port;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
withSaslSslListener(options) {
|
|
44
|
+
this.saslSslConfig = options;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
preStart() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const network = this.networkMode && this.networkAliases.length > 0 ? this.networkAliases[0] : "localhost";
|
|
50
|
+
this.withEnvironment({ KAFKA_ADVERTISED_LISTENERS: `BROKER://${network}:${KAFKA_BROKER_PORT}` });
|
|
51
|
+
if (this.saslSslConfig) {
|
|
52
|
+
this.addPlaintextAndSecureListener(this.saslSslConfig);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.addPlaintextListener();
|
|
56
|
+
}
|
|
57
|
+
let command = "#!/bin/bash\n";
|
|
58
|
+
if (this.isZooKeeperProvided) {
|
|
59
|
+
this.withEnvironment({ KAFKA_ZOOKEEPER_CONNECT: `${this.zooKeeperHost}:${this.zooKeeperPort}` });
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.zooKeeperHost = this.uuid.nextUuid();
|
|
63
|
+
this.zooKeeperPort = DEFAULT_ZOOKEEPER_PORT;
|
|
64
|
+
this.withExposedPorts(this.zooKeeperPort);
|
|
65
|
+
this.withEnvironment({ KAFKA_ZOOKEEPER_CONNECT: `localhost:${this.zooKeeperPort}` });
|
|
66
|
+
command += "echo 'clientPort=" + this.zooKeeperPort + "' > zookeeper.properties\n";
|
|
67
|
+
command += "echo 'dataDir=/var/lib/zookeeper/data' >> zookeeper.properties\n";
|
|
68
|
+
command += "echo 'dataLogDir=/var/lib/zookeeper/log' >> zookeeper.properties\n";
|
|
69
|
+
command += "zookeeper-server-start zookeeper.properties &\n";
|
|
70
|
+
}
|
|
71
|
+
command += "echo '' > /etc/confluent/docker/ensure \n";
|
|
72
|
+
command += "/etc/confluent/docker/run \n";
|
|
73
|
+
this.withCommand(["sh", "-c", command]);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
start() {
|
|
77
|
+
const _super = Object.create(null, {
|
|
78
|
+
start: { get: () => super.start }
|
|
79
|
+
});
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return new StartedKafkaContainer(yield _super.start.call(this));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
postStart(container, inspectResult, boundPorts) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
yield this.updateAdvertisedListeners(container, inspectResult, boundPorts);
|
|
87
|
+
if (this.saslSslConfig) {
|
|
88
|
+
yield this.createUser(container, this.saslSslConfig.sasl);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
addPlaintextAndSecureListener({ port, sasl, keystore, truststore }) {
|
|
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);
|
|
105
|
+
if (truststore) {
|
|
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
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
addPlaintextListener() {
|
|
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);
|
|
119
|
+
}
|
|
120
|
+
updateAdvertisedListeners(container, inspectResult, boundPorts) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const brokerAdvertisedListener = `BROKER://${inspectResult.hostname}:${KAFKA_BROKER_PORT}`;
|
|
123
|
+
let bootstrapServers = `PLAINTEXT://${container.getHost()}:${boundPorts.getBinding(KAFKA_PORT)}`;
|
|
124
|
+
if (this.saslSslConfig) {
|
|
125
|
+
bootstrapServers = `${bootstrapServers},SECURE://${container.getHost()}:${boundPorts.getBinding(this.saslSslConfig.port)}`;
|
|
126
|
+
}
|
|
127
|
+
const { output, exitCode } = yield container.exec([
|
|
128
|
+
"kafka-configs",
|
|
129
|
+
"--alter",
|
|
130
|
+
"--bootstrap-server",
|
|
131
|
+
brokerAdvertisedListener,
|
|
132
|
+
"--entity-type",
|
|
133
|
+
"brokers",
|
|
134
|
+
"--entity-name",
|
|
135
|
+
this.environment["KAFKA_BROKER_ID"],
|
|
136
|
+
"--add-config",
|
|
137
|
+
`advertised.listeners=[${bootstrapServers},${brokerAdvertisedListener}]`,
|
|
138
|
+
]);
|
|
139
|
+
if (exitCode !== 0) {
|
|
140
|
+
throw new Error(`Kafka container configuration failed with exit code ${exitCode}: ${output}`);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
createUser(container, { user: { name, password }, mechanism }) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
const { output, exitCode } = yield container.exec([
|
|
147
|
+
"kafka-configs",
|
|
148
|
+
"--alter",
|
|
149
|
+
// At the time of writing kafka-configs displays a warning stating that the 'zookeeper' flag is deprecated in favor of 'bootstrap-server'.
|
|
150
|
+
// Unfortunately, 'bootstrap-server' can only be used to set quotas and not to create a user.
|
|
151
|
+
"--zookeeper",
|
|
152
|
+
this.environment["KAFKA_ZOOKEEPER_CONNECT"],
|
|
153
|
+
"--entity-type",
|
|
154
|
+
"users",
|
|
155
|
+
"--entity-name",
|
|
156
|
+
`${name}`,
|
|
157
|
+
"--add-config",
|
|
158
|
+
`${mechanism}=[password=${password}]`,
|
|
159
|
+
]);
|
|
160
|
+
if (exitCode !== 0) {
|
|
161
|
+
throw new Error(`Kafka container configuration failed with exit code ${exitCode}: ${output}`);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.KafkaContainer = KafkaContainer;
|
|
167
|
+
class StartedKafkaContainer extends abstract_started_container_1.AbstractStartedContainer {
|
|
168
|
+
constructor(startedTestContainer) {
|
|
169
|
+
super(startedTestContainer);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.StartedKafkaContainer = StartedKafkaContainer;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GenericContainer } from "../../generic-container/generic-container";
|
|
2
|
+
import { AbstractStartedContainer } from "../abstract-started-container";
|
|
3
|
+
import { StartedTestContainer } from "../../test-container";
|
|
4
|
+
export declare class MongoDBContainer extends GenericContainer {
|
|
5
|
+
private readonly dockerImageName;
|
|
6
|
+
constructor(image?: string);
|
|
7
|
+
start(): Promise<StartedMongoDBContainer>;
|
|
8
|
+
protected postStart(startedTestContainer: StartedTestContainer): Promise<void>;
|
|
9
|
+
private initReplicaSet;
|
|
10
|
+
private executeMongoEvalCommand;
|
|
11
|
+
private buildMongoEvalCommand;
|
|
12
|
+
private getMongoCmdBasedOnImageTag;
|
|
13
|
+
private checkMongoNodeExitCode;
|
|
14
|
+
private buildMongoWaitCommand;
|
|
15
|
+
}
|
|
16
|
+
export declare class StartedMongoDBContainer extends AbstractStartedContainer {
|
|
17
|
+
constructor(startedTestContainer: StartedTestContainer);
|
|
18
|
+
getConnectionString(): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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.StartedMongoDBContainer = exports.MongoDBContainer = void 0;
|
|
13
|
+
const generic_container_1 = require("../../generic-container/generic-container");
|
|
14
|
+
const abstract_started_container_1 = require("../abstract-started-container");
|
|
15
|
+
const wait_1 = require("../../wait");
|
|
16
|
+
const docker_image_name_1 = require("../../docker-image-name");
|
|
17
|
+
const MONGODB_PORT = 27017;
|
|
18
|
+
class MongoDBContainer extends generic_container_1.GenericContainer {
|
|
19
|
+
constructor(image = "mongo:4.0.1") {
|
|
20
|
+
super(image);
|
|
21
|
+
this.dockerImageName = docker_image_name_1.DockerImageName.fromString(this.image);
|
|
22
|
+
}
|
|
23
|
+
start() {
|
|
24
|
+
const _super = Object.create(null, {
|
|
25
|
+
start: { get: () => super.start }
|
|
26
|
+
});
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
this.withExposedPorts(MONGODB_PORT)
|
|
29
|
+
.withCommand(["--replSet", "rs0"])
|
|
30
|
+
.withWaitStrategy(wait_1.Wait.forLogMessage(/.*waiting for connections.*/i))
|
|
31
|
+
.withStartupTimeout(120000);
|
|
32
|
+
return new StartedMongoDBContainer(yield _super.start.call(this));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
postStart(startedTestContainer) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
yield this.initReplicaSet(startedTestContainer);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
initReplicaSet(startedTestContainer) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
yield this.executeMongoEvalCommand(startedTestContainer, "rs.initiate();");
|
|
43
|
+
yield this.executeMongoEvalCommand(startedTestContainer, this.buildMongoWaitCommand());
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
executeMongoEvalCommand(startedTestContainer, command) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const execResult = yield startedTestContainer.exec(this.buildMongoEvalCommand(command));
|
|
49
|
+
this.checkMongoNodeExitCode(execResult);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
buildMongoEvalCommand(command) {
|
|
53
|
+
return [this.getMongoCmdBasedOnImageTag(), "--eval", command];
|
|
54
|
+
}
|
|
55
|
+
getMongoCmdBasedOnImageTag() {
|
|
56
|
+
return parseInt(this.dockerImageName.tag[0]) >= 5 ? "mongosh" : "mongo";
|
|
57
|
+
}
|
|
58
|
+
checkMongoNodeExitCode(execResult) {
|
|
59
|
+
const { exitCode, output } = execResult;
|
|
60
|
+
if (execResult.exitCode !== 0) {
|
|
61
|
+
throw new Error(`Error running mongo command. Exit code ${exitCode}: ${output}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
buildMongoWaitCommand() {
|
|
65
|
+
return `
|
|
66
|
+
var attempt = 0;
|
|
67
|
+
while(db.runCommand({isMaster: 1}).ismaster==false) {
|
|
68
|
+
if (attempt > 60) {
|
|
69
|
+
quit(1);
|
|
70
|
+
}
|
|
71
|
+
print(attempt); sleep(100); attempt++;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.MongoDBContainer = MongoDBContainer;
|
|
77
|
+
class StartedMongoDBContainer extends abstract_started_container_1.AbstractStartedContainer {
|
|
78
|
+
constructor(startedTestContainer) {
|
|
79
|
+
super(startedTestContainer);
|
|
80
|
+
}
|
|
81
|
+
getConnectionString() {
|
|
82
|
+
return `mongodb://${this.getHost()}:${this.getMappedPort(MONGODB_PORT)}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.StartedMongoDBContainer = StartedMongoDBContainer;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 MySqlContainer extends GenericContainer {
|
|
5
|
+
private database;
|
|
6
|
+
private username;
|
|
7
|
+
private userPassword;
|
|
8
|
+
private rootPassword;
|
|
9
|
+
constructor(image?: string);
|
|
10
|
+
withDatabase(database: string): this;
|
|
11
|
+
withUsername(username: string): this;
|
|
12
|
+
withRootPassword(rootPassword: string): this;
|
|
13
|
+
withUserPassword(userPassword: string): this;
|
|
14
|
+
start(): Promise<StartedMySqlContainer>;
|
|
15
|
+
}
|
|
16
|
+
export declare class StartedMySqlContainer extends AbstractStartedContainer {
|
|
17
|
+
private readonly database;
|
|
18
|
+
private readonly username;
|
|
19
|
+
private readonly userPassword;
|
|
20
|
+
private readonly rootPassword;
|
|
21
|
+
private readonly port;
|
|
22
|
+
constructor(startedTestContainer: StartedTestContainer, database: string, username: string, userPassword: string, rootPassword: string);
|
|
23
|
+
getPort(): number;
|
|
24
|
+
getDatabase(): string;
|
|
25
|
+
getUsername(): string;
|
|
26
|
+
getUserPassword(): string;
|
|
27
|
+
getRootPassword(): string;
|
|
28
|
+
executeQuery(query: string, additionalFlags?: string[]): Promise<string>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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.StartedMySqlContainer = exports.MySqlContainer = void 0;
|
|
13
|
+
const generic_container_1 = require("../../generic-container/generic-container");
|
|
14
|
+
const abstract_started_container_1 = require("../abstract-started-container");
|
|
15
|
+
const MYSQL_PORT = 3306;
|
|
16
|
+
class MySqlContainer extends generic_container_1.GenericContainer {
|
|
17
|
+
constructor(image = "mysql:8.0.31") {
|
|
18
|
+
super(image);
|
|
19
|
+
this.database = "test";
|
|
20
|
+
this.username = "test";
|
|
21
|
+
this.userPassword = "test";
|
|
22
|
+
this.rootPassword = "test";
|
|
23
|
+
}
|
|
24
|
+
withDatabase(database) {
|
|
25
|
+
this.database = database;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
withUsername(username) {
|
|
29
|
+
this.username = username;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
withRootPassword(rootPassword) {
|
|
33
|
+
this.rootPassword = rootPassword;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
withUserPassword(userPassword) {
|
|
37
|
+
this.userPassword = userPassword;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
start() {
|
|
41
|
+
const _super = Object.create(null, {
|
|
42
|
+
start: { get: () => super.start }
|
|
43
|
+
});
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [MYSQL_PORT]))
|
|
46
|
+
.withEnvironment({
|
|
47
|
+
MYSQL_DATABASE: this.database,
|
|
48
|
+
MYSQL_ROOT_PASSWORD: this.rootPassword,
|
|
49
|
+
MYSQL_USER: this.username,
|
|
50
|
+
MYSQL_PASSWORD: this.userPassword,
|
|
51
|
+
})
|
|
52
|
+
.withStartupTimeout(120000);
|
|
53
|
+
return new StartedMySqlContainer(yield _super.start.call(this), this.database, this.username, this.userPassword, this.rootPassword);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.MySqlContainer = MySqlContainer;
|
|
58
|
+
class StartedMySqlContainer extends abstract_started_container_1.AbstractStartedContainer {
|
|
59
|
+
constructor(startedTestContainer, database, username, userPassword, rootPassword) {
|
|
60
|
+
super(startedTestContainer);
|
|
61
|
+
this.database = database;
|
|
62
|
+
this.username = username;
|
|
63
|
+
this.userPassword = userPassword;
|
|
64
|
+
this.rootPassword = rootPassword;
|
|
65
|
+
this.port = startedTestContainer.getMappedPort(3306);
|
|
66
|
+
}
|
|
67
|
+
getPort() {
|
|
68
|
+
return this.port;
|
|
69
|
+
}
|
|
70
|
+
getDatabase() {
|
|
71
|
+
return this.database;
|
|
72
|
+
}
|
|
73
|
+
getUsername() {
|
|
74
|
+
return this.username;
|
|
75
|
+
}
|
|
76
|
+
getUserPassword() {
|
|
77
|
+
return this.userPassword;
|
|
78
|
+
}
|
|
79
|
+
getRootPassword() {
|
|
80
|
+
return this.rootPassword;
|
|
81
|
+
}
|
|
82
|
+
executeQuery(query, additionalFlags = []) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const result = yield this.startedTestContainer.exec([
|
|
85
|
+
"mysql",
|
|
86
|
+
"-h",
|
|
87
|
+
"127.0.0.1",
|
|
88
|
+
"-u",
|
|
89
|
+
this.username,
|
|
90
|
+
`-p${this.userPassword}`,
|
|
91
|
+
"-e",
|
|
92
|
+
`${query};`,
|
|
93
|
+
...additionalFlags,
|
|
94
|
+
]);
|
|
95
|
+
if (result.exitCode !== 0) {
|
|
96
|
+
throw new Error(`executeQuery failed with exit code ${result.exitCode} for query: ${query}`);
|
|
97
|
+
}
|
|
98
|
+
return result.output;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.StartedMySqlContainer = StartedMySqlContainer;
|
|
@@ -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
|
+
withUsername(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,97 @@
|
|
|
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 abstract_started_container_1 = require("../abstract-started-container");
|
|
15
|
+
const wait_1 = require("../../wait");
|
|
16
|
+
const CLIENT_PORT = 4222;
|
|
17
|
+
const ROUTING_PORT_FOR_CLUSTERING = 6222;
|
|
18
|
+
const HTTP_MANAGEMENT_PORT = 8222;
|
|
19
|
+
const USER_ARGUMENT_KEY = "--user";
|
|
20
|
+
const PASS_ARGUMENT_KEY = "--pass";
|
|
21
|
+
class NatsContainer extends generic_container_1.GenericContainer {
|
|
22
|
+
constructor(image = "nats:2.8-alpine") {
|
|
23
|
+
super(image);
|
|
24
|
+
this.args = {};
|
|
25
|
+
this.args[USER_ARGUMENT_KEY] = "test";
|
|
26
|
+
this.args[PASS_ARGUMENT_KEY] = "test";
|
|
27
|
+
}
|
|
28
|
+
withUsername(user) {
|
|
29
|
+
this.args[USER_ARGUMENT_KEY] = user;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
withPass(pass) {
|
|
33
|
+
this.args[PASS_ARGUMENT_KEY] = pass;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
withArg(name, value) {
|
|
37
|
+
name = NatsContainer.ensureDashInFrontOfArgumentName(name);
|
|
38
|
+
this.args[name] = value;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
static ensureDashInFrontOfArgumentName(name) {
|
|
42
|
+
if (name.startsWith("--") || name.startsWith("-")) {
|
|
43
|
+
return name;
|
|
44
|
+
}
|
|
45
|
+
if (name.length == 1) {
|
|
46
|
+
return "-" + name;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return "--" + name;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
start() {
|
|
53
|
+
const _super = Object.create(null, {
|
|
54
|
+
start: { get: () => super.start }
|
|
55
|
+
});
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
function buildCmdsFromArgs(args) {
|
|
58
|
+
const result = [];
|
|
59
|
+
result.push("nats-server");
|
|
60
|
+
for (const argsKey in args) {
|
|
61
|
+
result.push(argsKey);
|
|
62
|
+
result.push(args[argsKey]);
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
this.withCommand(buildCmdsFromArgs(this.args))
|
|
67
|
+
.withExposedPorts(...(this.hasExposedPorts ? this.ports : [CLIENT_PORT, ROUTING_PORT_FOR_CLUSTERING, HTTP_MANAGEMENT_PORT]))
|
|
68
|
+
.withWaitStrategy(wait_1.Wait.forLogMessage(/.*Server is ready.*/))
|
|
69
|
+
.withStartupTimeout(120000);
|
|
70
|
+
return new StartedNatsContainer(yield _super.start.call(this), this.getUser(), this.getPass());
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
getUser() {
|
|
74
|
+
return this.args[USER_ARGUMENT_KEY];
|
|
75
|
+
}
|
|
76
|
+
getPass() {
|
|
77
|
+
return this.args[PASS_ARGUMENT_KEY];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.NatsContainer = NatsContainer;
|
|
81
|
+
class StartedNatsContainer extends abstract_started_container_1.AbstractStartedContainer {
|
|
82
|
+
constructor(startedTestContainer, username, password) {
|
|
83
|
+
super(startedTestContainer);
|
|
84
|
+
this.username = username;
|
|
85
|
+
this.password = password;
|
|
86
|
+
const port = startedTestContainer.getMappedPort(CLIENT_PORT);
|
|
87
|
+
this.connectionOptions = {
|
|
88
|
+
servers: `${this.startedTestContainer.getHost()}:${port}`,
|
|
89
|
+
user: this.username,
|
|
90
|
+
pass: this.password,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
getConnectionOptions() {
|
|
94
|
+
return this.connectionOptions;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.StartedNatsContainer = StartedNatsContainer;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GenericContainer } from "../..";
|
|
2
|
+
import { StartedTestContainer } from "../../test-container";
|
|
3
|
+
import { AbstractStartedContainer } from "../abstract-started-container";
|
|
4
|
+
export declare class Neo4jContainer extends GenericContainer {
|
|
5
|
+
private password;
|
|
6
|
+
private apoc;
|
|
7
|
+
private ttl?;
|
|
8
|
+
constructor(image?: string);
|
|
9
|
+
withPassword(password: string): this;
|
|
10
|
+
withApoc(): this;
|
|
11
|
+
withTtl(schedule?: number): this;
|
|
12
|
+
start(): Promise<StartedNeo4jContainer>;
|
|
13
|
+
}
|
|
14
|
+
export declare class StartedNeo4jContainer extends AbstractStartedContainer {
|
|
15
|
+
private readonly password;
|
|
16
|
+
private readonly boltPort;
|
|
17
|
+
private readonly httpPort;
|
|
18
|
+
constructor(startedTestContainer: StartedTestContainer, password: string);
|
|
19
|
+
getBoltUri(): string;
|
|
20
|
+
getHttpUri(): string;
|
|
21
|
+
getPassword(): string;
|
|
22
|
+
getUsername(): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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.StartedNeo4jContainer = exports.Neo4jContainer = void 0;
|
|
13
|
+
const __1 = require("../..");
|
|
14
|
+
const abstract_started_container_1 = require("../abstract-started-container");
|
|
15
|
+
const BOLT_PORT = 7687;
|
|
16
|
+
const HTTP_PORT = 7474;
|
|
17
|
+
const USERNAME = "neo4j";
|
|
18
|
+
class Neo4jContainer extends __1.GenericContainer {
|
|
19
|
+
constructor(image = "neo4j:4.4.12") {
|
|
20
|
+
super(image);
|
|
21
|
+
this.password = "test";
|
|
22
|
+
this.apoc = false;
|
|
23
|
+
}
|
|
24
|
+
withPassword(password) {
|
|
25
|
+
this.password = password;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
withApoc() {
|
|
29
|
+
this.apoc = true;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
withTtl(schedule = 5) {
|
|
33
|
+
this.ttl = schedule;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
start() {
|
|
37
|
+
const _super = Object.create(null, {
|
|
38
|
+
start: { get: () => super.start }
|
|
39
|
+
});
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [BOLT_PORT, HTTP_PORT]))
|
|
42
|
+
.withWaitStrategy(__1.Wait.forLogMessage("Started."))
|
|
43
|
+
.withEnvironment({ NEO4J_AUTH: `${USERNAME}/${this.password}` })
|
|
44
|
+
.withStartupTimeout(120000);
|
|
45
|
+
if (this.apoc) {
|
|
46
|
+
this.withEnvironment({
|
|
47
|
+
NEO4JLABS_PLUGINS: '["apoc"]',
|
|
48
|
+
NEO4J_dbms_security_procedures_unrestricted: "apoc.*",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (this.ttl) {
|
|
52
|
+
this.withEnvironment({
|
|
53
|
+
NEO4J_apoc_ttl_enabled: "true",
|
|
54
|
+
NEO4J_apoc_ttl_schedule: this.ttl.toString(),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return new StartedNeo4jContainer(yield _super.start.call(this), this.password);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Neo4jContainer = Neo4jContainer;
|
|
62
|
+
class StartedNeo4jContainer extends abstract_started_container_1.AbstractStartedContainer {
|
|
63
|
+
constructor(startedTestContainer, password) {
|
|
64
|
+
super(startedTestContainer);
|
|
65
|
+
this.password = password;
|
|
66
|
+
this.boltPort = this.startedTestContainer.getMappedPort(BOLT_PORT);
|
|
67
|
+
this.httpPort = this.startedTestContainer.getMappedPort(HTTP_PORT);
|
|
68
|
+
}
|
|
69
|
+
getBoltUri() {
|
|
70
|
+
return `bolt://${this.getHost()}:${this.boltPort}/`;
|
|
71
|
+
}
|
|
72
|
+
getHttpUri() {
|
|
73
|
+
return `http://${this.getHost()}:${this.httpPort}/`;
|
|
74
|
+
}
|
|
75
|
+
getPassword() {
|
|
76
|
+
return this.password;
|
|
77
|
+
}
|
|
78
|
+
getUsername() {
|
|
79
|
+
return USERNAME;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.StartedNeo4jContainer = StartedNeo4jContainer;
|