use of io.strimzi.api.kafka.model.status.ListenerStatus in project strimzi by strimzi.
the class StatusDiffTest method testStatusDiff.
@ParallelTest
public void testStatusDiff() {
ListenerStatus ls1 = new ListenerStatusBuilder().withName("plain").withAddresses(new ListenerAddressBuilder().withHost("my-service.my-namespace.svc").withPort(9092).build()).build();
ListenerStatus ls2 = new ListenerStatusBuilder().withName("tls").withAddresses(new ListenerAddressBuilder().withHost("my-service.my-namespace.svc").withPort(9093).build()).build();
ListenerStatus ls3 = new ListenerStatusBuilder().withName("tls").withAddresses(new ListenerAddressBuilder().withHost("my-service.my-namespace.svc").withPort(9094).build()).build();
Condition condition1 = new ConditionBuilder().withLastTransitionTime(StatusUtils.iso8601(new Date())).withType("Ready").withStatus("True").build();
Condition condition2 = new ConditionBuilder().withLastTransitionTime(StatusUtils.iso8601(new Date())).withType("Ready2").withStatus("True").build();
KafkaStatus status1 = new KafkaStatusBuilder().withConditions(condition1).withListeners(ls1).build();
KafkaStatus status2 = new KafkaStatusBuilder().withConditions(condition1).withListeners(ls1).build();
KafkaStatus status3 = new KafkaStatusBuilder().withConditions(condition1).withListeners(ls1, ls2).build();
KafkaStatus status4 = new KafkaStatusBuilder().withConditions(condition1, condition2).withListeners(ls1).build();
KafkaStatus status5 = new KafkaStatusBuilder().withConditions(condition1).withListeners(ls1, ls3).build();
KafkaStatus status6 = new KafkaStatusBuilder().withConditions(condition1).withListeners(ls3, ls1).build();
StatusDiff diff = new StatusDiff(status1, status2);
assertThat(diff.isEmpty(), is(true));
diff = new StatusDiff(status1, status3);
assertThat(diff.isEmpty(), is(false));
diff = new StatusDiff(status1, status4);
assertThat(diff.isEmpty(), is(false));
diff = new StatusDiff(status3, status4);
assertThat(diff.isEmpty(), is(false));
diff = new StatusDiff(status3, status5);
assertThat(diff.isEmpty(), is(false));
diff = new StatusDiff(status5, status6);
assertThat(diff.isEmpty(), is(false));
}
use of io.strimzi.api.kafka.model.status.ListenerStatus in project strimzi by strimzi.
the class KafkaUtils method getKafkaStatusCertificates.
public static String getKafkaStatusCertificates(String listenerType, String namespace, String clusterName) {
String certs = "";
List<ListenerStatus> kafkaListeners = KafkaResource.kafkaClient().inNamespace(namespace).withName(clusterName).get().getStatus().getListeners();
for (ListenerStatus listener : kafkaListeners) {
if (listener.getName().equals(listenerType))
certs = listener.getCertificates().toString();
}
certs = certs.substring(1, certs.length() - 1);
return certs;
}
use of io.strimzi.api.kafka.model.status.ListenerStatus in project strimzi-kafka-operator by strimzi.
the class KafkaAssemblyOperatorLoadBalancerKafkaListenerTest method testLoadBalancerSkipBootstrapService.
@Test
public void testLoadBalancerSkipBootstrapService(VertxTestContext context) {
Kafka kafka = new KafkaBuilder().withNewMetadata().withName(NAME).withNamespace(NAMESPACE).endMetadata().withNewSpec().withNewKafka().withReplicas(3).withListeners(new GenericKafkaListenerBuilder().withName("external").withPort(LISTENER_PORT).withTls(true).withType(KafkaListenerType.LOADBALANCER).withNewConfiguration().withCreateBootstrapService(false).endConfiguration().build()).withNewEphemeralStorage().endEphemeralStorage().endKafka().withNewZookeeper().withReplicas(3).withNewEphemeralStorage().endEphemeralStorage().endZookeeper().withNewEntityOperator().withNewUserOperator().endUserOperator().withNewTopicOperator().endTopicOperator().endEntityOperator().endSpec().build();
ResourceOperatorSupplier supplier = prepareResourceOperatorSupplier(kafka);
KafkaAssemblyOperator op = new MockKafkaAssemblyOperatorForLoadBalancerTests(vertx, new PlatformFeaturesAvailability(false, KubernetesVersion.V1_16), certManager, passwordGenerator, supplier, ResourceUtils.dummyClusterOperatorConfig(KafkaVersionTestUtils.getKafkaVersionLookup()));
Reconciliation reconciliation = new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, NAME);
Checkpoint async = context.checkpoint();
op.reconcile(reconciliation).onComplete(context.succeeding(v -> context.verify(() -> {
assertThat(kafka.getStatus().getListeners().size(), is(1));
ListenerStatus listenerStatus = kafka.getStatus().getListeners().get(0);
assertThat(listenerStatus.getBootstrapServers(), is("broker-0.test.dns.name:9094,broker-1.test.dns.name:9094,broker-2.test.dns.name:9094"));
assertThat(listenerStatus.getAddresses().size(), is(3));
assertThat(listenerStatus.getAddresses().get(0).getHost(), is(DNS_NAME_FOR_BROKER_0));
assertThat(listenerStatus.getAddresses().get(1).getHost(), is(DNS_NAME_FOR_BROKER_1));
assertThat(listenerStatus.getAddresses().get(2).getHost(), is(DNS_NAME_FOR_BROKER_2));
assertThat(listenerStatus.getAddresses().get(0).getPort(), is(LISTENER_PORT));
assertThat(listenerStatus.getAddresses().get(1).getPort(), is(LISTENER_PORT));
assertThat(listenerStatus.getAddresses().get(2).getPort(), is(LISTENER_PORT));
async.flag();
})));
}
use of io.strimzi.api.kafka.model.status.ListenerStatus in project strimzi-kafka-operator by strimzi.
the class KafkaAssemblyOperatorLoadBalancerKafkaListenerTest method testLoadBalancerWithBootstrapService.
@Test
public void testLoadBalancerWithBootstrapService(VertxTestContext context) {
Kafka kafka = new KafkaBuilder().withNewMetadata().withName(NAME).withNamespace(NAMESPACE).endMetadata().withNewSpec().withNewKafka().withReplicas(3).withListeners(new GenericKafkaListenerBuilder().withName("external").withPort(LISTENER_PORT).withTls(true).withType(KafkaListenerType.LOADBALANCER).withNewConfiguration().withCreateBootstrapService(true).endConfiguration().build()).withNewEphemeralStorage().endEphemeralStorage().endKafka().withNewZookeeper().withReplicas(3).withNewEphemeralStorage().endEphemeralStorage().endZookeeper().withNewEntityOperator().withNewUserOperator().endUserOperator().withNewTopicOperator().endTopicOperator().endEntityOperator().endSpec().build();
ResourceOperatorSupplier supplier = prepareResourceOperatorSupplier(kafka);
KafkaAssemblyOperator op = new MockKafkaAssemblyOperatorForLoadBalancerTests(vertx, new PlatformFeaturesAvailability(false, KubernetesVersion.V1_16), certManager, passwordGenerator, supplier, ResourceUtils.dummyClusterOperatorConfig(KafkaVersionTestUtils.getKafkaVersionLookup()));
Reconciliation reconciliation = new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, NAME);
Checkpoint async = context.checkpoint();
op.reconcile(reconciliation).onComplete(context.succeeding(v -> context.verify(() -> {
assertThat(kafka.getStatus().getListeners().size(), is(1));
ListenerStatus listenerStatus = kafka.getStatus().getListeners().get(0);
assertThat(listenerStatus.getBootstrapServers(), is("bootstrap-broker.test.dns.name:9094"));
assertThat(listenerStatus.getAddresses().size(), is(1));
assertThat(listenerStatus.getAddresses().get(0).getHost(), is(DNS_NAME_FOR_BOOTSTRAP_SERVICE));
assertThat(listenerStatus.getAddresses().get(0).getPort(), is(LISTENER_PORT));
async.flag();
})));
}
use of io.strimzi.api.kafka.model.status.ListenerStatus in project strimzi by strimzi.
the class KafkaAssemblyOperatorLoadBalancerKafkaListenerTest method testLoadBalancerSkipBootstrapService.
@Test
public void testLoadBalancerSkipBootstrapService(VertxTestContext context) {
Kafka kafka = new KafkaBuilder().withNewMetadata().withName(NAME).withNamespace(NAMESPACE).endMetadata().withNewSpec().withNewKafka().withReplicas(3).withListeners(new GenericKafkaListenerBuilder().withName("external").withPort(LISTENER_PORT).withTls(true).withType(KafkaListenerType.LOADBALANCER).withNewConfiguration().withCreateBootstrapService(false).endConfiguration().build()).withNewEphemeralStorage().endEphemeralStorage().endKafka().withNewZookeeper().withReplicas(3).withNewEphemeralStorage().endEphemeralStorage().endZookeeper().withNewEntityOperator().withNewUserOperator().endUserOperator().withNewTopicOperator().endTopicOperator().endEntityOperator().endSpec().build();
ResourceOperatorSupplier supplier = prepareResourceOperatorSupplier(kafka);
KafkaAssemblyOperator op = new MockKafkaAssemblyOperatorForLoadBalancerTests(vertx, new PlatformFeaturesAvailability(false, KubernetesVersion.V1_16), certManager, passwordGenerator, supplier, ResourceUtils.dummyClusterOperatorConfig(KafkaVersionTestUtils.getKafkaVersionLookup()));
Reconciliation reconciliation = new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, NAME);
Checkpoint async = context.checkpoint();
op.reconcile(reconciliation).onComplete(context.succeeding(v -> context.verify(() -> {
assertThat(kafka.getStatus().getListeners().size(), is(1));
ListenerStatus listenerStatus = kafka.getStatus().getListeners().get(0);
assertThat(listenerStatus.getBootstrapServers(), is("broker-0.test.dns.name:9094,broker-1.test.dns.name:9094,broker-2.test.dns.name:9094"));
assertThat(listenerStatus.getAddresses().size(), is(3));
assertThat(listenerStatus.getAddresses().get(0).getHost(), is(DNS_NAME_FOR_BROKER_0));
assertThat(listenerStatus.getAddresses().get(1).getHost(), is(DNS_NAME_FOR_BROKER_1));
assertThat(listenerStatus.getAddresses().get(2).getHost(), is(DNS_NAME_FOR_BROKER_2));
assertThat(listenerStatus.getAddresses().get(0).getPort(), is(LISTENER_PORT));
assertThat(listenerStatus.getAddresses().get(1).getPort(), is(LISTENER_PORT));
assertThat(listenerStatus.getAddresses().get(2).getPort(), is(LISTENER_PORT));
async.flag();
})));
}
Aggregations