Search in sources :

Example 26 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class ConfigHelperTest method initImageConfiguration_withSimpleImageConfiguration_shouldReturnImageConfiguration.

@Test
public void initImageConfiguration_withSimpleImageConfiguration_shouldReturnImageConfiguration() {
    // Given
    ImageConfiguration dummyImageConfiguration = ImageConfiguration.builder().name("foo/bar:latest").build(BuildConfiguration.builder().from("foobase:latest").build()).build();
    List<ImageConfiguration> images = new ArrayList<>();
    images.add(dummyImageConfiguration);
    when(jKubeConfiguration.getBasedir()).thenReturn(new File("dummydir"));
    when(imageConfigResolver.resolve(dummyImageConfiguration, javaProject)).thenReturn(images);
    // When
    List<ImageConfiguration> resolvedImages = ConfigHelper.initImageConfiguration("1.12", new Date(), images, imageConfigResolver, logger, null, configs -> configs, jKubeConfiguration);
    // Then
    assertThat(resolvedImages).isNotNull().hasSize(1).element(0).isEqualTo(dummyImageConfiguration);
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ArrayList(java.util.ArrayList) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 27 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class GeneratorManagerTest method generate_withTestGenerator_shouldProcessImages.

@Test
public void generate_withTestGenerator_shouldProcessImages() {
    // Given
    final List<ImageConfiguration> images = Collections.singletonList(new ImageConfiguration());
    // When
    final List<ImageConfiguration> result = GeneratorManager.generate(images, generatorContext, false);
    // Then
    assertThat(result).isNotSameAs(images).hasSize(1).extracting(ImageConfiguration::getName).contains("processed-by-test");
    // @formatter:off
    new Verifications() {

        {
            logger.info("Running generator %s", "fake-generator");
            times = 1;
        }
    };
// @formatter:on
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Verifications(mockit.Verifications) Test(org.junit.Test)

Example 28 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class DockerHealthCheckEnricherTest method testEnrichFromSingleImage.

@Test
public void testEnrichFromSingleImage() throws Exception {
    // Setup mock behaviour
    new Expectations() {

        {
            List<ImageConfiguration> images = Arrays.asList(ImageConfiguration.builder().alias("myImage").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.cmd).cmd(Arguments.builder().shell("/bin/check").build()).timeout("1s").interval("1h1s").retries(3).build()).build()).build(), ImageConfiguration.builder().alias("myImage2").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.cmd).cmd(Arguments.builder().shell("/xxx/check").build()).timeout("3s").interval("3h1s").retries(9).build()).build()).build());
            context.getConfiguration();
            result = Configuration.builder().images(images).build();
        }
    };
    KubernetesListBuilder builder = createDeployment("myImage");
    DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
    enricher.create(PlatformMode.kubernetes, builder);
    KubernetesList list = builder.build();
    assertEquals(1, list.getItems().size());
    assertHealthCheckMatching(builder.build().getItems().get(0), "livenessProbe", "/bin/check", 1, 3601, 3);
    assertHealthCheckMatching(builder.build().getItems().get(0), "readinessProbe", "/bin/check", 1, 3601, 3);
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Test(org.junit.Test)

Example 29 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class DockerHealthCheckEnricherTest method testInvalidHealthCheck.

@Test
public void testInvalidHealthCheck() throws Exception {
    // Setup mock behaviour
    new Expectations() {

        {
            final ImageConfiguration image = ImageConfiguration.builder().alias("myImage").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.none).build()).build()).build();
            context.getConfiguration();
            result = Configuration.builder().image(image).build();
        }
    };
    KubernetesListBuilder builder = createDeployment("myImage");
    DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
    enricher.create(PlatformMode.kubernetes, builder);
    KubernetesList list = builder.build();
    assertEquals(1, list.getItems().size());
    assertNoProbes(list.getItems().get(0));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Test(org.junit.Test)

Example 30 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class DockerHealthCheckEnricherTest method testEnrichFromDoubleImage.

@Test
public void testEnrichFromDoubleImage() throws Exception {
    // Setup mock behaviour
    new Expectations() {

        {
            List<ImageConfiguration> images = Arrays.asList(ImageConfiguration.builder().alias("myImage").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.cmd).cmd(Arguments.builder().shell("/bin/check").build()).timeout("1s").interval("1h1s").retries(3).build()).build()).build(), ImageConfiguration.builder().alias("myImage2").build(BuildConfiguration.builder().healthCheck(HealthCheckConfiguration.builder().mode(HealthCheckMode.cmd).cmd(Arguments.builder().shell("/xxx/check").build()).timeout("3s").interval("3h1s").retries(9).build()).build()).build());
            context.getConfiguration();
            result = Configuration.builder().images(images).build();
            context.getProcessingInstructions();
            result = Collections.singletonMap("FABRIC8_GENERATED_CONTAINERS", "myImage,myImage2");
        }
    };
    KubernetesListBuilder builder = addDeployment(createDeployment("myImage"), "myImage2");
    DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
    enricher.create(PlatformMode.kubernetes, builder);
    KubernetesList list = builder.build();
    assertEquals(2, list.getItems().size());
    assertHealthCheckMatching(builder.build().getItems().get(0), "livenessProbe", "/bin/check", 1, 3601, 3);
    assertHealthCheckMatching(builder.build().getItems().get(0), "readinessProbe", "/bin/check", 1, 3601, 3);
    assertHealthCheckMatching(builder.build().getItems().get(1), "livenessProbe", "/xxx/check", 3, 10801, 9);
    assertHealthCheckMatching(builder.build().getItems().get(1), "readinessProbe", "/xxx/check", 3, 10801, 9);
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Test(org.junit.Test)

Aggregations

ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)109 Test (org.junit.Test)75 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)29 RunImageConfiguration (org.eclipse.jkube.kit.config.image.RunImageConfiguration)28 File (java.io.File)26 ArrayList (java.util.ArrayList)19 Expectations (mockit.Expectations)15 GroupArtifactVersion (org.eclipse.jkube.kit.config.resource.GroupArtifactVersion)11 Before (org.junit.Before)11 IOException (java.io.IOException)9 Properties (java.util.Properties)8 KitLogger (org.eclipse.jkube.kit.common.KitLogger)8 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)7 JKubeServiceException (org.eclipse.jkube.kit.config.service.JKubeServiceException)7 WatchImageConfiguration (org.eclipse.jkube.kit.config.image.WatchImageConfiguration)6 ResourceConfig (org.eclipse.jkube.kit.config.resource.ResourceConfig)6 List (java.util.List)5 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)5 VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)5 Container (io.fabric8.kubernetes.api.model.Container)4