diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-22 22:16:42 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-23 10:01:17 +0100 |
commit | ef637d4a7236d6570c748ba5782e0435f628bd9a (patch) | |
tree | d7c4a7ab240d2faca50eace28eb18db2cda5240c /container-search/src/test/java/com | |
parent | b8165e0e316527dc956489bc416f9ccb83cf1904 (diff) |
Make a few simpler interfaces instead of carrying one huge implement all SearchCluster around.
Diffstat (limited to 'container-search/src/test/java/com')
5 files changed, 45 insertions, 56 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java index 974441fc5fc..10e188d092c 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java @@ -33,7 +33,7 @@ class MockDispatcher extends Dispatcher { } private MockDispatcher(ClusterMonitor clusterMonitor, SearchCluster searchCluster, DispatchConfig dispatchConfig, RpcResourcePool rpcResourcePool) { - this(clusterMonitor, searchCluster, dispatchConfig, new RpcInvokerFactory(rpcResourcePool, searchCluster)); + this(clusterMonitor, searchCluster, dispatchConfig, new RpcInvokerFactory(rpcResourcePool, searchCluster, dispatchConfig)); } private MockDispatcher(ClusterMonitor clusterMonitor, SearchCluster searchCluster, DispatchConfig dispatchConfig, RpcInvokerFactory invokerFactory) { diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java index a6c07b74a92..bc92afdb8fc 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java @@ -10,6 +10,7 @@ import com.yahoo.search.dispatch.searchcluster.PingFactory; import com.yahoo.search.dispatch.searchcluster.Pinger; import com.yahoo.search.dispatch.searchcluster.PongHandler; import com.yahoo.search.dispatch.searchcluster.SearchCluster; +import com.yahoo.vespa.config.search.DispatchConfig; import org.junit.jupiter.api.Test; import java.util.List; @@ -26,18 +27,19 @@ import static org.junit.jupiter.api.Assertions.fail; * @author ollivir */ public class DispatcherTest { + private final DispatchConfig dispatchConfig = createDispatchConfig(); @Test void requireThatDispatcherSupportsSearchPath() { SearchCluster cl = new MockSearchCluster("1", 2, 2); Query q = new Query(); q.getModel().setSearchPath("1/0"); // second node in first group - MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, (nodes, a) -> { + MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, dispatchConfig, (nodes, a) -> { assertEquals(1, nodes.size()); assertEquals(1, nodes.get(0).key()); return true; }); - Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, createDispatchConfig(), invokerFactory); + Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, dispatchConfig, invokerFactory); SearchInvoker invoker = disp.getSearchInvoker(q, null); assertNotNull(invoker); invokerFactory.verifyAllEventsProcessed(); @@ -52,8 +54,8 @@ public class DispatcherTest { return Optional.of(new Node(1, "test", 1)); } }; - MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, (n, a) -> true); - Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, createDispatchConfig(), invokerFactory); + MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, dispatchConfig, (n, a) -> true); + Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, dispatchConfig, invokerFactory); SearchInvoker invoker = disp.getSearchInvoker(new Query(), null); assertNotNull(invoker); invokerFactory.verifyAllEventsProcessed(); @@ -64,14 +66,14 @@ public class DispatcherTest { void requireThatInvokerConstructionIsRetriedAndLastAcceptsAnyCoverage() { SearchCluster cl = new MockSearchCluster("1", 2, 1); - MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, (n, acceptIncompleteCoverage) -> { + MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, dispatchConfig, (n, acceptIncompleteCoverage) -> { assertFalse(acceptIncompleteCoverage); return false; }, (n, acceptIncompleteCoverage) -> { assertTrue(acceptIncompleteCoverage); return true; }); - Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, createDispatchConfig(), invokerFactory); + Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, dispatchConfig, invokerFactory); SearchInvoker invoker = disp.getSearchInvoker(new Query(), null); assertNotNull(invoker); invokerFactory.verifyAllEventsProcessed(); @@ -83,8 +85,8 @@ public class DispatcherTest { try { SearchCluster cl = new MockSearchCluster("1", 2, 1); - MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, (n, a) -> false, (n, a) -> false); - Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, createDispatchConfig(), invokerFactory); + MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, dispatchConfig, (n, a) -> false, (n, a) -> false); + Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, dispatchConfig, invokerFactory); disp.getSearchInvoker(new Query(), null); disp.deconstruct(); fail("Expected exception"); @@ -97,7 +99,7 @@ public class DispatcherTest { @Test void testGroup0IsSelected() { SearchCluster cluster = new MockSearchCluster("1", 3, 1); - Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true)); + Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, new MockInvokerFactory(cluster, dispatchConfig, (n, a) -> true)); cluster.pingIterationCompleted(); assertEquals(0, dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue()); @@ -107,7 +109,7 @@ public class DispatcherTest { @Test void testGroup0IsSkippedWhenItIsBlockingFeed() { SearchCluster cluster = new MockSearchCluster("1", 3, 1); - Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true)); + Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, new MockInvokerFactory(cluster, dispatchConfig, (n, a) -> true)); cluster.group(0).get().nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); assertEquals(1, @@ -119,7 +121,7 @@ public class DispatcherTest { @Test void testGroup0IsSelectedWhenMoreAreBlockingFeed() { SearchCluster cluster = new MockSearchCluster("1", 3, 1); - Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true)); + Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, new MockInvokerFactory(cluster, dispatchConfig, (n, a) -> true)); cluster.group(0).get().nodes().get(0).setBlockingWrites(true); cluster.group(1).get().nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); @@ -132,7 +134,7 @@ public class DispatcherTest { @Test void testGroup0IsSelectedWhenItIsBlockingFeedWhenNoOthers() { SearchCluster cluster = new MockSearchCluster("1", 1, 1); - Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true)); + Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, new MockInvokerFactory(cluster, dispatchConfig, (n, a) -> true)); cluster.group(0).get().nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); assertEquals(0, @@ -150,8 +152,8 @@ public class DispatcherTest { private final FactoryStep[] events; private int step = 0; - public MockInvokerFactory(SearchCluster cl, FactoryStep... events) { - super(cl); + public MockInvokerFactory(SearchCluster cl, DispatchConfig disptachConfig, FactoryStep... events) { + super(cl, disptachConfig); this.events = events; } 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 15656ffb457..178d3383805 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 @@ -10,7 +10,6 @@ import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.dispatch.searchcluster.Group; import com.yahoo.search.dispatch.searchcluster.Node; -import com.yahoo.search.dispatch.searchcluster.SearchCluster; import com.yahoo.search.result.Coverage; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.result.Hit; @@ -22,7 +21,6 @@ import com.yahoo.searchlib.expression.IntegerResultNode; import com.yahoo.searchlib.expression.StringResultNode; import com.yahoo.test.ManualClock; import com.yahoo.vespa.config.search.DispatchConfig; -import com.yahoo.vespa.config.search.DispatchNodesConfig; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -40,8 +38,6 @@ 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; -import static com.yahoo.search.dispatch.MockSearchCluster.createDispatchConfig; -import static com.yahoo.search.dispatch.MockSearchCluster.createNodesConfig; import static org.junit.jupiter.api.Assertions.*; /** @@ -53,11 +49,12 @@ public class InterleavedSearchInvokerTest { private final Query query = new TestQuery(); private final LinkedList<Event> expectedEvents = new LinkedList<>(); private final List<SearchInvoker> invokers = new ArrayList<>(); + DispatchConfig dispatchConfig = new DispatchConfig.Builder().build(); + TopKEstimator hitEstimator = new TopKEstimator(30, dispatchConfig.topKProbability(), 0.05); @Test void requireThatAdaptiveTimeoutsAreNotUsedWithFullCoverageRequirement() throws IOException { - SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(100.0), createNodesConfig(), 1, 3); - try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 3)) { + try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 3)) { expectedEvents.add(new Event(5000, 100, 0)); expectedEvents.add(new Event(4900, 100, 1)); @@ -71,8 +68,7 @@ public class InterleavedSearchInvokerTest { @Test void requireThatTimeoutsAreNotMarkedAsAdaptive() throws IOException { - SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(100.0), createNodesConfig(), 1, 3); - try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 3)) { + try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 3)) { expectedEvents.add(new Event(5000, 300, 0)); expectedEvents.add(new Event(4700, 300, 1)); @@ -90,8 +86,7 @@ public class InterleavedSearchInvokerTest { @Test void requireThatAdaptiveTimeoutDecreasesTimeoutWhenCoverageIsReached() throws IOException { - SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(50.0), createNodesConfig(), 1, 4); - try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 4)) { + try (SearchInvoker invoker = createInterleavedInvoker(hitEstimator, MockSearchCluster.createDispatchConfig(50.0), new Group(0, List.of()), 4)) { expectedEvents.add(new Event(5000, 100, 0)); expectedEvents.add(new Event(4900, 100, 1)); @@ -110,10 +105,9 @@ public class InterleavedSearchInvokerTest { @Test void requireCorrectCoverageCalculationWhenAllNodesOk() throws IOException { - SearchCluster cluster = new MockSearchCluster("!", 1, 2); invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 50155, 1, 1, 0))); invokers.add(new MockInvoker(1, createCoverage(49845, 49845, 49845, 1, 1, 0))); - try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) { + try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) { expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(new Event(null, 200, 1)); @@ -132,10 +126,9 @@ public class InterleavedSearchInvokerTest { @Test void requireCorrectCoverageCalculationWhenResultsAreLimitedByMatchPhase() throws IOException { - SearchCluster cluster = new MockSearchCluster("!", 1, 2); invokers.add(new MockInvoker(0, createCoverage(10101, 50155, 50155, 1, 1, DEGRADED_BY_MATCH_PHASE))); invokers.add(new MockInvoker(1, createCoverage(13319, 49845, 49845, 1, 1, DEGRADED_BY_MATCH_PHASE))); - try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) { + try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) { expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(new Event(null, 200, 1)); @@ -155,10 +148,9 @@ public class InterleavedSearchInvokerTest { @Test void requireCorrectCoverageCalculationWhenResultsAreLimitedBySoftTimeout() throws IOException { - SearchCluster cluster = new MockSearchCluster("!", 1, 2); invokers.add(new MockInvoker(0, createCoverage(5000, 50155, 50155, 1, 1, DEGRADED_BY_TIMEOUT))); invokers.add(new MockInvoker(1, createCoverage(4900, 49845, 49845, 1, 1, DEGRADED_BY_TIMEOUT))); - try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) { + try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) { expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(new Event(null, 200, 1)); @@ -178,10 +170,9 @@ public class InterleavedSearchInvokerTest { @Test void requireCorrectCoverageCalculationWhenOneNodeIsUnexpectedlyDown() throws IOException { - SearchCluster cluster = new MockSearchCluster("!", 1, 2); invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 50155, 1, 1, 0))); invokers.add(new MockInvoker(1, createCoverage(49845, 49845, 49845, 1, 1, 0))); - try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) { + try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) { expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(null); @@ -342,7 +333,6 @@ public class InterleavedSearchInvokerTest { @Test void requireThatGroupingsAreMerged() throws IOException { - SearchCluster cluster = new MockSearchCluster("!", 1, 2); List<SearchInvoker> invokers = new ArrayList<>(); Grouping grouping1 = new Grouping(0); @@ -365,7 +355,7 @@ public class InterleavedSearchInvokerTest { .addAggregationResult(new MinAggregationResult().setMin(new IntegerResultNode(6)).setTag(3)))); invokers.add(new MockInvoker(0).setHits(List.of(new GroupingListHit(List.of(grouping2))))); - try (InterleavedSearchInvoker invoker = new InterleavedSearchInvoker(Timer.monotonic, invokers, cluster, new Group(0, List.of()), Collections.emptySet())) { + try (InterleavedSearchInvoker invoker = new InterleavedSearchInvoker(Timer.monotonic, invokers, hitEstimator, dispatchConfig, new Group(0, List.of()), Collections.emptySet())) { invoker.responseAvailable(invokers.get(0)); invoker.responseAvailable(invokers.get(1)); Result result = invoker.search(query, null); @@ -377,11 +367,12 @@ public class InterleavedSearchInvokerTest { } private static InterleavedSearchInvoker createInterLeavedTestInvoker(List<Double> a, List<Double> b, Group group) { - SearchCluster cluster = new MockSearchCluster("!", 1, 2); + DispatchConfig dispatchConfig = new DispatchConfig.Builder().build(); + TopKEstimator hitEstimator = new TopKEstimator(30, dispatchConfig.topKProbability(), 0.05); List<SearchInvoker> invokers = new ArrayList<>(); invokers.add(createInvoker(a, 0)); invokers.add(createInvoker(b, 1)); - InterleavedSearchInvoker invoker = new InterleavedSearchInvoker(Timer.monotonic, invokers, cluster, group, Collections.emptySet()); + InterleavedSearchInvoker invoker = new InterleavedSearchInvoker(Timer.monotonic, invokers, hitEstimator, dispatchConfig, group, Collections.emptySet()); invoker.responseAvailable(invokers.get(0)); invoker.responseAvailable(invokers.get(1)); return invoker; @@ -402,13 +393,12 @@ public class InterleavedSearchInvokerTest { return hits; } - void verifyCorrectCoverageCalculationWhenDegradedCoverageIsExpected(DispatchConfig dispatchConfig, DispatchNodesConfig nodesConfig, int expectedCoverage) throws IOException { - SearchCluster cluster = new MockSearchCluster("!", dispatchConfig, nodesConfig, 1, 2); + void verifyCorrectCoverageCalculationWhenDegradedCoverageIsExpected(int expectedCoverage) throws IOException { invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 60000, 1, 1, 0))); Coverage errorCoverage = new Coverage(0, 0, 0); errorCoverage.setNodesTried(1); invokers.add(new SearchErrorInvoker(ErrorMessage.createBackendCommunicationError("node is down"), errorCoverage)); - try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) { + try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) { expectedEvents.add(new Event(null, 1, 1)); expectedEvents.add(new Event(null, 100, 0)); @@ -429,19 +419,20 @@ public class InterleavedSearchInvokerTest { @Test void requireCorrectCoverageCalculationWhenDegradedCoverageIsExpectedUsingTargetActiveDocs() throws IOException { - verifyCorrectCoverageCalculationWhenDegradedCoverageIsExpected(MockSearchCluster.createDispatchConfigBuilder(100.0) - .redundancy(1) - .build(), - MockSearchCluster.createNodesConfig(), + verifyCorrectCoverageCalculationWhenDegradedCoverageIsExpected( 42); } - private InterleavedSearchInvoker createInterleavedInvoker(SearchCluster searchCluster, Group group, int numInvokers) { + private InterleavedSearchInvoker createInterleavedInvoker(Group group, int numInvokers) { + return createInterleavedInvoker(hitEstimator, dispatchConfig, group, numInvokers); + } + private InterleavedSearchInvoker createInterleavedInvoker(TopKEstimator hitEstimator, DispatchConfig dispatchConfig, + Group group, int numInvokers) { for (int i = 0; i < numInvokers; i++) { invokers.add(new MockInvoker(i)); } - return new InterleavedSearchInvoker(Timer.wrap(clock), invokers, searchCluster, group,null) { + return new InterleavedSearchInvoker(Timer.wrap(clock), invokers, hitEstimator, dispatchConfig, group,null) { @Override protected LinkedBlockingQueue<SearchInvoker> newQueue() { diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java b/container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java index c90153e8008..32ca63693b4 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java @@ -62,9 +62,6 @@ public class MockSearchCluster extends SearchCluster { } @Override - public List<Node> nodes() { return nodes; } - - @Override public ImmutableMap<Integer, Group> groups() { return groups; } diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java index 6789d0347d5..82b7845d63d 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java @@ -5,7 +5,6 @@ package com.yahoo.search.dispatch.rpc; import ai.vespa.searchlib.searchprotocol.protobuf.SearchProtocol; import com.google.common.collect.ImmutableMap; import com.yahoo.compress.CompressionType; -import com.yahoo.prelude.fastsearch.FastHit; import com.yahoo.prelude.fastsearch.VespaBackEndSearcher; import com.yahoo.search.Query; import com.yahoo.search.Result; @@ -14,7 +13,6 @@ import com.yahoo.search.searchchain.Execution; import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -25,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.*; */ public class RpcSearchInvokerTest { + private final CompressService compressor = new CompressService(); @Test void testProtobufSerialization() throws IOException { var compressionTypeHolder = new AtomicReference<CompressionType>(); @@ -32,21 +31,21 @@ public class RpcSearchInvokerTest { var lengthHolder = new AtomicInteger(); var mockClient = parameterCollectorClient(compressionTypeHolder, payloadHolder, lengthHolder); var mockPool = new RpcResourcePool(ImmutableMap.of(7, mockClient.createConnection("foo", 123))); - var invoker = new RpcSearchInvoker(mockSearcher(), new Node(7, "seven", 1), mockPool, 1000); + var invoker = new RpcSearchInvoker(mockSearcher(), compressor, new Node(7, "seven", 1), mockPool, 1000); Query q = new Query("search/?query=test&hits=10&offset=3"); RpcSearchInvoker.RpcContext context = (RpcSearchInvoker.RpcContext) invoker.sendSearchRequest(q, null); assertEquals(lengthHolder.get(), context.compressedPayload.uncompressedSize()); assertSame(context.compressedPayload.data(), payloadHolder.get()); - var bytes = mockPool.compressor().decompress(payloadHolder.get(), compressionTypeHolder.get(), lengthHolder.get()); + var bytes = compressor.compressor().decompress(payloadHolder.get(), compressionTypeHolder.get(), lengthHolder.get()); var request = SearchProtocol.SearchRequest.newBuilder().mergeFrom(bytes).build(); assertEquals(10, request.getHits()); assertEquals(3, request.getOffset()); assertTrue(request.getQueryTreeBlob().size() > 0); - var invoker2 = new RpcSearchInvoker(mockSearcher(), new Node(8, "eight", 1), mockPool, 1000); + var invoker2 = new RpcSearchInvoker(mockSearcher(), compressor, new Node(8, "eight", 1), mockPool, 1000); RpcSearchInvoker.RpcContext context2 = (RpcSearchInvoker.RpcContext) invoker2.sendSearchRequest(q, context); assertSame(context, context2); assertEquals(lengthHolder.get(), context.compressedPayload.uncompressedSize()); @@ -61,12 +60,12 @@ public class RpcSearchInvokerTest { var lengthHolder = new AtomicInteger(); var mockClient = parameterCollectorClient(compressionTypeHolder, payloadHolder, lengthHolder); var mockPool = new RpcResourcePool(ImmutableMap.of(7, mockClient.createConnection("foo", 123))); - var invoker = new RpcSearchInvoker(mockSearcher(), new Node(7, "seven", 1), mockPool, maxHits); + var invoker = new RpcSearchInvoker(mockSearcher(), compressor, new Node(7, "seven", 1), mockPool, maxHits); Query q = new Query("search/?query=test&hits=10&offset=3"); invoker.sendSearchRequest(q, null); - var bytes = mockPool.compressor().decompress(payloadHolder.get(), compressionTypeHolder.get(), lengthHolder.get()); + var bytes = compressor.compressor().decompress(payloadHolder.get(), compressionTypeHolder.get(), lengthHolder.get()); var request = SearchProtocol.SearchRequest.newBuilder().mergeFrom(bytes).build(); assertEquals(maxHits, request.getHits()); |