From 5e69a465ee16e6f77f0b3658dac2688cfe087303 Mon Sep 17 00:00:00 2001 From: Andrzej Bialecki Date: Wed, 11 Oct 2017 19:26:00 +0200 Subject: [PATCH] SOLR-11407: Add more logging to this test to discover the reason for failures. --- .../admin/AutoscalingHistoryHandlerTest.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java index 09f5edc2e19..53ee12c0598 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java @@ -183,12 +183,15 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase { cluster.getSolrClient().getZkStateReader().registerCore(".system"); cluster.getSolrClient().getZkStateReader().registerCore(PREFIX + "_collection"); + log.info("### Start add node..."); JettySolrRunner jetty = cluster.startJettySolrRunner(); String nodeAddedName = jetty.getNodeName(); + log.info("### Added node " + nodeAddedName); boolean await = actionFiredLatch.await(60, TimeUnit.SECONDS); assertTrue("action did not execute", await); // commit on the history collection Thread.sleep(2000); + log.info("### Commit .system"); solrClient.commit(CollectionAdminParams.SYSTEM_COLL); Thread.sleep(2000); // verify that new docs exist @@ -249,12 +252,18 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase { resetLatch(); // kill a node + String node0Name = cluster.getJettySolrRunner(0).getNodeName(); + log.info("### Stopping node " + node0Name); cluster.stopJettySolrRunner(0); + log.info("### Stopped node " + node0Name); await = actionFiredLatch.await(60, TimeUnit.SECONDS); + assertTrue("action did not execute", await); + // wait for recovery waitForRecovery(PREFIX + "_collection"); Thread.sleep(5000); // commit on the history collection + log.info("### Commit .system"); solrClient.commit(CollectionAdminParams.SYSTEM_COLL); query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH, AutoscalingHistoryHandler.TRIGGER_PARAM, PREFIX + "_node_lost_trigger"); @@ -269,19 +278,27 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase { } private void waitForRecovery(String collection) throws Exception { + log.info("Waiting for recovery of " + collection); boolean recovered = false; + boolean allActive = true; + boolean hasLeaders = true; + DocCollection collState = null; for (int i = 0; i < 300; i++) { ClusterState state = solrClient.getZkStateReader().getClusterState(); - DocCollection collState = getCollectionState(collection); + collState = getCollectionState(collection); log.debug("###### " + collState); Collection replicas = collState.getReplicas(); - boolean allActive = true; - boolean hasLeaders = true; + allActive = true; + hasLeaders = true; if (replicas != null && !replicas.isEmpty()) { for (Replica r : replicas) { - if (!r.isActive(state.getLiveNodes())) { - log.info("Not active: " + r); - allActive = false; + if (state.getLiveNodes().contains(r.getNodeName())) { + if (!r.isActive(state.getLiveNodes())) { + log.info("Not active: " + r); + allActive = false; + } + } else { + log.info("Replica no longer on a live node, ignoring: " + r); } } } else { @@ -300,7 +317,7 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase { Thread.sleep(1000); } } - assertTrue("replica never fully recovered", recovered); + assertTrue("replica never fully recovered: allActive=" + allActive + ", hasLeaders=" + hasLeaders + ", collState=" + collState, recovered); }