You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2019/12/03 01:20:41 UTC
[tika] branch master updated: improve logging and error handling in
TikaServerIntegrationTest
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/master by this push:
new a6f74fe improve logging and error handling in TikaServerIntegrationTest
a6f74fe is described below
commit a6f74fea25c4c6a8bafd529492d2643a97622a99
Author: tallison <ta...@apache.org>
AuthorDate: Mon Dec 2 20:20:09 2019 -0500
improve logging and error handling in TikaServerIntegrationTest
---
.../tika/server/TikaServerIntegrationTest.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tika-server/src/test/java/org/apache/tika/server/TikaServerIntegrationTest.java b/tika-server/src/test/java/org/apache/tika/server/TikaServerIntegrationTest.java
index a91962b..c36ab90 100644
--- a/tika-server/src/test/java/org/apache/tika/server/TikaServerIntegrationTest.java
+++ b/tika-server/src/test/java/org/apache/tika/server/TikaServerIntegrationTest.java
@@ -43,6 +43,7 @@ import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -61,6 +62,8 @@ public class TikaServerIntegrationTest extends TikaTest {
private static final String TEST_STATIC_STDOUT_STDERR = "mock/testStaticStdOutErr.xml";
private static final String META_PATH = "/rmeta";
+ private static final long MAX_WAIT_MS = 60000;
+
//running into conflicts on 9998 with the CXFTestBase tests
//TODO: figure out why?!
private static final String INTEGRATION_TEST_PORT = "9999";
@@ -423,20 +426,17 @@ public class TikaServerIntegrationTest extends TikaTest {
}
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 < maxWaitMs) {
+ while (elapsed < MAX_WAIT_MS) {
try {
Response response = client.get();
if (response.getStatus() == 200) {
- Thread.sleep(100);
- response = client.get();
- if (response.getStatus() == 200) {
- LOG.info("client observes that server successfully started");
- return;
- }
+ elapsed = Duration.between(started, Instant.now()).toMillis();
+ LOG.info("client observes server successfully started after " +
+ elapsed+ " ms");
+ return;
}
LOG.debug("tika test client failed to connect to server with status: {}", response.getStatus());
@@ -447,8 +447,8 @@ public class TikaServerIntegrationTest extends TikaTest {
Thread.sleep(100);
elapsed = Duration.between(started, Instant.now()).toMillis();
}
- throw new IllegalStateException("couldn't connect to server after " +
- maxWaitMs + " ms");
+ throw new TimeoutException("couldn't connect to server after " +
+ elapsed + " ms");
}
@Test