Search in sources :

Example 6 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class OpenshiftBuildServiceIntegrationTest method testDockerBuildNoS2iSuffix.

@Test
public void testDockerBuildNoS2iSuffix() throws Exception {
    final BuildServiceConfig dockerConfig = withBuildServiceConfig(BuildServiceConfig.builder().buildDirectory(baseDir).buildRecreateMode(BuildRecreateMode.none).jKubeBuildStrategy(JKubeBuildStrategy.docker).resourceConfig(mockedResourceConfig).build());
    final WebServerEventCollector collector = prepareMockServer(dockerConfig, true, false, false);
    new OpenshiftBuildService(jKubeServiceHub).build(image);
    assertTrue(mockServer.getOpenShiftMockServer().getRequestCount() > 8);
    collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
    assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}", collector.getBodies().get(1));
    collector.assertEventsNotRecorded("patch-build-config");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) Test(org.junit.Test)

Example 7 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class OpenshiftBuildServiceIntegrationTest method testSuccessfulDockerImageOutputBuild.

@Test
public void testSuccessfulDockerImageOutputBuild() throws Exception {
    final BuildServiceConfig config = withBuildServiceConfig(dockerImageConfig.build());
    final WebServerEventCollector collector = prepareMockServer(config, true, false, false);
    new OpenshiftBuildService(jKubeServiceHub).build(image);
    // we should add a better way to assert that a certain call has been made
    assertTrue(mockServer.getOpenShiftMockServer().getRequestCount() > 7);
    collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
    assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i-suffix2\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"DockerImage\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}", collector.getBodies().get(1));
    collector.assertEventsNotRecorded("patch-build-config");
    assertFalse(containsRequest("imagestreams"));
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) Test(org.junit.Test)

Example 8 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class OpenshiftBuildServiceIntegrationTest method testSuccessfulSecondBuild.

@Test
public void testSuccessfulSecondBuild() throws Exception {
    final BuildServiceConfig config = withBuildServiceConfig(defaultConfig.build());
    final WebServerEventCollector collector = prepareMockServer(config, true, true, true);
    new OpenshiftBuildService(jKubeServiceHub).build(image);
    collector.assertEventsRecordedInOrder("build-config-check", "patch-build-config", "pushed");
    collector.assertEventsNotRecorded("new-build-config");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) Test(org.junit.Test)

Example 9 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class OpenshiftBuildServiceIntegrationTest method testDockerBuild.

@Test
public void testDockerBuild() throws Exception {
    final BuildServiceConfig dockerConfig = withBuildServiceConfig(BuildServiceConfig.builder().buildDirectory(baseDir).buildRecreateMode(BuildRecreateMode.none).s2iBuildNameSuffix("-docker").jKubeBuildStrategy(JKubeBuildStrategy.docker).resourceConfig(mockedResourceConfig).build());
    final WebServerEventCollector collector = prepareMockServer(dockerConfig, true, false, false);
    new OpenshiftBuildService(jKubeServiceHub).build(image);
    assertTrue(mockServer.getOpenShiftMockServer().getRequestCount() > 8);
    collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
    assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}", collector.getBodies().get(1));
    collector.assertEventsNotRecorded("patch-build-config");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) Test(org.junit.Test)

Example 10 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class BuildMojoTest method testBuildServiceConfigBuilderReturnsNonNullResourceConfigIfConfigured.

@Test
public void testBuildServiceConfigBuilderReturnsNonNullResourceConfigIfConfigured() {
    // Given
    BuildMojo buildMojo = new BuildMojo();
    buildMojo.project = mavenProject;
    buildMojo.resources = ResourceConfig.builder().openshiftBuildConfig(OpenshiftBuildConfig.builder().limit("cpu", "200m").request("memory", "1Gi").build()).build();
    buildMojo.resourceDir = new File("src/main/jkube");
    // When
    BuildServiceConfig.BuildServiceConfigBuilder buildServiceConfigBuilder = buildMojo.buildServiceConfigBuilder();
    // Then
    assertThat(buildServiceConfigBuilder).isNotNull();
    BuildServiceConfig buildServiceConfig = buildServiceConfigBuilder.build();
    assertThat(buildServiceConfig).isNotNull();
    assertThat(buildServiceConfig.getResourceConfig()).isNotNull();
    assertThat(buildServiceConfig.getResourceConfig().getOpenshiftBuildConfig()).isNotNull();
    assertThat(buildServiceConfig.getResourceConfig().getOpenshiftBuildConfig().getLimits()).containsEntry("cpu", "200m");
    assertThat(buildServiceConfig.getResourceConfig().getOpenshiftBuildConfig().getRequests()).containsEntry("memory", "1Gi");
    assertThat(buildServiceConfig.getResourceDir().getPath()).isEqualTo("src/main/jkube");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) File(java.io.File) Test(org.junit.Test)

Aggregations

BuildServiceConfig (org.eclipse.jkube.kit.config.service.BuildServiceConfig)24 Test (org.junit.Test)20 ImageName (org.eclipse.jkube.kit.config.image.ImageName)6 BuildOutput (io.fabric8.openshift.api.model.BuildOutput)3 File (java.io.File)3 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)3 JKubeServiceHub (org.eclipse.jkube.kit.config.service.JKubeServiceHub)3 LocalObjectReferenceBuilder (io.fabric8.kubernetes.api.model.LocalObjectReferenceBuilder)2 BuildStrategy (io.fabric8.openshift.api.model.BuildStrategy)2 BuildStrategyBuilder (io.fabric8.openshift.api.model.BuildStrategyBuilder)2 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)2 KitLogger (org.eclipse.jkube.kit.common.KitLogger)2 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)2 JKubeBuildStrategy (org.eclipse.jkube.kit.config.image.build.JKubeBuildStrategy)2 OpenShiftBuildServiceUtils.createBuildOutput (org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildOutput)2 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)1 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)1 BuildConfigSpec (io.fabric8.openshift.api.model.BuildConfigSpec)1 BuildOutputBuilder (io.fabric8.openshift.api.model.BuildOutputBuilder)1 FileWriter (java.io.FileWriter)1