Search in sources :

Example 11 with BuildServiceConfig

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

the class OpenShiftBuildServiceUtilsTest method computeS2IBuildName_withImageNameAndEmptyBuildServiceConfig_shouldReturnName.

@Test
public void computeS2IBuildName_withImageNameAndEmptyBuildServiceConfig_shouldReturnName() {
    // Given
    final ImageName imageName = new ImageName("registry/name:tag");
    // When
    final String result = computeS2IBuildName(new BuildServiceConfig(), imageName);
    // Then
    assertThat(result).isEqualTo("name");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageName(org.eclipse.jkube.kit.config.image.ImageName) Test(org.junit.Test)

Example 12 with BuildServiceConfig

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

the class OpenShiftBuildServiceUtilsTest method computeS2IBuildName_withImageNameAndBuildServiceWithS2I_shouldReturnNameWithDefaultSuffix.

@Test
public void computeS2IBuildName_withImageNameAndBuildServiceWithS2I_shouldReturnNameWithDefaultSuffix() {
    // Given
    final BuildServiceConfig buildServiceConfig = BuildServiceConfig.builder().jKubeBuildStrategy(JKubeBuildStrategy.s2i).buildDirectory(temporaryFolder.getRoot().getAbsolutePath()).build();
    final ImageName imageName = new ImageName("registry/name:tag");
    // When
    final String result = computeS2IBuildName(buildServiceConfig, imageName);
    // Then
    assertThat(result).isEqualTo("name-s2i");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageName(org.eclipse.jkube.kit.config.image.ImageName) Test(org.junit.Test)

Example 13 with BuildServiceConfig

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

the class OpenshiftBuildServiceIntegrationTest method testSuccessfulBuildWithResourceConfig.

@Test
public void testSuccessfulBuildWithResourceConfig() throws Exception {
    final Map<String, String> limitsMap = new HashMap<>();
    limitsMap.put("cpu", "100m");
    limitsMap.put("memory", "256Mi");
    when(mockedResourceConfig.getOpenshiftBuildConfig()).thenReturn(OpenshiftBuildConfig.builder().limits(limitsMap).build());
    final BuildServiceConfig config = withBuildServiceConfig(defaultConfig.resourceConfig(mockedResourceConfig).build());
    final WebServerEventCollector collector = prepareMockServer(config, true, false, false);
    new OpenshiftBuildService(jKubeServiceHub).build(image);
    collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
    collector.assertEventsNotRecorded("patch-build-config");
    assertThat(Serialization.unmarshal(collector.getBodies().get(1), BuildConfig.class)).hasFieldOrPropertyWithValue("metadata.name", "myapp-s2i-suffix2").extracting(BuildConfig::getSpec).hasFieldOrPropertyWithValue("output.to.kind", "ImageStreamTag").hasFieldOrPropertyWithValue("output.to.name", "myapp:latest").hasFieldOrPropertyWithValue("output.to.namespace", null).hasFieldOrPropertyWithValue("resources.limits.memory", Quantity.parse("256Mi")).hasFieldOrPropertyWithValue("resources.limits.cpu", Quantity.parse("100m")).hasFieldOrPropertyWithValue("source.type", "Binary").hasFieldOrPropertyWithValue("strategy.type", "Source").hasFieldOrPropertyWithValue("strategy.sourceStrategy.from.kind", "DockerImage").hasFieldOrPropertyWithValue("strategy.sourceStrategy.from.name", "myapp");
    assertTrue(containsRequest("imagestreams"));
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 14 with BuildServiceConfig

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

the class OpenshiftBuildServiceIntegrationTest method testSuccessfulDockerImageOutputBuildSecret.

@Test
public void testSuccessfulDockerImageOutputBuildSecret() throws Exception {
    final BuildServiceConfig config = withBuildServiceConfig(dockerImageConfigSecret.build());
    final WebServerEventCollector collector = prepareMockServer(config, true, false, false);
    new OpenshiftBuildService(jKubeServiceHub).build(image);
    // we should find 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\":{\"pushSecret\":{\"name\":\"pushsecret-fabric8\"},\"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 15 with BuildServiceConfig

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

the class OpenshiftBuildServiceIntegrationTest method testSuccessfulBuildNoS2iSuffix.

@Test
public void testSuccessfulBuildNoS2iSuffix() throws Exception {
    final BuildServiceConfig config = withBuildServiceConfig(defaultConfig.s2iBuildNameSuffix(null).build());
    final WebServerEventCollector collector = prepareMockServer(config, true, false, false);
    new OpenshiftBuildService(jKubeServiceHub).build(image);
    // we should find a better way to assert that a certain call has been made
    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-s2i\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"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");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) 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