Search in sources :

Example 91 with Result

use of io.fabric8.insight.metrics.model.Result in project camel by apache.

the class KubernetesBuildConfigsProducerTest 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_BUILD_CONFIGS_LABELS, labels);
        }
    });
    List<BuildConfig> result = ex.getOut().getBody(List.class);
    assertTrue(result.size() == 0);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 92 with Result

use of io.fabric8.insight.metrics.model.Result in project camel by apache.

the class KubernetesBuildsProducerTest 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_BUILDS_LABELS, labels);
        }
    });
    List<Build> result = ex.getOut().getBody(List.class);
    assertTrue(result.size() == 0);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Build(io.fabric8.openshift.api.model.Build) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 93 with Result

use of io.fabric8.insight.metrics.model.Result in project camel by apache.

the class KubernetesConfigMapsProducerTest method createGetAndDeleteConfigMap.

@Test
public void createGetAndDeleteConfigMap() throws Exception {
    if (ObjectHelper.isEmpty(authToken)) {
        return;
    }
    Exchange ex = template.request("direct:createConfigMap", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, "test");
            Map<String, String> labels = new HashMap<String, String>();
            labels.put("this", "rocks");
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS, labels);
            Map<String, String> data = new HashMap<String, String>();
            data.put("test", "test1");
            data.put("test1", "test2");
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_DATA, data);
        }
    });
    ex = template.request("direct:getConfigMap", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, "test");
        }
    });
    ConfigMap result = ex.getOut().getBody(ConfigMap.class);
    assertNotNull(result);
    assertTrue(result.getData().containsKey("test"));
    assertTrue(result.getData().containsKey("test1"));
    assertEquals("test1", result.getData().get("test"));
    assertEquals("test2", result.getData().get("test1"));
    ex = template.request("direct:deleteConfigMap", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, "test");
        }
    });
    boolean configMapDeleted = ex.getOut().getBody(Boolean.class);
    assertTrue(configMapDeleted);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Map(java.util.Map) HashMap(java.util.HashMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Test(org.junit.Test)

Example 94 with Result

use of io.fabric8.insight.metrics.model.Result in project camel by apache.

the class KubernetesNamespacesProducerTest method listTest.

@Test
public void listTest() throws Exception {
    if (ObjectHelper.isEmpty(authToken)) {
        return;
    }
    List<Namespace> result = template.requestBody("direct:list", "", List.class);
    boolean defaultExists = false;
    Iterator<Namespace> it = result.iterator();
    while (it.hasNext()) {
        Namespace namespace = it.next();
        if ("default".equalsIgnoreCase(namespace.getMetadata().getName())) {
            defaultExists = true;
        }
    }
    assertTrue(defaultExists);
}
Also used : Namespace(io.fabric8.kubernetes.api.model.Namespace) Test(org.junit.Test)

Example 95 with Result

use of io.fabric8.insight.metrics.model.Result in project camel by apache.

the class KubernetesNamespacesProducerTest method createListByLabelsAndDeleteNamespace.

@Test
public void createListByLabelsAndDeleteNamespace() throws Exception {
    if (ObjectHelper.isEmpty(authToken)) {
        return;
    }
    Exchange ex = template.request("direct:createNamespace", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "test");
            Map<String, String> labels = new HashMap<String, String>();
            labels.put("this", "rocks");
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_LABELS, labels);
        }
    });
    Namespace ns = ex.getOut().getBody(Namespace.class);
    assertEquals(ns.getMetadata().getName(), "test");
    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("this", "rocks");
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_LABELS, labels);
        }
    });
    List<Namespace> result = ex.getOut().getBody(List.class);
    boolean testExists = false;
    Iterator<Namespace> it = result.iterator();
    while (it.hasNext()) {
        Namespace namespace = it.next();
        if ("test".equalsIgnoreCase(namespace.getMetadata().getName())) {
            testExists = true;
        }
    }
    assertTrue(testExists);
    ex = template.request("direct:deleteNamespace", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "test");
        }
    });
    boolean nsDeleted = ex.getOut().getBody(Boolean.class);
    assertTrue(nsDeleted);
}
Also used : Processor(org.apache.camel.Processor) HashMap(java.util.HashMap) Namespace(io.fabric8.kubernetes.api.model.Namespace) Exchange(org.apache.camel.Exchange) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)104 Expectations (mockit.Expectations)49 HashMap (java.util.HashMap)32 Map (java.util.Map)24 ArrayList (java.util.ArrayList)23 File (java.io.File)21 GitContext (io.fabric8.api.GitContext)20 IOException (java.io.IOException)20 Exchange (org.apache.camel.Exchange)20 Processor (org.apache.camel.Processor)20 DefaultPullPushPolicy (io.fabric8.git.internal.DefaultPullPushPolicy)18 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)17 Probe (io.fabric8.kubernetes.api.model.Probe)16 PatchResult (io.fabric8.patch.management.PatchResult)13 Properties (java.util.Properties)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)11 Patch (io.fabric8.patch.management.Patch)11 PatchException (io.fabric8.patch.management.PatchException)11 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)10 TreeMap (java.util.TreeMap)10