use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesClientServiceDiscovery method getServices.
@Override
public List<ServiceDefinition> getServices(String name) {
LOG.debug("Discovering endpoints from namespace: {} with name: {}", getNamespace(), name);
Endpoints endpoints = client.endpoints().inNamespace(getNamespace()).withName(name).get();
List<ServiceDefinition> result = new ArrayList<>();
if (endpoints != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Found {} endpoints in namespace: {} for name: {} and portName: {}", endpoints.getSubsets().size(), getNamespace(), name, getPortName());
}
for (EndpointSubset subset : endpoints.getSubsets()) {
if (subset.getPorts().size() == 1) {
addServers(name, result, subset.getPorts().get(FIRST), subset);
} else {
final List<EndpointPort> ports = subset.getPorts();
final int portSize = ports.size();
EndpointPort port;
for (int p = 0; p < portSize; p++) {
port = ports.get(p);
if (ObjectHelper.isEmpty(getPortName()) || getPortName().endsWith(port.getName())) {
addServers(name, result, port, subset);
}
}
}
}
}
return result;
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesPodsProducerTest method getPodTest.
@Test
public void getPodTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:getPod", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_POD_NAME, "elasticsearch-7015o");
}
});
Pod result = ex.getOut().getBody(Pod.class);
assertNull(result);
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesReplicationControllersProducerTest method listTest.
@Test
public void listTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
List<ReplicationController> result = template.requestBody("direct:list", "", List.class);
boolean fabric8Exists = false;
Iterator<ReplicationController> it = result.iterator();
while (it.hasNext()) {
ReplicationController rc = it.next();
if ("fabric8".equalsIgnoreCase(rc.getMetadata().getName())) {
fabric8Exists = true;
}
}
assertTrue(fabric8Exists);
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesReplicationControllersProducerTest 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_REPLICATION_CONTROLLERS_LABELS, labels);
}
});
List<ReplicationController> result = ex.getOut().getBody(List.class);
boolean rcExists = false;
Iterator<ReplicationController> it = result.iterator();
while (it.hasNext()) {
ReplicationController rc = it.next();
if ("elasticsearch".equalsIgnoreCase(rc.getMetadata().getName())) {
rcExists = true;
}
}
assertFalse(rcExists);
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesReplicationControllersProducerTest method getReplicationControllerTest.
@Test
public void getReplicationControllerTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:getReplicationController", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_NAME, "elasticsearch");
}
});
ReplicationController result = ex.getOut().getBody(ReplicationController.class);
assertNull(result);
}
Aggregations