urbandan commented on code in PR #13137: URL: https://github.com/apache/kafka/pull/13137#discussion_r1091577828
########## connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/DedicatedMirrorIntegrationTest.java: ########## @@ -0,0 +1,228 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.connect.mirror.integration; + +import org.apache.kafka.clients.admin.Admin; +import org.apache.kafka.clients.admin.NewTopic; +import org.apache.kafka.clients.consumer.Consumer; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.common.utils.Utils; +import org.apache.kafka.connect.mirror.MirrorMaker; +import org.apache.kafka.connect.util.clusters.EmbeddedKafkaCluster; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.time.Duration; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; + +import static org.apache.kafka.clients.consumer.ConsumerConfig.AUTO_OFFSET_RESET_CONFIG; +import static org.apache.kafka.test.TestUtils.waitForCondition; + +@Tag("integration") +public class DedicatedMirrorIntegrationTest { + + private static final Logger log = LoggerFactory.getLogger(DedicatedMirrorIntegrationTest.class); + + private static final int TOPIC_CREATION_TIMEOUT_MS = 30_000; + private static final int TOPIC_REPLICATION_TIMEOUT_MS = 30_000; + + private Map<String, EmbeddedKafkaCluster> kafkaClusters; + private Map<String, MirrorMaker> mirrorMakers; + + @BeforeEach + public void setup() { + kafkaClusters = new HashMap<>(); + mirrorMakers = new HashMap<>(); + } + + @AfterEach + public void teardown() throws Throwable { + AtomicReference<Throwable> shutdownFailure = new AtomicReference<>(); + mirrorMakers.forEach((name, mirrorMaker) -> + Utils.closeQuietly(mirrorMaker::stop, "MirrorMaker worker '" + name + "'", shutdownFailure) + ); + kafkaClusters.forEach((name, kafkaCluster) -> + Utils.closeQuietly(kafkaCluster::stop, "Embedded Kafka cluster '" + name + "'", shutdownFailure) + ); + if (shutdownFailure.get() != null) { + throw shutdownFailure.get(); + } + } + + private EmbeddedKafkaCluster startKafkaCluster(String name, int numBrokers, Properties brokerProperties) { + if (kafkaClusters.containsKey(name)) + throw new IllegalStateException("Cannot register multiple Kafka clusters with the same name"); + + EmbeddedKafkaCluster result = new EmbeddedKafkaCluster(numBrokers, brokerProperties); + kafkaClusters.put(name, result); + + result.start(); + + return result; + } + + private MirrorMaker startMirrorMaker(String name, Map<String, String> mmProps) { + if (mirrorMakers.containsKey(name)) + throw new IllegalStateException("Cannot register multiple MirrorMaker nodes with the same name"); + + MirrorMaker result = new MirrorMaker(mmProps); + mirrorMakers.put(name, result); + + result.start(); + + return result; + } + + /** + * Test that a multi-node dedicated cluster is able to dynamically detect new topics at runtime Review Comment: Thanks for the clarification. I think using the EOS endpoints should be enough, as I don't really have any ideas on how to make sure that the task config update is triggered. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org