lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject lucene-solr:branch_7_0: SOLR-11041: Move testDataDirAndUlogAreMaintained() to another class, so it won't affect MoveReplicaTest.test()
Date Wed, 12 Jul 2017 10:13:44 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7_0 9b2a10d72 -> 6562c5589


SOLR-11041: Move testDataDirAndUlogAreMaintained() to another class, so it won't affect MoveReplicaTest.test()


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6562c558
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6562c558
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6562c558

Branch: refs/heads/branch_7_0
Commit: 6562c558943b4e655ced35bdb34f294dccc0b844
Parents: 9b2a10d
Author: Cao Manh Dat <datcm@apache.org>
Authored: Wed Jul 12 17:12:48 2017 +0700
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Wed Jul 12 17:13:33 2017 +0700

----------------------------------------------------------------------
 .../apache/solr/cloud/MoveReplicaHDFSTest.java  |  46 ---------
 .../solr/cloud/MoveReplicaHDFSUlogDirTest.java  | 103 +++++++++++++++++++
 2 files changed, 103 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6562c558/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSTest.java b/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSTest.java
index c350dd5b..70c4e46 100644
--- a/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSTest.java
@@ -16,24 +16,14 @@
  */
 package org.apache.solr.cloud;
 
-import java.io.IOException;
-
 import com.carrotsearch.randomizedtesting.ThreadFilter;
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.request.CollectionAdminRequest;
-import org.apache.solr.client.solrj.response.CollectionAdminResponse;
 import org.apache.solr.cloud.hdfs.HdfsTestUtil;
