Search in sources :

Example 56 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class DockerRegistrySecretEnricherTest method testDockerRegistry.

@Test
public void testDockerRegistry() {
    new Expectations() {

        {
            {
                context.getSettings();
                result = createSettings();
            }
        }
    };
    DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context);
    KubernetesListBuilder builder = new KubernetesListBuilder();
    builder.addToSecretItems(createBaseSecret(true));
    enricher.addMissingResources(builder);
    KubernetesListBuilder expectedBuilder = new KubernetesListBuilder();
    Secret expectedSecret = createBaseSecret(false);
    expectedSecret.getData().put(SecretConstants.DOCKER_DATA_KEY, "eyJkb2NrZXIuaW8iOnsicGFzc3dvcmQiOiJwYXNzd29yZCIsImVtYWlsIjoiZm9vQGZvby5jb20iLCJ1c2VybmFtZSI6InVzZXJuYW1lIn19");
    expectedBuilder.addToSecretItems(expectedSecret);
    assertEquals(expectedBuilder.build(), builder.build());
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Secret(io.fabric8.kubernetes.api.model.Secret) Test(org.junit.Test)

Example 57 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class JavaRunGeneratorTest method fromSelector.

@Test
public void fromSelector() throws IOException {
    Object[] data = { "3.1.123", PlatformMode.kubernetes, null, "java.upstream.docker", "3.1.redhat-101", PlatformMode.kubernetes, null, "java.redhat.docker", "3.1.123", PlatformMode.openshift, OpenShiftBuildStrategy.docker, "java.upstream.docker", "3.1.redhat-101", PlatformMode.openshift, OpenShiftBuildStrategy.docker, "java.redhat.docker", "3.1.123", PlatformMode.openshift, OpenShiftBuildStrategy.s2i, "java.upstream.s2i", "3.1.redhat-101", PlatformMode.openshift, OpenShiftBuildStrategy.s2i, "java.redhat.s2i" };
    Properties imageProps = getDefaultImageProps();
    for (int i = 0; i < data.length; i += 4) {
        prepareExpectation((String) data[i], (PlatformMode) data[i + 1], (OpenShiftBuildStrategy) data[i + 2]);
        final GeneratorContext context = ctx;
        FromSelector selector = new FromSelector.Default(context, "java");
        String from = selector.getFrom();
        assertEquals(imageProps.getProperty((String) data[i + 3]), from);
    }
}
Also used : GeneratorContext(io.fabric8.maven.generator.api.GeneratorContext) FromSelector(io.fabric8.maven.generator.api.FromSelector) Test(org.junit.Test)

Example 58 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class EnricherManagerTest method enrichSimple.

@Test
public void enrichSimple() {
    new Expectations() {

        {
            context.getConfig();
            result = new ProcessorConfig(Arrays.asList("fmp-project"), null, new HashMap<String, TreeMap>());
        }
    };
    EnricherManager manager = new EnricherManager(null, context);
    KubernetesListBuilder builder = new KubernetesListBuilder();
    builder.addNewReplicaSetItem().withNewSpec().withNewTemplate().withNewSpec().addNewContainer().withName("test").withImage("busybox").endContainer().endSpec().endTemplate().endSpec().endReplicaSetItem();
    manager.enrich(builder);
    KubernetesList list = builder.build();
    assertEquals(1, list.getItems().size());
    ReplicaSet pod = (ReplicaSet) list.getItems().get(0);
    ObjectMeta metadata = pod.getMetadata();
    assertNotNull(metadata);
    Map<String, String> labels = metadata.getLabels();
    assertNotNull(labels);
    assertEquals("fabric8", labels.get("provider"));
}
Also used : Expectations(mockit.Expectations) ReplicaSet(io.fabric8.kubernetes.api.model.extensions.ReplicaSet) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 59 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class EnricherManagerTest method createDefaultResources.

@Test
public void createDefaultResources() {
    new Expectations() {

        {
            context.getConfig();
            result = new ProcessorConfig(Arrays.asList("fmp-controller"), null, null);
            context.getImages();
            result = new ImageConfiguration.Builder().alias("img1").name("img1").build();
        }
    };
    EnricherManager manager = new EnricherManager(null, context);
    KubernetesListBuilder builder = new KubernetesListBuilder();
    manager.createDefaultResources(builder);
    assertTrue(builder.build().getItems().size() > 0);
}
Also used : Expectations(mockit.Expectations) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 60 with Context

use of io.fabric8.kubernetes.api.model.Context in project strimzi by strimzi.

the class KafkaAssemblyOperatorTest method testUpdateKafkaClusterScaleUp.

@Test
public void testUpdateKafkaClusterScaleUp(TestContext context) {
    ConfigMap clusterCm = getConfigMap("bar");
    clusterCm.getData().put(KafkaCluster.KEY_REPLICAS, "4");
    updateCluster(context, getConfigMap("bar"), clusterCm, false, false);
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)135 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)58 Async (io.vertx.ext.unit.Async)52 Expectations (mockit.Expectations)34 Probe (io.fabric8.kubernetes.api.model.Probe)33 Reconciliation (io.strimzi.controller.cluster.Reconciliation)24 File (java.io.File)23 Git (org.eclipse.jgit.api.Git)23 GitContext (io.fabric8.api.GitContext)21 IOException (java.io.IOException)21 ConfigMapOperator (io.strimzi.controller.cluster.operator.resource.ConfigMapOperator)20 ServiceOperator (io.strimzi.controller.cluster.operator.resource.ServiceOperator)20 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)18 HashMap (java.util.HashMap)17 LockHandle (io.fabric8.api.LockHandle)15 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)15 NonNamespaceOperation (io.fabric8.kubernetes.client.dsl.NonNamespaceOperation)15 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)15 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)14 Resource (io.fabric8.kubernetes.client.dsl.Resource)14