diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2023-05-23 15:55:14 +0200 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@yahooinc.com> | 2023-05-23 15:55:14 +0200 |
commit | 58ca50532a70115f34b81b3dfad56f72a38a46d3 (patch) | |
tree | f50ea4f99f7aa9bf3df6fb4a34dc8f839ae84ce7 /vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java | |
parent | cdda3f7d16c59c8bd61b8779e15f67cecff3f588 (diff) |
Properly handle open visitor timestamp ranges in request parameters
Diffstat (limited to 'vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java')
-rw-r--r-- | vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java | 33 |
1 files changed, 33 insertions, 0 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 c6cbd20651a..e8f42fbecfa 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 @@ -956,6 +956,39 @@ public class DocumentV1ApiTest { driver.close(); } + private void doTestVisitRequestWithParams(String httpReqParams, Consumer<VisitorParameters> paramChecker) { + try (var driver = new RequestHandlerTestDriver(handler)) { + access.expect(parameters -> { + paramChecker.accept(parameters); + parameters.getControlHandler().onDone(VisitorControlHandler.CompletionCode.SUCCESS, "great success"); + }); + var response = driver.sendRequest("http://localhost/document/v1/?cluster=content&%s".formatted(httpReqParams)); + assertSameJson(""" + { + "pathId": "/document/v1/", + "documents": [ ], + "documentCount": 0 + }""", + response.readAll()); + assertEquals(200, response.getStatus()); + } + } + + @Test + public void visit_timestamp_ranges_can_be_open_in_both_ends() { + // Only specifying fromTimestamp; visit up to current time + doTestVisitRequestWithParams("fromTimestamp=1234", (params) -> { + assertEquals(params.getFromTimestamp(), 1234); + assertEquals(params.getToTimestamp(), 0); // Means "current wall clock time" when it hits storage + }); + + // Only specifying toTimestamp; visit all docs up to this time point + doTestVisitRequestWithParams("toTimestamp=2345", (params) -> { + assertEquals(params.getFromTimestamp(), 0); // The dawn of time(tm) + assertEquals(params.getToTimestamp(), 2345); + }); + } + @Test public void testThroughput() throws InterruptedException { DocumentOperationExecutorConfig executorConfig = new DocumentOperationExecutorConfig.Builder().build(); |