Search in sources :

Example 6 with OpenshiftBuildService

use of io.fabric8.maven.core.service.openshift.OpenshiftBuildService in project fabric8-maven-plugin by fabric8io.

the class OpenshiftBuildServiceTest method testSuccessfulBuild.

@Test
public void testSuccessfulBuild() throws Exception {
    int nTries = 0;
    boolean bTestComplete = false;
    do {
        try {
            nTries++;
            BuildService.BuildServiceConfig config = defaultConfig.build();
            WebServerEventCollector<OpenShiftMockServer> collector = createMockServer(config, true, 50, false, false);
            OpenShiftMockServer mockServer = collector.getMockServer();
            DefaultOpenShiftClient client = (DefaultOpenShiftClient) mockServer.createOpenShiftClient();
            LOG.info("Current write timeout is : {}", client.getHttpClient().writeTimeoutMillis());
            LOG.info("Current read timeout is : {}", client.getHttpClient().readTimeoutMillis());
            LOG.info("Retry on failure : {}", client.getHttpClient().retryOnConnectionFailure());
            OpenshiftBuildService service = new OpenshiftBuildService(client, logger, dockerServiceHub, config);
            service.build(image);
            // we should Foadd a better way to assert that a certain call has been made
            assertTrue(mockServer.getRequestCount() > 8);
            collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
            collector.assertEventsNotRecorded("patch-build-config");
            bTestComplete = true;
        } catch (Fabric8ServiceException exception) {
            Throwable rootCause = getRootCause(exception);
            logger.warn("A problem encountered while running test {}, retrying..", exception.getMessage());
            // Let's wait for a while, and then retry again
            if (rootCause != null && rootCause instanceof IOException) {
                continue;
            }
        }
    } while (nTries < MAX_TIMEOUT_RETRIES && !bTestComplete);
}
Also used : OpenShiftMockServer(io.fabric8.openshift.client.server.mock.OpenShiftMockServer) Fabric8ServiceException(io.fabric8.maven.core.service.Fabric8ServiceException) BuildService(io.fabric8.maven.core.service.BuildService) IOException(java.io.IOException) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 BuildService (io.fabric8.maven.core.service.BuildService)4 DefaultOpenShiftClient (io.fabric8.openshift.client.DefaultOpenShiftClient)4 OpenShiftMockServer (io.fabric8.openshift.client.server.mock.OpenShiftMockServer)4 Fabric8ServiceException (io.fabric8.maven.core.service.Fabric8ServiceException)3 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)3 IOException (java.io.IOException)3 DockerBuildService (io.fabric8.maven.core.service.kubernetes.DockerBuildService)2 OpenshiftBuildService (io.fabric8.maven.core.service.openshift.OpenshiftBuildService)2 Controller (io.fabric8.kubernetes.api.Controller)1 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)1 ArchiverCustomizer (io.fabric8.maven.docker.assembly.ArchiverCustomizer)1 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)1 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)1 MojoParameters (io.fabric8.maven.docker.util.MojoParameters)1 BuildBuilder (io.fabric8.openshift.api.model.BuildBuilder)1 BuildConfigBuilder (io.fabric8.openshift.api.model.BuildConfigBuilder)1 ImageStreamBuilder (io.fabric8.openshift.api.model.ImageStreamBuilder)1 ImageStreamStatusBuilder (io.fabric8.openshift.api.model.ImageStreamStatusBuilder)1 NamedTagEventListBuilder (io.fabric8.openshift.api.model.NamedTagEventListBuilder)1