diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-10-29 10:37:55 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-10-29 10:37:55 +0100 |
commit | 7ca55cf2810664ee1acc4a79f606ff8e77868dc3 (patch) | |
tree | 49e4d53cc86a8f446f311d6c2ef154e2c8c72f3c /vespaclient-container-plugin/src/test | |
parent | 4fe6f3d49419766df69117956b0e352f2b94fe94 (diff) |
Support user specified timeout, and test timeout dispatch
Diffstat (limited to 'vespaclient-container-plugin/src/test')
-rw-r--r-- | vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java index 9e362069738..4aeb0c5f8cc 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java @@ -62,6 +62,9 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.TreeMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -168,7 +171,7 @@ public class DocumentV1ApiTest { } @Test - public void testResponses() { + public void testResponses() throws ExecutionException, InterruptedException { RequestHandlerTestDriver driver = new RequestHandlerTestDriver(handler); // GET at non-existent path returns 404 with available paths var response = driver.sendRequest("http://localhost/document/v1/not-found"); @@ -194,6 +197,7 @@ public class DocumentV1ApiTest { assertEquals(100, ((StaticThrottlePolicy) parameters.getThrottlePolicy()).getMaxPendingCount()); assertEquals("[id]", parameters.getFieldSet()); assertEquals("(all the things)", parameters.getDocumentSelection()); + assertEquals(1000, parameters.getSessionTimeoutMs()); // Put some documents in the response ((DumpVisitorDataHandler) parameters.getLocalDataHandler()).onDocument(doc1, 0); ((DumpVisitorDataHandler) parameters.getLocalDataHandler()).onDocument(doc2, 0); @@ -204,7 +208,7 @@ public class DocumentV1ApiTest { parameters.getControlHandler().onDone(VisitorControlHandler.CompletionCode.TIMEOUT, "timeout is OK"); }); response = driver.sendRequest("http://localhost/document/v1?cluster=content&bucketSpace=default&wantedDocumentCount=1025&concurrency=123" + - "&selection=all%20the%20things&fieldSet=[id]"); + "&selection=all%20the%20things&fieldSet=[id]&timeout=6"); assertSameJson("{" + " \"pathId\": \"/document/v1\"," + " \"documents\": [" + @@ -488,6 +492,28 @@ public class DocumentV1ApiTest { "}", response2.readAll()); assertEquals(500, response2.getStatus()); + // Request timeout is dispatched after timeout has passed. + CountDownLatch latch = new CountDownLatch(1); + var assertions = Executors.newSingleThreadExecutor().submit(() -> { + access.session.expect((id, parameters) -> { + try { + latch.await(); + } + catch (InterruptedException e) { + fail("Not supposed to be interrupted"); + } + return new Result(Result.ResultType.SUCCESS, null); + }); + var response4 = driver.sendRequest("http://localhost/document/v1/space/music/docid/one?cluster=content&fieldSet=go&timeout=0.001"); + assertSameJson("{" + + " \"pathId\": \"/document/v1/space/music/docid/one\"," + + " \"message\": \"Request timeout after 1ms\"" + + "}", response4.readAll()); + assertEquals(504, response4.getStatus()); + }); + latch.countDown(); + assertions.get(); + driver.close(); } |