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