-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-13255: use exclude filter for new topics #11401
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6a4cffc
KAFKA-13255: use exclude filter for new topics
bdesert 57cfc24
KAFKA-13255: add test for property exclude filter
bdesert b9d415d
adding exclude topic config integrated test
bdesert 75ff17c
adding exclude topic config unit test test
bdesert 3d87dff
adding exclude topic config unit test test
bdesert 2d52d51
integration test updates include simplification and order change sugg…
bdesert 3ba6d6c
integration test fix for IdentityReplication and optimizing the test …
bdesert 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 |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| import org.apache.kafka.common.utils.Exit; | ||
| import org.apache.kafka.common.TopicPartition; | ||
| import org.apache.kafka.connect.connector.Connector; | ||
| import org.apache.kafka.connect.mirror.DefaultConfigPropertyFilter; | ||
| import org.apache.kafka.connect.mirror.MirrorClient; | ||
| import org.apache.kafka.connect.mirror.MirrorHeartbeatConnector; | ||
| import org.apache.kafka.connect.mirror.MirrorMakerConfig; | ||
|
|
@@ -60,6 +61,7 @@ | |
| import org.slf4j.LoggerFactory; | ||
|
|
||
| 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.assertNotNull; | ||
|
|
@@ -155,6 +157,9 @@ public void startClusters(Map<String, String> additionalMM2Config) throws Except | |
| mm2Props.putAll(basicMM2Config()); | ||
| mm2Props.putAll(additionalMM2Config); | ||
|
|
||
| // exclude topic config: | ||
| mm2Props.put(DefaultConfigPropertyFilter.CONFIG_PROPERTIES_EXCLUDE_CONFIG, "delete\\.retention\\..*"); | ||
|
|
||
| mm2Config = new MirrorMakerConfig(mm2Props); | ||
| primaryWorkerProps = mm2Config.workerConfig(new SourceAndTarget(BACKUP_CLUSTER_ALIAS, PRIMARY_CLUSTER_ALIAS)); | ||
| backupWorkerProps.putAll(mm2Config.workerConfig(new SourceAndTarget(PRIMARY_CLUSTER_ALIAS, BACKUP_CLUSTER_ALIAS))); | ||
|
|
@@ -259,7 +264,8 @@ public void testReplication() throws Exception { | |
| waitForTopicCreated(primary, "mm2-offset-syncs.backup.internal"); | ||
| assertEquals(TopicConfig.CLEANUP_POLICY_COMPACT, getTopicConfig(backup.kafka(), "primary.test-topic-1", TopicConfig.CLEANUP_POLICY_CONFIG), | ||
| "topic config was not synced"); | ||
|
|
||
| createAndTestNewTopicWithConfigFilter(); | ||
|
|
||
| assertEquals(NUM_RECORDS_PRODUCED, primary.kafka().consume(NUM_RECORDS_PRODUCED, RECORD_TRANSFER_DURATION_MS, "test-topic-1").count(), | ||
| "Records were not produced to primary cluster."); | ||
| assertEquals(NUM_RECORDS_PRODUCED, backup.kafka().consume(NUM_RECORDS_PRODUCED, RECORD_TRANSFER_DURATION_MS, "primary.test-topic-1").count(), | ||
|
|
@@ -429,6 +435,7 @@ public void testOneWayReplicationWithAutoOffsetSync() throws InterruptedExceptio | |
| // 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); | ||
|
|
@@ -519,6 +526,44 @@ public void testOffsetSyncsTopicsOnTarget() throws Exception { | |
| assertFalse(primaryTopics.contains("mm2-offset-syncs." + BACKUP_CLUSTER_ALIAS + ".internal")); | ||
| } | ||
|
|
||
| /* | ||
| * Run tests for Exclude Filter for copying topic configurations | ||
| */ | ||
| void createAndTestNewTopicWithConfigFilter() throws Exception { | ||
| // create topic with configuration to test: | ||
| final Map<String, String> topicConfig = new HashMap<>(); | ||
| topicConfig.put("delete.retention.ms", "1000"); // should be excluded (default value is 86400000) | ||
| topicConfig.put("retention.bytes", "1000"); // should be included, default value is -1 | ||
|
|
||
| final String topic = "test-topic-with-config"; | ||
| final String backupTopic = backupClusterTopicName(topic); | ||
|
|
||
| primary.kafka().createTopic(topic, NUM_PARTITIONS, 1, topicConfig); | ||
| waitForTopicCreated(backup, backupTopic); | ||
|
|
||
| String primaryConfig, backupConfig; | ||
|
|
||
| primaryConfig = getTopicConfig(primary.kafka(), topic, "delete.retention.ms"); | ||
| backupConfig = getTopicConfig(backup.kafka(), backupTopic, "delete.retention.ms"); | ||
| assertNotEquals(primaryConfig, backupConfig, | ||
| "`delete.retention.ms` should be different, because it's in exclude filter! "); | ||
|
|
||
| // regression test for the config that are still supposed to be replicated | ||
| primaryConfig = getTopicConfig(primary.kafka(), topic, "retention.bytes"); | ||
| backupConfig = getTopicConfig(backup.kafka(), backupTopic, "retention.bytes"); | ||
| assertEquals(primaryConfig, backupConfig, | ||
| "`retention.bytes` should be the same, because it isn't in exclude filter! "); | ||
| assertEquals("1000", backupConfig, | ||
| "`retention.bytes` should be the same, because it's explicitly defined! "); | ||
|
Member
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.
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. updated per suggestions |
||
| } | ||
|
|
||
| /* | ||
| * Returns expected topic name on target cluster. | ||
| */ | ||
| String backupClusterTopicName(String topic) { | ||
| return PRIMARY_CLUSTER_ALIAS + "." + topic; | ||
| } | ||
|
|
||
| /* | ||
| * launch the connectors on kafka connect cluster and check if they are running | ||
| */ | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that calling verify on
targetConfig()is not the best. But I think we should call verify oncreateNewTopics(any())to ensure our mocked method, and the assertions, actually run.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree. with a small correction of
createNewTopics(any(), any()). since thetargetConfig()is being called from overloaded method with two params.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, the code we changed is actually in
createNewTopics(any(), any()). As we explicitly call that method ourselves, I don't think the verify call adds a lot of value. But I think it's fine, it shouldn't hurt