Skip to content

Commit

Permalink
Use Strimzi Test Container in TO tests (#10713)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Scholz <[email protected]>
  • Loading branch information
scholzj authored Oct 22, 2024
1 parent ff8521a commit bab6083
Show file tree
Hide file tree
Showing 13 changed files with 1,625 additions and 1,678 deletions.
2 changes: 1 addition & 1 deletion .azure/templates/jobs/build/test_strimzi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
jdk_version: '17'
main_build: 'true'
# Set timeout for jobs
timeoutInMinutes: 70
timeoutInMinutes: 90
# Base system
pool:
vmImage: Ubuntu-22.04
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public void startup() throws InterruptedException {
workerProps.put("value.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("value.converter.schemas.enable", "false");
workerProps.put("offset.storage.topic", getClass().getSimpleName() + "-offsets");
workerProps.put("offset.storage.replication.factor", "3");
workerProps.put("offset.storage.replication.factor", "1");
workerProps.put("config.storage.topic", getClass().getSimpleName() + "-config");
workerProps.put("config.storage.replication.factor", "3");
workerProps.put("config.storage.replication.factor", "1");
workerProps.put("status.storage.topic", getClass().getSimpleName() + "-status");
workerProps.put("status.storage.replication.factor", "3");
workerProps.put("status.storage.replication.factor", "1");
workerProps.put("bootstrap.servers", brokerList);

CountDownLatch l = new CountDownLatch(1); // Indicates that the Kafka Connect cluster startup is finished (successfully or not)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -71,9 +70,12 @@ public void afterEach() {
@BeforeAll
public static void before() throws IOException {
vertx = Vertx.vertx();
final Map<String, String> kafkaClusterConfiguration = new HashMap<>();
kafkaClusterConfiguration.put("zookeeper.connect", "zookeeper:2181");
cluster = new StrimziKafkaCluster(3, 1, kafkaClusterConfiguration);
cluster = new StrimziKafkaCluster.StrimziKafkaClusterBuilder()
.withKraft()
.withNumberOfBrokers(1)
.withInternalTopicReplicationFactor(1)
.withSharedNetwork()
.build();
cluster.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ public class KafkaConnectorIT {

@BeforeAll
public static void before() throws IOException {
final Map<String, String> kafkaClusterConfiguration = new HashMap<>();
kafkaClusterConfiguration.put("zookeeper.connect", "zookeeper:2181");
cluster = new StrimziKafkaCluster(3, 1, kafkaClusterConfiguration);
cluster = new StrimziKafkaCluster.StrimziKafkaClusterBuilder()
.withKraft()
.withNumberOfBrokers(1)
.withInternalTopicReplicationFactor(1)
.withSharedNetwork()
.build();
cluster.start();

// Configure the Kubernetes Mock
Expand Down Expand Up @@ -109,10 +112,10 @@ public void beforeEach(TestInfo testInfo) throws InterruptedException {
.setEnabled(true)
));

// Start a 3 node connect cluster
// Start Connect cluster
connectCluster = new ConnectCluster()
.usingBrokers(cluster.getBootstrapServers())
.addConnectNodes(3);
.addConnectNodes(1);
connectCluster.startup();
}

Expand Down Expand Up @@ -163,7 +166,7 @@ public void testConnectorNotUpdatedWhenConfigUnchanged(VertxTestContext context)
KafkaConnectAssemblyOperator operator = new KafkaConnectAssemblyOperator(vertx, pfa, ros,
ClusterOperatorConfig.buildFromMap(Map.of(), KafkaVersionTestUtils.getKafkaVersionLookup()),
connect -> new KafkaConnectApiImpl(vertx),
connectCluster.getPort(2)
connectCluster.getPort(0)
) { };

Checkpoint async = context.checkpoint();
Expand Down Expand Up @@ -234,7 +237,7 @@ public void testConnectorResourceNotReadyWhenConnectorFailed(VertxTestContext co
KafkaConnectAssemblyOperator operator = new KafkaConnectAssemblyOperator(vertx, pfa, ros,
ClusterOperatorConfig.buildFromMap(Map.of(), KafkaVersionTestUtils.getKafkaVersionLookup()),
connect -> new KafkaConnectApiImpl(vertx),
connectCluster.getPort(2)
connectCluster.getPort(0)
) { };

operator.reconcileConnectorAndHandleResult(new Reconciliation("test", "KafkaConnect", namespace, "bogus"),
Expand Down Expand Up @@ -284,7 +287,7 @@ public void testConnectorResourceNotReadyWhenTaskFailed(VertxTestContext context
KafkaConnectAssemblyOperator operator = new KafkaConnectAssemblyOperator(vertx, pfa, ros,
ClusterOperatorConfig.buildFromMap(Map.of(), KafkaVersionTestUtils.getKafkaVersionLookup()),
connect -> new KafkaConnectApiImpl(vertx),
connectCluster.getPort(2)
connectCluster.getPort(0)
) { };

operator.reconcileConnectorAndHandleResult(new Reconciliation("test", "KafkaConnect", namespace, "bogus"),
Expand Down Expand Up @@ -345,7 +348,7 @@ public void testConnectorIsAutoRestarted(VertxTestContext context) {
KafkaConnectAssemblyOperator operator = new KafkaConnectAssemblyOperator(vertx, pfa, ros,
ClusterOperatorConfig.buildFromMap(Map.of(), KafkaVersionTestUtils.getKafkaVersionLookup()),
connect -> new KafkaConnectApiImpl(vertx),
connectCluster.getPort(2)
connectCluster.getPort(0)
) { };

operator.reconcileConnectorAndHandleResult(new Reconciliation("test", "KafkaConnect", namespace, "bogus"),
Expand Down Expand Up @@ -395,7 +398,7 @@ public void testTaskIsAutoRestarted(VertxTestContext context) {
KafkaConnectAssemblyOperator operator = new KafkaConnectAssemblyOperator(vertx, pfa, ros,
ClusterOperatorConfig.buildFromMap(Map.of(), KafkaVersionTestUtils.getKafkaVersionLookup()),
connect -> new KafkaConnectApiImpl(vertx),
connectCluster.getPort(2)
connectCluster.getPort(0)
) { };

operator.reconcileConnectorAndHandleResult(new Reconciliation("test", "KafkaConnect", namespace, "bogus"),
Expand Down
21 changes: 1 addition & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,12 @@
<junit-platform-surefire-provider.version>1.3.2</junit-platform-surefire-provider.version>
<opentest4j.version>1.2.0</opentest4j.version>
<jupiter.version>5.8.2</jupiter.version>
<strimzi-test-container.version>0.107.0</strimzi-test-container.version>
<strimzi-test-container.version>0.108.0</strimzi-test-container.version>
<mockserver.version>5.13.2</mockserver.version>
<mockwebserver.version>3.14.7</mockwebserver.version>
<valid4j.version>1.1</valid4j.version>
<javax.json.version>1.1.4</javax.json.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<kroxylicious-testing.version>0.9.0</kroxylicious-testing.version>
<kindcontainer.version>1.4.7</kindcontainer.version>
<junit4.version>4.13.2</junit4.version>
<skodjob.test-frame.version>0.7.0</skodjob.test-frame.version>
Expand Down Expand Up @@ -858,24 +857,6 @@
<artifactId>javax.servlet-api</artifactId>
<version>${javax-servlet.version}</version>
</dependency>
<dependency>
<groupId>io.kroxylicious.testing</groupId>
<artifactId>testing-api</artifactId>
<version>${kroxylicious-testing.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.kroxylicious.testing</groupId>
<artifactId>testing-junit5-extension</artifactId>
<version>${kroxylicious-testing.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.kroxylicious.testing</groupId>
<artifactId>testing-impl</artifactId>
<version>${kroxylicious-testing.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.dajudge.kindcontainer</groupId>
<artifactId>kindcontainer</artifactId>
Expand Down
32 changes: 4 additions & 28 deletions topic-operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,6 @@
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.kroxylicious.testing</groupId>
<artifactId>testing-api</artifactId>
</dependency>
<dependency>
<groupId>io.kroxylicious.testing</groupId>
<artifactId>testing-junit5-extension</artifactId>
</dependency>
<dependency>
<groupId>io.kroxylicious.testing</groupId>
<artifactId>testing-impl</artifactId>
</dependency>
<dependency>
<!-- Override since both kroxylicious.testing and strimzi-test-container have it as a dependency
and inheriting the version from strimzi-test-container results in errors -->
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-api</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
Expand Down Expand Up @@ -97,6 +77,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
<artifactId>strimzi-test-container</artifactId>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
<artifactId>test</artifactId>
Expand Down Expand Up @@ -132,11 +116,6 @@
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.13</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
<artifactId>operator-common</artifactId>
Expand Down Expand Up @@ -221,9 +200,6 @@
<ignoredUnusedDeclaredDependency>io.fabric8:kubernetes-httpclient-jdk</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-slf4j-impl</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.mockito:mockito-inline</ignoredUnusedDeclaredDependency>
<!-- required by kroxylicious.testing -->
<ignoredUnusedDeclaredDependency>org.apache.kafka:kafka_2.13</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>com.github.docker-java:docker-java-api</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
<ignoredNonTestScopedDependencies>
<ignoredNonTestScopedDependency>org.apache.logging.log4j:log4j-api</ignoredNonTestScopedDependency>
Expand Down
Loading

0 comments on commit bab6083

Please sign in to comment.