-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-14569: Migrate Connect's integration test EmbeddedKafkaCluster from ZK to KRaft mode #13375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
yashmayya
wants to merge
6
commits into
apache:trunk
from
yashmayya:KAFKA-14569-migrate-embedded-kafka-to-kraft
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef4ab9f
Migrate Connect's integration test EmbeddedKafkaCluster from ZK to KR…
yashmayya 5428bfe
Minor refactors
yashmayya 60a9540
Remove redundant putIfAbsent method
yashmayya 724aed7
Produce each record synchronously for MM2 IT - testReplicationWithEmp…
yashmayya bc07e19
Only use listener security protocol map to configure non-plaintext li…
yashmayya 482b7e9
Allow overriding listeners for testBrokerCoordinator / restarting onl…
yashmayya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,45 +30,49 @@ | |
| import org.apache.kafka.clients.consumer.OffsetAndMetadata; | ||
| import org.apache.kafka.clients.producer.Producer; | ||
| import org.apache.kafka.clients.producer.ProducerRecord; | ||
| import org.apache.kafka.clients.producer.RecordMetadata; | ||
| import org.apache.kafka.common.TopicPartition; | ||
| import org.apache.kafka.common.config.ConfigResource; | ||
| import org.apache.kafka.common.config.TopicConfig; | ||
| import org.apache.kafka.common.utils.Exit; | ||
| import org.apache.kafka.common.TopicPartition; | ||
| import org.apache.kafka.common.utils.Time; | ||
| import org.apache.kafka.common.utils.Timer; | ||
| import org.apache.kafka.common.utils.Utils; | ||
| import org.apache.kafka.connect.connector.Connector; | ||
| import org.apache.kafka.connect.mirror.Checkpoint; | ||
| import org.apache.kafka.connect.mirror.DefaultConfigPropertyFilter; | ||
| import org.apache.kafka.connect.mirror.MirrorCheckpointConnector; | ||
| import org.apache.kafka.connect.mirror.MirrorClient; | ||
| import org.apache.kafka.connect.mirror.MirrorHeartbeatConnector; | ||
| import org.apache.kafka.connect.mirror.MirrorMakerConfig; | ||
| import org.apache.kafka.connect.mirror.MirrorSourceConnector; | ||
| import org.apache.kafka.connect.mirror.MirrorUtils; | ||
| import org.apache.kafka.connect.mirror.SourceAndTarget; | ||
| import org.apache.kafka.connect.mirror.Checkpoint; | ||
| import org.apache.kafka.connect.mirror.MirrorCheckpointConnector; | ||
| import org.apache.kafka.connect.mirror.TestUtils; | ||
| import org.apache.kafka.connect.runtime.rest.entities.ConnectorOffset; | ||
| import org.apache.kafka.connect.runtime.rest.entities.ConnectorOffsets; | ||
| import org.apache.kafka.connect.util.clusters.EmbeddedConnectCluster; | ||
| import org.apache.kafka.connect.util.clusters.EmbeddedKafkaCluster; | ||
| import org.apache.kafka.connect.util.clusters.UngracefulShutdownException; | ||
| 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.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.Properties; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ExecutionException; | ||
| import java.util.concurrent.Future; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.concurrent.TimeoutException; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
@@ -77,19 +81,12 @@ | |
| import java.util.function.LongUnaryOperator; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import org.junit.jupiter.api.Tag; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import static org.apache.kafka.test.TestUtils.waitForCondition; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
| import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| /** | ||
| * Tests MM2 replication and failover/failback logic. | ||
|
|
@@ -429,12 +426,12 @@ public void testReplicationWithEmptyPartition() throws Exception { | |
| try (Consumer<byte[], byte[]> primaryConsumer = primary.kafka().createConsumerAndSubscribeTo(consumerProps, topic)) { | ||
| waitForConsumingAllRecords(primaryConsumer, expectedRecords); | ||
| } | ||
|
|
||
| // one way replication from primary to backup | ||
| mm2Props.put(BACKUP_CLUSTER_ALIAS + "->" + PRIMARY_CLUSTER_ALIAS + ".enabled", "false"); | ||
| mm2Config = new MirrorMakerConfig(mm2Props); | ||
| waitUntilMirrorMakerIsRunning(backup, CONNECTOR_LIST, mm2Config, PRIMARY_CLUSTER_ALIAS, BACKUP_CLUSTER_ALIAS); | ||
|
|
||
| // sleep few seconds to have MM2 finish replication so that "end" consumer will consume some record | ||
| Thread.sleep(TimeUnit.SECONDS.toMillis(3)); | ||
|
|
||
|
|
@@ -445,7 +442,7 @@ public void testReplicationWithEmptyPartition() throws Exception { | |
| backupTopic)) { | ||
| waitForConsumingAllRecords(backupConsumer, expectedRecords); | ||
| } | ||
|
|
||
| try (Admin backupClient = backup.kafka().createAdminClient()) { | ||
| // retrieve the consumer group offset from backup cluster | ||
| Map<TopicPartition, OffsetAndMetadata> remoteOffsets = | ||
|
|
@@ -1093,14 +1090,11 @@ protected Producer<byte[], byte[]> initializeProducer(EmbeddedConnectCluster clu | |
| * @param records Records to send in one parallel batch | ||
| */ | ||
| protected void produceMessages(Producer<byte[], byte[]> producer, List<ProducerRecord<byte[], byte[]>> records) { | ||
| List<Future<RecordMetadata>> futures = new ArrayList<>(); | ||
| for (ProducerRecord<byte[], byte[]> record : records) { | ||
| futures.add(producer.send(record)); | ||
| } | ||
| Timer timer = Time.SYSTEM.timer(RECORD_PRODUCE_DURATION_MS); | ||
|
|
||
| try { | ||
| for (Future<RecordMetadata> future : futures) { | ||
| future.get(timer.remainingMs(), TimeUnit.MILLISECONDS); | ||
| for (ProducerRecord<byte[], byte[]> record : records) { | ||
| producer.send(record).get(timer.remainingMs(), TimeUnit.MILLISECONDS); | ||
|
Comment on lines
1096
to
1097
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| timer.update(); | ||
| } | ||
| } catch (ExecutionException | InterruptedException | TimeoutException e) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.