use of io.fabric8.kubernetes.api.model.Context in project strimzi by strimzi.
the class ControllerIT method deleteTopic.
private void deleteTopic(TestContext context, String topicName, String configMapName) throws InterruptedException, ExecutionException {
LOGGER.info("Deleting topic {} (ConfigMap {})", topicName, configMapName);
// Now we can delete the topic
DeleteTopicsResult dlt = adminClient.deleteTopics(singletonList(topicName));
dlt.all().get();
LOGGER.info("Deleted topic {}", topicName);
// Wait for the configmap to be deleted
waitFor(context, () -> {
ConfigMap cm = kubeClient.configMaps().inNamespace(NAMESPACE).withName(configMapName).get();
LOGGER.info("Polled configmap {}, got {}, waiting for deletion", configMapName, cm);
return cm == null;
}, timeout, "Expected the configmap to have been deleted by now");
}
use of io.fabric8.kubernetes.api.model.Context in project strimzi by strimzi.
the class ControllerIT method waitForEvent.
private void waitForEvent(TestContext context, ConfigMap cm, String expectedMessage, Controller.EventType expectedType) {
waitFor(context, () -> {
List<Event> items = kubeClient.events().inNamespace(NAMESPACE).withLabels(cmPredicate.labels()).list().getItems();
List<Event> filtered = items.stream().filter(evt -> !preExistingEvents.contains(evt.getMetadata().getUid()) && "ConfigMap".equals(evt.getInvolvedObject().getKind()) && cm.getMetadata().getName().equals(evt.getInvolvedObject().getName())).collect(Collectors.toList());
LOGGER.debug("Waiting for events: {}", filtered.stream().map(evt -> evt.getMessage()).collect(Collectors.toList()));
if (!filtered.isEmpty()) {
assertEquals(1, filtered.size());
Event event = filtered.get(0);
assertEquals(expectedMessage, event.getMessage());
assertEquals(expectedType.name, event.getType());
assertNotNull(event.getInvolvedObject());
assertEquals("ConfigMap", event.getInvolvedObject().getKind());
assertEquals(cm.getMetadata().getName(), event.getInvolvedObject().getName());
return true;
} else {
return false;
}
}, timeout, "Expected an error event");
}
use of io.fabric8.kubernetes.api.model.Context in project strimzi by strimzi.
the class ControllerIT method createTopic.
private String createTopic(TestContext context, String topicName) throws InterruptedException, ExecutionException {
LOGGER.info("Creating topic {}", topicName);
// Create a topic
String configMapName = new TopicName(topicName).asMapName().toString();
CreateTopicsResult crt = adminClient.createTopics(singletonList(new NewTopic(topicName, 1, (short) 1)));
crt.all().get();
// Wait for the configmap to be created
waitFor(context, () -> {
ConfigMap cm = kubeClient.configMaps().inNamespace(NAMESPACE).withName(configMapName).get();
LOGGER.info("Polled configmap {} waiting for creation", configMapName);
return cm != null;
}, timeout, "Expected the configmap to have been created by now");
LOGGER.info("configmap {} has been created", configMapName);
return configMapName;
}
use of io.fabric8.kubernetes.api.model.Context in project strimzi by strimzi.
the class MockK8s method assertContains.
public void assertContains(TestContext context, ConfigMap cm) {
ConfigMap configMap = byName.get(new MapName(cm));
context.assertEquals(cm, configMap);
}
use of io.fabric8.kubernetes.api.model.Context in project fabric8 by fabric8io.
the class CamelState method doCheck.
@Override
protected List<Check> doCheck() {
MBeanServer server = this.mbeanServer.getService();
if (server != null) {
try {
List<Check> checks = new ArrayList<>();
Set<ObjectName> contexts = server.queryNames(new ObjectName("org.apache.camel:type=context,*"), null);
for (ObjectName ctxName : contexts) {
String state = server.getAttribute(ctxName, "State").toString();
if (!"Started".equals(state)) {
String name = ctxName.getKeyProperty("name");
checks.add(new Check("camel-state", "Camel context " + name + " is in state " + state));
}
}
return checks;
} catch (Exception e) {
return Collections.singletonList(new Check("camel-state", "Unable to check camel contexts: " + e.toString()));
}
}
return Collections.emptyList();
}
Aggregations