use of org.apache.kafka.streams.processor.internals.InternalTopicManager.ValidationResult in project kafka by apache.
the class InternalTopicManagerTest method shouldValidateSuccessfully.
@Test
public void shouldValidateSuccessfully() {
setupTopicInMockAdminClient(topic1, repartitionTopicConfig());
setupTopicInMockAdminClient(topic2, repartitionTopicConfig());
final InternalTopicConfig internalTopicConfig1 = setupRepartitionTopicConfig(topic1, 1);
final InternalTopicConfig internalTopicConfig2 = setupRepartitionTopicConfig(topic2, 1);
final ValidationResult validationResult = internalTopicManager.validate(mkMap(mkEntry(topic1, internalTopicConfig1), mkEntry(topic2, internalTopicConfig2)));
assertThat(validationResult.missingTopics(), empty());
assertThat(validationResult.misconfigurationsForTopics(), anEmptyMap());
}
use of org.apache.kafka.streams.processor.internals.InternalTopicManager.ValidationResult in project kafka by apache.
the class InternalTopicManagerTest method shouldReportMisconfigurationsOfCleanupPolicyForWindowedChangelogTopics.
@Test
public void shouldReportMisconfigurationsOfCleanupPolicyForWindowedChangelogTopics() {
final long retentionMs = 1000;
final long shorterRetentionMs = 900;
setupTopicInMockAdminClient(topic1, windowedChangelogConfig(retentionMs));
setupTopicInMockAdminClient(topic2, windowedChangelogConfig(shorterRetentionMs));
final Map<String, String> windowedChangelogConfigOnlyCleanupPolicyCompact = windowedChangelogConfig(retentionMs);
windowedChangelogConfigOnlyCleanupPolicyCompact.put(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_COMPACT);
setupTopicInMockAdminClient(topic3, windowedChangelogConfigOnlyCleanupPolicyCompact);
final Map<String, String> windowedChangelogConfigOnlyCleanupPolicyDelete = windowedChangelogConfig(shorterRetentionMs);
windowedChangelogConfigOnlyCleanupPolicyDelete.put(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_DELETE);
setupTopicInMockAdminClient(topic4, windowedChangelogConfigOnlyCleanupPolicyDelete);
final Map<String, String> windowedChangelogConfigWithRetentionBytes = windowedChangelogConfig(retentionMs);
windowedChangelogConfigWithRetentionBytes.put(TopicConfig.RETENTION_BYTES_CONFIG, "1024");
setupTopicInMockAdminClient(topic5, windowedChangelogConfigWithRetentionBytes);
final InternalTopicConfig internalTopicConfig1 = setupWindowedChangelogTopicConfig(topic1, 1, retentionMs);
final InternalTopicConfig internalTopicConfig2 = setupWindowedChangelogTopicConfig(topic2, 1, retentionMs);
final InternalTopicConfig internalTopicConfig3 = setupWindowedChangelogTopicConfig(topic3, 1, retentionMs);
final InternalTopicConfig internalTopicConfig4 = setupWindowedChangelogTopicConfig(topic4, 1, retentionMs);
final InternalTopicConfig internalTopicConfig5 = setupWindowedChangelogTopicConfig(topic5, 1, retentionMs);
final ValidationResult validationResult = internalTopicManager.validate(mkMap(mkEntry(topic1, internalTopicConfig1), mkEntry(topic2, internalTopicConfig2), mkEntry(topic3, internalTopicConfig3), mkEntry(topic4, internalTopicConfig4), mkEntry(topic5, internalTopicConfig5)));
final Map<String, List<String>> misconfigurationsForTopics = validationResult.misconfigurationsForTopics();
assertThat(validationResult.missingTopics(), empty());
assertThat(misconfigurationsForTopics.size(), is(3));
assertThat(misconfigurationsForTopics, hasKey(topic2));
assertThat(misconfigurationsForTopics.get(topic2).size(), is(1));
assertThat(misconfigurationsForTopics.get(topic2).get(0), is("Retention time (" + TopicConfig.RETENTION_MS_CONFIG + ") of existing internal topic " + topic2 + " is " + shorterRetentionMs + " but should be " + retentionMs + " or larger."));
assertThat(misconfigurationsForTopics, hasKey(topic4));
assertThat(misconfigurationsForTopics.get(topic4).size(), is(1));
assertThat(misconfigurationsForTopics.get(topic4).get(0), is("Retention time (" + TopicConfig.RETENTION_MS_CONFIG + ") of existing internal topic " + topic4 + " is " + shorterRetentionMs + " but should be " + retentionMs + " or larger."));
assertThat(misconfigurationsForTopics, hasKey(topic5));
assertThat(misconfigurationsForTopics.get(topic5).size(), is(1));
assertThat(misconfigurationsForTopics.get(topic5).get(0), is("Retention byte (" + TopicConfig.RETENTION_BYTES_CONFIG + ") of existing internal topic " + topic5 + " is set but it should be unset."));
assertThat(misconfigurationsForTopics, not(hasKey(topic1)));
assertThat(misconfigurationsForTopics, not(hasKey(topic3)));
}
use of org.apache.kafka.streams.processor.internals.InternalTopicManager.ValidationResult in project kafka by apache.
the class InternalTopicManagerTest method shouldReportMissingTopics.
@Test
public void shouldReportMissingTopics() {
final String missingTopic1 = "missingTopic1";
final String missingTopic2 = "missingTopic2";
setupTopicInMockAdminClient(topic1, repartitionTopicConfig());
final InternalTopicConfig internalTopicConfig1 = setupRepartitionTopicConfig(topic1, 1);
final InternalTopicConfig internalTopicConfig2 = setupRepartitionTopicConfig(missingTopic1, 1);
final InternalTopicConfig internalTopicConfig3 = setupRepartitionTopicConfig(missingTopic2, 1);
final ValidationResult validationResult = internalTopicManager.validate(mkMap(mkEntry(topic1, internalTopicConfig1), mkEntry(missingTopic1, internalTopicConfig2), mkEntry(missingTopic2, internalTopicConfig3)));
final Set<String> missingTopics = validationResult.missingTopics();
assertThat(missingTopics.size(), is(2));
assertThat(missingTopics, hasItem(missingTopic1));
assertThat(missingTopics, hasItem(missingTopic2));
assertThat(validationResult.misconfigurationsForTopics(), anEmptyMap());
}
Aggregations