From 4a2529ba0187a9c23a0d444230e7eae1674490d3 Mon Sep 17 00:00:00 2001 From: Maros Orsak Date: Mon, 11 Nov 2024 13:12:09 +0100 Subject: [PATCH] Add Kafka 3.9.0 (#107) * Add Kafka 3.9.0 Signed-off-by: see-quick * Update to work also with 3.9.0 Signed-off-by: see-quick * proxy check back Signed-off-by: see-quick * remove cat Signed-off-by: see-quick * fix UTs Signed-off-by: see-quick --------- Signed-off-by: see-quick --- README.md | 2 +- .../test/container/StrimziKafkaContainer.java | 5 +++-- src/main/resources/kafka_versions.json | 3 ++- .../test/container/StrimziKafkaClusterIT.java | 16 ++++++---------- .../container/StrimziKafkaContainerIT.java | 2 +- .../StrimziKafkaContainerMockTest.java | 2 +- .../container/StrimziKafkaKRaftClusterIT.java | 19 ++++++++----------- .../container/StrimziKafkaKRaftOauthIT.java | 3 +++ 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index d790fa5..eca3fe2 100644 --- a/README.md +++ b/README.md @@ -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() diff --git a/src/main/java/io/strimzi/test/container/StrimziKafkaContainer.java b/src/main/java/io/strimzi/test/container/StrimziKafkaContainer.java index 66510c0..9edeefb 100644 --- a/src/main/java/io/strimzi/test/container/StrimziKafkaContainer.java +++ b/src/main/java/io/strimzi/test/container/StrimziKafkaContainer.java @@ -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); } diff --git a/src/main/resources/kafka_versions.json b/src/main/resources/kafka_versions.json index 2030de9..77dafde 100644 --- a/src/main/resources/kafka_versions.json +++ b/src/main/resources/kafka_versions.json @@ -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" } } \ No newline at end of file diff --git a/src/test/java/io/strimzi/test/container/StrimziKafkaClusterIT.java b/src/test/java/io/strimzi/test/container/StrimziKafkaClusterIT.java index 34365e6..a37decb 100644 --- a/src/test/java/io/strimzi/test/container/StrimziKafkaClusterIT.java +++ b/src/test/java/io/strimzi/test/container/StrimziKafkaClusterIT.java @@ -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 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(); } } diff --git a/src/test/java/io/strimzi/test/container/StrimziKafkaContainerIT.java b/src/test/java/io/strimzi/test/container/StrimziKafkaContainerIT.java index d44acba..0cb7804 100644 --- a/src/test/java/io/strimzi/test/container/StrimziKafkaContainerIT.java +++ b/src/test/java/io/strimzi/test/container/StrimziKafkaContainerIT.java @@ -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) diff --git a/src/test/java/io/strimzi/test/container/StrimziKafkaContainerMockTest.java b/src/test/java/io/strimzi/test/container/StrimziKafkaContainerMockTest.java index ba7ee10..cb28a26 100644 --- a/src/test/java/io/strimzi/test/container/StrimziKafkaContainerMockTest.java +++ b/src/test/java/io/strimzi/test/container/StrimziKafkaContainerMockTest.java @@ -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)); diff --git a/src/test/java/io/strimzi/test/container/StrimziKafkaKRaftClusterIT.java b/src/test/java/io/strimzi/test/container/StrimziKafkaKRaftClusterIT.java index 3ff3dd9..6f037b9 100644 --- a/src/test/java/io/strimzi/test/container/StrimziKafkaKRaftClusterIT.java +++ b/src/test/java/io/strimzi/test/container/StrimziKafkaKRaftClusterIT.java @@ -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 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(); + } } } diff --git a/src/test/java/io/strimzi/test/container/StrimziKafkaKRaftOauthIT.java b/src/test/java/io/strimzi/test/container/StrimziKafkaKRaftOauthIT.java index 9d6705c..cde3ee5 100644 --- a/src/test/java/io/strimzi/test/container/StrimziKafkaKRaftOauthIT.java +++ b/src/test/java/io/strimzi/test/container/StrimziKafkaKRaftOauthIT.java @@ -74,6 +74,9 @@ void testIsOAuthEnabledReturnsTrueWhenOAuthConfiguredAndOAuthEnvsAreSet() { if (this.systemUnderTest != null) { this.systemUnderTest.stop(); } + if (this.keycloakContainer != null) { + this.keycloakContainer.stop(); + } } }