use of io.fabric8.kubernetes.api.model.Condition in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedConnectorConditionsTest method conditionAdd.
@Test
void conditionAdd() {
ManagedConnector connector = new ManagedConnector();
Condition condition = new Condition();
condition.setType("Ready");
condition.setStatus("True");
condition.setReason("reason");
condition.setMessage("message");
condition.setLastTransitionTime(ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
connector.getStatus().setConditions(List.of(condition));
assertThat(ManagedConnectorConditions.setCondition(connector, ManagedConnectorConditions.Type.Ready, ManagedConnectorConditions.Status.True, "new reason", "new message")).isTrue();
assertThat(connector.getStatus().getConditions()).hasSize(1).allMatch(c -> {
return Objects.equals(c.getType(), "Ready") && Objects.equals(c.getStatus(), "True") && Objects.equals(c.getReason(), "new reason") && Objects.equals(c.getMessage(), "new message") && !Objects.equals(c.getLastTransitionTime(), condition.getLastTransitionTime());
});
assertThat(ManagedConnectorConditions.setCondition(connector, ManagedConnectorConditions.Type.Ready, ManagedConnectorConditions.Status.True, "new reason", "new message")).isFalse();
}
use of io.fabric8.kubernetes.api.model.Condition in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class KameletBindingSteps method klb_phase_and_conditions.
@SuppressWarnings("unchecked")
@When("the klb phase is {string} with conditions:")
public void klb_phase_and_conditions(String phase, DataTable table) {
// TODO: investigate using KubernetesClient.resources(KameletBinding.class) result in a bad patch
kubernetesClient.genericKubernetesResources(KameletBinding.RESOURCE_DEFINITION).inNamespace(ctx.connector().getMetadata().getNamespace()).withName(ctx.connector().getMetadata().getName()).editStatus(binding -> {
Map<String, Object> status = (Map<String, Object>) binding.getAdditionalProperties().get("status");
if (status == null) {
status = new HashMap<>();
}
List<Map<String, String>> rows = table.asMaps(String.class, String.class);
List<Condition> conditions = new ArrayList<>(rows.size());
for (Map<String, String> columns : rows) {
conditions.add(new ConditionBuilder().withMessage(columns.get("message")).withReason(columns.get("reason")).withStatus(columns.get("status")).withType(columns.get("type")).withLastTransitionTime(columns.get("lastTransitionTime")).build());
}
status.put("phase", phase);
status.put("conditions", conditions);
binding.getAdditionalProperties().put("status", status);
return binding;
});
// kubernetesClient.resources(KameletBinding.class)
// .inNamespace(ctx.connector().getMetadata().getNamespace())
// .withName(ctx.connector().getMetadata().getName())
// .editStatus(binding -> {
// if (binding.getStatus() == null) {
// binding.setStatus(new KameletBindingStatus());
// }
//
// List<Map<String, String>> rows = table.asMaps(String.class, String.class);
// List<Condition> conditions = new ArrayList<>(rows.size());
//
// for (Map<String, String> columns : rows) {
// conditions.add(new ConditionBuilder()
// .withMessage(columns.get("message"))
// .withReason(columns.get("reason"))
// .withStatus(columns.get("status"))
// .withType(columns.get("type"))
// .withLastTransitionTime(columns.get("lastTransitionTime"))
// .build());
// }
//
// binding.getStatus().setPhase(phase);
// binding.getStatus().setConditions(conditions);
//
// return binding;
// });
}
use of io.fabric8.kubernetes.api.model.Condition in project strimzi-kafka-operator by strimzi.
the class MirrorMaker2IsolatedST method testKafkaMirrorMaker2ReflectsConnectorsState.
@ParallelNamespaceTest
void testKafkaMirrorMaker2ReflectsConnectorsState(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(INFRA_NAMESPACE, extensionContext);
String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
String kafkaClusterSourceName = clusterName + "-source";
String kafkaClusterTargetName = clusterName + "-target";
String errorMessage = "One or more connectors are in FAILED state";
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterSourceName, 1, 1).build(), KafkaTemplates.kafkaEphemeral(kafkaClusterTargetName, 1, 1).build());
resourceManager.createResource(extensionContext, false, KafkaMirrorMaker2Templates.kafkaMirrorMaker2(clusterName, kafkaClusterTargetName, kafkaClusterSourceName, 1, false).editSpec().editMatchingCluster(spec -> spec.getAlias().equals(kafkaClusterSourceName)).withBootstrapServers(KafkaResources.bootstrapServiceName(kafkaClusterSourceName) + ".:9092").endCluster().endSpec().build());
KafkaMirrorMaker2Utils.waitForKafkaMirrorMaker2StatusMessage(namespaceName, clusterName, errorMessage);
KafkaMirrorMaker2Resource.replaceKafkaMirrorMaker2ResourceInSpecificNamespace(clusterName, mm2 -> mm2.getSpec().getClusters().stream().filter(mm2ClusterSpec -> mm2ClusterSpec.getAlias().equals(kafkaClusterSourceName)).findFirst().get().setBootstrapServers(KafkaUtils.namespacedPlainBootstrapAddress(kafkaClusterSourceName, namespaceName)), namespaceName);
KafkaMirrorMaker2Utils.waitForKafkaMirrorMaker2Ready(namespaceName, clusterName);
KafkaMirrorMaker2Status kmm2Status = KafkaMirrorMaker2Resource.kafkaMirrorMaker2Client().inNamespace(namespaceName).withName(clusterName).get().getStatus();
assertFalse(kmm2Status.getConditions().stream().anyMatch(condition -> condition.getMessage() != null && condition.getMessage().contains(errorMessage)));
}
use of io.fabric8.kubernetes.api.model.Condition in project strimzi-kafka-operator by strimzi.
the class CustomResourceStatusIsolatedST method assertKafkaTopicWrongMinInSyncReplicasStatus.
void assertKafkaTopicWrongMinInSyncReplicasStatus(String topicName, String invalidValue) {
KafkaTopicStatus kafkaTopicStatus = KafkaTopicResource.kafkaTopicClient().inNamespace(Constants.INFRA_NAMESPACE).withName(topicName).get().getStatus();
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getType().equals(NotReady.toString())), is(true));
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getReason().equals("InvalidRequestException")), is(true));
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getMessage().contains(String.format("Invalid value %s for configuration min.insync.replicas", invalidValue))), is(true));
}
use of io.fabric8.kubernetes.api.model.Condition in project strimzi-kafka-operator by strimzi.
the class CustomResourceStatusIsolatedST method assertKafkaTopicDecreasePartitionsStatus.
void assertKafkaTopicDecreasePartitionsStatus(String topicName) {
KafkaTopicStatus kafkaTopicStatus = KafkaTopicResource.kafkaTopicClient().inNamespace(Constants.INFRA_NAMESPACE).withName(topicName).get().getStatus();
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getType().equals(NotReady.toString())), is(true));
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getReason().equals("PartitionDecreaseException")), is(true));
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getMessage().contains("Number of partitions cannot be decreased")), is(true));
}
Aggregations