use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesNodesProducerTest method listByLabelsTest.
@Test
public void listByLabelsTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:listByLabels", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Map<String, String> labels = new HashMap<String, String>();
labels.put("kubernetes.io/hostname", "172.28.128.4");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NODES_LABELS, labels);
}
});
List<Node> result = ex.getOut().getBody(List.class);
Node node = result.get(0);
assertTrue(node.getStatus().getCapacity().get("pods").getAmount().equals("110"));
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesPersistentVolumesClaimsProducerTest method listByLabelsTest.
@Test
public void listByLabelsTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:listByLabels", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
Map<String, String> labels = new HashMap<String, String>();
labels.put("component", "elasticsearch");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS, labels);
}
});
List<PersistentVolume> result = ex.getOut().getBody(List.class);
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesPersistentVolumesClaimsProducerTest method createListAndDeletePersistentVolumeClaim.
@Test
public void createListAndDeletePersistentVolumeClaim() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:create", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_NAME, "test");
Map<String, String> labels = new HashMap<String, String>();
labels.put("this", "rocks");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS, labels);
PersistentVolumeClaimSpec pvcSpec = new PersistentVolumeClaimSpec();
ResourceRequirements rr = new ResourceRequirements();
Map<String, Quantity> mp = new HashMap<String, Quantity>();
mp.put("storage", new Quantity("100"));
rr.setLimits(mp);
Map<String, Quantity> req = new HashMap<String, Quantity>();
req.put("storage", new Quantity("100"));
rr.setRequests(req);
pvcSpec.setResources(rr);
pvcSpec.setVolumeName("vol001");
List<String> access = new ArrayList<String>();
access.add("ReadWriteOnce");
pvcSpec.setAccessModes(access);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_SPEC, pvcSpec);
}
});
PersistentVolumeClaim pvc = ex.getOut().getBody(PersistentVolumeClaim.class);
assertEquals(pvc.getMetadata().getName(), "test");
ex = template.request("direct:listByLabels", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
Map<String, String> labels = new HashMap<String, String>();
labels.put("this", "rocks");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS, labels);
}
});
List<PersistentVolumeClaim> result = ex.getOut().getBody(List.class);
boolean pvcExists = false;
Iterator<PersistentVolumeClaim> it = result.iterator();
while (it.hasNext()) {
PersistentVolumeClaim pvcLocal = it.next();
if ("test".equalsIgnoreCase(pvcLocal.getMetadata().getName())) {
pvcExists = true;
}
}
assertTrue(pvcExists);
ex = template.request("direct:delete", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_NAME, "test");
}
});
boolean pvcDeleted = ex.getOut().getBody(Boolean.class);
assertTrue(pvcDeleted);
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesPersistentVolumesProducerTest method listByLabelsTest.
@Test
public void listByLabelsTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:listByLabels", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
Map<String, String> labels = new HashMap<String, String>();
labels.put("component", "elasticsearch");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_LABELS, labels);
}
});
List<PersistentVolume> result = ex.getOut().getBody(List.class);
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesPodsProducerTest method listTest.
@Test
public void listTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
List<Pod> result = template.requestBody("direct:list", "", List.class);
boolean defaultExists = false;
Iterator<Pod> it = result.iterator();
while (it.hasNext()) {
Pod pod = it.next();
if ((pod.getMetadata().getName()).contains("fabric8")) {
defaultExists = true;
}
}
assertTrue(defaultExists);
}
Aggregations