aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java
diff options
context:
space:
mode:
authorOlli Virtanen <olli.virtanen@oath.com>2019-03-22 09:51:14 +0100
committerOlli Virtanen <olli.virtanen@oath.com>2019-03-22 09:51:14 +0100
commit37bf79fdedacad3b46796667e29d86a302f98fc0 (patch)
treee6024f6cdb1aaaa3ee5f888aef3da8473c5cd926 /container-search/src/test/java
parent519d59334ca8c3e314e71f83de618e375a7c2d6c (diff)
Report partial group connection failures through trace, not error
Diffstat (limited to 'container-search/src/test/java')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/FS4SearchInvokerTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java20
2 files changed, 17 insertions, 5 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/FS4SearchInvokerTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/FS4SearchInvokerTestCase.java
index 80f62f879ab..8fd3bc1f3eb 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/FS4SearchInvokerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/FS4SearchInvokerTestCase.java
@@ -31,7 +31,7 @@ public class FS4SearchInvokerTestCase {
var searcher = mockSearcher();
var cluster = new MockSearchCluster("?", 1, 1);
var fs4invoker = new FS4SearchInvoker(searcher, query, mockFailingChannel(), Optional.empty());
- var interleave = new InterleavedSearchInvoker(Collections.singleton(fs4invoker), searcher, cluster);
+ var interleave = new InterleavedSearchInvoker(Collections.singleton(fs4invoker), searcher, cluster, null);
long start = System.currentTimeMillis();
interleave.search(query, QueryPacket.create(null, null), null);
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
index 8c5976a2815..f84f35020d2 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
@@ -15,8 +15,10 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
+import java.util.stream.StreamSupport;
import static com.yahoo.container.handler.Coverage.DEGRADED_BY_MATCH_PHASE;
import static com.yahoo.container.handler.Coverage.DEGRADED_BY_TIMEOUT;
@@ -25,7 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -64,7 +66,9 @@ public class InterleavedSearchInvokerTest {
Result result = invoker.search(query, null, null);
assertTrue("All test scenario events processed", expectedEvents.isEmpty());
- assertNotNull("Result is marked as an error", result.hits().getErrorHit());
+ assertNull("Result is not marked as an error", result.hits().getErrorHit());
+ var message = findTrace(result, "Backend communication timeout");
+ assertThat("Timeout should be reported in a trace message", message.isPresent());
assertTrue("Degradation reason is a normal timeout", result.getCoverage(false).isDegradedByTimeout());
}
@@ -81,7 +85,9 @@ public class InterleavedSearchInvokerTest {
Result result = invoker.search(query, null, null);
assertTrue("All test scenario events processed", expectedEvents.isEmpty());
- assertNotNull("Result is marked as an error", result.hits().getErrorHit());
+ assertNull("Result is not marked as an error", result.hits().getErrorHit());
+ var message = findTrace(result, "Backend communication timeout");
+ assertThat("Timeout should be reported in a trace message", message.isPresent());
assertTrue("Degradataion reason is an adaptive timeout", result.getCoverage(false).isDegradedByAdapativeTimeout());
}
@@ -203,7 +209,7 @@ public class InterleavedSearchInvokerTest {
invokers.add(new MockInvoker(i));
}
- return new InterleavedSearchInvoker(invokers, null, searchCluster) {
+ return new InterleavedSearchInvoker(invokers, null, searchCluster, null) {
@Override
protected long currentTime() {
return clock.millis();
@@ -235,6 +241,11 @@ public class InterleavedSearchInvokerTest {
return coverage;
}
+ private static Optional<String> findTrace(Result result, String prefix) {
+ var strings = result.getQuery().getContext(false).getTrace().traceNode().descendants(String.class).spliterator();
+ return StreamSupport.stream(strings, false).filter(s -> s.startsWith(prefix)).findFirst();
+ }
+
private class Event {
Long expectedTimeout;
long delay;
@@ -270,6 +281,7 @@ public class InterleavedSearchInvokerTest {
public TestQuery() {
super();
setTimeout(5000);
+ setTraceLevel(5);
}
@Override