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");
}
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");
}
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"));
}
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"));
}
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");
}
Aggregations