use of org.apache.kafka.common.config.ConfigResource in project kafka by apache.
the class InternalTopicManagerTest method shouldThrowWhenTopicDescriptionsDoNotContainTopicDuringValidation.
@Test
public void shouldThrowWhenTopicDescriptionsDoNotContainTopicDuringValidation() {
final AdminClient admin = EasyMock.createNiceMock(AdminClient.class);
final InternalTopicManager topicManager = new InternalTopicManager(time, admin, new StreamsConfig(config));
final KafkaFutureImpl<TopicDescription> topicDescriptionSuccessfulFuture = new KafkaFutureImpl<>();
topicDescriptionSuccessfulFuture.complete(new TopicDescription(topic1, false, Collections.singletonList(new TopicPartitionInfo(0, broker1, cluster, Collections.emptyList()))));
EasyMock.expect(admin.describeTopics(Collections.singleton(topic1))).andStubAnswer(() -> new MockDescribeTopicsResult(mkMap(mkEntry(topic2, topicDescriptionSuccessfulFuture))));
final KafkaFutureImpl<Config> topicConfigSuccessfulFuture = new KafkaFutureImpl<>();
topicConfigSuccessfulFuture.complete(new Config(Collections.emptySet()));
final ConfigResource topicResource = new ConfigResource(Type.TOPIC, topic1);
EasyMock.expect(admin.describeConfigs(Collections.singleton(topicResource))).andStubAnswer(() -> new MockDescribeConfigsResult(mkMap(mkEntry(topicResource, topicConfigSuccessfulFuture))));
EasyMock.replay(admin);
final InternalTopicConfig internalTopicConfig = setupRepartitionTopicConfig(topic1, 1);
assertThrows(IllegalStateException.class, () -> topicManager.validate(Collections.singletonMap(topic1, internalTopicConfig)));
}
use of org.apache.kafka.common.config.ConfigResource in project kafka by apache.
the class InternalTopicManagerTest method shouldThrowWhenConfigDescriptionsDoNotContainTopicDuringValidation.
@Test
public void shouldThrowWhenConfigDescriptionsDoNotContainTopicDuringValidation() {
final AdminClient admin = EasyMock.createNiceMock(AdminClient.class);
final InternalTopicManager topicManager = new InternalTopicManager(time, admin, new StreamsConfig(config));
final KafkaFutureImpl<TopicDescription> topicDescriptionSuccessfulFuture = new KafkaFutureImpl<>();
topicDescriptionSuccessfulFuture.complete(new TopicDescription(topic1, false, Collections.singletonList(new TopicPartitionInfo(0, broker1, cluster, Collections.emptyList()))));
EasyMock.expect(admin.describeTopics(Collections.singleton(topic1))).andStubAnswer(() -> new MockDescribeTopicsResult(mkMap(mkEntry(topic1, topicDescriptionSuccessfulFuture))));
final KafkaFutureImpl<Config> topicConfigSuccessfulFuture = new KafkaFutureImpl<>();
topicConfigSuccessfulFuture.complete(new Config(Collections.emptySet()));
final ConfigResource topicResource1 = new ConfigResource(Type.TOPIC, topic1);
final ConfigResource topicResource2 = new ConfigResource(Type.TOPIC, topic2);
EasyMock.expect(admin.describeConfigs(Collections.singleton(topicResource1))).andStubAnswer(() -> new MockDescribeConfigsResult(mkMap(mkEntry(topicResource2, topicConfigSuccessfulFuture))));
EasyMock.replay(admin);
final InternalTopicConfig internalTopicConfig = setupRepartitionTopicConfig(topic1, 1);
assertThrows(IllegalStateException.class, () -> topicManager.validate(Collections.singletonMap(topic1, internalTopicConfig)));
}
use of org.apache.kafka.common.config.ConfigResource in project kafka by apache.
the class InternalTopicManagerTest method shouldThrowWhenConfigDescriptionsDoNotContainConfigDuringValidation.
private void shouldThrowWhenConfigDescriptionsDoNotContainConfigDuringValidation(final InternalTopicConfig streamsSideTopicConfig, final Config brokerSideTopicConfig) {
final AdminClient admin = EasyMock.createNiceMock(AdminClient.class);
final InternalTopicManager topicManager = new InternalTopicManager(time, admin, new StreamsConfig(config));
final KafkaFutureImpl<TopicDescription> topicDescriptionSuccessfulFuture = new KafkaFutureImpl<>();
topicDescriptionSuccessfulFuture.complete(new TopicDescription(topic1, false, Collections.singletonList(new TopicPartitionInfo(0, broker1, cluster, Collections.emptyList()))));
EasyMock.expect(admin.describeTopics(Collections.singleton(topic1))).andStubAnswer(() -> new MockDescribeTopicsResult(mkMap(mkEntry(topic1, topicDescriptionSuccessfulFuture))));
final KafkaFutureImpl<Config> topicConfigSuccessfulFuture = new KafkaFutureImpl<>();
topicConfigSuccessfulFuture.complete(brokerSideTopicConfig);
final ConfigResource topicResource1 = new ConfigResource(Type.TOPIC, topic1);
EasyMock.expect(admin.describeConfigs(Collections.singleton(topicResource1))).andStubAnswer(() -> new MockDescribeConfigsResult(mkMap(mkEntry(topicResource1, topicConfigSuccessfulFuture))));
EasyMock.replay(admin);
assertThrows(IllegalStateException.class, () -> topicManager.validate(Collections.singletonMap(topic1, streamsSideTopicConfig)));
}
use of org.apache.kafka.common.config.ConfigResource in project kafka by apache.
the class InternalTopicManagerTest method shouldOnlyRetryNotSuccessfulFuturesDuringValidation.
@Test
public void shouldOnlyRetryNotSuccessfulFuturesDuringValidation() {
final AdminClient admin = EasyMock.createNiceMock(AdminClient.class);
final InternalTopicManager topicManager = new InternalTopicManager(time, admin, new StreamsConfig(config));
final KafkaFutureImpl<TopicDescription> topicDescriptionFailFuture = new KafkaFutureImpl<>();
topicDescriptionFailFuture.completeExceptionally(new LeaderNotAvailableException("Leader Not Available!"));
final KafkaFutureImpl<TopicDescription> topicDescriptionSuccessfulFuture1 = new KafkaFutureImpl<>();
topicDescriptionSuccessfulFuture1.complete(new TopicDescription(topic1, false, Collections.singletonList(new TopicPartitionInfo(0, broker1, cluster, Collections.emptyList()))));
final KafkaFutureImpl<TopicDescription> topicDescriptionSuccessfulFuture2 = new KafkaFutureImpl<>();
topicDescriptionSuccessfulFuture2.complete(new TopicDescription(topic2, false, Collections.singletonList(new TopicPartitionInfo(0, broker1, cluster, Collections.emptyList()))));
EasyMock.expect(admin.describeTopics(mkSet(topic1, topic2))).andAnswer(() -> new MockDescribeTopicsResult(mkMap(mkEntry(topic1, topicDescriptionSuccessfulFuture1), mkEntry(topic2, topicDescriptionFailFuture))));
EasyMock.expect(admin.describeTopics(mkSet(topic2))).andAnswer(() -> new MockDescribeTopicsResult(mkMap(mkEntry(topic2, topicDescriptionSuccessfulFuture2))));
final KafkaFutureImpl<Config> topicConfigSuccessfulFuture = new KafkaFutureImpl<>();
topicConfigSuccessfulFuture.complete(new Config(repartitionTopicConfig().entrySet().stream().map(entry -> new ConfigEntry(entry.getKey(), entry.getValue())).collect(Collectors.toSet())));
final ConfigResource topicResource1 = new ConfigResource(Type.TOPIC, topic1);
final ConfigResource topicResource2 = new ConfigResource(Type.TOPIC, topic2);
EasyMock.expect(admin.describeConfigs(mkSet(topicResource1, topicResource2))).andAnswer(() -> new MockDescribeConfigsResult(mkMap(mkEntry(topicResource1, topicConfigSuccessfulFuture), mkEntry(topicResource2, topicConfigSuccessfulFuture))));
EasyMock.replay(admin);
final InternalTopicConfig internalTopicConfig1 = setupRepartitionTopicConfig(topic1, 1);
final InternalTopicConfig internalTopicConfig2 = setupRepartitionTopicConfig(topic2, 1);
final ValidationResult validationResult = topicManager.validate(mkMap(mkEntry(topic1, internalTopicConfig1), mkEntry(topic2, internalTopicConfig2)));
assertThat(validationResult.missingTopics(), empty());
assertThat(validationResult.misconfigurationsForTopics(), anEmptyMap());
EasyMock.verify(admin);
}
use of org.apache.kafka.common.config.ConfigResource in project kafka by apache.
the class ReplicationControlManagerTest method assertEmptyTopicConfigs.
private void assertEmptyTopicConfigs(ReplicationControlTestContext ctx, String topic) {
Map<String, String> configs = ctx.configurationControl.getConfigs(new ConfigResource(ConfigResource.Type.TOPIC, topic));
assertEquals(Collections.emptyMap(), configs);
}
Aggregations