use of io.strimzi.api.kafka.model.status.KafkaStatus in project strimzi by strimzi.
the class KafkaStatusTest method testPauseReconciliationsStatus.
@Test
public void testPauseReconciliationsStatus(VertxTestContext context) throws ParseException {
Kafka kafka = getKafkaCrd();
kafka.getMetadata().setAnnotations(singletonMap("strimzi.io/pause-reconciliation", Boolean.toString(true)));
ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);
// Mock the Kafka Operator
CrdOperator mockKafkaOps = supplier.kafkaOperator;
when(mockKafkaOps.getAsync(eq(namespace), eq(clusterName))).thenReturn(Future.succeededFuture(getKafkaCrd()));
when(mockKafkaOps.get(eq(namespace), eq(clusterName))).thenReturn(kafka);
ArgumentCaptor<Kafka> kafkaCaptor = ArgumentCaptor.forClass(Kafka.class);
when(mockKafkaOps.updateStatusAsync(any(), kafkaCaptor.capture())).thenReturn(Future.succeededFuture());
MockWorkingKafkaAssemblyOperator kao = new MockWorkingKafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(false, kubernetesVersion), certManager, passwordGenerator, supplier, config);
Checkpoint async = context.checkpoint();
kao.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, namespace, clusterName)).onComplete(res -> {
assertThat(res.succeeded(), is(true));
assertThat(kafkaCaptor.getValue(), is(notNullValue()));
assertThat(kafkaCaptor.getValue().getStatus(), is(notNullValue()));
KafkaStatus status = kafkaCaptor.getValue().getStatus();
assertThat(status.getConditions().size(), is(1));
assertThat(status.getConditions().get(0).getStatus(), is("True"));
assertThat(status.getConditions().get(0).getType(), is("ReconciliationPaused"));
assertThat(status.getObservedGeneration(), is(1L));
async.flag();
});
}
use of io.strimzi.api.kafka.model.status.KafkaStatus in project strimzi by strimzi.
the class KafkaStatusTest method testStatusAfterSuccessfulReconciliationWithPreviousFailure.
@Test
public void testStatusAfterSuccessfulReconciliationWithPreviousFailure(VertxTestContext context) throws ParseException {
Kafka kafka = getKafkaCrd();
ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);
// Mock the Kafka Operator
CrdOperator mockKafkaOps = supplier.kafkaOperator;
when(mockKafkaOps.getAsync(eq(namespace), eq(clusterName))).thenReturn(Future.succeededFuture(getKafkaCrd()));
when(mockKafkaOps.get(eq(namespace), eq(clusterName))).thenReturn(kafka);
ArgumentCaptor<Kafka> kafkaCaptor = ArgumentCaptor.forClass(Kafka.class);
when(mockKafkaOps.updateStatusAsync(any(), kafkaCaptor.capture())).thenReturn(Future.succeededFuture());
MockWorkingKafkaAssemblyOperator kao = new MockWorkingKafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(false, kubernetesVersion), certManager, passwordGenerator, supplier, config);
Checkpoint async = context.checkpoint();
kao.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, namespace, clusterName)).onComplete(res -> {
assertThat(res.succeeded(), is(true));
assertThat(kafkaCaptor.getValue(), is(notNullValue()));
assertThat(kafkaCaptor.getValue().getStatus(), is(notNullValue()));
KafkaStatus status = kafkaCaptor.getValue().getStatus();
assertThat(status.getListeners().size(), is(2));
assertThat(status.getListeners().get(0).getType(), is("plain"));
assertThat(status.getListeners().get(0).getName(), is("plain"));
assertThat(status.getListeners().get(0).getAddresses().get(0).getHost(), is("my-service.my-namespace.svc"));
assertThat(status.getListeners().get(0).getAddresses().get(0).getPort(), is(Integer.valueOf(9092)));
assertThat(status.getListeners().get(0).getBootstrapServers(), is("my-service.my-namespace.svc:9092"));
assertThat(status.getListeners().get(1).getType(), is("external"));
assertThat(status.getListeners().get(1).getName(), is("external"));
assertThat(status.getListeners().get(1).getAddresses().get(0).getHost(), is("my-route-address.domain.tld"));
assertThat(status.getListeners().get(1).getAddresses().get(0).getPort(), is(Integer.valueOf(443)));
assertThat(status.getListeners().get(1).getBootstrapServers(), is("my-route-address.domain.tld:443"));
assertThat(status.getConditions().size(), is(1));
assertThat(status.getConditions().get(0).getType(), is("Ready"));
assertThat(status.getConditions().get(0).getStatus(), is("True"));
assertThat(status.getObservedGeneration(), is(2L));
async.flag();
});
}
use of io.strimzi.api.kafka.model.status.KafkaStatus in project strimzi by strimzi.
the class KafkaStatusTest method testStatusAfterFailedReconciliationWithPreviousSuccess.
@Test
public void testStatusAfterFailedReconciliationWithPreviousSuccess(VertxTestContext context) throws ParseException {
Kafka kafka = getKafkaCrd();
ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);
// Mock the Kafka Operator
CrdOperator mockKafkaOps = supplier.kafkaOperator;
Kafka readyKafka = new KafkaBuilder(kafka).editStatus().withObservedGeneration(1L).editCondition(0).withType("Ready").endCondition().withListeners(new ListenerStatusBuilder().withName("plain").withAddresses(new ListenerAddressBuilder().withHost("my-service.my-namespace.svc").withPort(9092).build()).build(), new ListenerStatusBuilder().withName("external").withAddresses(new ListenerAddressBuilder().withHost("my-route-address.domain.tld").withPort(443).build()).build()).endStatus().build();
when(mockKafkaOps.getAsync(eq(namespace), eq(clusterName))).thenReturn(Future.succeededFuture(readyKafka));
when(mockKafkaOps.get(eq(namespace), eq(clusterName))).thenReturn(readyKafka);
ArgumentCaptor<Kafka> kafkaCaptor = ArgumentCaptor.forClass(Kafka.class);
when(mockKafkaOps.updateStatusAsync(any(), kafkaCaptor.capture())).thenReturn(Future.succeededFuture());
MockFailingKafkaAssemblyOperator kao = new MockFailingKafkaAssemblyOperator(new RuntimeException("Something went wrong"), vertx, new PlatformFeaturesAvailability(false, kubernetesVersion), certManager, passwordGenerator, supplier, config);
Checkpoint async = context.checkpoint();
kao.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, namespace, clusterName)).onComplete(res -> {
assertThat(res.succeeded(), is(false));
assertThat(kafkaCaptor.getValue(), is(notNullValue()));
assertThat(kafkaCaptor.getValue().getStatus(), is(notNullValue()));
KafkaStatus status = kafkaCaptor.getValue().getStatus();
assertThat(status.getListeners().size(), is(1));
assertThat(status.getListeners().get(0).getType(), is("plain"));
assertThat(status.getListeners().get(0).getName(), is("plain"));
assertThat(status.getListeners().get(0).getAddresses().get(0).getHost(), is("my-service.my-namespace.svc"));
assertThat(status.getListeners().get(0).getAddresses().get(0).getPort(), is(Integer.valueOf(9092)));
assertThat(status.getListeners().get(0).getBootstrapServers(), is("my-service.my-namespace.svc:9092"));
assertThat(status.getConditions().size(), is(1));
assertThat(status.getConditions().get(0).getType(), is("NotReady"));
assertThat(status.getConditions().get(0).getStatus(), is("True"));
assertThat(status.getConditions().get(0).getReason(), is("RuntimeException"));
assertThat(status.getConditions().get(0).getMessage(), is("Something went wrong"));
assertThat(status.getObservedGeneration(), is(2L));
async.flag();
});
}
use of io.strimzi.api.kafka.model.status.KafkaStatus in project strimzi by strimzi.
the class KafkaStatusTest method testStatusAfterFailedReconciliationWithPreviousFailure.
public void testStatusAfterFailedReconciliationWithPreviousFailure(VertxTestContext context, Throwable exception) throws ParseException {
Kafka kafka = getKafkaCrd();
ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);
// Mock the Kafka Operator
CrdOperator mockKafkaOps = supplier.kafkaOperator;
when(mockKafkaOps.getAsync(eq(namespace), eq(clusterName))).thenReturn(Future.succeededFuture(getKafkaCrd()));
when(mockKafkaOps.get(eq(namespace), eq(clusterName))).thenReturn(kafka);
ArgumentCaptor<Kafka> kafkaCaptor = ArgumentCaptor.forClass(Kafka.class);
when(mockKafkaOps.updateStatusAsync(any(), kafkaCaptor.capture())).thenReturn(Future.succeededFuture());
MockFailingKafkaAssemblyOperator kao = new MockFailingKafkaAssemblyOperator(exception, vertx, new PlatformFeaturesAvailability(false, kubernetesVersion), certManager, passwordGenerator, supplier, config);
Checkpoint async = context.checkpoint();
kao.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, namespace, clusterName)).onComplete(res -> {
assertThat(res.succeeded(), is(false));
assertThat(kafkaCaptor.getValue(), is(notNullValue()));
assertThat(kafkaCaptor.getValue().getStatus(), is(notNullValue()));
KafkaStatus status = kafkaCaptor.getValue().getStatus();
assertThat(status.getListeners().size(), is(1));
assertThat(status.getListeners().get(0).getType(), is("plain"));
assertThat(status.getListeners().get(0).getName(), is("plain"));
assertThat(status.getListeners().get(0).getAddresses().get(0).getHost(), is("my-service.my-namespace.svc"));
assertThat(status.getListeners().get(0).getAddresses().get(0).getPort(), is(Integer.valueOf(9092)));
assertThat(status.getListeners().get(0).getBootstrapServers(), is("my-service.my-namespace.svc:9092"));
assertThat(status.getConditions().size(), is(1));
assertThat(status.getConditions().get(0).getType(), is("NotReady"));
assertThat(status.getConditions().get(0).getStatus(), is("True"));
assertThat(status.getConditions().get(0).getReason(), is(exception.getClass().getSimpleName()));
assertThat(status.getConditions().get(0).getMessage(), is(exception.getMessage()));
assertThat(status.getObservedGeneration(), is(2L));
async.flag();
});
}
use of io.strimzi.api.kafka.model.status.KafkaStatus in project strimzi by strimzi.
the class CruiseControlST method testCruiseControlWithSingleNodeKafka.
@ParallelNamespaceTest
void testCruiseControlWithSingleNodeKafka(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
final String errMessage = "Kafka " + namespaceName + "/" + clusterName + " has invalid configuration." + " Cruise Control cannot be deployed with a single-node Kafka cluster. It requires " + "at least two Kafka nodes.";
LOGGER.info("Deploying single node Kafka with CruiseControl");
resourceManager.createResource(extensionContext, false, KafkaTemplates.kafkaWithCruiseControl(clusterName, 1, 1).build());
KafkaUtils.waitUntilKafkaStatusConditionContainsMessage(clusterName, namespaceName, errMessage, Duration.ofMinutes(6).toMillis());
KafkaStatus kafkaStatus = KafkaTemplates.kafkaClient().inNamespace(namespaceName).withName(clusterName).get().getStatus();
assertThat(kafkaStatus.getConditions().get(0).getReason(), is("InvalidResourceException"));
LOGGER.info("Increasing Kafka nodes to 3");
KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> kafka.getSpec().getKafka().setReplicas(3), namespaceName);
KafkaUtils.waitForKafkaReady(namespaceName, clusterName);
kafkaStatus = KafkaTemplates.kafkaClient().inNamespace(namespaceName).withName(clusterName).get().getStatus();
assertThat(kafkaStatus.getConditions().get(0).getMessage(), is(not(errMessage)));
}
Aggregations