Skip to content

Commit

Permalink
improve logging and error reporting in TikaServerIntegrationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison committed Dec 2, 2019
1 parent 85cd36d commit 42676a6
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,27 +423,32 @@ public void run() {
}

private void awaitServerStartup() throws Exception {

long maxWaitMs = 30000;
Instant started = Instant.now();
long elapsed = Duration.between(started, Instant.now()).toMillis();
WebClient client = WebClient.create(endPoint+"/tika").accept("text/plain");
while (elapsed < 30000) {
while (elapsed < maxWaitMs) {
try {
Response response = client.get();
if (response.getStatus() == 200) {
return;
Thread.sleep(100);
response = client.get();
if (response.getStatus() == 200) {
LOG.info("client observes that server successfully started");
return;
}
}
LOG.info("tika test client failed to connect to server with status: {}", response.getStatus());
LOG.debug("tika test client failed to connect to server with status: {}", response.getStatus());

} catch (javax.ws.rs.ProcessingException e) {
LOG.info("tika test client failed to connect to server: {}", e.getMessage());
LOG.debug("tika test client failed to connect to server", e);
}

Thread.sleep(100);
elapsed = Duration.between(started, Instant.now()).toMillis();
}

throw new IllegalStateException("couldn't connect to server after " +
maxWaitMs + " ms");
}

@Test
Expand Down

0 comments on commit 42676a6

Please sign in to comment.