use of io.strimzi.api.kafka.model.status.ConditionBuilder in project strimzi-kafka-operator 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.ConditionBuilder in project strimzi-kafka-operator by strimzi.
the class StatusDiffTest method testTimestampDiff.
@ParallelTest
public void testTimestampDiff() throws ParseException {
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();
Condition condition1 = new ConditionBuilder().withLastTransitionTime(StatusUtils.iso8601(new Date())).withType("Ready").withStatus("True").build();
Condition condition2 = new ConditionBuilder().withLastTransitionTime(StatusUtils.iso8601(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse("2011-01-01 00:00:00"))).withType("Ready").withStatus("True").build();
KafkaStatus status1 = new KafkaStatusBuilder().withConditions(condition1).withListeners(ls1, ls2).build();
KafkaStatus status2 = new KafkaStatusBuilder().withConditions(condition2).withListeners(ls1, ls2).build();
StatusDiff diff = new StatusDiff(status1, status2);
assertThat(diff.isEmpty(), is(true));
}
use of io.strimzi.api.kafka.model.status.ConditionBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManagerTest method testStrimziVersionChange.
@Test
public void testStrimziVersionChange() {
ManagedKafka mk = ManagedKafka.getDummyInstance(1);
mk.getSpec().getVersions().setStrimzi("strimzi-cluster-operator.v1");
Kafka kafka = this.kafkaCluster.kafkaFrom(mk, null);
kafkaClient.create(kafka);
// Kafka reconcile not paused and current label version as the ManagedKafka one
assertFalse(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_RECONCILE_ANNOTATION));
assertEquals(kafka.getMetadata().getLabels().get(this.strimziManager.getVersionLabel()), mk.getSpec().getVersions().getStrimzi());
// ManagedKafka and Kafka updated their status information
mk.setStatus(new ManagedKafkaStatusBuilder().withVersions(new VersionsBuilder().withStrimzi("strimzi-cluster-operator.v1").build()).build());
kafka.setStatus(new KafkaStatusBuilder().withConditions(new ConditionBuilder().withType("Ready").withStatus("True").build()).build());
kafkaClient.replaceStatus(kafka);
// ask for a Strimzi version change on ManagedKafka
mk.getSpec().getVersions().setStrimzi("strimzi-cluster-operator.v2");
kafka = this.kafkaCluster.kafkaFrom(mk, kafka);
// Kafka reconcile paused but label is still the current version
assertTrue(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_RECONCILE_ANNOTATION));
assertTrue(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_REASON_ANNOTATION));
assertEquals(kafka.getMetadata().getLabels().get(this.strimziManager.getVersionLabel()), mk.getStatus().getVersions().getStrimzi());
// nothing should change after an intermediate reconcile
kafka = this.kafkaCluster.kafkaFrom(mk, kafka);
assertTrue(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_REASON_ANNOTATION));
// Kafka moves to be paused
kafka.setStatus(new KafkaStatusBuilder().withConditions(new ConditionBuilder().withType("ReconciliationPaused").withStatus("True").build()).build());
kafkaClient.replaceStatus(kafka);
kafka = this.kafkaCluster.kafkaFrom(mk, kafka);
// Kafka reconcile not paused and Kafka label updated to requested Strimzi version
assertFalse(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_RECONCILE_ANNOTATION));
// the pause reason should stay until strimzi updates to ready
assertTrue(kafka.getMetadata().getAnnotations().containsKey(StrimziManager.STRIMZI_PAUSE_REASON_ANNOTATION));
assertEquals(kafka.getMetadata().getLabels().get(this.strimziManager.getVersionLabel()), "strimzi-cluster-operator.v2");
}
use of io.strimzi.api.kafka.model.status.ConditionBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaClusterTest method pausedUnknownStatus.
@Test
void pausedUnknownStatus() throws InterruptedException {
ManagedKafka mk = ManagedKafka.getDummyInstance(1);
InformerManager informer = Mockito.mock(InformerManager.class);
Kafka kafka = new KafkaBuilder(this.kafkaCluster.kafkaFrom(mk, null)).editMetadata().withAnnotations(Map.of(StrimziManager.STRIMZI_PAUSE_REASON_ANNOTATION, "custom")).endMetadata().withNewStatus().withConditions(new ConditionBuilder().withType("ReconciliationPaused").withStatus("True").build()).endStatus().build();
Mockito.when(informer.getLocalKafka(Mockito.anyString(), Mockito.anyString())).thenReturn(kafka);
QuarkusMock.installMockForType(informer, InformerManager.class);
OperandReadiness readiness = this.kafkaCluster.getReadiness(mk);
assertEquals(Status.Unknown, readiness.getStatus());
assertEquals(Reason.Paused, readiness.getReason());
assertEquals("Kafka mk-1 is paused for an unknown reason", readiness.getMessage());
}
Aggregations