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