summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-01-13 13:06:05 +0100
committerHarald Musum <musum@verizonmedia.com>2020-01-13 13:06:05 +0100
commit6dee1f03f77ff7395c375ef561bcae4b56b1f390 (patch)
tree036e9afede8f2e76e5a94efdc9527fb83ce125ae
parent4e2478aabcd2ed3945ac0294cefd2cf325e39bbf (diff)
Remove unused executor, log if we get InterruptedException
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java36
1 files changed, 12 insertions, 24 deletions
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 f7d2ebc2c1e..5e188cb5c17 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,14 +9,12 @@ 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.jetbrains.annotations.NotNull;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
-import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -32,20 +30,6 @@ public class SearchClusterTest {
static class State {
- class MyExecutor implements Executor {
- private final List<Runnable> list = new ArrayList<>();
- @Override
- public void execute(@NotNull Runnable command) {
- list.add(command);
- }
- void run() {
- for (Runnable runnable : list) {
- runnable.run();
- }
- list.clear();
- }
- }
-
final String clusterId;
final int nodesPerGroup;
final VipStatus vipStatus;
@@ -57,22 +41,22 @@ public class SearchClusterTest {
this(clusterId, nodesPergroup, Arrays.asList(nodeNames));
}
- State(String clusterId, int nodesPergroup, List<String> nodeNames) {
+ State(String clusterId, int nodesPerGroup, List<String> nodeNames) {
this.clusterId = clusterId;
- this.nodesPerGroup = nodesPergroup;
+ this.nodesPerGroup = nodesPerGroup;
vipStatus = new VipStatus(new QrSearchersConfig.Builder().searchcluster(new QrSearchersConfig.Searchcluster.Builder().name(clusterId)).build(), new ClustersStatus());
numDocsPerNode = new ArrayList<>(nodeNames.size());
pingCounts = new ArrayList<>(nodeNames.size());
List<Node> nodes = new ArrayList<>(nodeNames.size());
for (String name : nodeNames) {
- int key = nodes.size() % nodesPergroup;
- int group = nodes.size() / nodesPergroup;
+ int key = nodes.size() % nodesPerGroup;
+ int group = nodes.size() / nodesPerGroup;
nodes.add(new Node(key, name, group));
numDocsPerNode.add(new AtomicInteger(1));
pingCounts.add(new AtomicInteger(0));
}
- searchCluster = new SearchCluster(clusterId, MockSearchCluster.createDispatchConfig(nodes), nodes.size() / nodesPergroup, vipStatus);
+ searchCluster = new SearchCluster(clusterId, MockSearchCluster.createDispatchConfig(nodes), nodes.size() / nodesPerGroup, vipStatus);
}
void startMonitoring() {
@@ -108,7 +92,9 @@ public class SearchClusterTest {
boolean completed = executor.awaitTermination(120, TimeUnit.SECONDS);
if ( ! completed )
throw new IllegalStateException("Ping thread timed out");
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ System.out.println("Ping thread interrupted");
+ }
}
}
@@ -125,7 +111,7 @@ public class SearchClusterTest {
this.pingCount = pingCount;
}
@Override
- public Pong call() throws Exception {
+ public Pong call() {
int docs = numDocs.get();
pingCount.incrementAndGet();
return (docs < 0)
@@ -164,7 +150,7 @@ public class SearchClusterTest {
@Test
public void requireThatZeroDocsAreFine() {
- State test = new State("cluster.1", 2,"a", "b");
+ State test = new State("cluster.1", 2, "a", "b");
test.startMonitoring();
test.waitOneFullPingRound();
@@ -260,6 +246,7 @@ public class SearchClusterTest {
test.waitOneFullPingRound();
assertFalse(test.vipStatus.isInRotation());
}
+
@Test
public void requireThatVipStatusDownRequireAllNodesDown() {
verifyThatVipStatusDownRequireAllNodesDown(1,2);
@@ -297,6 +284,7 @@ public class SearchClusterTest {
test.waitOneFullPingRound();
assertTrue(test.vipStatus.isInRotation());
}
+
@Test
public void requireThatVipStatusUpRequireOnlyOneOnlineNode() {
verifyThatVipStatusUpRequireOnlyOneOnlineNode(1, 2);