-
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
Changes from 2 commits
6a4cffc
57cfc24
b9d415d
75ff17c
3d87dff
2d52d51
3ba6d6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,6 +152,44 @@ public void testConfigPropertyFiltering() { | |
| .anyMatch(x -> x.name().equals("min.insync.replicas")), "should not replicate excluded properties"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testConfigPropertyFilteringExclude() { | ||
|
|
||
| Map<String, Object> mmConfig = new HashMap<>(); | ||
| mmConfig.put(DefaultConfigPropertyFilter.CONFIG_PROPERTIES_EXCLUDE_CONFIG, "follower\\.replication\\.throttled\\.replicas, " | ||
| + "leader\\.replication\\.throttled\\.replicas, " | ||
| + "message\\.timestamp\\.difference\\.max\\.ms, " | ||
| + "message\\.timestamp\\.type, " | ||
| + "unclean\\.leader\\.election\\.enable, " | ||
| + "min\\.insync\\.replicas," | ||
| + "exclude_param.*"); | ||
|
|
||
| DefaultConfigPropertyFilter filter = new DefaultConfigPropertyFilter(); | ||
| filter.configure(mmConfig); | ||
|
|
||
| MirrorSourceConnector connector = new MirrorSourceConnector(new SourceAndTarget("source", "target"), | ||
| new DefaultReplicationPolicy(), x -> true, filter); | ||
| ArrayList<ConfigEntry> entries = new ArrayList<>(); | ||
| entries.add(new ConfigEntry("name-1", "value-1")); | ||
| entries.add(new ConfigEntry("exclude_param.param1", "value-param1")); | ||
| entries.add(new ConfigEntry("min.insync.replicas", "2")); | ||
| Config config = new Config(entries); | ||
| Config targetConfig = connector.targetConfig(config); | ||
|
|
||
| // property 'name-1' isn't defined in the exclude filter -> should be replicated | ||
| assertTrue(targetConfig.entries().stream().anyMatch(x -> x.name().equals("name-1")), | ||
| "should replicate properties"); | ||
|
|
||
| // this property is in default list, just double check it: | ||
| String prop1 = "min.insync.replicas"; | ||
| assertFalse(targetConfig.entries().stream().anyMatch(x -> x.name().equals(prop1)), | ||
| "should not replicate excluded properties " + prop1); | ||
| // this property is only in exclude filter custom parameter, also tests regex on the way: | ||
| String prop2 = "exclude_param.param1"; | ||
| assertFalse(targetConfig.entries().stream().anyMatch(x -> x.name().equals(prop2)), | ||
| "should not replicate excluded properties " + prop2); | ||
| } | ||
|
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. I agree that calling verify on
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. agree. with a small correction of
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. Ah right, the code we changed is actually in |
||
|
|
||
| @Test | ||
| public void testMirrorSourceConnectorTaskConfig() { | ||
| List<TopicPartition> knownSourceTopicPartitions = new ArrayList<>(); | ||
|
|
||
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.
Even without the code change, this test is passing. It's because it's calling
connector.targetConfig()while the fix is increateNewTopics().Uh oh!
There was an error while loading. Please reload this page.
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.
@mimaison, thanks for the comments. Makes perfect sense.
I'm adding integration test to address your suggestion.
Along with that, i'm still keeping the unitTest committed before, so it will test configuration filtering logic without integration. The method I've added to unitTest follows the suit of the very previous test
testConfigPropertyFiltering, which tests default exclude list this particular way.