summaryrefslogtreecommitdiffstats
path: root/documentapi/src/test
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahoo-inc.com>2017-05-09 12:33:44 +0200
committerGitHub <noreply@github.com>2017-05-09 12:33:44 +0200
commit795969419adfa7e34cda2ba8c959502f43324b09 (patch)
tree073374eeb22a0dba8b05db1b839ac6ea58552514 /documentapi/src/test
parent4f36cf1ae65ceaac515c7a3828fef4bd093ddff7 (diff)
Treat document V1 API visiting timeouts with progress as successful (#2401)
Previously, using a visitor with a selection that did not match any buckets visited during the session's lifetime would trigger a timeout error to the client and abort the visiting. With this change, we special case timeouts if they have successfully visited at least 1 bucket and return a successful response for these. The client can then use the updated continuation token for its subsequent request and continue from where the timed out session left off. The timeout special cased handling is done _outside_ the session and control handler to avoid increasing session-internal complexity, and since not all visitor use cases want this behavior (e.g. streaming search).
Diffstat (limited to 'documentapi/src/test')
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/test/VisitorControlHandlerTest.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/test/VisitorControlHandlerTest.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/test/VisitorControlHandlerTest.java
new file mode 100644
index 00000000000..d8340e6a3f6
--- /dev/null
+++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/test/VisitorControlHandlerTest.java
@@ -0,0 +1,39 @@
+// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.documentapi.messagebus.test;
+
+import com.yahoo.documentapi.VisitorControlHandler;
+import com.yahoo.vdslib.VisitorStatistics;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class VisitorControlHandlerTest {
+
+ @Test
+ public void has_visited_any_buckets_is_false_if_no_bucket_stats_recorded() {
+ VisitorControlHandler handler = new VisitorControlHandler();
+ assertFalse(handler.hasVisitedAnyBuckets());
+ }
+
+ @Test
+ public void has_visited_any_buckets_is_false_if_zero_buckets_visited() {
+ VisitorControlHandler handler = new VisitorControlHandler();
+ VisitorStatistics stats = new VisitorStatistics();
+ stats.setBucketsVisited(0);
+ handler.onVisitorStatistics(stats);
+
+ assertFalse(handler.hasVisitedAnyBuckets());
+ }
+
+ @Test
+ public void has_visited_any_buckets_is_true_if_more_than_zero_buckets_visited() {
+ VisitorControlHandler handler = new VisitorControlHandler();
+ VisitorStatistics stats = new VisitorStatistics();
+ stats.setBucketsVisited(1);
+ handler.onVisitorStatistics(stats);
+
+ assertTrue(handler.hasVisitedAnyBuckets());
+ }
+
+}