diff options
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/dispatch')
11 files changed, 169 insertions, 182 deletions
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 42df2a829e3..715154e85ba 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 @@ -12,17 +12,14 @@ 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 org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Optional; import java.util.OptionalInt; import static com.yahoo.search.dispatch.MockSearchCluster.createDispatchConfig; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; /** * @author ollivir @@ -30,7 +27,7 @@ import static org.junit.Assert.fail; public class DispatcherTest { @Test - public void requireThatDispatcherSupportsSearchPath() { + void requireThatDispatcherSupportsSearchPath() { SearchCluster cl = new MockSearchCluster("1", 2, 2); Query q = new Query(); q.getModel().setSearchPath("1/0"); // second node in first group @@ -46,7 +43,7 @@ public class DispatcherTest { } @Test - public void requireThatDispatcherSupportsSingleNodeDirectDispatch() { + void requireThatDispatcherSupportsSingleNodeDirectDispatch() { SearchCluster cl = new MockSearchCluster("1", 0, 0) { @Override public Optional<Node> localCorpusDispatchTarget() { @@ -61,7 +58,7 @@ public class DispatcherTest { } @Test - public void requireThatInvokerConstructionIsRetriedAndLastAcceptsAnyCoverage() { + void requireThatInvokerConstructionIsRetriedAndLastAcceptsAnyCoverage() { SearchCluster cl = new MockSearchCluster("1", 2, 1); MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, (n, acceptIncompleteCoverage) -> { @@ -78,7 +75,7 @@ public class DispatcherTest { } @Test - public void requireThatInvokerConstructionDoesNotRepeatGroups() { + void requireThatInvokerConstructionDoesNotRepeatGroups() { try { SearchCluster cl = new MockSearchCluster("1", 2, 1); @@ -94,49 +91,49 @@ public class DispatcherTest { } @Test - public void testGroup0IsSelected() { + 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), new MockMetric()); cluster.pingIterationCompleted(); assertEquals(0, - dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue()); + dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue()); dispatcher.deconstruct(); } @Test - public void testGroup0IsSkippedWhenItIsBlockingFeed() { + 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), new MockMetric()); cluster.group(0).get().nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); - assertEquals("Blocking group is avoided", - 1, - (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue()); + assertEquals(1, + (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue(), + "Blocking group is avoided"); dispatcher.deconstruct(); } @Test - public void testGroup0IsSelectedWhenMoreAreBlockingFeed() { + 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), new MockMetric()); cluster.group(0).get().nodes().get(0).setBlockingWrites(true); cluster.group(1).get().nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); - assertEquals("Blocking group is used when multiple groups are blocking", - 0, - dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue()); + assertEquals(0, + dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue(), + "Blocking group is used when multiple groups are blocking"); dispatcher.deconstruct(); } @Test - public void testGroup0IsSelectedWhenItIsBlockingFeedWhenNoOthers() { + 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), new MockMetric()); cluster.group(0).get().nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); - assertEquals("Blocking group is used when there is no alternative", - 0, - (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue()); + assertEquals(0, + (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue(), + "Blocking group is used when there is no alternative"); dispatcher.deconstruct(); } 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 e07d38fbf10..1293975deb5 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 @@ -20,7 +20,7 @@ import com.yahoo.searchlib.aggregation.MinAggregationResult; import com.yahoo.searchlib.expression.IntegerResultNode; import com.yahoo.searchlib.expression.StringResultNode; import com.yahoo.test.ManualClock; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.time.Duration; @@ -38,11 +38,7 @@ 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 org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; /** * @author ollivir @@ -55,7 +51,7 @@ public class InterleavedSearchInvokerTest { private final List<SearchInvoker> invokers = new ArrayList<>(); @Test - public void requireThatAdaptiveTimeoutsAreNotUsedWithFullCoverageRequirement() throws IOException { + void requireThatAdaptiveTimeoutsAreNotUsedWithFullCoverageRequirement() throws IOException { SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(100.0), 1, 3); SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 3); @@ -65,11 +61,11 @@ public class InterleavedSearchInvokerTest { invoker.search(query, null); - assertTrue("All test scenario events processed", expectedEvents.isEmpty()); + assertTrue(expectedEvents.isEmpty(), "All test scenario events processed"); } @Test - public void requireThatTimeoutsAreNotMarkedAsAdaptive() throws IOException { + void requireThatTimeoutsAreNotMarkedAsAdaptive() throws IOException { SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(100.0), 1, 3); SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 3); @@ -79,15 +75,15 @@ public class InterleavedSearchInvokerTest { Result result = invoker.search(query, null); - assertTrue("All test scenario events processed", expectedEvents.isEmpty()); - assertNull("Result is not marked as an error", result.hits().getErrorHit()); + assertTrue(expectedEvents.isEmpty(), "All test scenario events processed"); + assertNull(result.hits().getErrorHit(), "Result is not marked as an error"); var message = findTrace(result, "Backend communication timeout"); - assertTrue("Timeout should be reported in a trace message", message.isPresent()); - assertTrue("Degradation reason is a normal timeout", result.getCoverage(false).isDegradedByTimeout()); + assertTrue(message.isPresent(), "Timeout should be reported in a trace message"); + assertTrue(result.getCoverage(false).isDegradedByTimeout(), "Degradation reason is a normal timeout"); } @Test - public void requireThatAdaptiveTimeoutDecreasesTimeoutWhenCoverageIsReached() throws IOException { + void requireThatAdaptiveTimeoutDecreasesTimeoutWhenCoverageIsReached() throws IOException { SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(50.0), 1, 4); SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 4); @@ -98,15 +94,15 @@ public class InterleavedSearchInvokerTest { Result result = invoker.search(query, null); - assertTrue("All test scenario events processed", expectedEvents.isEmpty()); - assertNull("Result is not marked as an error", result.hits().getErrorHit()); + assertTrue(expectedEvents.isEmpty(), "All test scenario events processed"); + assertNull(result.hits().getErrorHit(), "Result is not marked as an error"); var message = findTrace(result, "Backend communication timeout"); - assertTrue("Timeout should be reported in a trace message", message.isPresent()); - assertTrue("Degradataion reason is an adaptive timeout", result.getCoverage(false).isDegradedByAdapativeTimeout()); + assertTrue(message.isPresent(), "Timeout should be reported in a trace message"); + assertTrue(result.getCoverage(false).isDegradedByAdapativeTimeout(), "Degradataion reason is an adaptive timeout"); } @Test - public void requireCorrectCoverageCalculationWhenAllNodesOk() throws IOException { + 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))); @@ -127,7 +123,7 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireCorrectCoverageCalculationWhenResultsAreLimitedByMatchPhase() throws IOException { + 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))); @@ -149,11 +145,11 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireCorrectCoverageCalculationWhenResultsAreLimitedBySoftTimeout() throws IOException { + 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))); - SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()),0); + SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0); expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(new Event(null, 200, 1)); @@ -171,7 +167,7 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireCorrectCoverageCalculationWhenOneNodeIsUnexpectedlyDown() throws IOException { + 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))); @@ -231,13 +227,13 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireThatTopKProbabilityOverrideTakesEffect() throws IOException { + void requireThatTopKProbabilityOverrideTakesEffect() throws IOException { validateThatTopKProbabilityOverrideTakesEffect(null, 8, new Group(0, List.of())); validateThatTopKProbabilityOverrideTakesEffect(0.8, 7, new Group(0, List.of())); } @Test - public void requireThatTopKProbabilityOverrideIsDisabledOnContentSkew() throws IOException { + void requireThatTopKProbabilityOverrideIsDisabledOnContentSkew() throws IOException { Node node0 = new Node(0, "host0", 0); Node node1 = new Node(1, "host1", 0); Group group = new Group(0, List.of(node0, node1)); @@ -249,7 +245,7 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireThatTopKProbabilityOverrideIsDisabledOnLittleContent() throws IOException { + void requireThatTopKProbabilityOverrideIsDisabledOnLittleContent() throws IOException { Node node0 = new Node(0, "host0", 0); Node node1 = new Node(1, "host1", 0); Group group = new Group(0, List.of(node0, node1)); @@ -261,7 +257,7 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireThatMergeOfConcreteHitsObeySorting() throws IOException { + void requireThatMergeOfConcreteHitsObeySorting() throws IOException { InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5, B5, new Group(0, List.of())); query.setHits(12); Result result = invoker.search(query, null); @@ -281,7 +277,7 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireThatMergeOfConcreteHitsObeyOffset() throws IOException { + void requireThatMergeOfConcreteHitsObeyOffset() throws IOException { InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5, B5, new Group(0, List.of())); query.setHits(3); query.setOffset(5); @@ -303,7 +299,7 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireThatMergeOfConcreteHitsObeyOffsetWithAuxilliaryStuff() throws IOException { + void requireThatMergeOfConcreteHitsObeyOffsetWithAuxilliaryStuff() throws IOException { InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5Aux, B5Aux, new Group(0, List.of())); query.setHits(3); query.setOffset(5); @@ -327,7 +323,7 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireThatGroupingsAreMerged() throws IOException { + void requireThatGroupingsAreMerged() throws IOException { SearchCluster cluster = new MockSearchCluster("!", 1, 2); List<SearchInvoker> invokers = new ArrayList<>(); @@ -386,7 +382,7 @@ public class InterleavedSearchInvokerTest { } @Test - public void requireCorrectCoverageCalculationWhenDegradedCoverageIsExpected() throws IOException { + void requireCorrectCoverageCalculationWhenDegradedCoverageIsExpected() throws IOException { SearchCluster cluster = new MockSearchCluster("!", 1, 2); invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 50155, 1, 1, 0))); Coverage errorCoverage = new Coverage(0, 0, 0); @@ -468,7 +464,7 @@ public class InterleavedSearchInvokerTest { public SearchInvoker process(Query query, long currentTimeout) { if (expectedTimeout != null) { - assertEquals("Expecting timeout to be " + expectedTimeout, (long) expectedTimeout, currentTimeout); + assertEquals((long) expectedTimeout, currentTimeout, "Expecting timeout to be " + expectedTimeout); } clock.advance(Duration.ofMillis(delay)); if (query.getTimeLeft() < 0) { diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java index a2080ce6b05..3d2ab17b15d 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/LeanHitTest.java @@ -1,11 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.dispatch; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class LeanHitTest { private static final byte [] gidA = {'a'}; @@ -20,34 +18,39 @@ public class LeanHitTest { assertTrue(c.compareTo(b) > 0); assertTrue(c.compareTo(a) > 0); } + @Test - public void testOrderingByRelevance() { + void testOrderingByRelevance() { assertEquals(0, new LeanHit(gidA, 0, 0, 1).compareTo(new LeanHit(gidA, 0, 0, 1))); verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 1), new LeanHit(gidA, 0, 0, 0), new LeanHit(gidA, 0, 0, -1)); } + @Test - public void testOrderingByGid() { + void testOrderingByGid() { assertEquals(0, new LeanHit(gidA, 0, 0, 1).compareTo(new LeanHit(gidA, 0, 0, 1))); verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 1), new LeanHit(gidB, 0, 0, 1), new LeanHit(gidC, 0, 0, 1)); } + @Test - public void testOrderingBySortData() { + void testOrderingBySortData() { assertEquals(0, new LeanHit(gidA, 0, 0, 0.0, gidA).compareTo(new LeanHit(gidA, 0, 0, 0.0, gidA))); verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 0.0, gidA), new LeanHit(gidA, 0, 0, 0.0, gidB), new LeanHit(gidA, 0, 0, 0.0, gidC)); } + @Test - public void testRelevanceIsKeptEvenWithBySortData() { + void testRelevanceIsKeptEvenWithBySortData() { assertEquals(1.3, new LeanHit(gidA, 0, 0, 1.3, gidA).getRelevance(), 0.0); } + @Test - public void testNaN2negativeInfinity() { + void testNaN2negativeInfinity() { LeanHit nan = new LeanHit(gidA, 0, 0, Double.NaN); assertFalse(Double.isNaN(nan.getRelevance())); assertTrue(Double.isInfinite(nan.getRelevance())); diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java index e95fbc366a6..e9ed1c48302 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java @@ -6,8 +6,8 @@ import com.yahoo.search.dispatch.LoadBalancer.GroupStatus; import com.yahoo.search.dispatch.searchcluster.Group; import com.yahoo.search.dispatch.searchcluster.Node; import com.yahoo.search.dispatch.searchcluster.SearchCluster; -import junit.framework.AssertionFailedError; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.opentest4j.AssertionFailedError; import java.util.ArrayList; import java.util.Collections; @@ -16,9 +16,9 @@ import java.util.Optional; import java.util.Random; import static com.yahoo.search.dispatch.MockSearchCluster.createDispatchConfig; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author ollivir @@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue; public class LoadBalancerTest { @Test - public void requireThatLoadBalancerServesSingleNodeSetups() { + void requireThatLoadBalancerServesSingleNodeSetups() { Node n1 = new Node(0, "test-node1", 0); SearchCluster cluster = new SearchCluster("a", createDispatchConfig(n1), null, null); LoadBalancer lb = new LoadBalancer(cluster, true); @@ -39,7 +39,7 @@ public class LoadBalancerTest { } @Test - public void requireThatLoadBalancerServesMultiGroupSetups() { + void requireThatLoadBalancerServesMultiGroupSetups() { Node n1 = new Node(0, "test-node1", 0); Node n2 = new Node(1, "test-node2", 1); SearchCluster cluster = new SearchCluster("a", createDispatchConfig(n1, n2), null, null); @@ -53,7 +53,7 @@ public class LoadBalancerTest { } @Test - public void requireThatLoadBalancerServesClusteredGroups() { + void requireThatLoadBalancerServesClusteredGroups() { Node n1 = new Node(0, "test-node1", 0); Node n2 = new Node(1, "test-node2", 0); Node n3 = new Node(0, "test-node3", 1); @@ -66,10 +66,10 @@ public class LoadBalancerTest { } @Test - public void requireThatLoadBalancerReturnsDifferentGroups() { + void requireThatLoadBalancerReturnsDifferentGroups() { Node n1 = new Node(0, "test-node1", 0); Node n2 = new Node(1, "test-node2", 1); - SearchCluster cluster = new SearchCluster("a", createDispatchConfig(n1, n2), null,null); + SearchCluster cluster = new SearchCluster("a", createDispatchConfig(n1, n2), null, null); LoadBalancer lb = new LoadBalancer(cluster, true); // get first group @@ -86,7 +86,7 @@ public class LoadBalancerTest { } @Test - public void requireCorrectAverageSearchTimeDecay() { + void requireCorrectAverageSearchTimeDecay() { final double delta = 0.00001; GroupStatus gs = newGroupStatus(1); @@ -115,7 +115,7 @@ public class LoadBalancerTest { } @Test - public void requireEqualDistributionInFlatWeightListWithAdaptiveScheduler() { + void requireEqualDistributionInFlatWeightListWithAdaptiveScheduler() { List<GroupStatus> scoreboard = new ArrayList<>(); for (int i = 0; i < 5; i++) { scoreboard.add(newGroupStatus(i)); @@ -134,7 +134,7 @@ public class LoadBalancerTest { } @Test - public void requireThatAdaptiveSchedulerObeysWeights() { + void requireThatAdaptiveSchedulerObeysWeights() { List<GroupStatus> scoreboard = new ArrayList<>(); for (int i = 0; i < 5; i++) { GroupStatus gs = newGroupStatus(i); diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java index 3a1a60df7af..12cbe488485 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java @@ -3,16 +3,13 @@ package com.yahoo.search.dispatch; import com.yahoo.search.dispatch.SearchPath.InvalidSearchPathException; import com.yahoo.search.dispatch.searchcluster.Node; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Collection; import java.util.Set; import java.util.stream.Collectors; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; /** * @author ollivir @@ -20,7 +17,7 @@ import static org.junit.Assert.fail; public class SearchPathTest { @Test - public void requreThatSearchPathsAreParsedCorrectly() { + void requreThatSearchPathsAreParsedCorrectly() { assertEquals(SearchPath.fromString("0/0").get().toString(), "0/0"); assertEquals(SearchPath.fromString("1/0").get().toString(), "1/0"); assertEquals(SearchPath.fromString("0/1").get().toString(), "0/1"); @@ -43,7 +40,7 @@ public class SearchPathTest { } @Test - public void requreThatWildcardsAreDetected() { + void requreThatWildcardsAreDetected() { assertFalse(SearchPath.fromString("").isPresent()); assertFalse(SearchPath.fromString("*/*").isPresent()); assertFalse(SearchPath.fromString("/").isPresent()); @@ -52,7 +49,7 @@ public class SearchPathTest { } @Test - public void invalidRangeMustThrowException() { + void invalidRangeMustThrowException() { try { SearchPath.fromString("[p,0>/0"); fail("Expected exception"); @@ -63,7 +60,7 @@ public class SearchPathTest { } @Test - public void invalidPartMustThrowException() { + void invalidPartMustThrowException() { try { SearchPath.fromString("p/0"); fail("Expected exception"); @@ -74,7 +71,7 @@ public class SearchPathTest { } @Test - public void invalidRowMustThrowException() { + void invalidRowMustThrowException() { try { SearchPath.fromString("1,2,3/r"); fail("Expected exception"); @@ -92,8 +89,8 @@ public class SearchPathTest { } @Test - public void searchPathMustFilterNodesBasedOnDefinition() { - MockSearchCluster cluster = new MockSearchCluster("a",3, 3); + void searchPathMustFilterNodesBasedOnDefinition() { + MockSearchCluster cluster = new MockSearchCluster("a", 3, 3); assertEquals(distKeysAsString(SearchPath.selectNodes("1/1", cluster)), "4"); assertEquals(distKeysAsString(SearchPath.selectNodes("/1", cluster)), "3,4,5"); diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java index 5dfcd8901da..283596322e6 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java @@ -1,15 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.dispatch; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Locale; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class TopKEstimatorTest { @Test - public void requireHitsAreEstimatedAccordingToPartitionsAndProbability() { + void requireHitsAreEstimatedAccordingToPartitionsAndProbability() { TopKEstimator estimator = new TopKEstimator(30, 0.999); assertEquals(91.97368471911312, estimator.estimateExactK(200, 3), 0.0); assertEquals(92, estimator.estimateK(200, 3)); @@ -27,8 +27,9 @@ public class TopKEstimatorTest { assertEquals(44.909040374464155, estimator.estimateExactK(200, 10, 0.99999), 0.0); assertEquals(45, estimator.estimateK(200, 10, 0.99999)); } + @Test - public void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K200() { + void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K200() { TopKEstimator estimator = new TopKEstimator(30, 0.99999); assertEquals(200, estimator.estimateExactK(200, 1), 0.0); assertEquals(200, estimator.estimateK(200, 1)); @@ -39,7 +40,7 @@ public class TopKEstimatorTest { } @Test - public void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K20() { + void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K20() { TopKEstimator estimator = new TopKEstimator(30, 0.99999); assertEquals(20, estimator.estimateExactK(20, 1), 0.0); assertEquals(20, estimator.estimateK(20, 1)); @@ -50,7 +51,7 @@ public class TopKEstimatorTest { } @Test - public void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K10_Five9() { + void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K10_Five9() { TopKEstimator estimator = new TopKEstimator(30, 0.99999); assertEquals(10, estimator.estimateExactK(10, 1), 0.0); assertEquals(10, estimator.estimateK(10, 1)); @@ -61,7 +62,7 @@ public class TopKEstimatorTest { } @Test - public void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K10_Four9() { + void requireHitsAreEstimatedAccordingToPartitionsAndProbabilityForVaryingN_K10_Four9() { TopKEstimator estimator = new TopKEstimator(30, 0.9999); assertEquals(10, estimator.estimateExactK(10, 1), 0.0); assertEquals(10, estimator.estimateK(10, 1)); @@ -72,21 +73,21 @@ public class TopKEstimatorTest { } @Test - public void requireEstimatesAreRoundeUp() { + void requireEstimatesAreRoundeUp() { TopKEstimator estimator = new TopKEstimator(30, 0.9999); assertEquals(5.794676146031378, estimator.estimateExactK(10, 10), 0.0); assertEquals(6, estimator.estimateK(10, 10)); } @Test - public void requireEstimatesAreCappedAtInputK() { + void requireEstimatesAreCappedAtInputK() { TopKEstimator estimator = new TopKEstimator(30, 0.9999); assertEquals(12.087323848369289, estimator.estimateExactK(10, 2), 0.0); assertEquals(10, estimator.estimateK(10, 2)); } @Test - public void requireThatLargeKAreSane() { + void requireThatLargeKAreSane() { System.out.println(dumpProbability(10, 0.05)); TopKEstimator idealEstimator = new TopKEstimator(30, 0.9999); TopKEstimator skewedEstimator = new TopKEstimator(30, 0.9999, 0.05); @@ -100,23 +101,23 @@ public class TopKEstimatorTest { String expected = "Prob/Hits: 1.0000000000 0.9999000000 0.9999900000 0.9999990000 0.9999999000 0.9999999900 0.9999999990 0.9999999999\n" + - " 10: 10.000 6.000 7.000 8.000 9.000 10.000 10.000 10.000\n" + - " 20: 10.000 4.500 5.000 5.500 6.500 7.000 7.500 8.000\n" + - " 40: 10.000 3.500 4.000 4.250 4.750 5.250 5.500 6.000\n" + - " 80: 10.000 2.750 3.000 3.250 3.625 3.875 4.250 4.500\n" + - " 100: 10.000 2.600 2.800 3.100 3.300 3.600 3.900 4.200\n" + - " 200: 10.000 2.100 2.250 2.450 2.650 2.800 3.000 3.200\n" + - " 400: 10.000 1.775 1.900 2.025 2.150 2.275 2.425 2.575\n" + - " 800: 10.000 1.538 1.625 1.713 1.813 1.900 2.000 2.100\n" + - " 1000: 10.000 1.480 1.560 1.640 1.720 1.810 1.890 1.990\n" + - " 2000: 10.000 1.340 1.395 1.450 1.510 1.570 1.630 1.695\n" + - " 4000: 10.000 1.240 1.280 1.320 1.360 1.403 1.445 1.493\n" + - " 8000: 10.000 1.170 1.198 1.225 1.254 1.284 1.315 1.348\n" + - " 10000: 10.000 1.152 1.177 1.202 1.227 1.254 1.282 1.311\n" + - " 20000: 10.000 1.108 1.125 1.143 1.161 1.180 1.199 1.220\n" + - " 40000: 10.000 1.076 1.088 1.101 1.114 1.127 1.141 1.156\n" + - " 80000: 10.000 1.054 1.062 1.071 1.080 1.090 1.100 1.110\n" + - " 100000: 10.000 1.048 1.056 1.064 1.072 1.080 1.089 1.098\n"; + " 10: 10.000 6.000 7.000 8.000 9.000 10.000 10.000 10.000\n" + + " 20: 10.000 4.500 5.000 5.500 6.500 7.000 7.500 8.000\n" + + " 40: 10.000 3.500 4.000 4.250 4.750 5.250 5.500 6.000\n" + + " 80: 10.000 2.750 3.000 3.250 3.625 3.875 4.250 4.500\n" + + " 100: 10.000 2.600 2.800 3.100 3.300 3.600 3.900 4.200\n" + + " 200: 10.000 2.100 2.250 2.450 2.650 2.800 3.000 3.200\n" + + " 400: 10.000 1.775 1.900 2.025 2.150 2.275 2.425 2.575\n" + + " 800: 10.000 1.538 1.625 1.713 1.813 1.900 2.000 2.100\n" + + " 1000: 10.000 1.480 1.560 1.640 1.720 1.810 1.890 1.990\n" + + " 2000: 10.000 1.340 1.395 1.450 1.510 1.570 1.630 1.695\n" + + " 4000: 10.000 1.240 1.280 1.320 1.360 1.403 1.445 1.493\n" + + " 8000: 10.000 1.170 1.198 1.225 1.254 1.284 1.315 1.348\n" + + " 10000: 10.000 1.152 1.177 1.202 1.227 1.254 1.282 1.311\n" + + " 20000: 10.000 1.108 1.125 1.143 1.161 1.180 1.199 1.220\n" + + " 40000: 10.000 1.076 1.088 1.101 1.114 1.127 1.141 1.156\n" + + " 80000: 10.000 1.054 1.062 1.071 1.080 1.090 1.100 1.110\n" + + " 100000: 10.000 1.048 1.056 1.064 1.072 1.080 1.089 1.098\n"; assertEquals(expected, dumpProbability(10, 0.0)); String expectedSkew = "Prob/Hits: 1.0000000000 0.9999000000 0.9999900000 0.9999990000 0.9999999000 0.9999999900 0.9999999990 0.9999999999\n" + diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java index 6834a5edf9b..861ed4d165d 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/MatchFeatureDataTest.java @@ -6,14 +6,12 @@ import com.yahoo.data.access.ArrayTraverser; import com.yahoo.data.access.Inspector; import com.yahoo.data.access.ObjectTraverser; import com.yahoo.data.access.Type; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * @author arnej @@ -21,14 +19,14 @@ import static org.junit.Assert.assertTrue; public class MatchFeatureDataTest { @Test - public void testHitValueAPI() { + void testHitValueAPI() { List<String> names = List.of("foo", "bar", "baz", "qux", "quux"); var mf = new MatchFeatureData(names); var hit = mf.addHit(); assertEquals(hit.type(), Type.OBJECT); assertTrue(hit.valid()); hit.set(0, 1.0); - byte[] somebytes = { 42, 0, 17 }; + byte[] somebytes = {42, 0, 17}; hit.set(2, somebytes); hit.set(4, 5.0); hit.set(1, 2.0); @@ -64,7 +62,7 @@ public class MatchFeatureDataTest { var fields = hit.fields().iterator(); assertTrue(fields.hasNext()); - Map.Entry<String,Inspector> entry = fields.next(); + Map.Entry<String, Inspector> entry = fields.next(); assertEquals("foo", entry.getKey()); assertEquals(f1.type(), entry.getValue().type()); assertEquals(f1.asDouble(), entry.getValue().asDouble(), 0.0); @@ -94,9 +92,9 @@ public class MatchFeatureDataTest { assertEquals(f5.asDouble(), entry.getValue().asDouble(), 0.0); assertFalse(fields.hasNext()); - + assertEquals("{\"foo\":1.0,\"bar\":2.0,\"baz\":\"0x2A0011\",\"qux\":4.0,\"quux\":5.0}", - hit.toString()); + hit.toString()); } } diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java index 9953d1467e1..72b3095b2f9 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/ProtobufSerializationTest.java @@ -12,14 +12,12 @@ import com.yahoo.search.dispatch.InvokerResult; import com.yahoo.search.dispatch.LeanHit; import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry; import com.yahoo.search.query.profile.config.QueryProfileXMLReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * @author ollivir @@ -29,38 +27,38 @@ public class ProtobufSerializationTest { static final double DELTA = 0.000000000001; @Test - public void testQuerySerialization() { + void testQuerySerialization() { CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/tensortypes").compile(); Query query = new Query.Builder().setQueryProfile(registry.getComponent("profile1")) - .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]") - .build(); + .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]") + .build(); - SearchProtocol.SearchRequest request1 = ProtobufSerialization.convertFromQuery(query, 9,"serverId", 0.5); + SearchProtocol.SearchRequest request1 = ProtobufSerialization.convertFromQuery(query, 9, "serverId", 0.5); assertEquals(9, request1.getHits()); assertEquals(0, request1.getRankPropertiesCount()); assertEquals(0, request1.getTensorRankPropertiesCount()); assertEquals(0, request1.getFeatureOverridesCount()); assertEquals(2, request1.getTensorFeatureOverridesCount()); assertEquals("\"\\001\\001\\003key\\001\\rpre_key1_post?\\360\\000\\000\\000\\000\\000\\000\"", - contentsOf(request1.getTensorFeatureOverrides(0).getValue())); + contentsOf(request1.getTensorFeatureOverrides(0).getValue())); assertEquals("\"\\006\\001\\001\\001x\\001?\\231\\231\\232\"", - contentsOf(request1.getTensorFeatureOverrides(1).getValue())); + contentsOf(request1.getTensorFeatureOverrides(1).getValue())); query.prepare(); // calling prepare() moves "overrides" to "features" - content stays the same - SearchProtocol.SearchRequest request2 = ProtobufSerialization.convertFromQuery(query, 9,"serverId", 0.5); + SearchProtocol.SearchRequest request2 = ProtobufSerialization.convertFromQuery(query, 9, "serverId", 0.5); assertEquals(9, request2.getHits()); assertEquals(0, request2.getRankPropertiesCount()); assertEquals(2, request2.getTensorRankPropertiesCount()); assertEquals("\"\\001\\001\\003key\\001\\rpre_key1_post?\\360\\000\\000\\000\\000\\000\\000\"", - contentsOf(request2.getTensorRankProperties(0).getValue())); + contentsOf(request2.getTensorRankProperties(0).getValue())); assertEquals("\"\\006\\001\\001\\001x\\001?\\231\\231\\232\"", - contentsOf(request2.getTensorRankProperties(1).getValue())); + contentsOf(request2.getTensorRankProperties(1).getValue())); assertEquals(0, request2.getFeatureOverridesCount()); assertEquals(0, request2.getTensorFeatureOverridesCount()); } @Test - public void testDocsumSerialization() { + void testDocsumSerialization() { Query q = new Query("search/?query=test&hits=10&offset=3"); var builder = ProtobufSerialization.createDocsumRequestBuilder(q, "server", "summary", true, 0.5); builder.setTimeout(0); @@ -95,8 +93,9 @@ public class ProtobufSerializationTest { } return reply.build(); } + @Test - public void testSearchReplyDecodingWithRelevance() { + void testSearchReplyDecodingWithRelevance() { Query q = new Query("search/?query=test"); InvokerResult result = ProtobufSerialization.convertToResult(q, createSearchReply(5, false), null, 1, 2); assertEquals(result.getResult().getTotalHitCount(), 7); @@ -114,8 +113,9 @@ public class ProtobufSerializationTest { hitNum++; } } + @Test - public void testSearchReplyDecodingWithSortData() { + void testSearchReplyDecodingWithSortData() { Query q = new Query("search/?query=test"); InvokerResult result = ProtobufSerialization.convertToResult(q, createSearchReply(5, true), null, 1, 2); assertEquals(result.getResult().getTotalHitCount(), 7); 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 c26bef05fb6..6789d0347d5 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 @@ -11,17 +11,14 @@ import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.dispatch.searchcluster.Node; import com.yahoo.search.searchchain.Execution; -import org.junit.Test; +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; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; /** * @author ollivir @@ -29,7 +26,7 @@ import static org.junit.Assert.fail; public class RpcSearchInvokerTest { @Test - public void testProtobufSerialization() throws IOException { + void testProtobufSerialization() throws IOException { var compressionTypeHolder = new AtomicReference<CompressionType>(); var payloadHolder = new AtomicReference<byte[]>(); var lengthHolder = new AtomicInteger(); @@ -50,14 +47,14 @@ public class RpcSearchInvokerTest { assertTrue(request.getQueryTreeBlob().size() > 0); var invoker2 = new RpcSearchInvoker(mockSearcher(), new Node(8, "eight", 1), mockPool, 1000); - RpcSearchInvoker.RpcContext context2 = (RpcSearchInvoker.RpcContext)invoker2.sendSearchRequest(q, context); + RpcSearchInvoker.RpcContext context2 = (RpcSearchInvoker.RpcContext) invoker2.sendSearchRequest(q, context); assertSame(context, context2); assertEquals(lengthHolder.get(), context.compressedPayload.uncompressedSize()); assertSame(context.compressedPayload.data(), payloadHolder.get()); } @Test - public void testProtobufSerializationWithMaxHitsSet() throws IOException { + void testProtobufSerializationWithMaxHitsSet() throws IOException { int maxHits = 5; var compressionTypeHolder = new AtomicReference<CompressionType>(); var payloadHolder = new AtomicReference<byte[]>(); diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java index c21bf623366..3d981c5e45a 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java @@ -1,10 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.dispatch.searchcluster; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author bratseth @@ -12,7 +12,7 @@ import static org.junit.Assert.assertTrue; public class SearchClusterCoverageTest { @Test - public void two_groups_equal_docs() { + void two_groups_equal_docs() { var tester = new SearchClusterTester(2, 3); tester.setDocsPerNode(100, 0); @@ -23,22 +23,22 @@ public class SearchClusterCoverageTest { } @Test - public void two_groups_one_missing_docs() { + void two_groups_one_missing_docs() { var tester = new SearchClusterTester(2, 3); tester.setDocsPerNode(100, 0); - tester.setDocsPerNode( 70, 1); + tester.setDocsPerNode(70, 1); tester.pingIterationCompleted(); assertTrue(tester.group(0).hasSufficientCoverage()); assertFalse(tester.group(1).hasSufficientCoverage()); } @Test - public void three_groups_one_missing_docs() { + void three_groups_one_missing_docs() { var tester = new SearchClusterTester(3, 3); tester.setDocsPerNode(100, 0); - tester.setDocsPerNode( 87, 1); // min is set to 88 in MockSearchCluster + tester.setDocsPerNode(87, 1); // min is set to 88 in MockSearchCluster tester.setDocsPerNode(100, 2); tester.pingIterationCompleted(); assertTrue(tester.group(0).hasSufficientCoverage()); @@ -47,11 +47,11 @@ public class SearchClusterCoverageTest { } @Test - public void three_groups_one_missing_docs_but_too_few() { + void three_groups_one_missing_docs_but_too_few() { var tester = new SearchClusterTester(3, 3); tester.setDocsPerNode(100, 0); - tester.setDocsPerNode( 89, 1); // min is set to 88 in MockSearchCluster + tester.setDocsPerNode(89, 1); // min is set to 88 in MockSearchCluster tester.setDocsPerNode(100, 2); tester.pingIterationCompleted(); assertTrue(tester.group(0).hasSufficientCoverage()); @@ -60,7 +60,7 @@ public class SearchClusterCoverageTest { } @Test - public void three_groups_one_has_too_many_docs() { + void three_groups_one_has_too_many_docs() { var tester = new SearchClusterTester(3, 3); tester.setDocsPerNode(100, 0); @@ -73,7 +73,7 @@ public class SearchClusterCoverageTest { } @Test - public void three_groups_one_has_a_node_down() { + void three_groups_one_has_a_node_down() { var tester = new SearchClusterTester(3, 3); tester.setDocsPerNode(100, 0); @@ -87,7 +87,7 @@ public class SearchClusterCoverageTest { } @Test - public void three_groups_one_has_a_node_down_but_remaining_has_enough_docs() { + void three_groups_one_has_a_node_down_but_remaining_has_enough_docs() { var tester = new SearchClusterTester(3, 3); tester.setDocsPerNode(100, 0); @@ -96,12 +96,12 @@ public class SearchClusterCoverageTest { tester.setWorking(1, 1, false); tester.pingIterationCompleted(); assertTrue(tester.group(0).hasSufficientCoverage()); - assertTrue("Sufficient documents on remaining two nodes", tester.group(1).hasSufficientCoverage()); + assertTrue(tester.group(1).hasSufficientCoverage(), "Sufficient documents on remaining two nodes"); assertTrue(tester.group(2).hasSufficientCoverage()); } @Test - public void one_group_few_docs_unbalanced() { + void one_group_few_docs_unbalanced() { var tester = new SearchClusterTester(1, 2); Node node0 = tester.group(0).nodes().get(0); @@ -120,7 +120,7 @@ public class SearchClusterCoverageTest { } @Test - public void one_group_many_docs_unbalanced() { + void one_group_many_docs_unbalanced() { var tester = new SearchClusterTester(1, 2); Node node0 = tester.group(0).nodes().get(0); diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java index 94df796b370..473b24af19f 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java @@ -9,7 +9,7 @@ import com.yahoo.prelude.Pong; import com.yahoo.search.cluster.ClusterMonitor; import com.yahoo.search.dispatch.MockSearchCluster; import com.yahoo.search.result.ErrorMessage; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; @@ -19,9 +19,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * @author baldersheim @@ -151,7 +149,7 @@ public class SearchClusterTest { } @Test - public void requireThatVipStatusIsDefaultDownButComesUpAfterPinging() { + void requireThatVipStatusIsDefaultDownButComesUpAfterPinging() { try (State test = new State("cluster.1", 2, "a", "b")) { assertTrue(test.searchCluster.localCorpusDispatchTarget().isEmpty()); @@ -162,7 +160,7 @@ public class SearchClusterTest { } @Test - public void requireThatZeroDocsAreFine() { + void requireThatZeroDocsAreFine() { try (State test = new State("cluster.1", 2, "a", "b")) { test.waitOneFullPingRound(); @@ -180,7 +178,7 @@ public class SearchClusterTest { } @Test - public void requireThatVipStatusIsDefaultDownWithLocalDispatch() { + void requireThatVipStatusIsDefaultDownWithLocalDispatch() { try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "b")) { assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent()); @@ -191,7 +189,7 @@ public class SearchClusterTest { } @Test - public void requireThatVipStatusStaysUpWithLocalDispatchAndClusterSize1() { + void requireThatVipStatusStaysUpWithLocalDispatchAndClusterSize1() { try (State test = new State("cluster.1", 1, HostName.getLocalhost())) { assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent()); @@ -205,7 +203,7 @@ public class SearchClusterTest { } @Test - public void requireThatVipStatusIsDefaultDownWithLocalDispatchAndClusterSize2() { + void requireThatVipStatusIsDefaultDownWithLocalDispatchAndClusterSize2() { try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "otherhost")) { assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent()); @@ -219,7 +217,7 @@ public class SearchClusterTest { } @Test - public void requireThatVipStatusDownWhenLocalIsDown() { + void requireThatVipStatusDownWhenLocalIsDown() { try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "b")) { test.waitOneFullPingRound(); @@ -276,8 +274,8 @@ public class SearchClusterTest { } @Test - public void requireThatVipStatusDownRequireAllNodesDown() { - verifyThatVipStatusDownRequireAllNodesDown(1,2); + void requireThatVipStatusDownRequireAllNodesDown() { + verifyThatVipStatusDownRequireAllNodesDown(1, 2); verifyThatVipStatusDownRequireAllNodesDown(3, 3); } @@ -315,13 +313,13 @@ public class SearchClusterTest { } @Test - public void requireThatVipStatusUpRequireOnlyOneOnlineNode() { + void requireThatVipStatusUpRequireOnlyOneOnlineNode() { verifyThatVipStatusUpRequireOnlyOneOnlineNode(1, 2); verifyThatVipStatusUpRequireOnlyOneOnlineNode(3, 3); } @Test - public void requireThatPingSequenceIsUpHeld() { + void requireThatPingSequenceIsUpHeld() { Node node = new Node(1, "n", 1); assertEquals(1, node.createPingSequenceId()); assertEquals(2, node.createPingSequenceId()); @@ -335,7 +333,7 @@ public class SearchClusterTest { } @Test - public void requireThatEmptyGroupIsInBalance() { + void requireThatEmptyGroupIsInBalance() { Group group = new Group(0, new ArrayList<>()); assertTrue(group.isBalanced()); group.aggregateNodeValues(); @@ -343,7 +341,7 @@ public class SearchClusterTest { } @Test - public void requireThatSingleNodeGroupIsInBalance() { + void requireThatSingleNodeGroupIsInBalance() { Group group = new Group(0, Arrays.asList(new Node(1, "n", 1))); group.nodes().forEach(node -> node.setWorking(true)); assertTrue(group.isBalanced()); @@ -355,7 +353,7 @@ public class SearchClusterTest { } @Test - public void requireThatMultiNodeGroupDetectsBalance() { + void requireThatMultiNodeGroupDetectsBalance() { Group group = new Group(0, Arrays.asList(new Node(1, "n1", 1), new Node(2, "n2", 1))); assertTrue(group.isBalanced()); group.nodes().forEach(node -> node.setWorking(true)); |