-import org.apache.solr.common.cloud.ClusterStateUtil;
-import org.apache.solr.common.cloud.DocCollection;
-import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.ZkConfigManager;
-import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.util.BadHdfsThreadsFilter;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Test;
 
 /**
  *
@@ -64,42 +54,6 @@ public class MoveReplicaHDFSTest extends MoveReplicaTest {
     dfsCluster = null;
   }
 
-  @Test
-  public void testDataDirAndUlogAreMaintained() throws IOException, SolrServerException {
-    String coll = "movereplicatest_coll2";
-    CollectionAdminRequest.createCollection(coll, "conf1", 1, 1)
-        .setCreateNodeSet("")
-        .process(cluster.getSolrClient());
-    String hdfsUri = HdfsTestUtil.getURI(dfsCluster);
-    String dataDir = hdfsUri + "/dummyFolder/dataDir";
-    String ulogDir = hdfsUri + "/dummyFolder2/ulogDir";
-    CollectionAdminResponse res = CollectionAdminRequest
-        .addReplicaToShard(coll, "shard1")
-        .setDataDir(dataDir)
-        .setUlogDir(ulogDir)
-        .setNode(cluster.getJettySolrRunner(0).getNodeName())
-        .process(cluster.getSolrClient());
-
-    ulogDir += "/tlog";
-    ZkStateReader zkStateReader = cluster.getSolrClient().getZkStateReader();
-    ClusterStateUtil.waitForAllActiveAndLiveReplicas(zkStateReader, 120000);
-    DocCollection docCollection = zkStateReader.getClusterState().getCollection(coll);
-    Replica replica = docCollection.getReplicas().iterator().next();
-    assertTrue(replica.getStr("ulogDir"), replica.getStr("ulogDir").equals(ulogDir) || replica.getStr("ulogDir").equals(ulogDir+'/'));
-    assertTrue(replica.getStr("dataDir"),replica.getStr("dataDir").equals(dataDir) || replica.getStr("dataDir").equals(dataDir+'/'));
-
-    new CollectionAdminRequest.MoveReplica(coll, replica.getName(), cluster.getJettySolrRunner(1).getNodeName())
-        .process(cluster.getSolrClient());
-    ClusterStateUtil.waitForAllActiveAndLiveReplicas(zkStateReader, 120000);
-    docCollection = zkStateReader.getClusterState().getCollection(coll);
-    assertEquals(1, docCollection.getSlice("shard1").getReplicas().size());
-    replica = docCollection.getReplicas().iterator().next();
-    assertEquals(replica.getNodeName(), cluster.getJettySolrRunner(1).getNodeName());
-    assertTrue(replica.getStr("ulogDir"), replica.getStr("ulogDir").equals(ulogDir) || replica.getStr("ulogDir").equals(ulogDir+'/'));
-    assertTrue(replica.getStr("dataDir"),replica.getStr("dataDir").equals(dataDir) || replica.getStr("dataDir").equals(dataDir+'/'));
-
-  }
-
   public static class ForkJoinThreadsFilter implements ThreadFilter {
 
     @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6562c558/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSUlogDirTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSUlogDirTest.java b/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSUlogDirTest.java
new file mode 100644
index 0000000..dfcf58e
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/cloud/MoveReplicaHDFSUlogDirTest.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.cloud;
+
+import java.io.IOException;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.cloud.hdfs.HdfsTestUtil;
+import org.apache.solr.common.cloud.ClusterStateUtil;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.ZkConfigManager;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.util.BadHdfsThreadsFilter;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@ThreadLeakFilters(defaultFilters = true, filters = {
+    BadHdfsThreadsFilter.class, // hdfs currently leaks thread(s)
+    MoveReplicaHDFSTest.ForkJoinThreadsFilter.class
+})
+public class MoveReplicaHDFSUlogDirTest extends SolrCloudTestCase {
+  private static MiniDFSCluster dfsCluster;
+
+  @BeforeClass
+  public static void setupClass() throws Exception {
+    configureCluster(2)
+        .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-dynamic").resolve("conf"))
+        .configure();
+
+    System.setProperty("solr.hdfs.blockcache.enabled", "false");
+    dfsCluster = HdfsTestUtil.setupClass(createTempDir().toFile().getAbsolutePath());
+
+    ZkConfigManager configManager = new ZkConfigManager(zkClient());
+    configManager.uploadConfigDir(configset("cloud-hdfs"), "conf1");
+
+    System.setProperty("solr.hdfs.home", HdfsTestUtil.getDataDir(dfsCluster, "data"));
+  }
+
+  @AfterClass
+  public static void teardownClass() throws Exception {
+    cluster.shutdown(); // need to close before the MiniDFSCluster
+    HdfsTestUtil.teardownClass(dfsCluster);
+    dfsCluster = null;
+  }
+
+  @Test
+  public void testDataDirAndUlogAreMaintained() throws IOException, SolrServerException {
+    String coll = "movereplicatest_coll2";
+    CollectionAdminRequest.createCollection(coll, "conf1", 1, 1)
+        .setCreateNodeSet("")
+        .process(cluster.getSolrClient());
+    String hdfsUri = HdfsTestUtil.getURI(dfsCluster);
+    String dataDir = hdfsUri + "/dummyFolder/dataDir";
+    String ulogDir = hdfsUri + "/dummyFolder2/ulogDir";
+    CollectionAdminResponse res = CollectionAdminRequest
+        .addReplicaToShard(coll, "shard1")
+        .setDataDir(dataDir)
+        .setUlogDir(ulogDir)
+        .setNode(cluster.getJettySolrRunner(0).getNodeName())
+        .process(cluster.getSolrClient());
+
+    ulogDir += "/tlog";
+    ZkStateReader zkStateReader = cluster.getSolrClient().getZkStateReader();
+    ClusterStateUtil.waitForAllActiveAndLiveReplicas(zkStateReader, 120000);
+    DocCollection docCollection = zkStateReader.getClusterState().getCollection(coll);
+    Replica replica = docCollection.getReplicas().iterator().next();
+    assertTrue(replica.getStr("ulogDir"), replica.getStr("ulogDir").equals(ulogDir) || replica.getStr("ulogDir").equals(ulogDir+'/'));
+    assertTrue(replica.getStr("dataDir"),replica.getStr("dataDir").equals(dataDir) || replica.getStr("dataDir").equals(dataDir+'/'));
+
+    new CollectionAdminRequest.MoveReplica(coll, replica.getName(), cluster.getJettySolrRunner(1).getNodeName())
+        .process(cluster.getSolrClient());
+    ClusterStateUtil.waitForAllActiveAndLiveReplicas(zkStateReader, 120000);
+    docCollection = zkStateReader.getClusterState().getCollection(coll);
+    assertEquals(1, docCollection.getSlice("shard1").getReplicas().size());
+    replica = docCollection.getReplicas().iterator().next();
+    assertEquals(replica.getNodeName(), cluster.getJettySolrRunner(1).getNodeName());
+    assertTrue(replica.getStr("ulogDir"), replica.getStr("ulogDir").equals(ulogDir) || replica.getStr("ulogDir").equals(ulogDir+'/'));
+    assertTrue(replica.getStr("dataDir"),replica.getStr("dataDir").equals(dataDir) || replica.getStr("dataDir").equals(dataDir+'/'));
+
+  }
+
+}


Mime
View raw message