You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/07/21 16:03:06 UTC

[lucene-solr] branch reference_impl updated: @271 Just some tweaks around tests.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/reference_impl by this push:
     new 8a93f3b  @271 Just some tweaks around tests.
8a93f3b is described below

commit 8a93f3bcf624aa837e720d2b5812547d5e8de534
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Jul 21 11:02:42 2020 -0500

    @271 Just some tweaks around tests.
---
 .../solr/handler/component/HttpShardHandler.java   |  2 +-
 .../CollectionsAPIDistClusterPerZkTest.java        |  3 +-
 .../CollectionsAPIDistributedZkTest.java           |  2 +-
 .../autoscaling/sim/TestSimDistributedQueue.java   |  2 +-
 .../apache/solr/cloud/MiniSolrCloudCluster.java    | 74 +++++++++++-----------
 5 files changed, 43 insertions(+), 40 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
index 8c0fd92..ec7b034 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
@@ -294,7 +294,7 @@ public class HttpShardHandler extends ShardHandler {
         if (urls != null && !urls.isEmpty()) {
           MDC.put("ShardRequest.urlList", urls.toString());
         }
-        if (!HttpShardHandlerFactory.ASYNC) pending.add( completionService.submit(task) );
+        if (!HttpShardHandlerFactory.ASYNC) pending.add(completionService.submit(task));
       } finally {
         MDC.remove("ShardRequest.shards");
         MDC.remove("ShardRequest.urlList");
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistClusterPerZkTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistClusterPerZkTest.java
index 3185e42..55f6a01 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistClusterPerZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistClusterPerZkTest.java
@@ -113,7 +113,7 @@ public class CollectionsAPIDistClusterPerZkTest extends SolrCloudTestCase {
     System.setProperty("solr.so_commit_timeout.default", "20000");
     System.setProperty("solr.httpclient.defaultSoTimeout", "20000");
 
-    configureCluster(4)
+    configureCluster(TEST_NIGHTLY ? 4 : 2)
         .addConfig("conf", configset(getConfigSet()))
         .addConfig("conf2", configset(getConfigSet()))
         .withSolrXml(TEST_PATH().resolve("solr.xml"))
@@ -183,6 +183,7 @@ public class CollectionsAPIDistClusterPerZkTest extends SolrCloudTestCase {
   }
 
   @Test
+  @Nightly // needs 4 nodes
   public void testCoresAreDistributedAcrossNodes() throws Exception {
     CollectionAdminRequest.createCollection("nodes_used_collection", "conf", 2, 2)
         .process(cluster.getSolrClient());
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistributedZkTest.java
index 79bc705..25b8eb6 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistributedZkTest.java
@@ -67,7 +67,7 @@ public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase {
       System.setProperty("createCollectionWaitTimeTillActive", "10");
     }
 
-    configureCluster(4)
+    configureCluster(TEST_NIGHTLY ? 4 : 2)
         .addConfig("conf", configset(getConfigSet()))
         .addConfig("conf2", configset(getConfigSet()))
         .withSolrXml(TEST_PATH().resolve("solr.xml"))
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimDistributedQueue.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimDistributedQueue.java
index 10f2fd4..ab705f6 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimDistributedQueue.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimDistributedQueue.java
@@ -72,7 +72,7 @@ public class TestSimDistributedQueue extends SolrTestCaseJ4 {
 
     // should block until the background thread makes the offer
     (new QueueChangerThread(dq, 500)).start();
-    assertNotNull(dq.peek(15000));
+    assertNotNull(dq.peek(1500));
     assertNotNull(dq.remove());
     assertNull(dq.poll());
 
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
index 27e501e..9efbf2a 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
@@ -653,50 +653,52 @@ public class MiniSolrCloudCluster {
    * Shut down the cluster, including all Solr nodes and ZooKeeper
    */
   public void shutdown() throws Exception {
-    try {
-      log.info("creating cluster shutdown zk node");
-      zkServer.getZkClient().mkdirs("/solr" + ZkController.CLUSTER_SHUTDOWN);
-      zkServer.getZkClient().printLayout();
-      zkServer.getZkClient().printLayoutToStream(System.out);
-
-      CountDownLatch latch = new CountDownLatch(1);
-      List<String> children = zkServer.getZkClient().getChildren("/solr" + ZkStateReader.LIVE_NODES_ZKNODE, new Watcher() {
-        @Override
-        public void process(WatchedEvent event) {
-          if (Event.EventType.None.equals(event.getType())) {
-            return;
-          }
-          if (event.getType() == Event.EventType.NodeChildrenChanged) {
-            try {
-              List<String> children = zkServer.getZkClient().getChildren("/solr" + ZkStateReader.LIVE_NODES_ZKNODE, this, false);
-              if (children.size() == 0) {
-                latch.countDown();
-              }
-            } catch (KeeperException e) {
-              log.error("Exception on proper shutdown", e);
-              return;
-            } catch (InterruptedException e) {
-              ParWork.propegateInterrupt(e);
+    if (zkServer.getZkClient().isConnected()) {
+      try {
+        log.info("creating cluster shutdown zk node");
+
+        zkServer.getZkClient().mkdirs("/solr" + ZkController.CLUSTER_SHUTDOWN);
+        zkServer.getZkClient().printLayout();
+        zkServer.getZkClient().printLayoutToStream(System.out);
+
+        CountDownLatch latch = new CountDownLatch(1);
+        List<String> children = zkServer.getZkClient().getChildren("/solr" + ZkStateReader.LIVE_NODES_ZKNODE, new Watcher() {
+          @Override
+          public void process(WatchedEvent event) {
+            if (Event.EventType.None.equals(event.getType())) {
               return;
             }
+            if (event.getType() == Event.EventType.NodeChildrenChanged) {
+              try {
+                List<String> children = zkServer.getZkClient().getChildren("/solr" + ZkStateReader.LIVE_NODES_ZKNODE, this, false);
+                if (children.size() == 0) {
+                  latch.countDown();
+                }
+              } catch (KeeperException e) {
+                log.error("Exception on proper shutdown", e);
+                return;
+              } catch (InterruptedException e) {
+                ParWork.propegateInterrupt(e);
+                return;
+              }
+            }
           }
-        }
-      }, false);
+        }, false);
 
-      if (children.size() > 0) {
-        boolean success = latch.await(10, TimeUnit.SECONDS);
-        if (!success)  {
-          throw new TimeoutException("Time out waiting to see solr live nodes go down " + children.size());
+        if (children.size() > 0) {
+          boolean success = latch.await(10, TimeUnit.SECONDS);
+          if (!success) {
+            throw new TimeoutException("Time out waiting to see solr live nodes go down " + children.size());
+          }
         }
-      }
 
-    } catch (KeeperException.NodeExistsException e) {
-      log.info("Shutdown zk node already exists");
-    } catch (Exception e) {
-      log.error("Exception on proper shutdown", e);
+      } catch (KeeperException.NodeExistsException e) {
+        log.info("Shutdown zk node already exists");
+      } catch (Exception e) {
+        log.error("Exception on proper shutdown", e);
+      }
     }
 
-
     //ZkStateReader reader = zkServer.getZkClient().getZkStateReader();
 
 //    try {