use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicOperatorTest method testOnKafkaTopicAdded_ignorable.
/**
* Test what happens when a non-topic KafkaTopic gets created in kubernetes
*/
@Test
public void testOnKafkaTopicAdded_ignorable(VertxTestContext context) {
KafkaTopic kafkaTopic = new KafkaTopicBuilder().withMetadata(new ObjectMetaBuilder().withName("non-topic").build()).build();
Checkpoint async = context.checkpoint();
K8sTopicWatcher w = new K8sTopicWatcher(topicOperator, Future.succeededFuture(), () -> {
});
w.eventReceived(ADDED, kafkaTopic);
mockKafka.assertEmpty(context);
mockTopicStore.assertEmpty(context);
async.flag();
}
use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicSerializationTest method testErrorInReplicas.
@Test
public void testErrorInReplicas() {
KafkaTopic kafkaTopic = new KafkaTopicBuilder().withMetadata(new ObjectMetaBuilder().withName("my-topic").build()).withNewSpec().withReplicas(-1).withPartitions(1).withConfig(emptyMap()).endSpec().build();
try {
TopicSerialization.fromTopicResource(kafkaTopic);
fail("Should throw");
} catch (InvalidTopicException e) {
assertThat(e.getMessage(), is("KafkaTopic's spec.replicas should be between 1 and 32767 inclusive"));
}
}
use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicSerializationTest method testErrorInDefaultTopicName.
@Test
public void testErrorInDefaultTopicName() {
// The problem with this resource name is it's too long to be a legal topic name
String illegalAsATopicName = "012345678901234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890123456789012345678901234567890123456789" + "012345678901234567890123456789";
KafkaTopic kafkaTopic = new KafkaTopicBuilder().withMetadata(new ObjectMetaBuilder().withName(illegalAsATopicName).build()).withNewSpec().withReplicas(1).withPartitions(1).withConfig(emptyMap()).endSpec().build();
try {
TopicSerialization.fromTopicResource(kafkaTopic);
fail("Should throw");
} catch (InvalidTopicException e) {
assertThat(e.getMessage(), is("KafkaTopics's spec.topicName property is absent and KafkaTopics's metadata.name is invalid as a topic name: " + "Topic name is illegal, it can't be longer than 249 characters, Topic name: " + illegalAsATopicName));
}
}
use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicSerializationTest method testErrorInPartitions.
@Test
public void testErrorInPartitions() {
KafkaTopic kafkaTopic = new KafkaTopicBuilder().withMetadata(new ObjectMetaBuilder().withName("my-topic").build()).withNewSpec().withReplicas(1).withPartitions(-1).withConfig(emptyMap()).endSpec().build();
try {
TopicSerialization.fromTopicResource(kafkaTopic);
fail("Should throw");
} catch (InvalidTopicException e) {
assertThat(e.getMessage(), is("KafkaTopic's spec.partitions should be strictly greater than 0"));
}
}
use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicSerializationTest method testErrorInTopicName.
@Test
public void testErrorInTopicName() {
KafkaTopic kafkaTopic = new KafkaTopicBuilder().withMetadata(new ObjectMetaBuilder().withName("foo").build()).withNewSpec().withReplicas(1).withPartitions(1).withConfig(emptyMap()).withTopicName("An invalid topic name!").endSpec().build();
try {
TopicSerialization.fromTopicResource(kafkaTopic);
fail("Should throw");
} catch (InvalidTopicException e) {
assertThat(e.getMessage(), is("KafkaTopics's spec.topicName property is invalid as a topic name: Topic name \"An invalid topic name!\" is illegal, it contains a character other than ASCII alphanumerics, '.', '_' and '-'"));
}
}
Aggregations