use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener in project strimzi by strimzi.
the class ListenersValidatorTest method testValidateDuplicateNames.
@ParallelTest
public void testValidateDuplicateNames() {
GenericKafkaListener listener1 = new GenericKafkaListenerBuilder().withName("listener1").withPort(9900).withType(KafkaListenerType.INTERNAL).build();
GenericKafkaListener listener2 = new GenericKafkaListenerBuilder().withName("listener2").withPort(9901).withType(KafkaListenerType.INTERNAL).build();
GenericKafkaListener listener3 = new GenericKafkaListenerBuilder().withName("listener1").withPort(9902).withType(KafkaListenerType.INTERNAL).build();
List<GenericKafkaListener> listeners = asList(listener1, listener2, listener3);
assertThat(ListenersValidator.validateAndGetErrorMessages(3, listeners), containsInAnyOrder("every listener needs to have a unique name"));
}
use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener in project strimzi by strimzi.
the class ListenersValidatorTest method testTlsAuthOnNonTlsListener.
@ParallelTest
public void testTlsAuthOnNonTlsListener() {
GenericKafkaListener listener1 = new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).withNewKafkaListenerAuthenticationTlsAuth().endKafkaListenerAuthenticationTlsAuth().build();
List<GenericKafkaListener> listeners = asList(listener1);
assertThat(ListenersValidator.validateAndGetErrorMessages(3, listeners), containsInAnyOrder("listener plain cannot use tls type authentication with disabled TLS encryption"));
}
use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener in project strimzi by strimzi.
the class ListenersValidatorTest method testIngressListener.
@ParallelTest
public void testIngressListener() {
String name = "ingress";
GenericKafkaListener listener1 = new GenericKafkaListenerBuilder().withName(name).withPort(9092).withType(KafkaListenerType.INGRESS).withTls(true).withNewConfiguration().withIngressClass("my-ingress").withUseServiceDnsDomain(true).withExternalTrafficPolicy(ExternalTrafficPolicy.LOCAL).withIpFamilyPolicy(IpFamilyPolicy.REQUIRE_DUAL_STACK).withIpFamilies(IpFamily.IPV4, IpFamily.IPV6).withPreferredNodePortAddressType(NodeAddressType.INTERNAL_DNS).withLoadBalancerSourceRanges(asList("10.0.0.0/8", "130.211.204.1/32")).withFinalizers(asList("service.kubernetes.io/load-balancer-cleanup")).withNewBootstrap().withAlternativeNames(asList("my-name-1", "my-name-2")).withLoadBalancerIP("130.211.204.1").withNodePort(32189).withHost("my-host").withAnnotations(Collections.singletonMap("dns-anno", "dns-value")).endBootstrap().withBrokers(new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(0).withAdvertisedHost("advertised-host").withAdvertisedPort(9092).withLoadBalancerIP("130.211.204.1").withNodePort(32189).withHost("my-host").withAnnotations(Collections.singletonMap("dns-anno", "dns-value")).build(), new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(1).withAdvertisedHost("advertised-host").withAdvertisedPort(9092).withLoadBalancerIP("130.211.204.1").withNodePort(32189).withHost("my-host").withAnnotations(Collections.singletonMap("dns-anno", "dns-value")).build()).endConfiguration().build();
List<GenericKafkaListener> listeners = asList(listener1);
List<String> expectedErrors = asList("listener " + name + " cannot configure useServiceDnsDomain because it is not internal listener", "listener " + name + " cannot configure externalTrafficPolicy because it is not LoadBalancer or NodePort based listener", "listener " + name + " cannot configure loadBalancerSourceRanges because it is not LoadBalancer based listener", "listener " + name + " cannot configure finalizers because it is not LoadBalancer based listener", "listener " + name + " cannot configure preferredAddressType because it is not NodePort based listener", "listener " + name + " cannot configure bootstrap.loadBalancerIP because it is not LoadBalancer based listener", "listener " + name + " cannot configure bootstrap.nodePort because it is not NodePort based listener", "listener " + name + " cannot configure brokers[].loadBalancerIP because it is not LoadBalancer based listener", "listener " + name + " cannot configure brokers[].nodePort because it is not NodePort based listener");
assertThat(ListenersValidator.validateAndGetErrorMessages(2, listeners), containsInAnyOrder(expectedErrors.toArray()));
}
use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener in project strimzi by strimzi.
the class ListenersValidatorTest method testMinimalConfiguration.
@ParallelTest
public void testMinimalConfiguration() {
GenericKafkaListener internal = new GenericKafkaListenerBuilder().withName("internal").withPort(9092).withType(KafkaListenerType.INTERNAL).build();
GenericKafkaListener route = new GenericKafkaListenerBuilder().withName("route").withPort(9093).withType(KafkaListenerType.ROUTE).withTls(true).build();
GenericKafkaListener lb = new GenericKafkaListenerBuilder().withName("lb").withPort(9094).withType(KafkaListenerType.LOADBALANCER).build();
GenericKafkaListener np = new GenericKafkaListenerBuilder().withName("np").withPort(9095).withType(KafkaListenerType.NODEPORT).build();
GenericKafkaListener inq = new GenericKafkaListenerBuilder().withName("inq").withPort(9096).withType(KafkaListenerType.INGRESS).withTls(true).withNewConfiguration().withNewBootstrap().withHost("my-host").endBootstrap().withBrokers(new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(0).withHost("my-host").build(), new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(1).withHost("my-host").build(), new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(2).withHost("my-host").build()).endConfiguration().build();
List<GenericKafkaListener> listeners = asList(internal, route, lb, np, inq);
assertThat(ListenersValidator.validateAndGetErrorMessages(3, listeners), empty());
}
use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener in project strimzi by strimzi.
the class ListenersValidatorTest method testValidateThrowsException.
@ParallelTest
public void testValidateThrowsException() {
GenericKafkaListener listener1 = new GenericKafkaListenerBuilder().withName("listener1").withPort(9900).withType(KafkaListenerType.INTERNAL).build();
GenericKafkaListener listener2 = new GenericKafkaListenerBuilder().withName("listener2").withPort(9900).withType(KafkaListenerType.INTERNAL).build();
List<GenericKafkaListener> listeners = asList(listener1, listener2);
Exception exception = assertThrows(InvalidResourceException.class, () -> ListenersValidator.validate(Reconciliation.DUMMY_RECONCILIATION, 3, listeners));
assertThat(exception.getMessage(), containsString("every listener needs to have a unique port number"));
}
Aggregations