@testcontainers/kafka 11.13.0 → 12.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.
|
@@ -23,7 +23,7 @@ export declare class KafkaContainer extends GenericContainer {
|
|
|
23
23
|
private zooKeeperHost?;
|
|
24
24
|
private zooKeeperPort?;
|
|
25
25
|
private saslSslConfig?;
|
|
26
|
-
private
|
|
26
|
+
private originalWaitStrategy;
|
|
27
27
|
constructor(image: string);
|
|
28
28
|
withZooKeeper(host: string, port: number): this;
|
|
29
29
|
withKraft(): this;
|
package/build/kafka-container.js
CHANGED
|
@@ -8,7 +8,7 @@ const KAFKA_BROKER_PORT = 9092;
|
|
|
8
8
|
const KAFKA_CONTROLLER_PORT = 9094;
|
|
9
9
|
const DEFAULT_ZOOKEEPER_PORT = 2181;
|
|
10
10
|
const DEFAULT_CLUSTER_ID = "4L6g3nShT-eMCtK--X86sw";
|
|
11
|
-
const STARTER_SCRIPT = "/testcontainers_start.sh";
|
|
11
|
+
const STARTER_SCRIPT = "/tmp/testcontainers_start.sh";
|
|
12
12
|
const WAIT_FOR_SCRIPT_MESSAGE = "Waiting for script...";
|
|
13
13
|
// https://docs.confluent.io/platform/7.0.0/release-notes/index.html#ak-raft-kraft
|
|
14
14
|
const MIN_KRAFT_VERSION = "7.0.0";
|
|
@@ -25,7 +25,7 @@ class KafkaContainer extends testcontainers_1.GenericContainer {
|
|
|
25
25
|
zooKeeperHost;
|
|
26
26
|
zooKeeperPort;
|
|
27
27
|
saslSslConfig;
|
|
28
|
-
|
|
28
|
+
originalWaitStrategy;
|
|
29
29
|
constructor(image) {
|
|
30
30
|
super(image);
|
|
31
31
|
if ((0, compare_versions_1.satisfies)(this.imageName.tag, ">=8.0.0")) {
|
|
@@ -42,7 +42,7 @@ class KafkaContainer extends testcontainers_1.GenericContainer {
|
|
|
42
42
|
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: "0",
|
|
43
43
|
KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE: "false",
|
|
44
44
|
});
|
|
45
|
-
this.
|
|
45
|
+
this.originalWaitStrategy = this.waitStrategy;
|
|
46
46
|
}
|
|
47
47
|
withZooKeeper(host, port) {
|
|
48
48
|
this.mode = KafkaMode.PROVIDED_ZOOKEEPER;
|
|
@@ -93,7 +93,7 @@ class KafkaContainer extends testcontainers_1.GenericContainer {
|
|
|
93
93
|
}
|
|
94
94
|
// Change the wait strategy to wait for a log message from a fake starter script
|
|
95
95
|
// so that we can put a real starter script in place at that moment
|
|
96
|
-
this.
|
|
96
|
+
this.originalWaitStrategy = this.waitStrategy;
|
|
97
97
|
this.waitStrategy = testcontainers_1.Wait.forLogMessage(WAIT_FOR_SCRIPT_MESSAGE);
|
|
98
98
|
this.withEntrypoint(["sh"]);
|
|
99
99
|
this.withCommand([
|
|
@@ -134,8 +134,13 @@ class KafkaContainer extends testcontainers_1.GenericContainer {
|
|
|
134
134
|
await container.copyContentToContainer([{ content: command, target: STARTER_SCRIPT, mode: 0o777 }]);
|
|
135
135
|
const client = await (0, testcontainers_1.getContainerRuntimeClient)();
|
|
136
136
|
const dockerContainer = client.container.getById(container.getId());
|
|
137
|
+
const dockerInspectResult = await client.container.inspect(dockerContainer);
|
|
137
138
|
const boundPorts = testcontainers_1.BoundPorts.fromInspectResult(client.info.containerRuntime.hostIps, inspectResult).filter(this.exposedPorts);
|
|
138
|
-
await
|
|
139
|
+
const waitStrategy = await this.selectWaitStrategy(client, dockerInspectResult, this.originalWaitStrategy);
|
|
140
|
+
if (this.startupTimeoutMs !== undefined) {
|
|
141
|
+
waitStrategy.withStartupTimeout(this.startupTimeoutMs);
|
|
142
|
+
}
|
|
143
|
+
await (0, testcontainers_1.waitForContainer)(client, dockerContainer, waitStrategy, boundPorts);
|
|
139
144
|
if (this.saslSslConfig && this.mode !== KafkaMode.KRAFT) {
|
|
140
145
|
await this.createUser(container, this.saslSslConfig.sasl);
|
|
141
146
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testcontainers/kafka",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kafka",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"build": "tsc --project tsconfig.build.json"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@confluentinc/kafka-javascript": "^1.
|
|
32
|
+
"@confluentinc/kafka-javascript": "^1.9.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"compare-versions": "^6.1.1",
|
|
36
|
-
"testcontainers": "^
|
|
36
|
+
"testcontainers": "^12.0.0"
|
|
37
37
|
}
|
|
38
38
|
}
|