Skip to content

Commit

Permalink
Add Kafka 3.9.0 (#107)
Browse files Browse the repository at this point in the history
* Add Kafka 3.9.0

Signed-off-by: see-quick <[email protected]>

* Update to work also with 3.9.0

Signed-off-by: see-quick <[email protected]>

* proxy check back

Signed-off-by: see-quick <[email protected]>

* remove cat

Signed-off-by: see-quick <[email protected]>

* fix UTs

Signed-off-by: see-quick <[email protected]>

---------

Signed-off-by: see-quick <[email protected]>
  • Loading branch information
see-quick authored Nov 11, 2024
1 parent 87aec18 commit 4a2529b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Every Kafka broker request will pass through the proxy where you can simulate ne

```java
ToxiproxyContainer proxyContainer = new ToxiproxyContainer(
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.4.0")
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.11.0")
.asCompatibleSubstituteFor("shopify/toxiproxy"));

StrimziKafkaContainer strimziKafkaContainer = new StrimziKafkaContainer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ protected String[] buildListenersConfig(final InspectContainerResponse container
if (this.useKraft) {
final String controllerListenerName = "CONTROLLER";
// adding Controller listener for Kraft mode
// (wildcard address for multi-node setup; that way we other nodes can connect and communicate between each other)
kafkaListeners.append(controllerListenerName).append("://0.0.0.0:9094");
// (DNS alias for multi-node setup; that way we other nodes can connect and communicate between each other)
// we can't use 0.0.0.0 because https://github.com/apache/kafka/commit/9be27e715a209a892941bf35e66859d9c39c28c4
kafkaListeners.append(controllerListenerName).append("://" + NETWORK_ALIAS_PREFIX + this.brokerId + ":9094");
this.listenerNames.add(controllerListenerName);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/kafka_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"3.5.2": "quay.io/strimzi-test-container/test-container:latest-kafka-3.5.2",
"3.6.2": "quay.io/strimzi-test-container/test-container:latest-kafka-3.6.2",
"3.7.1": "quay.io/strimzi-test-container/test-container:latest-kafka-3.7.1",
"3.8.1": "quay.io/strimzi-test-container/test-container:latest-kafka-3.8.1"
"3.8.1": "quay.io/strimzi-test-container/test-container:latest-kafka-3.8.1",
"3.9.0": "quay.io/strimzi-test-container/test-container:latest-kafka-3.9.0"
}
}
16 changes: 6 additions & 10 deletions src/test/java/io/strimzi/test/container/StrimziKafkaClusterIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,28 @@ void testKafkaClusterWithSharedNetworkFunctionality() throws ExecutionException,

@Test
void testStartClusterWithProxyContainer() {
setUpKafkaCluster();

ToxiproxyContainer proxyContainer = new ToxiproxyContainer(
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.6.0")
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.11.0")
.asCompatibleSubstituteFor("shopify/toxiproxy"));

StrimziKafkaCluster kafkaCluster = null;

try {
kafkaCluster = new StrimziKafkaCluster.StrimziKafkaClusterBuilder()
systemUnderTest = new StrimziKafkaCluster.StrimziKafkaClusterBuilder()
.withNumberOfBrokers(NUMBER_OF_REPLICAS)
.withProxyContainer(proxyContainer)
.build();

kafkaCluster.start();
systemUnderTest.start();
List<String> bootstrapUrls = new ArrayList<>();
for (KafkaContainer kafkaContainer : kafkaCluster.getBrokers()) {
for (KafkaContainer kafkaContainer : systemUnderTest.getBrokers()) {
Proxy proxy = ((StrimziKafkaContainer) kafkaContainer).getProxy();
assertThat(proxy, notNullValue());
bootstrapUrls.add(kafkaContainer.getBootstrapServers());
}

assertThat(kafkaCluster.getBootstrapServers(),
assertThat(systemUnderTest.getBootstrapServers(),
is(bootstrapUrls.stream().collect(Collectors.joining(","))));
} finally {
kafkaCluster.stop();
systemUnderTest.stop();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void testIllegalStateUsingInternalZooKeeperWithExternalZooKeeper() {
@MethodSource("retrieveKafkaVersionsFile")
void testStartBrokerWithProxyContainer(final String imageName) {
ToxiproxyContainer proxyContainer = new ToxiproxyContainer(
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.6.0")
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.11.0")
.asCompatibleSubstituteFor("shopify/toxiproxy"));

systemUnderTest = new StrimziKafkaContainer(imageName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public String getBootstrapServers() {

String[] listenersConfig = kafkaContainer.buildListenersConfig(containerInfo);

String expectedListeners = "PLAINTEXT://0.0.0.0:9092,BROKER1://0.0.0.0:9091,CONTROLLER://0.0.0.0:9094";
String expectedListeners = "PLAINTEXT://0.0.0.0:9092,BROKER1://0.0.0.0:9091,CONTROLLER://broker-0:9094";
String expectedAdvertisedListeners = "PLAINTEXT://localhost:9092,BROKER1://172.17.0.2:9091";

assertThat(listenersConfig[0], is(expectedListeners));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,31 @@ void testKafkaClusterWithSharedNetworkFunctionality() throws ExecutionException,

@Test
void testStartClusterWithProxyContainer() {
setUpKafkaKRaftCluster();

ToxiproxyContainer proxyContainer = new ToxiproxyContainer(
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.6.0")
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.11.0")
.asCompatibleSubstituteFor("shopify/toxiproxy"));

StrimziKafkaCluster kafkaCluster = null;

try {
kafkaCluster = new StrimziKafkaCluster.StrimziKafkaClusterBuilder()
systemUnderTest = new StrimziKafkaCluster.StrimziKafkaClusterBuilder()
.withNumberOfBrokers(NUMBER_OF_REPLICAS)
.withProxyContainer(proxyContainer)
.withKraft()
.build();

kafkaCluster.start();
systemUnderTest.start();
List<String> bootstrapUrls = new ArrayList<>();
for (KafkaContainer kafkaContainer : kafkaCluster.getBrokers()) {
for (KafkaContainer kafkaContainer : systemUnderTest.getBrokers()) {
Proxy proxy = ((StrimziKafkaContainer) kafkaContainer).getProxy();
assertThat(proxy, notNullValue());
bootstrapUrls.add(kafkaContainer.getBootstrapServers());
}

assertThat(kafkaCluster.getBootstrapServers(),
assertThat(systemUnderTest.getBootstrapServers(),
is(bootstrapUrls.stream().collect(Collectors.joining(","))));
} finally {
kafkaCluster.stop();
systemUnderTest.stop();
if (systemUnderTest != null) {
systemUnderTest.stop();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ void testIsOAuthEnabledReturnsTrueWhenOAuthConfiguredAndOAuthEnvsAreSet() {
if (this.systemUnderTest != null) {
this.systemUnderTest.stop();
}
if (this.keycloakContainer != null) {
this.keycloakContainer.stop();
}
}
}

Expand Down

0 comments on commit 4a2529b

Please sign in to comment.