You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/02/09 00:53:25 UTC
svn commit: r1658277 [27/38] - in /lucene/dev/branches/lucene6005: ./
dev-tools/ dev-tools/idea/solr/contrib/dataimporthandler/
dev-tools/idea/solr/contrib/velocity/ dev-tools/maven/lucene/replicator/
dev-tools/maven/solr/ dev-tools/maven/solr/contrib/...
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java Sun Feb 8 23:53:14 2015
@@ -338,6 +338,8 @@ public class OverseerCollectionProcessor
}
}).anyTimes();
+ zkMap.put("/configs/myconfig", null);
+
return liveNodes;
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java Sun Feb 8 23:53:14 2015
@@ -18,20 +18,6 @@ package org.apache.solr.cloud;
*/
-import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
-import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
-import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.getSortedOverseerNodeNames;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.getLeaderNode;
-import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrRequest;
@@ -46,9 +32,22 @@ import org.apache.solr.common.params.Col
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.zookeeper.data.Stat;
-import org.junit.After;
-import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.getLeaderNode;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.getSortedOverseerNodeNames;
+import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
+import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
+import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
@LuceneTestCase.Slow
@SuppressSSL // See SOLR-5776
@@ -60,19 +59,18 @@ public class OverseerRolesTest extends
}
- @Before
@Override
- public void setUp() throws Exception {
- super.setUp();
+ public void distribSetUp() throws Exception {
+ super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true");
client = createCloudClient(null);
}
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- client.shutdown();
+ @Override
+ public void distribTearDown() throws Exception {
+ super.distribTearDown();
+ client.close();
}
protected String getSolrXml() {
@@ -80,16 +78,14 @@ public class OverseerRolesTest extends
}
public OverseerRolesTest() {
- fixShardCount = true;
-
sliceCount = 2;
- shardCount = TEST_NIGHTLY ? 6 : 2;
+ fixShardCount(TEST_NIGHTLY ? 6 : 2);
checkCreatedVsState = false;
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
testQuitCommand();
testOverseerRole();
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java Sun Feb 8 23:53:14 2015
@@ -17,20 +17,11 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.HttpSolrClient;
-import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
-import org.apache.solr.common.cloud.DocRouter;
import org.apache.solr.common.params.CollectionParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
-import org.junit.After;
-import org.junit.Before;
-
-import java.io.IOException;
+import org.junit.Test;
public class OverseerStatusTest extends BasicDistributedZkTest {
@@ -39,33 +30,15 @@ public class OverseerStatusTest extends
}
@Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
+ public void distribSetUp() throws Exception {
+ super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true");
}
- @Override
- @After
- public void tearDown() throws Exception {
- if (VERBOSE || printLayoutOnTearDown) {
- super.printLayout();
- }
- if (controlClient != null) {
- controlClient.shutdown();
- }
- if (cloudClient != null) {
- cloudClient.shutdown();
- }
- if (controlClientCloud != null) {
- controlClientCloud.shutdown();
- }
- super.tearDown();
- }
+ @Test
+ public void test() throws Exception {
- @Override
- public void doTest() throws Exception {
waitForThingsToLevelOut(15);
// find existing command counts because collection may be created by base test class too
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Sun Feb 8 23:53:14 2015
@@ -71,6 +71,8 @@ public class OverseerTest extends SolrTe
private List<Overseer> overseers = new ArrayList<>();
private List<ZkStateReader> readers = new ArrayList<>();
+ private List<HttpShardHandlerFactory> httpShardHandlerFactorys = new ArrayList<>();
+ private List<UpdateShardHandler> updateShardHandlers = new ArrayList<>();
private String collection = "collection1";
@@ -205,6 +207,16 @@ public class OverseerTest extends SolrTe
reader.close();
}
readers.clear();
+
+ for (HttpShardHandlerFactory handlerFactory : httpShardHandlerFactorys) {
+ handlerFactory.close();
+ }
+ httpShardHandlerFactorys.clear();
+
+ for (UpdateShardHandler updateShardHandler : updateShardHandlers) {
+ updateShardHandler.close();
+ }
+ updateShardHandlers.clear();
}
@Test
@@ -1118,8 +1130,11 @@ public class OverseerTest extends SolrTe
overseers.get(overseers.size() -1).getZkStateReader().getZkClient().close();
}
UpdateShardHandler updateShardHandler = new UpdateShardHandler(null);
+ updateShardHandlers.add(updateShardHandler);
+ HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();
+ httpShardHandlerFactorys.add(httpShardHandlerFactory);
Overseer overseer = new Overseer(
- new HttpShardHandlerFactory().getShardHandler(), updateShardHandler, "/admin/cores", reader, null, new MockConfigSolr());
+ httpShardHandlerFactory.getShardHandler(), updateShardHandler, "/admin/cores", reader, null, new MockConfigSolr());
overseers.add(overseer);
ElectionContext ec = new OverseerElectionContext(zkClient, overseer,
address.replaceAll("/", "_"));
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java Sun Feb 8 23:53:14 2015
@@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.Solr
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.ZkStateReader;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,7 +40,7 @@ public class RecoveryZkTest extends Abst
public RecoveryZkTest() {
super();
sliceCount = 1;
- shardCount = 2;
+ fixShardCount(2);
schemaString = "schema15.xml"; // we need a string id
}
@@ -54,8 +55,8 @@ public class RecoveryZkTest extends Abst
return randVals;
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
handle.clear();
handle.put("timestamp", SKIPVAL);
@@ -148,7 +149,7 @@ public class RecoveryZkTest extends Abst
@Override
- public void tearDown() throws Exception {
+ public void distribTearDown() throws Exception {
// make sure threads have been stopped...
indexThread.safeStop();
indexThread2.safeStop();
@@ -156,7 +157,7 @@ public class RecoveryZkTest extends Abst
indexThread.join();
indexThread2.join();
- super.tearDown();
+ super.distribTearDown();
}
// skip the randoms - they can deadlock...
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java Sun Feb 8 23:53:14 2015
@@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTest
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
+import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
@@ -36,11 +37,11 @@ public class RemoteQueryErrorTest extend
public RemoteQueryErrorTest() {
super();
sliceCount = 1;
- shardCount = random().nextBoolean() ? 3 : 4;
+ fixShardCount(random().nextBoolean() ? 3 : 4);
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
handle.clear();
handle.put("timestamp", SKIPVAL);
@@ -66,8 +67,8 @@ public class RemoteQueryErrorTest extend
} catch(Exception ex) {
fail("Expected a SolrException to occur, instead received: " + ex.getClass());
} finally {
- solrClient.shutdown();
+ solrClient.close();
}
}
}
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java Sun Feb 8 23:53:14 2015
@@ -19,27 +19,22 @@ package org.apache.solr.cloud;
import java.io.File;
import java.net.ServerSocket;
-import java.net.URI;
-import java.net.URL;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.ZkCoreNodeProps;
-import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.NamedList;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,31 +54,25 @@ public class ReplicationFactorTest exten
public ReplicationFactorTest() {
super();
sliceCount = 3;
- shardCount = 3;
+ fixShardCount(3);
}
- @Before
@Override
- public void setUp() throws Exception {
- super.setUp();
+ public void distribSetUp() throws Exception {
+ super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount));
}
@Override
- @After
- public void tearDown() throws Exception {
+ public void distribTearDown() throws Exception {
log.info("tearing down replicationFactorTest!");
System.clearProperty("numShards");
- try {
- super.tearDown();
- } catch (Exception exc) {}
-
- resetExceptionIgnores();
-
- log.info("super.tearDown complete, closing all socket proxies");
+ super.distribTearDown();
+
+ log.info("super.distribTearDown complete, closing all socket proxies");
if (!proxies.isEmpty()) {
for (SocketProxy proxy : proxies.values()) {
proxy.close();
@@ -111,10 +100,10 @@ public class ReplicationFactorTest exten
port = s.getLocalPort();
}
return port;
- }
-
- @Override
- public void doTest() throws Exception {
+ }
+
+ @Test
+ public void test() throws Exception {
log.info("replication factor test running");
waitForThingsToLevelOut(30000);
@@ -141,7 +130,20 @@ public class ReplicationFactorTest exten
String shardId = "shard1";
int minRf = 2;
- createCollection(testCollectionName, numShards, replicationFactor, maxShardsPerNode);
+ CollectionAdminResponse resp = createCollection(testCollectionName, numShards, replicationFactor, maxShardsPerNode);
+
+ if (resp.getResponse().get("failure") != null) {
+ CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
+ req.setCollectionName(testCollectionName);
+ req.process(cloudClient);
+
+ resp = createCollection(testCollectionName, numShards, replicationFactor, maxShardsPerNode);
+
+ if (resp.getResponse().get("failure") != null) {
+ fail("Could not create " + testCollectionName);
+ }
+ }
+
cloudClient.setDefaultCollection(testCollectionName);
List<Replica> replicas =
@@ -162,8 +164,8 @@ public class ReplicationFactorTest exten
up.add(batch);
Replica leader = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, shardId);
- sendNonDirectUpdateRequestReplica(leader, up, 2, testCollectionName);
- sendNonDirectUpdateRequestReplica(replicas.get(0), up, 2, testCollectionName);
+ sendNonDirectUpdateRequestReplicaWithRetry(leader, up, 2, testCollectionName);
+ sendNonDirectUpdateRequestReplicaWithRetry(replicas.get(0), up, 2, testCollectionName);
// so now kill the replica of shard2 and verify the achieved rf is only 1
List<Replica> shard2Replicas =
@@ -175,8 +177,8 @@ public class ReplicationFactorTest exten
Thread.sleep(2000);
// shard1 will have rf=2 but shard2 will only have rf=1
- sendNonDirectUpdateRequestReplica(leader, up, 1, testCollectionName);
- sendNonDirectUpdateRequestReplica(replicas.get(0), up, 1, testCollectionName);
+ sendNonDirectUpdateRequestReplicaWithRetry(leader, up, 1, testCollectionName);
+ sendNonDirectUpdateRequestReplicaWithRetry(replicas.get(0), up, 1, testCollectionName);
// heal the partition
getProxyForReplica(shard2Replicas.get(0)).reopen();
@@ -184,22 +186,27 @@ public class ReplicationFactorTest exten
Thread.sleep(2000);
}
+
+ protected void sendNonDirectUpdateRequestReplicaWithRetry(Replica replica, UpdateRequest up, int expectedRf, String collection) throws Exception {
+ try {
+ sendNonDirectUpdateRequestReplica(replica, up, expectedRf, collection);
+ } catch (Exception e) {
+ sendNonDirectUpdateRequestReplica(replica, up, expectedRf, collection);
+ }
+ }
+
@SuppressWarnings("rawtypes")
protected void sendNonDirectUpdateRequestReplica(Replica replica, UpdateRequest up, int expectedRf, String collection) throws Exception {
- HttpSolrClient solrServer = null;
- try {
- ZkCoreNodeProps zkProps = new ZkCoreNodeProps(replica);
- String url = zkProps.getBaseUrl() + "/" + collection;
- solrServer = new HttpSolrClient(url);
-
+
+ ZkCoreNodeProps zkProps = new ZkCoreNodeProps(replica);
+ String url = zkProps.getBaseUrl() + "/" + collection;
+
+ try (HttpSolrClient solrServer = new HttpSolrClient(url)) {
NamedList resp = solrServer.request(up);
NamedList hdr = (NamedList) resp.get("responseHeader");
Integer batchRf = (Integer)hdr.get(UpdateRequest.REPFACT);
assertTrue("Expected rf="+expectedRf+" for batch but got "+
batchRf+"; clusterState: "+printClusterStateInfo(), batchRf == expectedRf);
- } finally {
- if (solrServer != null)
- solrServer.shutdown();
}
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java Sun Feb 8 23:53:14 2015
@@ -21,8 +21,7 @@ import org.apache.commons.collections.Co
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.params.CollectionParams;
import org.apache.zookeeper.KeeperException;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,29 +35,25 @@ public class RollingRestartTest extends
private static final long MAX_WAIT_TIME = TimeUnit.NANOSECONDS.convert(300, TimeUnit.SECONDS);
public RollingRestartTest() {
- fixShardCount = true;
sliceCount = 2;
- shardCount = TEST_NIGHTLY ? 16 : 2;
+ fixShardCount(TEST_NIGHTLY ? 16 : 2);
}
- @Before
@Override
- public void setUp() throws Exception {
- super.setUp();
+ public void distribSetUp() throws Exception {
+ super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount));
useFactory("solr.StandardDirectoryFactory");
}
@Override
- @After
- public void tearDown() throws Exception {
+ public void distribTearDown() throws Exception {
System.clearProperty("numShards");
- super.tearDown();
- resetExceptionIgnores();
+ super.distribTearDown();
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
waitForRecoveriesToFinish(false);
restartWithRolesTest();
@@ -75,11 +70,11 @@ public class RollingRestartTest extends
cloudClient.getZkStateReader().getZkClient().printLayoutToStdOut();
int numDesignateOverseers = TEST_NIGHTLY ? 16 : 2;
- numDesignateOverseers = Math.max(shardCount, numDesignateOverseers);
+ numDesignateOverseers = Math.max(getShardCount(), numDesignateOverseers);
List<String> designates = new ArrayList<>();
List<CloudJettyRunner> designateJettys = new ArrayList<>();
for (int i = 0; i < numDesignateOverseers; i++) {
- int n = random().nextInt(shardCount);
+ int n = random().nextInt(getShardCount());
String nodeName = cloudJettys.get(n).nodeName;
log.info("Chose {} as overseer designate", nodeName);
invokeCollectionApi(CollectionParams.ACTION, CollectionParams.CollectionAction.ADDROLE.toLower(), "role", "overseer", "node", nodeName);
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java Sun Feb 8 23:53:14 2015
@@ -41,6 +41,7 @@ import org.apache.solr.common.params.Sol
import org.apache.solr.util.SSLTestConfig;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.junit.Test;
/**
* We want to make sure that when migrating between http and https modes the
@@ -51,9 +52,9 @@ import org.apache.lucene.util.LuceneTest
@SuppressSSL
@BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-6213")
public class SSLMigrationTest extends AbstractFullDistribZkTestBase {
-
- @Override
- public void doTest() throws Exception {
+
+ @Test
+ public void test() throws Exception {
//Migrate from HTTP -> HTTPS -> HTTP
assertReplicaInformation("http");
testMigrateSSL(new SSLTestConfig(true, false));
@@ -118,4 +119,4 @@ public class SSLMigrationTest extends Ab
new LBHttpSolrClient(urls.toArray(new String[]{})).request(request);
}
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java Sun Feb 8 23:53:14 2015
@@ -18,6 +18,7 @@ package org.apache.solr.cloud;
*/
import org.junit.BeforeClass;
+import org.junit.Test;
public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {
@@ -34,8 +35,8 @@ public class ShardRoutingCustomTest exte
sliceCount = 0;
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
boolean testFinished = false;
try {
doCustomSharding();
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java Sun Feb 8 23:53:14 2015
@@ -17,32 +17,16 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.cloud.CompositeIdRouter;
-import org.apache.solr.common.cloud.ZkNodeProps;
-import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
-import org.apache.solr.common.util.StrUtils;
-import org.apache.solr.servlet.SolrDispatchFilter;
-import org.apache.solr.update.DirectUpdateHandler2;
import org.junit.BeforeClass;
-import org.junit.Ignore;
+import org.junit.Test;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
public class ShardRoutingTest extends AbstractFullDistribZkTestBase {
@@ -66,8 +50,6 @@ public class ShardRoutingTest extends Ab
public ShardRoutingTest() {
schemaString = "schema15.xml"; // we need a string id
super.sliceCount = 4;
- super.shardCount = 8;
- super.fixShardCount = true; // we only want to test with exactly 4 slices.
// from negative to positive, the upper bits of the hash ranges should be
// shard1: top bits:10 80000000:bfffffff
@@ -109,8 +91,9 @@ public class ShardRoutingTest extends Ab
***/
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ @ShardsFixed(num = 8)
+ public void test() throws Exception {
boolean testFinished = false;
try {
handle.clear();
@@ -137,7 +120,7 @@ public class ShardRoutingTest extends Ab
private void doHashingTest() throws Exception {
log.info("### STARTING doHashingTest");
assertEquals(4, cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION).getSlices().size());
- String shardKeys = ShardParams.SHARD_KEYS;
+ String shardKeys = ShardParams._ROUTE_;
// for now, we know how ranges will be distributed to shards.
// may have to look it up in clusterstate if that assumption changes.
@@ -282,12 +265,12 @@ public class ShardRoutingTest extends Ab
assertEquals(1, nEnd - nStart); // short circuit should prevent distrib search
nStart = getNumRequests();
- replica.client.solrClient.query( params("q","*:*", "shard.keys","b!") );
+ replica.client.solrClient.query( params("q","*:*", ShardParams._ROUTE_, "b!") );
nEnd = getNumRequests();
assertEquals(1, nEnd - nStart); // short circuit should prevent distrib search
nStart = getNumRequests();
- leader2.client.solrClient.query( params("q","*:*", "shard.keys","b!") );
+ leader2.client.solrClient.query( params("q","*:*", ShardParams._ROUTE_, "b!") );
nEnd = getNumRequests();
assertEquals(3, nEnd - nStart); // original + 2 phase distrib search. we could improve this!
@@ -297,12 +280,12 @@ public class ShardRoutingTest extends Ab
assertEquals(9, nEnd - nStart); // original + 2 phase distrib search * 4 shards.
nStart = getNumRequests();
- leader2.client.solrClient.query( params("q","*:*", "shard.keys","b!,d!") );
+ leader2.client.solrClient.query( params("q","*:*", ShardParams._ROUTE_, "b!,d!") );
nEnd = getNumRequests();
assertEquals(5, nEnd - nStart); // original + 2 phase distrib search * 2 shards.
nStart = getNumRequests();
- leader2.client.solrClient.query( params("q","*:*", "shard.keys","b!,f1!f2!") );
+ leader2.client.solrClient.query( params("q","*:*", ShardParams._ROUTE_, "b!,f1!f2!") );
nEnd = getNumRequests();
assertEquals(5, nEnd - nStart);
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java Sun Feb 8 23:53:14 2015
@@ -39,8 +39,7 @@ import org.apache.solr.common.cloud.ZkNo
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -66,33 +65,15 @@ public class ShardSplitTest extends Basi
}
@Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
+ public void distribSetUp() throws Exception {
+ super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true");
}
- @Override
- @After
- public void tearDown() throws Exception {
- if (VERBOSE || printLayoutOnTearDown) {
- super.printLayout();
- }
- if (controlClient != null) {
- controlClient.shutdown();
- }
- if (cloudClient != null) {
- cloudClient.shutdown();
- }
- if (controlClientCloud != null) {
- controlClientCloud.shutdown();
- }
- super.tearDown();
- }
+ @Test
+ public void test() throws Exception {
- @Override
- public void doTest() throws Exception {
waitForThingsToLevelOut(15);
if (usually()) {
@@ -251,10 +232,8 @@ public class ShardSplitTest extends Basi
.getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
HashMap<String, List<Integer>> collectionInfos = new HashMap<>();
- CloudSolrClient client = null;
String shard_fld = "shard_s";
- try {
- client = createCloudClient(null);
+ try (CloudSolrClient client = createCloudClient(null)) {
Map<String, Object> props = ZkNodeProps.makeMap(
REPLICATION_FACTOR, replicationFactor,
MAX_SHARDS_PER_NODE, maxShardsPerNode,
@@ -262,8 +241,6 @@ public class ShardSplitTest extends Basi
"router.field", shard_fld);
createCollection(collectionInfos, collectionName,props,client);
- } finally {
- if (client != null) client.shutdown();
}
List<Integer> list = collectionInfos.get(collectionName);
@@ -273,52 +250,52 @@ public class ShardSplitTest extends Basi
String url = CustomCollectionTest.getUrlFromZk(getCommonCloudSolrClient().getZkStateReader().getClusterState(), collectionName);
- HttpSolrClient collectionClient = new HttpSolrClient(url);
+ try (HttpSolrClient collectionClient = new HttpSolrClient(url)) {
- ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
- final DocRouter router = clusterState.getCollection(collectionName).getRouter();
- Slice shard1 = clusterState.getSlice(collectionName, SHARD1);
- DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
- final List<DocRouter.Range> ranges = router.partitionRange(2, shard1Range);
- final int[] docCounts = new int[ranges.size()];
-
- for (int i = 100; i <= 200; i++) {
- String shardKey = "" + (char)('a' + (i % 26)); // See comment in ShardRoutingTest for hash distribution
-
- collectionClient.add(getDoc(id, i, "n_ti", i, shard_fld, shardKey));
- int idx = getHashRangeIdx(router, ranges, shardKey);
- if (idx != -1) {
- docCounts[idx]++;
+ ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
+ final DocRouter router = clusterState.getCollection(collectionName).getRouter();
+ Slice shard1 = clusterState.getSlice(collectionName, SHARD1);
+ DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
+ final List<DocRouter.Range> ranges = router.partitionRange(2, shard1Range);
+ final int[] docCounts = new int[ranges.size()];
+
+ for (int i = 100; i <= 200; i++) {
+ String shardKey = "" + (char) ('a' + (i % 26)); // See comment in ShardRoutingTest for hash distribution
+
+ collectionClient.add(getDoc(id, i, "n_ti", i, shard_fld, shardKey));
+ int idx = getHashRangeIdx(router, ranges, shardKey);
+ if (idx != -1) {
+ docCounts[idx]++;
+ }
}
- }
- for (int i = 0; i < docCounts.length; i++) {
- int docCount = docCounts[i];
- log.info("Shard {} docCount = {}", "shard1_" + i, docCount);
- }
+ for (int i = 0; i < docCounts.length; i++) {
+ int docCount = docCounts[i];
+ log.info("Shard {} docCount = {}", "shard1_" + i, docCount);
+ }
- collectionClient.commit();
+ collectionClient.commit();
- for (int i = 0; i < 3; i++) {
- try {
- splitShard(collectionName, SHARD1, null, null);
- break;
- } catch (HttpSolrClient.RemoteSolrException e) {
- if (e.code() != 500) {
- throw e;
- }
- log.error("SPLITSHARD failed. " + (i < 2 ? " Retring split" : ""), e);
- if (i == 2) {
- fail("SPLITSHARD was not successful even after three tries");
+ for (int i = 0; i < 3; i++) {
+ try {
+ splitShard(collectionName, SHARD1, null, null);
+ break;
+ } catch (HttpSolrClient.RemoteSolrException e) {
+ if (e.code() != 500) {
+ throw e;
+ }
+ log.error("SPLITSHARD failed. " + (i < 2 ? " Retring split" : ""), e);
+ if (i == 2) {
+ fail("SPLITSHARD was not successful even after three tries");
+ }
}
}
- }
- waitForRecoveriesToFinish(collectionName, false);
+ waitForRecoveriesToFinish(collectionName, false);
- assertEquals(docCounts[0], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_0")).getResults().getNumFound());
- assertEquals(docCounts[1], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_1")).getResults().getNumFound());
- collectionClient.shutdown();
+ assertEquals(docCounts[0], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_0")).getResults().getNumFound());
+ assertEquals(docCounts[1], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_1")).getResults().getNumFound());
+ }
}
private void splitByRouteKeyTest() throws Exception {
@@ -330,17 +307,14 @@ public class ShardSplitTest extends Basi
.getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
HashMap<String, List<Integer>> collectionInfos = new HashMap<>();
- CloudSolrClient client = null;
- try {
- client = createCloudClient(null);
+
+ try (CloudSolrClient client = createCloudClient(null)) {
Map<String, Object> props = ZkNodeProps.makeMap(
REPLICATION_FACTOR, replicationFactor,
MAX_SHARDS_PER_NODE, maxShardsPerNode,
NUM_SLICES, numShards);
createCollection(collectionInfos, collectionName,props,client);
- } finally {
- if (client != null) client.shutdown();
}
List<Integer> list = collectionInfos.get(collectionName);
@@ -350,66 +324,66 @@ public class ShardSplitTest extends Basi
String url = CustomCollectionTest.getUrlFromZk(getCommonCloudSolrClient().getZkStateReader().getClusterState(), collectionName);
- HttpSolrClient collectionClient = new HttpSolrClient(url);
+ try (HttpSolrClient collectionClient = new HttpSolrClient(url)) {
- String splitKey = "b!";
+ String splitKey = "b!";
- ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
- final DocRouter router = clusterState.getCollection(collectionName).getRouter();
- Slice shard1 = clusterState.getSlice(collectionName, SHARD1);
- DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
- final List<DocRouter.Range> ranges = ((CompositeIdRouter) router).partitionRangeByKey(splitKey, shard1Range);
- final int[] docCounts = new int[ranges.size()];
-
- int uniqIdentifier = (1<<12);
- int splitKeyDocCount = 0;
- for (int i = 100; i <= 200; i++) {
- String shardKey = "" + (char)('a' + (i % 26)); // See comment in ShardRoutingTest for hash distribution
-
- String idStr = shardKey + "!" + i;
- collectionClient.add(getDoc(id, idStr, "n_ti", (shardKey + "!").equals(splitKey) ? uniqIdentifier : i));
- int idx = getHashRangeIdx(router, ranges, idStr);
- if (idx != -1) {
- docCounts[idx]++;
+ ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
+ final DocRouter router = clusterState.getCollection(collectionName).getRouter();
+ Slice shard1 = clusterState.getSlice(collectionName, SHARD1);
+ DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
+ final List<DocRouter.Range> ranges = ((CompositeIdRouter) router).partitionRangeByKey(splitKey, shard1Range);
+ final int[] docCounts = new int[ranges.size()];
+
+ int uniqIdentifier = (1 << 12);
+ int splitKeyDocCount = 0;
+ for (int i = 100; i <= 200; i++) {
+ String shardKey = "" + (char) ('a' + (i % 26)); // See comment in ShardRoutingTest for hash distribution
+
+ String idStr = shardKey + "!" + i;
+ collectionClient.add(getDoc(id, idStr, "n_ti", (shardKey + "!").equals(splitKey) ? uniqIdentifier : i));
+ int idx = getHashRangeIdx(router, ranges, idStr);
+ if (idx != -1) {
+ docCounts[idx]++;
+ }
+ if (splitKey.equals(shardKey + "!"))
+ splitKeyDocCount++;
}
- if (splitKey.equals(shardKey + "!"))
- splitKeyDocCount++;
- }
- for (int i = 0; i < docCounts.length; i++) {
- int docCount = docCounts[i];
- log.info("Shard {} docCount = {}", "shard1_" + i, docCount);
- }
- log.info("Route key doc count = {}", splitKeyDocCount);
+ for (int i = 0; i < docCounts.length; i++) {
+ int docCount = docCounts[i];
+ log.info("Shard {} docCount = {}", "shard1_" + i, docCount);
+ }
+ log.info("Route key doc count = {}", splitKeyDocCount);
- collectionClient.commit();
+ collectionClient.commit();
- for (int i = 0; i < 3; i++) {
- try {
- splitShard(collectionName, null, null, splitKey);
- break;
- } catch (HttpSolrClient.RemoteSolrException e) {
- if (e.code() != 500) {
- throw e;
- }
- log.error("SPLITSHARD failed. " + (i < 2 ? " Retring split" : ""), e);
- if (i == 2) {
- fail("SPLITSHARD was not successful even after three tries");
+ for (int i = 0; i < 3; i++) {
+ try {
+ splitShard(collectionName, null, null, splitKey);
+ break;
+ } catch (HttpSolrClient.RemoteSolrException e) {
+ if (e.code() != 500) {
+ throw e;
+ }
+ log.error("SPLITSHARD failed. " + (i < 2 ? " Retring split" : ""), e);
+ if (i == 2) {
+ fail("SPLITSHARD was not successful even after three tries");
+ }
}
}
- }
- waitForRecoveriesToFinish(collectionName, false);
- SolrQuery solrQuery = new SolrQuery("*:*");
- assertEquals("DocCount on shard1_0 does not match", docCounts[0], collectionClient.query(solrQuery.setParam("shards", "shard1_0")).getResults().getNumFound());
- assertEquals("DocCount on shard1_1 does not match", docCounts[1], collectionClient.query(solrQuery.setParam("shards", "shard1_1")).getResults().getNumFound());
- assertEquals("DocCount on shard1_2 does not match", docCounts[2], collectionClient.query(solrQuery.setParam("shards", "shard1_2")).getResults().getNumFound());
-
- solrQuery = new SolrQuery("n_ti:" + uniqIdentifier);
- assertEquals("shard1_0 must have 0 docs for route key: " + splitKey, 0, collectionClient.query(solrQuery.setParam("shards", "shard1_0")).getResults().getNumFound());
- assertEquals("Wrong number of docs on shard1_1 for route key: " + splitKey, splitKeyDocCount, collectionClient.query(solrQuery.setParam("shards", "shard1_1")).getResults().getNumFound());
- assertEquals("shard1_2 must have 0 docs for route key: " + splitKey, 0, collectionClient.query(solrQuery.setParam("shards", "shard1_2")).getResults().getNumFound());
- collectionClient.shutdown();
+ waitForRecoveriesToFinish(collectionName, false);
+ SolrQuery solrQuery = new SolrQuery("*:*");
+ assertEquals("DocCount on shard1_0 does not match", docCounts[0], collectionClient.query(solrQuery.setParam("shards", "shard1_0")).getResults().getNumFound());
+ assertEquals("DocCount on shard1_1 does not match", docCounts[1], collectionClient.query(solrQuery.setParam("shards", "shard1_1")).getResults().getNumFound());
+ assertEquals("DocCount on shard1_2 does not match", docCounts[2], collectionClient.query(solrQuery.setParam("shards", "shard1_2")).getResults().getNumFound());
+
+ solrQuery = new SolrQuery("n_ti:" + uniqIdentifier);
+ assertEquals("shard1_0 must have 0 docs for route key: " + splitKey, 0, collectionClient.query(solrQuery.setParam("shards", "shard1_0")).getResults().getNumFound());
+ assertEquals("Wrong number of docs on shard1_1 for route key: " + splitKey, splitKeyDocCount, collectionClient.query(solrQuery.setParam("shards", "shard1_1")).getResults().getNumFound());
+ assertEquals("shard1_2 must have 0 docs for route key: " + splitKey, 0, collectionClient.query(solrQuery.setParam("shards", "shard1_2")).getResults().getNumFound());
+ }
}
protected void checkDocCountsAndShardStates(int[] docCounts, int numReplicas) throws Exception {
@@ -446,23 +420,17 @@ public class ShardSplitTest extends Basi
query.set("distrib", false);
ZkCoreNodeProps shard1_0 = getLeaderUrlFromZk(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1_0);
- HttpSolrClient shard1_0Client = new HttpSolrClient(shard1_0.getCoreUrl());
QueryResponse response;
- try {
+ try (HttpSolrClient shard1_0Client = new HttpSolrClient(shard1_0.getCoreUrl())) {
response = shard1_0Client.query(query);
- } finally {
- shard1_0Client.shutdown();
}
long shard10Count = response.getResults().getNumFound();
ZkCoreNodeProps shard1_1 = getLeaderUrlFromZk(
AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1_1);
- HttpSolrClient shard1_1Client = new HttpSolrClient(shard1_1.getCoreUrl());
QueryResponse response2;
- try {
+ try (HttpSolrClient shard1_1Client = new HttpSolrClient(shard1_1.getCoreUrl())) {
response2 = shard1_1Client.query(query);
- } finally {
- shard1_1Client.shutdown();
}
long shard11Count = response2.getResults().getNumFound();
@@ -472,7 +440,7 @@ public class ShardSplitTest extends Basi
assertEquals("Wrong doc count on shard1_1. See SOLR-5309", docCounts[1], shard11Count);
}
- protected void checkSubShardConsistency(String shard) throws SolrServerException {
+ protected void checkSubShardConsistency(String shard) throws SolrServerException, IOException {
SolrQuery query = new SolrQuery("*:*").setRows(1000).setFields("id", "_version_");
query.set("distrib", false);
@@ -482,12 +450,9 @@ public class ShardSplitTest extends Basi
int c = 0;
for (Replica replica : slice.getReplicas()) {
String coreUrl = new ZkCoreNodeProps(replica).getCoreUrl();
- HttpSolrClient client = new HttpSolrClient(coreUrl);
QueryResponse response;
- try {
+ try (HttpSolrClient client = new HttpSolrClient(coreUrl)) {
response = client.query(query);
- } finally {
- client.shutdown();
}
numFound[c++] = response.getResults().getNumFound();
log.info("Shard: " + shard + " Replica: {} has {} docs", coreUrl, String.valueOf(response.getResults().getNumFound()));
@@ -525,11 +490,11 @@ public class ShardSplitTest extends Basi
.getBaseURL();
baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());
- HttpSolrClient baseClient = new HttpSolrClient(baseUrl);
- baseClient.setConnectionTimeout(30000);
- baseClient.setSoTimeout(60000 * 5);
- baseClient.request(request);
- baseClient.shutdown();
+ try (HttpSolrClient baseServer = new HttpSolrClient(baseUrl)) {
+ baseServer.setConnectionTimeout(30000);
+ baseServer.setSoTimeout(60000 * 5);
+ baseServer.request(request);
+ }
}
protected void indexAndUpdateCount(DocRouter router, List<DocRouter.Range> ranges, int[] docCounts, String id, int n) throws Exception {
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java Sun Feb 8 23:53:14 2015
@@ -49,6 +49,7 @@ import org.apache.solr.util.DefaultSolrT
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Test;
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
@@ -80,10 +81,9 @@ public class SharedFSAutoReplicaFailover
dfsCluster = null;
}
- @Before
@Override
- public void setUp() throws Exception {
- super.setUp();
+ public void distribSetUp() throws Exception {
+ super.distribSetUp();
useJettyDataDir = false;
System.setProperty("solr.xml.persist", "true");
}
@@ -94,18 +94,16 @@ public class SharedFSAutoReplicaFailover
public SharedFSAutoReplicaFailoverTest() {
- fixShardCount = true;
-
sliceCount = 2;
- shardCount = 4;
completionService = new ExecutorCompletionService<>(executor);
pending = new HashSet<>();
checkCreatedVsState = false;
}
-
- @Override
- public void doTest() throws Exception {
+
+ @Test
+ @ShardsFixed(num = 4)
+ public void test() throws Exception {
try {
testBasics();
} finally {
@@ -238,8 +236,8 @@ public class SharedFSAutoReplicaFailover
}
@Override
- public void tearDown() throws Exception {
- super.tearDown();
+ public void distribTearDown() throws Exception {
+ super.distribTearDown();
System.clearProperty("solr.xml.persist");
}
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SimpleCollectionCreateDeleteTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SimpleCollectionCreateDeleteTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SimpleCollectionCreateDeleteTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SimpleCollectionCreateDeleteTest.java Sun Feb 8 23:53:14 2015
@@ -22,17 +22,17 @@ import org.apache.solr.client.solrj.requ
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.junit.Test;
public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestBase {
public SimpleCollectionCreateDeleteTest() {
- fixShardCount = true;
sliceCount = 1;
- shardCount = 1;
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ @ShardsFixed(num = 1)
+ public void test() throws Exception {
String overseerNode = OverseerCollectionProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient());
String notOverseerNode = null;
for (CloudJettyRunner cloudJetty : cloudJettys) {
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java Sun Feb 8 23:53:14 2015
@@ -29,6 +29,7 @@ import org.apache.solr.common.cloud.ZkSt
import org.apache.solr.core.ConfigSolr;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.servlet.SolrDispatchFilter;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -52,10 +53,19 @@ public class SolrXmlInZkTest extends Sol
private ConfigSolr cfg;
+ private SolrDispatchFilter solrDispatchFilter;
+
@Before
- public void beforeClass() {
+ public void before() {
System.setProperty("solr.solrxml.location", "zookeeper");
}
+
+ @After
+ public void after() {
+ if (solrDispatchFilter != null) {
+ solrDispatchFilter.destroy();
+ }
+ }
private void setUpZkAndDiskXml(boolean toZk, boolean leaveOnLocal) throws Exception {
File tmpDir = createTempDir().toFile();
@@ -96,8 +106,9 @@ public class SolrXmlInZkTest extends Sol
Method method = SolrDispatchFilter.class.getDeclaredMethod("loadConfigSolr", SolrResourceLoader.class);
method.setAccessible(true);
-
- Object obj = method.invoke(new SolrDispatchFilter(), new SolrResourceLoader(null));
+ if (solrDispatchFilter != null) solrDispatchFilter.destroy();
+ solrDispatchFilter = new SolrDispatchFilter();
+ Object obj = method.invoke(solrDispatchFilter, new SolrResourceLoader(null));
cfg = (ConfigSolr) obj;
log.info("####SETUP_END " + getTestName());
@@ -200,7 +211,9 @@ public class SolrXmlInZkTest extends Sol
try {
Method method = SolrDispatchFilter.class.getDeclaredMethod("loadConfigSolr", SolrResourceLoader.class);
method.setAccessible(true);
- method.invoke(new SolrDispatchFilter(), new SolrResourceLoader(null));
+ if (solrDispatchFilter != null) solrDispatchFilter.destroy();
+ solrDispatchFilter = new SolrDispatchFilter();
+ method.invoke(solrDispatchFilter, new SolrResourceLoader(null));
fail("Should have thrown an exception");
} catch (InvocationTargetException ite) {
assertTrue("Should be catching a SolrException", ite.getTargetException() instanceof SolrException);
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java Sun Feb 8 23:53:14 2015
@@ -32,10 +32,9 @@ import org.apache.solr.common.cloud.Slic
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.ModifiableSolrParams;
-import org.junit.After;
import org.junit.AfterClass;
-import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -61,33 +60,30 @@ public class SyncSliceTest extends Abstr
}
- @Before
@Override
- public void setUp() throws Exception {
- super.setUp();
+ public void distribSetUp() throws Exception {
+ super.distribSetUp();
// we expect this time of exception as shards go up and down...
//ignoreException(".*");
System.setProperty("numShards", Integer.toString(sliceCount));
}
@Override
- @After
- public void tearDown() throws Exception {
+ public void distribTearDown() throws Exception {
if (!success) {
printLayoutOnTearDown = true;
}
- super.tearDown();
- resetExceptionIgnores();
+ super.distribTearDown();
}
public SyncSliceTest() {
super();
sliceCount = 1;
- shardCount = TEST_NIGHTLY ? 7 : 4;
+ fixShardCount(TEST_NIGHTLY ? 7 : 4);
}
-
- @Override
- public void doTest() throws Exception {
+
+ @Test
+ public void test() throws Exception {
handle.clear();
handle.put("timestamp", SKIPVAL);
@@ -132,13 +128,12 @@ public class SyncSliceTest extends Abstr
.getBaseURL();
baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());
- HttpSolrClient baseClient = new HttpSolrClient(baseUrl);
- // we only set the connect timeout, not so timeout
- baseClient.setConnectionTimeout(30000);
- baseClient.request(request);
- baseClient.shutdown();
- baseClient = null;
-
+ try (HttpSolrClient baseClient = new HttpSolrClient(baseUrl)) {
+ // we only set the connect timeout, not so timeout
+ baseClient.setConnectionTimeout(30000);
+ baseClient.request(request);
+ }
+
waitForThingsToLevelOut(15);
checkShardConsistency(false, true);
@@ -160,7 +155,7 @@ public class SyncSliceTest extends Abstr
Set<CloudJettyRunner> jetties = new HashSet<>();
jetties.addAll(shardToJetty.get("shard1"));
jetties.remove(leaderJetty);
- assertEquals(shardCount - 1, jetties.size());
+ assertEquals(getShardCount() - 1, jetties.size());
chaosMonkey.killJetty(leaderJetty);
@@ -224,7 +219,7 @@ public class SyncSliceTest extends Abstr
jetties = new HashSet<>();
jetties.addAll(shardToJetty.get("shard1"));
jetties.remove(leaderJetty);
- assertEquals(shardCount - 1, jetties.size());
+ assertEquals(getShardCount() - 1, jetties.size());
// kill the current leader
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java Sun Feb 8 23:53:14 2015
@@ -16,8 +16,6 @@
*/
package org.apache.solr.cloud;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.lucene.util.CollectionUtil;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrServerException;
@@ -38,6 +36,7 @@ import org.apache.commons.lang.StringUti
import org.junit.BeforeClass;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -95,8 +94,8 @@ public class TestCloudPivotFacet extends
log.info("init'ing useFieldRandomizedFactor = {}", useFieldRandomizedFactor);
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
sanityCheckAssertDoubles();
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java Sun Feb 8 23:53:14 2015
@@ -33,9 +33,7 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException;
-import org.junit.Before;
-
-import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARD_UNIQUE;
+import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -44,6 +42,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARD_UNIQUE;
+
public class TestCollectionAPI extends ReplicaPropertiesBase {
public static final String COLLECTION_NAME = "testcollection";
@@ -54,23 +54,17 @@ public class TestCollectionAPI extends R
}
@Override
- @Before
- public void setUp() throws Exception {
- fixShardCount = true;
+ public void distribSetUp() throws Exception {
sliceCount = 2;
- shardCount = 2;
- super.setUp();
+ super.distribSetUp();
}
- @Override
- public void doTest() throws Exception {
- CloudSolrClient client = createCloudClient(null);
- try {
+ @Test
+ @ShardsFixed(num = 2)
+ public void test() throws Exception {
+ try (CloudSolrClient client = createCloudClient(null)) {
createCollection(null, COLLECTION_NAME, 2, 2, 2, client, null, "conf1");
createCollection(null, COLLECTION_NAME1, 1, 1, 1, client, null, "conf1");
- } finally {
- //remove collections
- client.shutdown();
}
waitForCollection(cloudClient.getZkStateReader(), COLLECTION_NAME, 2);
@@ -89,8 +83,8 @@ public class TestCollectionAPI extends R
}
private void clusterStatusWithCollectionAndShard() throws IOException, SolrServerException {
- CloudSolrClient client = createCloudClient(null);
- try {
+
+ try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
params.set("collection", COLLECTION_NAME);
@@ -111,16 +105,12 @@ public class TestCollectionAPI extends R
Map<String, Object> selectedShardStatus = (Map<String, Object>) shardStatus.get(SHARD1);
assertNotNull(selectedShardStatus);
- } finally {
- //remove collections
- client.shutdown();
}
}
private void listCollection() throws IOException, SolrServerException {
- CloudSolrClient client = createCloudClient(null);
- try {
+ try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.LIST.toString());
SolrRequest request = new QueryRequest(params);
@@ -132,17 +122,13 @@ public class TestCollectionAPI extends R
assertTrue(DEFAULT_COLLECTION + " was not found in list", collections.contains(DEFAULT_COLLECTION));
assertTrue(COLLECTION_NAME + " was not found in list", collections.contains(COLLECTION_NAME));
assertTrue(COLLECTION_NAME1 + " was not found in list", collections.contains(COLLECTION_NAME1));
- } finally {
- //remove collections
- client.shutdown();
}
-
}
private void clusterStatusNoCollection() throws Exception {
- CloudSolrClient client = createCloudClient(null);
- try {
+
+ try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
SolrRequest request = new QueryRequest(params);
@@ -159,16 +145,12 @@ public class TestCollectionAPI extends R
List<String> liveNodes = (List<String>) cluster.get("live_nodes");
assertNotNull("Live nodes should not be null", liveNodes);
assertFalse(liveNodes.isEmpty());
- } finally {
- //remove collections
- client.shutdown();
}
}
private void clusterStatusWithCollection() throws IOException, SolrServerException {
- CloudSolrClient client = createCloudClient(null);
- try {
+ try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
params.set("collection", COLLECTION_NAME);
@@ -182,15 +164,11 @@ public class TestCollectionAPI extends R
assertNotNull("Collections should not be null in cluster state", collections);
assertNotNull(collections.get(COLLECTION_NAME));
assertEquals(1, collections.size());
- } finally {
- //remove collections
- client.shutdown();
}
}
private void clusterStatusWithRouteKey() throws IOException, SolrServerException {
- CloudSolrClient client = createCloudClient(DEFAULT_COLLECTION);
- try {
+ try (CloudSolrClient client = createCloudClient(DEFAULT_COLLECTION)) {
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "a!123"); // goes to shard2. see ShardRoutingTest for details
client.add(doc);
@@ -215,15 +193,11 @@ public class TestCollectionAPI extends R
assertEquals(1, shardStatus.size());
Map<String, Object> selectedShardStatus = (Map<String, Object>) shardStatus.get(SHARD2);
assertNotNull(selectedShardStatus);
- } finally {
- //remove collections
- client.shutdown();
}
}
private void clusterStatusAliasTest() throws Exception {
- CloudSolrClient client = createCloudClient(null);
- try {
+ try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CREATEALIAS.toString());
params.set("name", "myalias");
@@ -253,14 +227,11 @@ public class TestCollectionAPI extends R
Map<String, Object> collection = (Map<String, Object>) collections.get(DEFAULT_COLLECTION);
List<String> collAlias = (List<String>) collection.get("aliases");
assertEquals("Aliases not found", Lists.newArrayList("myalias"), collAlias);
- } finally {
- client.shutdown();
}
}
private void clusterStatusRolesTest() throws Exception {
- CloudSolrClient client = createCloudClient(null);
- try {
+ try (CloudSolrClient client = createCloudClient(null)) {
client.connect();
Replica replica = client.getZkStateReader().getLeaderRetry(DEFAULT_COLLECTION, SHARD1);
@@ -287,14 +258,11 @@ public class TestCollectionAPI extends R
assertNotNull(overseer);
assertEquals(1, overseer.size());
assertTrue(overseer.contains(replica.getNodeName()));
- } finally {
- client.shutdown();
}
}
private void replicaPropTest() throws Exception {
- CloudSolrClient client = createCloudClient(null);
- try {
+ try (CloudSolrClient client = createCloudClient(null)) {
client.connect();
Map<String, Slice> slices = client.getZkStateReader().getClusterState().getCollection(COLLECTION_NAME).getSlicesMap();
List<String> sliceList = new ArrayList<>(slices.keySet());
@@ -570,8 +538,6 @@ public class TestCollectionAPI extends R
verifyPropertyNotPresent(client, COLLECTION_NAME, c1_s1_r1, "property.node_name");
verifyPropertyNotPresent(client, COLLECTION_NAME, c1_s1_r1, "property.base_url");
- } finally {
- client.shutdown();
}
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java Sun Feb 8 23:53:14 2015
@@ -24,6 +24,7 @@ import org.apache.solr.common.SolrDocume
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.StrUtils;
import org.junit.BeforeClass;
+import org.junit.Test;
import java.util.HashMap;
import java.util.HashSet;
@@ -53,8 +54,6 @@ public class TestDistribDocBasedVersion
public TestDistribDocBasedVersion() {
schemaString = "schema15.xml"; // we need a string id
super.sliceCount = 2;
- super.shardCount = 4;
- super.fixShardCount = true; // we only want to test with exactly 2 slices.
/***
@@ -87,8 +86,9 @@ public class TestDistribDocBasedVersion
***/
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ @ShardsFixed(num = 4)
+ public void test() throws Exception {
boolean testFinished = false;
try {
handle.clear();
@@ -346,10 +346,4 @@ public class TestDistribDocBasedVersion
req.setParams(params(reqParams));
req.process(cloudClient);
}
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java Sun Feb 8 23:53:14 2015
@@ -45,7 +45,6 @@ public class TestLeaderElectionZkExpiry
server.run();
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
- cc.load();
final ZkController zkController = new ZkController(cc, server.getZkAddress(), 15000, 30000, "dummy.host.com", "8984", "/solr", 180000, 180000, true, new CurrentCoreDescriptorProvider() {
@Override
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java Sun Feb 8 23:53:14 2015
@@ -27,7 +27,7 @@ import org.apache.solr.common.params.Col
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException;
-import org.junit.Before;
+import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@@ -42,15 +42,7 @@ public class TestRebalanceLeaders extend
public TestRebalanceLeaders() {
schemaString = "schema15.xml"; // we need a string id
- }
-
- @Override
- @Before
- public void setUp() throws Exception {
- fixShardCount = true;
sliceCount = 4;
- shardCount = 4;
- super.setUp();
}
int reps = 10;
@@ -59,12 +51,11 @@ public class TestRebalanceLeaders extend
Map<String, Replica> expected = new HashMap<>();
-
- @Override
- public void doTest() throws Exception {
- CloudSolrClient client = createCloudClient(null);
+ @Test
+ @ShardsFixed(num = 4)
+ public void test() throws Exception {
reps = random().nextInt(9) + 1; // make sure and do at least one.
- try {
+ try (CloudSolrClient client = createCloudClient(null)) {
// Mix up a bunch of different combinations of shards and replicas in order to exercise boundary cases.
// shards, replicationfactor, maxreplicaspernode
int shards = random().nextInt(7);
@@ -72,9 +63,6 @@ public class TestRebalanceLeaders extend
int rFactor = random().nextInt(4);
if (rFactor < 2) rFactor = 2;
createCollection(null, COLLECTION_NAME, shards, rFactor, shards * rFactor + 1, client, null, "conf1");
- } finally {
- //remove collections
- client.shutdown();
}
waitForCollection(cloudClient.getZkStateReader(), COLLECTION_NAME, 2);
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestReplicaProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestReplicaProperties.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestReplicaProperties.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestReplicaProperties.java Sun Feb 8 23:53:14 2015
@@ -18,11 +18,6 @@ package org.apache.solr.cloud;
*/
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
@@ -36,7 +31,12 @@ import org.apache.solr.common.params.Col
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException;
-import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
@Slow
public class TestReplicaProperties extends ReplicaPropertiesBase {
@@ -45,21 +45,14 @@ public class TestReplicaProperties exten
public TestReplicaProperties() {
schemaString = "schema15.xml"; // we need a string id
- }
-
- @Override
- @Before
- public void setUp() throws Exception {
- fixShardCount = true;
sliceCount = 2;
- shardCount = 4;
- super.setUp();
}
- @Override
- public void doTest() throws Exception {
- CloudSolrClient client = createCloudClient(null);
- try {
+ @Test
+ @ShardsFixed(num = 4)
+ public void test() throws Exception {
+
+ try (CloudSolrClient client = createCloudClient(null)) {
// Mix up a bunch of different combinations of shards and replicas in order to exercise boundary cases.
// shards, replicationfactor, maxreplicaspernode
int shards = random().nextInt(7);
@@ -67,9 +60,6 @@ public class TestReplicaProperties exten
int rFactor = random().nextInt(4);
if (rFactor < 2) rFactor = 2;
createCollection(null, COLLECTION_NAME, shards, rFactor, shards * rFactor + 1, client, null, "conf1");
- } finally {
- //remove collections
- client.shutdown();
}
waitForCollection(cloudClient.getZkStateReader(), COLLECTION_NAME, 2);
@@ -81,8 +71,8 @@ public class TestReplicaProperties exten
}
private void listCollection() throws IOException, SolrServerException {
- CloudSolrClient client = createCloudClient(null);
- try {
+
+ try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.LIST.toString());
SolrRequest request = new QueryRequest(params);
@@ -93,16 +83,13 @@ public class TestReplicaProperties exten
assertTrue("control_collection was not found in list", collections.contains("control_collection"));
assertTrue(DEFAULT_COLLECTION + " was not found in list", collections.contains(DEFAULT_COLLECTION));
assertTrue(COLLECTION_NAME + " was not found in list", collections.contains(COLLECTION_NAME));
- } finally {
- //remove collections
- client.shutdown();
}
}
private void clusterAssignPropertyTest() throws Exception {
- CloudSolrClient client = createCloudClient(null);
- try {
+
+ try (CloudSolrClient client = createCloudClient(null)) {
client.connect();
try {
doPropertyAction(client,
@@ -199,8 +186,6 @@ public class TestReplicaProperties exten
verifyLeaderAssignment(client, COLLECTION_NAME);
- } finally {
- client.shutdown();
}
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java Sun Feb 8 23:53:14 2015
@@ -24,7 +24,7 @@ import org.apache.solr.client.solrj.requ
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
-import org.junit.Before;
+import org.junit.Test;
import java.io.IOException;
@@ -36,14 +36,8 @@ public class TestRequestStatusCollection
schemaString = "schema15.xml"; // we need a string id
}
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
-
- }
-
- public void doTest() {
+ @Test
+ public void test() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CollectionParams.ACTION, CollectionParams.CollectionAction.CREATE.toString());
@@ -55,9 +49,7 @@ public class TestRequestStatusCollection
params.set("async", "1000");
try {
sendRequest(params);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -74,9 +66,7 @@ public class TestRequestStatusCollection
try {
message = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -90,9 +80,7 @@ public class TestRequestStatusCollection
r = sendRequest(params);
status = (NamedList) r.get("status");
message = (String) status.get("msg");
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -105,9 +93,7 @@ public class TestRequestStatusCollection
params.set("async", "1001");
try {
sendRequest(params);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -117,9 +103,7 @@ public class TestRequestStatusCollection
params.set(OverseerCollectionProcessor.REQUESTID, "1001");
try {
message = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -135,9 +119,7 @@ public class TestRequestStatusCollection
params.set("async", "1002");
try {
sendRequest(params);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -149,9 +131,7 @@ public class TestRequestStatusCollection
try {
message = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -168,9 +148,7 @@ public class TestRequestStatusCollection
params.set("async", "1002");
try {
r = sendRequest(params);
- } catch (SolrServerException e) {
- e.printStackTrace();
- } catch (IOException e) {
+ } catch (SolrServerException | IOException e) {
e.printStackTrace();
}
@@ -218,8 +196,10 @@ public class TestRequestStatusCollection
.getBaseURL();
baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());
- HttpSolrClient baseClient = new HttpSolrClient(baseUrl);
- baseClient.setConnectionTimeout(15000);
- return baseClient.request(request);
+ try (HttpSolrClient baseServer = new HttpSolrClient(baseUrl)) {
+ baseServer.setConnectionTimeout(15000);
+ return baseServer.request(request);
+ }
+
}
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java Sun Feb 8 23:53:14 2015
@@ -23,18 +23,18 @@ import org.apache.solr.client.solrj.resp
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList;
+import org.junit.Test;
public class TestShortCircuitedRequests extends AbstractFullDistribZkTestBase {
public TestShortCircuitedRequests() {
schemaString = "schema15.xml"; // we need a string id
super.sliceCount = 4;
- super.shardCount = 4;
- super.fixShardCount = true; // we only want to test with exactly 4 slices.
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ @ShardsFixed(num = 4)
+ public void test() throws Exception {
waitForRecoveriesToFinish(false);
assertEquals(4, cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION).getSlices().size());
index("id", "a!doc1"); // shard3
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java Sun Feb 8 23:53:14 2015
@@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTest
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.junit.BeforeClass;
+import org.junit.Test;
import java.util.HashMap;
import java.util.HashSet;
@@ -47,14 +48,12 @@ public class TriLevelCompositeIdRoutingT
public TriLevelCompositeIdRoutingTest() {
schemaString = "schema15.xml"; // we need a string id
- super.sliceCount = TEST_NIGHTLY ? 12 : 2; // a lot of slices for more ranges and buckets
- super.shardCount = TEST_NIGHTLY ? 24 : 3;
- super.fixShardCount = true;
-
+ sliceCount = TEST_NIGHTLY ? 12 : 2; // a lot of slices for more ranges and buckets
+ fixShardCount(TEST_NIGHTLY ? 24 : 3);
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
boolean testFinished = false;
try {
handle.clear();
@@ -74,7 +73,6 @@ public class TriLevelCompositeIdRoutingT
}
}
-
private void doTriLevelHashingTest() throws Exception {
log.info("### STARTING doTriLevelHashingTest");
// for now, we know how ranges will be distributed to shards.
@@ -153,10 +151,4 @@ public class TriLevelCompositeIdRoutingT
private String getKey(String id) {
return id.substring(0, id.lastIndexOf('!'));
}
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
}