Search in sources :

Example 6 with Collector

use of io.fabric8.support.api.Collector 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

OpenShiftMockServer (io.fabric8.openshift.client.server.mock.OpenShiftMockServer)5 BuildService (io.fabric8.maven.core.service.BuildService)4 DefaultOpenShiftClient (io.fabric8.openshift.client.DefaultOpenShiftClient)4 IOException (java.io.IOException)4 Test (org.junit.Test)4 Fabric8ServiceException (io.fabric8.maven.core.service.Fabric8ServiceException)3 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)3 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)2 BuildBuilder (io.fabric8.openshift.api.model.BuildBuilder)2 BuildConfigBuilder (io.fabric8.openshift.api.model.BuildConfigBuilder)2 ImageStreamBuilder (io.fabric8.openshift.api.model.ImageStreamBuilder)2 ImageStreamStatusBuilder (io.fabric8.openshift.api.model.ImageStreamStatusBuilder)2 NamedTagEventListBuilder (io.fabric8.openshift.api.model.NamedTagEventListBuilder)2 File (java.io.File)2 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)1 WatchEvent (io.fabric8.kubernetes.api.model.WatchEvent)1 WebServerEventCollector (io.fabric8.maven.core.util.WebServerEventCollector)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