SOLR-6902: Use JUnit rules instead of inheritance with distributed Solr tests to allow for multiple tests without the same class

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1654256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2015-01-23 16:13:32 +00:00
parent e12dbe663a
commit 7fda449473
99 changed files with 856 additions and 1170 deletions

View File

@ -54,6 +54,10 @@ Other Changes
* SOLR-6895: Deprecated SolrServer classes have been removed (Alan Woodward, * SOLR-6895: Deprecated SolrServer classes have been removed (Alan Woodward,
Erik Hatcher) Erik Hatcher)
* SOLR-6902Use JUnit rules instead of inheritance with distributed Solr
tests to allow for multiple tests without the same class.
(Ramkumar Aiyengar, Erick Erickson, Mike McCandless)
================== 5.1.0 ================== ================== 5.1.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -20,6 +20,7 @@ package org.apache.solr.handler.clustering;
import org.apache.solr.BaseDistributedSearchTestCase; import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL; import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.junit.Test;
@SuppressSSL @SuppressSSL
public class DistributedClusteringComponentTest extends public class DistributedClusteringComponentTest extends
@ -30,8 +31,8 @@ public class DistributedClusteringComponentTest extends
return getFile("clustering/solr/collection1").getParent(); return getFile("clustering/solr/collection1").getParent();
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
del("*:*"); del("*:*");
int numberOfDocs = 0; int numberOfDocs = 0;
for (String[] doc : AbstractClusteringTestCase.DOCUMENTS) { for (String[] doc : AbstractClusteringTestCase.DOCUMENTS) {
@ -47,7 +48,7 @@ public class DistributedClusteringComponentTest extends
CommonParams.Q, "*:*", CommonParams.Q, "*:*",
CommonParams.SORT, id + " desc", CommonParams.SORT, id + " desc",
ClusteringParams.USE_SEARCH_RESULTS, "true"); ClusteringParams.USE_SEARCH_RESULTS, "true");
// destroy is not needed because tearDown method of base class does it. // destroy is not needed because distribTearDown method of base class does it.
//destroyServers(); //destroyServers();
} }

View File

@ -71,9 +71,7 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.hadoop.hack.MiniMRClientCluster; import org.apache.solr.hadoop.hack.MiniMRClientCluster;
import org.apache.solr.hadoop.hack.MiniMRClientClusterFactory; import org.apache.solr.hadoop.hack.MiniMRClientClusterFactory;
import org.apache.solr.morphlines.solr.AbstractSolrMorphlineTestBase; import org.apache.solr.morphlines.solr.AbstractSolrMorphlineTestBase;
import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -120,10 +118,9 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
this.inputAvroFile1 = "sample-statuses-20120521-100919.avro"; this.inputAvroFile1 = "sample-statuses-20120521-100919.avro";
this.inputAvroFile2 = "sample-statuses-20120906-141433.avro"; this.inputAvroFile2 = "sample-statuses-20120906-141433.avro";
this.inputAvroFile3 = "sample-statuses-20120906-141433-medium.avro"; this.inputAvroFile3 = "sample-statuses-20120906-141433-medium.avro";
fixShardCount = true;
sliceCount = TEST_NIGHTLY ? 7 : 3; sliceCount = TEST_NIGHTLY ? 7 : 3;
shardCount = TEST_NIGHTLY ? 7 : 3; fixShardCount(TEST_NIGHTLY ? 7 : 3);
} }
@BeforeClass @BeforeClass
@ -197,9 +194,8 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
} }
@Override @Override
@Before public void distribSetUp() throws Exception {
public void setUp() throws Exception { super.distribSetUp();
super.setUp();
System.setProperty("host", "127.0.0.1"); System.setProperty("host", "127.0.0.1");
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
URI uri = dfsCluster.getFileSystem().getUri(); URI uri = dfsCluster.getFileSystem().getUri();
@ -208,9 +204,8 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception { super.distribTearDown();
super.tearDown();
System.clearProperty("host"); System.clearProperty("host");
System.clearProperty("numShards"); System.clearProperty("numShards");
System.clearProperty("solr.hdfs.home"); System.clearProperty("solr.hdfs.home");
@ -242,12 +237,6 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
return jobConf; return jobConf;
} }
@Test
@Override
public void testDistribSearch() throws Exception {
super.testDistribSearch();
}
@Test @Test
public void testBuildShardUrls() throws Exception { public void testBuildShardUrls() throws Exception {
// 2x3 // 2x3
@ -350,9 +339,9 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
}; };
return concat(head, args); return concat(head, args);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
waitForRecoveriesToFinish(false); waitForRecoveriesToFinish(false);
@ -691,7 +680,7 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
} }
private void getShardUrlArgs(List<String> args) { private void getShardUrlArgs(List<String> args) {
for (int i = 0; i < shardCount; i++) { for (int i = 0; i < getShardCount(); i++) {
args.add("--shard-url"); args.add("--shard-url");
args.add(cloudJettys.get(i).url); args.add(cloudJettys.get(i).url);
} }

View File

@ -27,10 +27,7 @@ import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
import org.apache.solr.cloud.AbstractZkTestCase; import org.apache.solr.cloud.AbstractZkTestCase;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.cloud.SolrZkClient; import org.apache.solr.common.cloud.SolrZkClient;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.kitesdk.morphline.api.Collector; import org.kitesdk.morphline.api.Collector;
import org.kitesdk.morphline.api.Command; import org.kitesdk.morphline.api.Command;
import org.kitesdk.morphline.api.MorphlineContext; import org.kitesdk.morphline.api.MorphlineContext;
@ -61,9 +58,8 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri
} }
public AbstractSolrMorphlineZkTestBase() { public AbstractSolrMorphlineZkTestBase() {
fixShardCount = true;
sliceCount = 3; sliceCount = 3;
shardCount = 3; fixShardCount(3);
} }
@BeforeClass @BeforeClass
@ -76,9 +72,8 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri
} }
@Override @Override
@Before public void distribSetUp() throws Exception {
public void setUp() throws Exception { super.distribSetUp();
super.setUp();
System.setProperty("host", "127.0.0.1"); System.setProperty("host", "127.0.0.1");
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
uploadConfFiles(); uploadConfFiles();
@ -86,19 +81,12 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception { super.distribTearDown();
super.tearDown();
System.clearProperty("host"); System.clearProperty("host");
System.clearProperty("numShards"); System.clearProperty("numShards");
} }
@Test
@Override
public void testDistribSearch() throws Exception {
super.testDistribSearch();
}
@Override @Override
protected void commit() throws Exception { protected void commit() throws Exception {
Notifications.notifyCommitTransaction(morphline); Notifications.notifyCommitTransaction(morphline);

View File

@ -33,6 +33,7 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.kitesdk.morphline.api.Record; import org.kitesdk.morphline.api.Record;
import org.kitesdk.morphline.base.Fields; import org.kitesdk.morphline.base.Fields;
import org.kitesdk.morphline.base.Notifications; import org.kitesdk.morphline.base.Notifications;
@ -48,8 +49,9 @@ import java.util.Iterator;
@Slow @Slow
public class SolrMorphlineZkAliasTest extends AbstractSolrMorphlineZkTestBase { public class SolrMorphlineZkAliasTest extends AbstractSolrMorphlineZkTestBase {
@Override
public void doTest() throws Exception { @Test
public void test() throws Exception {
waitForRecoveriesToFinish(false); waitForRecoveriesToFinish(false);

View File

@ -35,6 +35,8 @@ import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
import org.junit.BeforeClass;
import org.junit.Test;
import org.kitesdk.morphline.api.Record; import org.kitesdk.morphline.api.Record;
import org.kitesdk.morphline.base.Fields; import org.kitesdk.morphline.base.Fields;
import org.kitesdk.morphline.base.Notifications; import org.kitesdk.morphline.base.Notifications;
@ -53,8 +55,9 @@ import java.util.List;
@Slow @Slow
public class SolrMorphlineZkAvroTest extends AbstractSolrMorphlineZkTestBase { public class SolrMorphlineZkAvroTest extends AbstractSolrMorphlineZkTestBase {
@Override
public void doTest() throws Exception { @Test
public void test() throws Exception {
Joiner joiner = Joiner.on(File.separator); Joiner joiner = Joiner.on(File.separator);
File file = new File(joiner.join(RESOURCES_DIR, "test-documents", "sample-statuses-20120906-141433-medium.avro")); File file = new File(joiner.join(RESOURCES_DIR, "test-documents", "sample-statuses-20120906-141433-medium.avro"));

View File

@ -28,6 +28,7 @@ import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.kitesdk.morphline.api.Record; import org.kitesdk.morphline.api.Record;
import org.kitesdk.morphline.base.Fields; import org.kitesdk.morphline.base.Fields;
import org.kitesdk.morphline.base.Notifications; import org.kitesdk.morphline.base.Notifications;
@ -42,8 +43,9 @@ import java.util.Iterator;
@Slow @Slow
public class SolrMorphlineZkTest extends AbstractSolrMorphlineZkTestBase { public class SolrMorphlineZkTest extends AbstractSolrMorphlineZkTestBase {
@Override
public void doTest() throws Exception { @Test
public void test() throws Exception {
waitForRecoveriesToFinish(false); waitForRecoveriesToFinish(false);

View File

@ -10,6 +10,7 @@ import org.apache.solr.client.solrj.response.IntervalFacet.Count;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -37,8 +38,8 @@ public class DistributedIntervalFacetingTest extends
configString = "solrconfig-basic.xml"; configString = "solrconfig-basic.xml";
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
del("*:*"); del("*:*");
commit(); commit();
testRandom(); testRandom();

View File

@ -24,6 +24,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.Test;
/** /**
* TODO? perhaps use: * TODO? perhaps use:
@ -43,8 +44,8 @@ public class TestDistributedGrouping extends BaseDistributedSearchTestCase {
String tdate_b = "b_n_tdt"; String tdate_b = "b_n_tdt";
String oddField="oddField_s"; String oddField="oddField_s";
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
del("*:*"); del("*:*");
commit(); commit();

View File

@ -19,6 +19,7 @@ package org.apache.solr;
import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.junit.Test;
/** /**
* Tests sortMissingFirst and sortMissingLast in distributed sort * Tests sortMissingFirst and sortMissingLast in distributed sort
@ -37,8 +38,8 @@ public class TestDistributedMissingSort extends BaseDistributedSearchTestCase {
String string1_ml = "five_s1_ml"; // StringField, sortMissingLast=true, multiValued=false String string1_ml = "five_s1_ml"; // StringField, sortMissingLast=true, multiValued=false
String string1_mf = "six_s1_mf"; // StringField, sortMissingFirst=true, multiValued=false String string1_mf = "six_s1_mf"; // StringField, sortMissingFirst=true, multiValued=false
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
index(); index();
testSortMissingLast(); testSortMissingLast();
testSortMissingFirst(); testSortMissingFirst();

View File

@ -37,6 +37,7 @@ import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams; import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.Test;
/** /**
* TODO? perhaps use: * TODO? perhaps use:
@ -61,8 +62,8 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
String missingField="ignore_exception__missing_but_valid_field_t"; String missingField="ignore_exception__missing_but_valid_field_t";
String invalidField="ignore_exception__invalid_field_not_in_schema"; String invalidField="ignore_exception__invalid_field_not_in_schema";
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
QueryResponse rsp = null; QueryResponse rsp = null;
int backupStress = stress; // make a copy so we can restore int backupStress = stress; // make a copy so we can restore

View File

@ -17,11 +17,11 @@
package org.apache.solr; package org.apache.solr;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.TestUtil; import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
@ -35,14 +35,9 @@ public class TestHighlightDedupGrouping extends BaseDistributedSearchTestCase {
private static final String group_ti1 = "group_ti1"; private static final String group_ti1 = "group_ti1";
private static final String shard_i1 = "shard_i1"; private static final String shard_i1 = "shard_i1";
public TestHighlightDedupGrouping() { @Test
super(); @ShardsFixed(num = 2)
fixShardCount = true; public void test() throws Exception {
shardCount = 2;
}
@Override
public void doTest() throws Exception {
basicTest(); basicTest();
randomizedTest(); randomizedTest();
} }
@ -57,7 +52,7 @@ public class TestHighlightDedupGrouping extends BaseDistributedSearchTestCase {
int docid = 1; int docid = 1;
int group = 5; int group = 5;
for (int shard = 0 ; shard < shardCount ; ++shard) { for (int shard = 0 ; shard < getShardCount(); ++shard) {
addDoc(docid, group, shard); // add the same doc to both shards addDoc(docid, group, shard); // add the same doc to both shards
clients.get(shard).commit(); clients.get(shard).commit();
} }
@ -67,7 +62,7 @@ public class TestHighlightDedupGrouping extends BaseDistributedSearchTestCase {
"shards", shards, "shards", shards,
"group", "true", "group", "true",
"group.field", id_s1, "group.field", id_s1,
"group.limit", Integer.toString(shardCount), "group.limit", Integer.toString(getShardCount()),
"hl", "true", "hl", "true",
"hl.fl", id_s1 "hl.fl", id_s1
)); ));
@ -93,15 +88,15 @@ public class TestHighlightDedupGrouping extends BaseDistributedSearchTestCase {
++docsInGroup[group]; ++docsInGroup[group];
boolean makeDuplicate = 0 == TestUtil.nextInt(random(), 0, numDocs / percentDuplicates); boolean makeDuplicate = 0 == TestUtil.nextInt(random(), 0, numDocs / percentDuplicates);
if (makeDuplicate) { if (makeDuplicate) {
for (int shard = 0 ; shard < shardCount ; ++shard) { for (int shard = 0 ; shard < getShardCount(); ++shard) {
addDoc(docid, group, shard); addDoc(docid, group, shard);
} }
} else { } else {
int shard = TestUtil.nextInt(random(), 0, shardCount - 1); int shard = TestUtil.nextInt(random(), 0, getShardCount() - 1);
addDoc(docid, group, shard); addDoc(docid, group, shard);
} }
} }
for (int shard = 0 ; shard < shardCount ; ++shard) { for (int shard = 0 ; shard < getShardCount(); ++shard) {
clients.get(shard).commit(); clients.get(shard).commit();
} }

View File

@ -37,12 +37,11 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.CollectionParams.CollectionAction; import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.junit.Test;
/** /**
* Test sync phase that occurs when Leader goes down and a new Leader is * Test sync phase that occurs when Leader goes down and a new Leader is
@ -62,28 +61,20 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
} }
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
resetExceptionIgnores();
}
public AliasIntegrationTest() { public AliasIntegrationTest() {
super(); super();
sliceCount = 1; sliceCount = 1;
shardCount = random().nextBoolean() ? 3 : 4; fixShardCount(random().nextBoolean() ? 3 : 4);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);

View File

@ -24,7 +24,7 @@ import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.Before; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
@ -36,13 +36,8 @@ public class AsyncMigrateRouteKeyTest extends MigrateRouteKeyTest {
private static final int MAX_WAIT_SECONDS = 2 * 60; private static final int MAX_WAIT_SECONDS = 2 * 60;
@Override @Test
@Before public void test() throws Exception {
public void setUp() throws Exception {
super.setUp();
}
public void doTest() throws Exception {
waitForThingsToLevelOut(15); waitForThingsToLevelOut(15);
multipleShardMigrateTest(); multipleShardMigrateTest();

View File

@ -38,6 +38,7 @@ import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.handler.ReplicationHandler; import org.apache.solr.handler.ReplicationHandler;
import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
@ -58,21 +59,12 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
public BasicDistributedZk2Test() { public BasicDistributedZk2Test() {
super(); super();
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 4;
} }
/* @Test
* (non-Javadoc) @ShardsFixed(num = 4)
* public void test() throws Exception {
* @see org.apache.solr.BaseDistributedSearchTestCase#doTest()
*
* Create 3 shards, each with one replica
*/
@Override
public void doTest() throws Exception {
boolean testFinished = false; boolean testFinished = false;
try { try {
handle.clear(); handle.clear();

View File

@ -50,8 +50,8 @@ import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.solr.util.DefaultSolrThreadFactory;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -106,20 +106,16 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
public static void beforeThisClass2() throws Exception { public static void beforeThisClass2() throws Exception {
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
} }
public BasicDistributedZkTest() { public BasicDistributedZkTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 4;
completionService = new ExecutorCompletionService<>(executor); completionService = new ExecutorCompletionService<>(executor);
pending = new HashSet<>(); pending = new HashSet<>();
@ -133,7 +129,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
} else { } else {
// use shard ids rather than physical locations // use shard ids rather than physical locations
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < shardCount; i++) { for (int i = 0; i < getShardCount(); i++) {
if (i > 0) if (i > 0)
sb.append(','); sb.append(',');
sb.append("shard" + (i + 3)); sb.append("shard" + (i + 3));
@ -141,9 +137,10 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
params.set("shards", sb.toString()); params.set("shards", sb.toString());
} }
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
// setLoggingLevel(null); // setLoggingLevel(null);
ZkStateReader zkStateReader = cloudClient.getZkStateReader(); ZkStateReader zkStateReader = cloudClient.getZkStateReader();
@ -1160,8 +1157,8 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
} }
@Override @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
if (commondCloudSolrClient != null) { if (commondCloudSolrClient != null) {
commondCloudSolrClient.shutdown(); commondCloudSolrClient.shutdown();
} }
@ -1175,9 +1172,8 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
otherCollectionClients = null; otherCollectionClients = null;
List<Runnable> tasks = executor.shutdownNow(); List<Runnable> tasks = executor.shutdownNow();
assertTrue(tasks.isEmpty()); assertTrue(tasks.isEmpty());
System.clearProperty("numShards"); System.clearProperty("numShards");
System.clearProperty("zkHost");
System.clearProperty("solr.xml.persist"); System.clearProperty("solr.xml.persist");
// insurance // insurance

View File

@ -18,7 +18,6 @@ package org.apache.solr.cloud;
*/ */
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL; import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
@ -33,10 +32,9 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.IOUtils; import org.apache.solr.common.util.IOUtils;
import org.apache.solr.core.Diagnostics; import org.apache.solr.core.Diagnostics;
import org.apache.solr.update.SolrCmdDistributor; import org.apache.solr.update.SolrCmdDistributor;
import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -88,10 +86,9 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase
return randVals; return randVals;
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
// can help to hide this when testing and looking at logs // can help to hide this when testing and looking at logs
//ignoreException("shard update error"); //ignoreException("shard update error");
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
@ -99,28 +96,27 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception {
System.clearProperty("numShards"); System.clearProperty("numShards");
super.tearDown(); super.distribTearDown();
resetExceptionIgnores();
} }
public ChaosMonkeyNothingIsSafeTest() { public ChaosMonkeyNothingIsSafeTest() {
super(); super();
sliceCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.slicecount", "-1")); sliceCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.slicecount", "-1"));
shardCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.shardcount", "-1"));
if (sliceCount == -1) { if (sliceCount == -1) {
sliceCount = random().nextInt(TEST_NIGHTLY ? 5 : 3) + 1; sliceCount = random().nextInt(TEST_NIGHTLY ? 5 : 3) + 1;
} }
if (shardCount == -1) {
shardCount = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2); int numShards = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.shardcount", "-1"));
if (numShards == -1) {
numShards = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2);
} }
fixShardCount(numShards);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
boolean testsSuccesful = false; boolean testsSuccesful = false;
try { try {
handle.clear(); handle.clear();

View File

@ -28,10 +28,9 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.Diagnostics; import org.apache.solr.core.Diagnostics;
import org.apache.solr.update.SolrCmdDistributor; import org.apache.solr.update.SolrCmdDistributor;
import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
@Slow @Slow
public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase { public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {
@ -69,39 +68,37 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {
return randVals; return randVals;
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
useFactory("solr.StandardDirectoryFactory"); useFactory("solr.StandardDirectoryFactory");
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception {
System.clearProperty("numShards"); System.clearProperty("numShards");
super.tearDown(); super.distribTearDown();
resetExceptionIgnores();
} }
public ChaosMonkeySafeLeaderTest() { public ChaosMonkeySafeLeaderTest() {
super(); super();
sliceCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.slicecount", "-1")); sliceCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.slicecount", "-1"));
shardCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.shardcount", "-1"));
if (sliceCount == -1) { if (sliceCount == -1) {
sliceCount = random().nextInt(TEST_NIGHTLY ? 5 : 3) + 1; sliceCount = random().nextInt(TEST_NIGHTLY ? 5 : 3) + 1;
} }
if (shardCount == -1) {
shardCount = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2); int numShards = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.shardcount", "-1"));
if (numShards == -1) {
numShards = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2);
} }
fixShardCount(numShards);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);

View File

@ -31,9 +31,8 @@ import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.solr.update.UpdateShardHandler; import org.apache.solr.update.UpdateShardHandler;
import org.apache.solr.util.MockConfigSolr; import org.apache.solr.util.MockConfigSolr;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
@ -50,20 +49,8 @@ public class ChaosMonkeyShardSplitTest extends ShardSplitTest {
static final int TIMEOUT = 10000; static final int TIMEOUT = 10000;
private AtomicInteger killCounter = new AtomicInteger(); private AtomicInteger killCounter = new AtomicInteger();
@Before @Test
@Override public void test() throws Exception {
public void setUp() throws Exception {
super.setUp();
}
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
}
@Override
public void doTest() throws Exception {
waitForThingsToLevelOut(15); waitForThingsToLevelOut(15);
ClusterState clusterState = cloudClient.getZkStateReader().getClusterState(); ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();

View File

@ -22,6 +22,7 @@ import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.TestUtil; import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -43,8 +44,8 @@ public class CloudExitableDirectoryReaderTest extends AbstractFullDistribZkTestB
return configString; return configString;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);
waitForRecoveriesToFinish(false); waitForRecoveriesToFinish(false);

View File

@ -28,7 +28,7 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest.SplitShard;
import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.junit.Before; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
@ -40,10 +40,9 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT
private static final int MAX_TIMEOUT_SECONDS = 60; private static final int MAX_TIMEOUT_SECONDS = 60;
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
useJettyDataDir = false; useJettyDataDir = false;
@ -52,23 +51,12 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT
} }
public CollectionsAPIAsyncDistributedZkTest() { public CollectionsAPIAsyncDistributedZkTest() {
fixShardCount = true;
sliceCount = 1; sliceCount = 1;
shardCount = 1;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 1)
public void testSolrJAPICalls() throws Exception {
testSolrJAPICalls();
if (DEBUG) {
super.printLayout();
}
}
private void testSolrJAPICalls() throws Exception {
SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0))); SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)));
try { try {
Create createCollectionRequest = new Create(); Create createCollectionRequest = new Create();
@ -115,6 +103,10 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT
} finally { } finally {
client.shutdown(); client.shutdown();
} }
if (DEBUG) {
printLayout();
}
} }
private String getRequestStateAfterCompletion(String requestId, int waitForSeconds, SolrClient client) private String getRequestStateAfterCompletion(String requestId, int waitForSeconds, SolrClient client)
@ -141,10 +133,9 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT
} }
@Override @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
System.clearProperty("numShards"); System.clearProperty("numShards");
System.clearProperty("zkHost");
System.clearProperty("solr.xml.persist"); System.clearProperty("solr.xml.persist");
// insurance // insurance

View File

@ -57,8 +57,8 @@ import org.apache.solr.core.SolrInfoMBean.Category;
import org.apache.solr.servlet.SolrDispatchFilter; import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.solr.util.DefaultSolrThreadFactory;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import javax.management.MBeanServerFactory; import javax.management.MBeanServerFactory;
@ -117,10 +117,9 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
useJettyDataDir = false; useJettyDataDir = false;
@ -161,10 +160,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
public CollectionsAPIDistributedZkTest() { public CollectionsAPIDistributedZkTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 4;
completionService = new ExecutorCompletionService<>(executor); completionService = new ExecutorCompletionService<>(executor);
pending = new HashSet<>(); pending = new HashSet<>();
checkCreatedVsState = false; checkCreatedVsState = false;
@ -179,7 +175,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
} else { } else {
// use shard ids rather than physical locations // use shard ids rather than physical locations
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < shardCount; i++) { for (int i = 0; i < getShardCount(); i++) {
if (i > 0) if (i > 0)
sb.append(','); sb.append(',');
sb.append("shard" + (i + 3)); sb.append("shard" + (i + 3));
@ -187,9 +183,10 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
params.set("shards", sb.toString()); params.set("shards", sb.toString());
} }
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
testNodesUsedByCreate(); testNodesUsedByCreate();
testCollectionsAPI(); testCollectionsAPI();
testCollectionsAPIAddRemoveStress(); testCollectionsAPIAddRemoveStress();
@ -600,7 +597,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
int cnt = random().nextInt(TEST_NIGHTLY ? 6 : 1) + 1; int cnt = random().nextInt(TEST_NIGHTLY ? 6 : 1) + 1;
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
int numShards = TestUtil.nextInt(random(), 0, shardCount) + 1; int numShards = TestUtil.nextInt(random(), 0, getShardCount()) + 1;
int replicationFactor = TestUtil.nextInt(random(), 0, 3) + 1; int replicationFactor = TestUtil.nextInt(random(), 0, 3) + 1;
int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrClient() int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrClient()
.getZkStateReader().getClusterState().getLiveNodes().size())) + 1; .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
@ -896,7 +893,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
String collectionName = "awholynewstresscollection_" + name + "_" + i; String collectionName = "awholynewstresscollection_" + name + "_" + i;
int numShards = TestUtil.nextInt(random(), 0, shardCount * 2) + 1; int numShards = TestUtil.nextInt(random(), 0, getShardCount() * 2) + 1;
int replicationFactor = TestUtil.nextInt(random(), 0, 3) + 1; int replicationFactor = TestUtil.nextInt(random(), 0, 3) + 1;
int maxShardsPerNode = (((numShards * 2 * replicationFactor) / getCommonCloudSolrClient() int maxShardsPerNode = (((numShards * 2 * replicationFactor) / getCommonCloudSolrClient()
.getZkStateReader().getClusterState().getLiveNodes().size())) + 1; .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
@ -1202,10 +1199,9 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
} }
@Override @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
System.clearProperty("numShards"); System.clearProperty("numShards");
System.clearProperty("zkHost");
System.clearProperty("solr.xml.persist"); System.clearProperty("solr.xml.persist");
// insurance // insurance

View File

@ -34,6 +34,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CoreAdminParams; import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -49,9 +50,9 @@ import static org.apache.solr.cloud.ReplicaPropertiesBase.verifyUniqueAcrossColl
@LuceneTestCase.Slow @LuceneTestCase.Slow
public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase { public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
testCreateAndDeleteCollection(); testCreateAndDeleteCollection();
testCreateAndDeleteShard(); testCreateAndDeleteShard();
testReloadCollection(); testReloadCollection();
@ -67,19 +68,6 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
testBalanceShardUnique(); testBalanceShardUnique();
} }
public void tearDown() throws Exception {
if (controlClient != null) {
controlClient.shutdown();
}
if (cloudClient != null) {
cloudClient.shutdown();
}
if (controlClientCloud != null) {
controlClientCloud.shutdown();
}
super.tearDown();
}
protected void testCreateAndDeleteCollection() throws Exception { protected void testCreateAndDeleteCollection() throws Exception {
String collectionName = "solrj_test"; String collectionName = "solrj_test";
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create(); CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();

View File

@ -60,8 +60,8 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.solr.util.DefaultSolrThreadFactory;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
/** /**
* Tests the Custom Sharding API. * Tests the Custom Sharding API.
@ -84,10 +84,9 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {
public static void beforeThisClass2() throws Exception { public static void beforeThisClass2() throws Exception {
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
} }
@ -98,10 +97,7 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {
public CustomCollectionTest() { public CustomCollectionTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 4;
completionService = new ExecutorCompletionService<>(executor); completionService = new ExecutorCompletionService<>(executor);
pending = new HashSet<>(); pending = new HashSet<>();
checkCreatedVsState = false; checkCreatedVsState = false;
@ -116,7 +112,7 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {
} else { } else {
// use shard ids rather than physical locations // use shard ids rather than physical locations
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < shardCount; i++) { for (int i = 0; i < getShardCount(); i++) {
if (i > 0) if (i > 0)
sb.append(','); sb.append(',');
sb.append("shard" + (i + 3)); sb.append("shard" + (i + 3));
@ -125,8 +121,9 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {
} }
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
testCustomCollectionsAPI(); testCustomCollectionsAPI();
testRouteFieldForHashRouter(); testRouteFieldForHashRouter();
testCreateShardRepFactor(); testCreateShardRepFactor();
@ -492,10 +489,9 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {
} }
@Override @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
System.clearProperty("numShards"); System.clearProperty("numShards");
System.clearProperty("zkHost");
System.clearProperty("solr.xml.persist"); System.clearProperty("solr.xml.persist");
// insurance // insurance

View File

@ -29,8 +29,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CoreAdminParams; import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import java.net.URL; import java.net.URL;
import java.util.Map; import java.util.Map;
@ -41,22 +40,8 @@ import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
//@Ignore("Not currently valid see SOLR-5580") //@Ignore("Not currently valid see SOLR-5580")
public class DeleteInactiveReplicaTest extends DeleteReplicaTest{ public class DeleteInactiveReplicaTest extends DeleteReplicaTest{
@Override @Test
public void doTest() throws Exception { public void deleteInactiveReplicaTest() throws Exception {
deleteInactiveReplicaTest();
}
@Before
public void setUp() throws Exception {
super.setUp();
}
@After
public void tearDown() throws Exception {
super.tearDown();
}
private void deleteInactiveReplicaTest() throws Exception {
CloudSolrClient client = createCloudClient(null); CloudSolrClient client = createCloudClient(null);
String collectionName = "delDeadColl"; String collectionName = "delDeadColl";

View File

@ -27,10 +27,9 @@ import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.ZkNodeProps; import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -53,18 +52,17 @@ public class DeleteLastCustomShardedReplicaTest extends AbstractFullDistribZkTes
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
client = createCloudClient(null); client = createCloudClient(null);
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
client.shutdown(); client.shutdown();
} }
@ -73,16 +71,13 @@ public class DeleteLastCustomShardedReplicaTest extends AbstractFullDistribZkTes
} }
public DeleteLastCustomShardedReplicaTest() { public DeleteLastCustomShardedReplicaTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 2;
checkCreatedVsState = false; checkCreatedVsState = false;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 2)
public void test() throws Exception {
int replicationFactor = 1; int replicationFactor = 1;
int maxShardsPerNode = 5; int maxShardsPerNode = 5;

View File

@ -32,9 +32,8 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -56,18 +55,17 @@ public class DeleteReplicaTest extends AbstractFullDistribZkTestBase {
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
client = createCloudClient(null); client = createCloudClient(null);
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
client.shutdown(); client.shutdown();
} }
@ -76,20 +74,13 @@ public class DeleteReplicaTest extends AbstractFullDistribZkTestBase {
} }
public DeleteReplicaTest() { public DeleteReplicaTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 4;
checkCreatedVsState = false; checkCreatedVsState = false;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
deleteLiveReplicaTest(); public void deleteLiveReplicaTest() throws Exception {
}
private void deleteLiveReplicaTest() throws Exception {
String collectionName = "delLiveColl"; String collectionName = "delLiveColl";
CloudSolrClient client = createCloudClient(null); CloudSolrClient client = createCloudClient(null);
try { try {

View File

@ -30,8 +30,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -41,46 +40,28 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
public DeleteShardTest() { public DeleteShardTest() {
super(); super();
fixShardCount = true;
shardCount = 2;
sliceCount = 2; sliceCount = 2;
} }
@Override @Override
@Before public void distribSetUp() throws Exception {
public void setUp() throws Exception { super.distribSetUp();
super.setUp();
System.setProperty("numShards", "2"); System.setProperty("numShards", "2");
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception { super.distribTearDown();
super.tearDown();
if (VERBOSE || printLayoutOnTearDown) {
super.printLayout();
}
if (controlClient != null) {
controlClient.shutdown();
}
if (cloudClient != null) {
cloudClient.shutdown();
}
if (controlClientCloud != null) {
controlClientCloud.shutdown();
}
super.tearDown();
System.clearProperty("numShards"); System.clearProperty("numShards");
System.clearProperty("solr.xml.persist"); System.clearProperty("solr.xml.persist");
} }
// TODO: Custom hash slice deletion test // TODO: Custom hash slice deletion test
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 2)
public void test() throws Exception {
ClusterState clusterState = cloudClient.getZkStateReader().getClusterState(); ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
Slice slice1 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1); Slice slice1 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1);

View File

@ -37,6 +37,7 @@ import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_NEXT;
import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_START; import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_START;
import org.apache.solr.search.CursorMark; //jdoc import org.apache.solr.search.CursorMark; //jdoc
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -69,8 +70,8 @@ public class DistribCursorPagingTest extends AbstractFullDistribZkTestBase {
return configString; return configString;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
boolean testFinished = false; boolean testFinished = false;
try { try {
handle.clear(); handle.clear();

View File

@ -26,6 +26,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.update.processor.DocExpirationUpdateProcessorFactory; // jdoc import org.apache.solr.update.processor.DocExpirationUpdateProcessorFactory; // jdoc
import org.apache.solr.update.processor.DocExpirationUpdateProcessorFactoryTest; import org.apache.solr.update.processor.DocExpirationUpdateProcessorFactoryTest;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -52,8 +53,8 @@ public class DistribDocExpirationUpdateProcessorTest extends AbstractFullDistrib
return configString; return configString;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
assertTrue("only one shard?!?!?!", 1 < shardToJetty.keySet().size()); assertTrue("only one shard?!?!?!", 1 < shardToJetty.keySet().size());
log.info("number of shards: {}", shardToJetty.keySet().size()); log.info("number of shards: {}", shardToJetty.keySet().size());

View File

@ -27,30 +27,22 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.handler.BlobHandler; import org.apache.solr.handler.BlobHandler;
import org.apache.solr.handler.TestBlobHandler; import org.apache.solr.handler.TestBlobHandler;
import org.apache.zookeeper.data.Stat; import org.apache.zookeeper.data.Stat;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import org.junit.BeforeClass;
public class ExternalCollectionsTest extends AbstractFullDistribZkTestBase { public class ExternalCollectionsTest extends AbstractFullDistribZkTestBase {
private CloudSolrClient client; private CloudSolrClient client;
@BeforeClass
public static void beforeThisClass2() throws Exception {
}
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
client = createCloudClient(null); client = createCloudClient(null);
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
client.shutdown(); client.shutdown();
} }
@ -59,17 +51,13 @@ public class ExternalCollectionsTest extends AbstractFullDistribZkTestBase {
} }
public ExternalCollectionsTest() { public ExternalCollectionsTest() {
fixShardCount = true;
sliceCount = 2;
shardCount = 4;
checkCreatedVsState = false; checkCreatedVsState = false;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
testZkNodeLocation(); testZkNodeLocation();
testConfNameAndCollectionNameSame(); testConfNameAndCollectionNameSame();
} }

View File

@ -39,6 +39,7 @@ import org.apache.solr.update.VersionInfo;
import org.apache.solr.update.processor.DistributedUpdateProcessor; import org.apache.solr.update.processor.DistributedUpdateProcessor;
import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.CreateMode;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -58,13 +59,12 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBase
public FullSolrCloudDistribCmdsTest() { public FullSolrCloudDistribCmdsTest() {
super(); super();
fixShardCount = true;
shardCount = 6;
sliceCount = 3; sliceCount = 3;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 6)
public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);
@ -499,11 +499,6 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBase
return client.query(query); return client.query(query);
} }
@Override
public void tearDown() throws Exception {
super.tearDown();
}
protected SolrInputDocument addRandFields(SolrInputDocument sdoc) { protected SolrInputDocument addRandFields(SolrInputDocument sdoc) {
return sdoc; return sdoc;
} }

View File

@ -36,8 +36,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.CoreContainer; import org.apache.solr.core.CoreContainer;
import org.apache.solr.servlet.SolrDispatchFilter; import org.apache.solr.servlet.SolrDispatchFilter;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -73,26 +72,15 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
public HttpPartitionTest() { public HttpPartitionTest() {
super(); super();
sliceCount = 2; sliceCount = 2;
shardCount = 3; fixShardCount(3);
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
} }
@Override
@After
public void tearDown() throws Exception {
try {
super.tearDown();
} catch (Exception exc) {}
resetExceptionIgnores();
}
/** /**
* Overrides the parent implementation to install a SocketProxy in-front of the Jetty server. * Overrides the parent implementation to install a SocketProxy in-front of the Jetty server.
*/ */
@ -104,8 +92,8 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride); return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
waitForThingsToLevelOut(30000); waitForThingsToLevelOut(30000);
testLeaderInitiatedRecoveryCRUD(); testLeaderInitiatedRecoveryCRUD();

View File

@ -28,6 +28,7 @@ import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Replica;
import org.junit.Test;
/** /**
* Tests leader-initiated recovery scenarios after a leader node fails * Tests leader-initiated recovery scenarios after a leader node fails
@ -42,8 +43,8 @@ public class LeaderFailoverAfterPartitionTest extends HttpPartitionTest {
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
waitForThingsToLevelOut(30000); waitForThingsToLevelOut(30000);
// kill a leader and make sure recovery occurs as expected // kill a leader and make sure recovery occurs as expected

View File

@ -22,8 +22,7 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.ZkCoreNodeProps; import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -35,29 +34,22 @@ public class LeaderInitiatedRecoveryOnCommitTest extends BasicDistributedZkTest
public LeaderInitiatedRecoveryOnCommitTest() { public LeaderInitiatedRecoveryOnCommitTest() {
super(); super();
sliceCount = 1; sliceCount = 1;
shardCount = 4; fixShardCount(4);
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception {
System.clearProperty("numShards"); System.clearProperty("numShards");
try { super.distribTearDown();
super.tearDown();
} catch (Exception exc) {
}
resetExceptionIgnores(); // close socket proxies after super.distribTearDown
// close socket proxies after super.tearDown
if (!proxies.isEmpty()) { if (!proxies.isEmpty()) {
for (SocketProxy proxy : proxies.values()) { for (SocketProxy proxy : proxies.values()) {
proxy.close(); proxy.close();
@ -65,8 +57,8 @@ public class LeaderInitiatedRecoveryOnCommitTest extends BasicDistributedZkTest
} }
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
oneShardTest(); oneShardTest();
multiShardTest(); multiShardTest();
} }
@ -171,4 +163,4 @@ public class LeaderInitiatedRecoveryOnCommitTest extends BasicDistributedZkTest
return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride); return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride);
} }
} }

View File

@ -33,8 +33,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -52,31 +51,15 @@ public class MigrateRouteKeyTest extends BasicDistributedZkTest {
} }
@Override @Override
@Before public void distribSetUp() throws Exception {
public void setUp() throws Exception { super.distribSetUp();
super.setUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception { super.distribTearDown();
super.tearDown();
if (VERBOSE || printLayoutOnTearDown) {
super.printLayout();
}
if (controlClient != null) {
controlClient.shutdown();
}
if (cloudClient != null) {
cloudClient.shutdown();
}
if (controlClientCloud != null) {
controlClientCloud.shutdown();
}
super.tearDown();
System.clearProperty("zkHost"); System.clearProperty("zkHost");
System.clearProperty("numShards"); System.clearProperty("numShards");
@ -86,8 +69,8 @@ public class MigrateRouteKeyTest extends BasicDistributedZkTest {
DirectUpdateHandler2.commitOnClose = true; DirectUpdateHandler2.commitOnClose = true;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
waitForThingsToLevelOut(15); waitForThingsToLevelOut(15);
if (usually()) { if (usually()) {

View File

@ -30,7 +30,7 @@ import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.junit.Before; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,10 +49,9 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {
private static final int NUM_COLLECTIONS = 4; private static final int NUM_COLLECTIONS = 4;
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
useJettyDataDir = false; useJettyDataDir = false;
@ -61,13 +60,12 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {
} }
public MultiThreadedOCPTest() { public MultiThreadedOCPTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 4;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
testParallelCollectionAPICalls(); testParallelCollectionAPICalls();
testTaskExclusivity(); testTaskExclusivity();
@ -311,10 +309,9 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {
} }
@Override @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
System.clearProperty("numShards"); System.clearProperty("numShards");
System.clearProperty("zkHost");
System.clearProperty("solr.xml.persist"); System.clearProperty("solr.xml.persist");
// insurance // insurance

View File

@ -46,9 +46,8 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.apache.zookeeper.data.Stat; import org.apache.zookeeper.data.Stat;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
@LuceneTestCase.Slow @LuceneTestCase.Slow
@SuppressSSL // See SOLR-5776 @SuppressSSL // See SOLR-5776
@ -60,18 +59,17 @@ public class OverseerRolesTest extends AbstractFullDistribZkTestBase{
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
client = createCloudClient(null); client = createCloudClient(null);
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
client.shutdown(); client.shutdown();
} }
@ -80,16 +78,14 @@ public class OverseerRolesTest extends AbstractFullDistribZkTestBase{
} }
public OverseerRolesTest() { public OverseerRolesTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = TEST_NIGHTLY ? 6 : 2; fixShardCount(TEST_NIGHTLY ? 6 : 2);
checkCreatedVsState = false; checkCreatedVsState = false;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
testQuitCommand(); testQuitCommand();
testOverseerRole(); testOverseerRole();
} }

View File

@ -17,20 +17,11 @@ package org.apache.solr.cloud;
* limitations under the License. * 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.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.common.cloud.DocRouter;
import org.apache.solr.common.params.CollectionParams; 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.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.common.util.SimpleOrderedMap;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import java.io.IOException;
public class OverseerStatusTest extends BasicDistributedZkTest { public class OverseerStatusTest extends BasicDistributedZkTest {
@ -39,33 +30,14 @@ public class OverseerStatusTest extends BasicDistributedZkTest {
} }
@Override @Override
@Before public void distribSetUp() throws Exception {
public void setUp() throws Exception { super.distribSetUp();
super.setUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
} }
@Override @Test
@After public void test() throws Exception {
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();
}
@Override
public void doTest() throws Exception {
waitForThingsToLevelOut(15); waitForThingsToLevelOut(15);
// find existing command counts because collection may be created by base test class too // find existing command counts because collection may be created by base test class too

View File

@ -28,15 +28,15 @@ import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Replica;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
// See SOLR-6640 // See SOLR-6640
@SolrTestCaseJ4.SuppressSSL @SolrTestCaseJ4.SuppressSSL
public class RecoveryAfterSoftCommitTest extends AbstractFullDistribZkTestBase { public class RecoveryAfterSoftCommitTest extends AbstractFullDistribZkTestBase {
public RecoveryAfterSoftCommitTest() { public RecoveryAfterSoftCommitTest() {
fixShardCount = true;
sliceCount = 1; sliceCount = 1;
shardCount = 2; fixShardCount(2);
} }
@BeforeClass @BeforeClass
@ -60,8 +60,8 @@ public class RecoveryAfterSoftCommitTest extends AbstractFullDistribZkTestBase {
return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride); return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
// flush twice // flush twice
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
SolrInputDocument document = new SolrInputDocument(); SolrInputDocument document = new SolrInputDocument();

View File

@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner; import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -39,7 +40,7 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {
public RecoveryZkTest() { public RecoveryZkTest() {
super(); super();
sliceCount = 1; sliceCount = 1;
shardCount = 2; fixShardCount(2);
schemaString = "schema15.xml"; // we need a string id schemaString = "schema15.xml"; // we need a string id
} }
@ -54,8 +55,8 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {
return randVals; return randVals;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);
@ -148,7 +149,7 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {
@Override @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
// make sure threads have been stopped... // make sure threads have been stopped...
indexThread.safeStop(); indexThread.safeStop();
indexThread2.safeStop(); indexThread2.safeStop();
@ -156,7 +157,7 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {
indexThread.join(); indexThread.join();
indexThread2.join(); indexThread2.join();
super.tearDown(); super.distribTearDown();
} }
// skip the randoms - they can deadlock... // skip the randoms - they can deadlock...

View File

@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.junit.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -36,11 +37,11 @@ public class RemoteQueryErrorTest extends AbstractFullDistribZkTestBase {
public RemoteQueryErrorTest() { public RemoteQueryErrorTest() {
super(); super();
sliceCount = 1; sliceCount = 1;
shardCount = random().nextBoolean() ? 3 : 4; fixShardCount(random().nextBoolean() ? 3 : 4);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);
@ -70,4 +71,4 @@ public class RemoteQueryErrorTest extends AbstractFullDistribZkTestBase {
} }
} }
} }
} }

View File

@ -19,15 +19,10 @@ package org.apache.solr.cloud;
import java.io.File; import java.io.File;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; 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.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL; import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.embedded.JettySolrRunner; import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@ -36,10 +31,8 @@ import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.ZkCoreNodeProps; import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -59,31 +52,25 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
public ReplicationFactorTest() { public ReplicationFactorTest() {
super(); super();
sliceCount = 3; sliceCount = 3;
shardCount = 3; fixShardCount(3);
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception {
log.info("tearing down replicationFactorTest!"); log.info("tearing down replicationFactorTest!");
System.clearProperty("numShards"); System.clearProperty("numShards");
try { super.distribTearDown();
super.tearDown();
} catch (Exception exc) {} log.info("super.distribTearDown complete, closing all socket proxies");
resetExceptionIgnores();
log.info("super.tearDown complete, closing all socket proxies");
if (!proxies.isEmpty()) { if (!proxies.isEmpty()) {
for (SocketProxy proxy : proxies.values()) { for (SocketProxy proxy : proxies.values()) {
proxy.close(); proxy.close();
@ -111,10 +98,10 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
port = s.getLocalPort(); port = s.getLocalPort();
} }
return port; return port;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
log.info("replication factor test running"); log.info("replication factor test running");
waitForThingsToLevelOut(30000); waitForThingsToLevelOut(30000);

View File

@ -21,8 +21,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.solr.common.cloud.SolrZkClient; import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CollectionParams;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -36,29 +35,25 @@ public class RollingRestartTest extends AbstractFullDistribZkTestBase {
private static final long MAX_WAIT_TIME = TimeUnit.NANOSECONDS.convert(300, TimeUnit.SECONDS); private static final long MAX_WAIT_TIME = TimeUnit.NANOSECONDS.convert(300, TimeUnit.SECONDS);
public RollingRestartTest() { public RollingRestartTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = TEST_NIGHTLY ? 16 : 2; fixShardCount(TEST_NIGHTLY ? 16 : 2);
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
useFactory("solr.StandardDirectoryFactory"); useFactory("solr.StandardDirectoryFactory");
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception {
System.clearProperty("numShards"); System.clearProperty("numShards");
super.tearDown(); super.distribTearDown();
resetExceptionIgnores();
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
waitForRecoveriesToFinish(false); waitForRecoveriesToFinish(false);
restartWithRolesTest(); restartWithRolesTest();
@ -75,11 +70,11 @@ public class RollingRestartTest extends AbstractFullDistribZkTestBase {
cloudClient.getZkStateReader().getZkClient().printLayoutToStdOut(); cloudClient.getZkStateReader().getZkClient().printLayoutToStdOut();
int numDesignateOverseers = TEST_NIGHTLY ? 16 : 2; int numDesignateOverseers = TEST_NIGHTLY ? 16 : 2;
numDesignateOverseers = Math.max(shardCount, numDesignateOverseers); numDesignateOverseers = Math.max(getShardCount(), numDesignateOverseers);
List<String> designates = new ArrayList<>(); List<String> designates = new ArrayList<>();
List<CloudJettyRunner> designateJettys = new ArrayList<>(); List<CloudJettyRunner> designateJettys = new ArrayList<>();
for (int i = 0; i < numDesignateOverseers; i++) { for (int i = 0; i < numDesignateOverseers; i++) {
int n = random().nextInt(shardCount); int n = random().nextInt(getShardCount());
String nodeName = cloudJettys.get(n).nodeName; String nodeName = cloudJettys.get(n).nodeName;
log.info("Chose {} as overseer designate", nodeName); log.info("Chose {} as overseer designate", nodeName);
invokeCollectionApi(CollectionParams.ACTION, CollectionParams.CollectionAction.ADDROLE.toLower(), "role", "overseer", "node", nodeName); invokeCollectionApi(CollectionParams.ACTION, CollectionParams.CollectionAction.ADDROLE.toLower(), "role", "overseer", "node", nodeName);

View File

@ -41,6 +41,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.util.SSLTestConfig; import org.apache.solr.util.SSLTestConfig;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL; import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.lucene.util.LuceneTestCase.Slow; 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 * We want to make sure that when migrating between http and https modes the
@ -51,9 +52,9 @@ import org.apache.lucene.util.LuceneTestCase.Slow;
@SuppressSSL @SuppressSSL
@BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-6213") @BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-6213")
public class SSLMigrationTest extends AbstractFullDistribZkTestBase { public class SSLMigrationTest extends AbstractFullDistribZkTestBase {
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
//Migrate from HTTP -> HTTPS -> HTTP //Migrate from HTTP -> HTTPS -> HTTP
assertReplicaInformation("http"); assertReplicaInformation("http");
testMigrateSSL(new SSLTestConfig(true, false)); testMigrateSSL(new SSLTestConfig(true, false));
@ -118,4 +119,4 @@ public class SSLMigrationTest extends AbstractFullDistribZkTestBase {
new LBHttpSolrClient(urls.toArray(new String[]{})).request(request); new LBHttpSolrClient(urls.toArray(new String[]{})).request(request);
} }
} }

View File

@ -18,6 +18,7 @@ package org.apache.solr.cloud;
*/ */
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase { public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {
@ -34,8 +35,8 @@ public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {
sliceCount = 0; sliceCount = 0;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
boolean testFinished = false; boolean testFinished = false;
try { try {
doCustomSharding(); doCustomSharding();

View File

@ -23,6 +23,7 @@ import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ShardParams; import org.apache.solr.common.params.ShardParams;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -49,8 +50,6 @@ public class ShardRoutingTest extends AbstractFullDistribZkTestBase {
public ShardRoutingTest() { public ShardRoutingTest() {
schemaString = "schema15.xml"; // we need a string id schemaString = "schema15.xml"; // we need a string id
super.sliceCount = 4; 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 // from negative to positive, the upper bits of the hash ranges should be
// shard1: top bits:10 80000000:bfffffff // shard1: top bits:10 80000000:bfffffff
@ -92,8 +91,9 @@ public class ShardRoutingTest extends AbstractFullDistribZkTestBase {
***/ ***/
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 8)
public void test() throws Exception {
boolean testFinished = false; boolean testFinished = false;
try { try {
handle.clear(); handle.clear();

View File

@ -39,8 +39,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.After; import org.junit.Test;
import org.junit.Before;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -66,33 +65,14 @@ public class ShardSplitTest extends BasicDistributedZkTest {
} }
@Override @Override
@Before public void distribSetUp() throws Exception {
public void setUp() throws Exception { super.distribSetUp();
super.setUp();
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
} }
@Override @Test
@After public void test() throws Exception {
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();
}
@Override
public void doTest() throws Exception {
waitForThingsToLevelOut(15); waitForThingsToLevelOut(15);
if (usually()) { if (usually()) {

View File

@ -49,6 +49,7 @@ import org.apache.solr.util.DefaultSolrThreadFactory;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap; import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
@ -80,10 +81,9 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa
dfsCluster = null; dfsCluster = null;
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
useJettyDataDir = false; useJettyDataDir = false;
System.setProperty("solr.xml.persist", "true"); System.setProperty("solr.xml.persist", "true");
} }
@ -94,18 +94,16 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa
public SharedFSAutoReplicaFailoverTest() { public SharedFSAutoReplicaFailoverTest() {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 4;
completionService = new ExecutorCompletionService<>(executor); completionService = new ExecutorCompletionService<>(executor);
pending = new HashSet<>(); pending = new HashSet<>();
checkCreatedVsState = false; checkCreatedVsState = false;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
try { try {
testBasics(); testBasics();
} finally { } finally {
@ -238,8 +236,8 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa
} }
@Override @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
System.clearProperty("solr.xml.persist"); System.clearProperty("solr.xml.persist");
} }
} }

View File

@ -22,17 +22,17 @@ import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.Test;
public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestBase { public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestBase {
public SimpleCollectionCreateDeleteTest() { public SimpleCollectionCreateDeleteTest() {
fixShardCount = true;
sliceCount = 1; sliceCount = 1;
shardCount = 1;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 1)
public void test() throws Exception {
String overseerNode = OverseerCollectionProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient()); String overseerNode = OverseerCollectionProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient());
String notOverseerNode = null; String notOverseerNode = null;
for (CloudJettyRunner cloudJetty : cloudJettys) { for (CloudJettyRunner cloudJetty : cloudJettys) {

View File

@ -32,10 +32,9 @@ import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams.CollectionAction; import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -61,33 +60,30 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
// we expect this time of exception as shards go up and down... // we expect this time of exception as shards go up and down...
//ignoreException(".*"); //ignoreException(".*");
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception {
if (!success) { if (!success) {
printLayoutOnTearDown = true; printLayoutOnTearDown = true;
} }
super.tearDown(); super.distribTearDown();
resetExceptionIgnores();
} }
public SyncSliceTest() { public SyncSliceTest() {
super(); super();
sliceCount = 1; sliceCount = 1;
shardCount = TEST_NIGHTLY ? 7 : 4; fixShardCount(TEST_NIGHTLY ? 7 : 4);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);
@ -160,7 +156,7 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {
Set<CloudJettyRunner> jetties = new HashSet<>(); Set<CloudJettyRunner> jetties = new HashSet<>();
jetties.addAll(shardToJetty.get("shard1")); jetties.addAll(shardToJetty.get("shard1"));
jetties.remove(leaderJetty); jetties.remove(leaderJetty);
assertEquals(shardCount - 1, jetties.size()); assertEquals(getShardCount() - 1, jetties.size());
chaosMonkey.killJetty(leaderJetty); chaosMonkey.killJetty(leaderJetty);
@ -224,7 +220,7 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {
jetties = new HashSet<>(); jetties = new HashSet<>();
jetties.addAll(shardToJetty.get("shard1")); jetties.addAll(shardToJetty.get("shard1"));
jetties.remove(leaderJetty); jetties.remove(leaderJetty);
assertEquals(shardCount - 1, jetties.size()); assertEquals(getShardCount() - 1, jetties.size());
// kill the current leader // kill the current leader

View File

@ -16,8 +16,6 @@
*/ */
package org.apache.solr.cloud; 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.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL; import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
@ -38,6 +36,7 @@ import org.apache.commons.lang.StringUtils;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -95,8 +94,8 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase {
log.info("init'ing useFieldRandomizedFactor = {}", useFieldRandomizedFactor); log.info("init'ing useFieldRandomizedFactor = {}", useFieldRandomizedFactor);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
sanityCheckAssertDoubles(); sanityCheckAssertDoubles();

View File

@ -33,7 +33,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams; import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.Before; import org.junit.Test;
import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARD_UNIQUE; import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARD_UNIQUE;
@ -54,16 +54,14 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
} }
@Override @Override
@Before public void distribSetUp() throws Exception {
public void setUp() throws Exception {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 2; super.distribSetUp();
super.setUp();
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 2)
public void test() throws Exception {
CloudSolrClient client = createCloudClient(null); CloudSolrClient client = createCloudClient(null);
try { try {
createCollection(null, COLLECTION_NAME, 2, 2, 2, client, null, "conf1"); createCollection(null, COLLECTION_NAME, 2, 2, 2, client, null, "conf1");

View File

@ -24,6 +24,7 @@ import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.StrUtils; import org.apache.solr.common.util.StrUtils;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -53,8 +54,6 @@ public class TestDistribDocBasedVersion extends AbstractFullDistribZkTestBase {
public TestDistribDocBasedVersion() { public TestDistribDocBasedVersion() {
schemaString = "schema15.xml"; // we need a string id schemaString = "schema15.xml"; // we need a string id
super.sliceCount = 2; 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 extends AbstractFullDistribZkTestBase {
***/ ***/
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
boolean testFinished = false; boolean testFinished = false;
try { try {
handle.clear(); handle.clear();
@ -346,10 +346,4 @@ public class TestDistribDocBasedVersion extends AbstractFullDistribZkTestBase {
req.setParams(params(reqParams)); req.setParams(params(reqParams));
req.process(cloudClient); req.process(cloudClient);
} }
@Override
public void tearDown() throws Exception {
super.tearDown();
}
} }

View File

@ -27,7 +27,7 @@ import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.Before; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,15 +42,7 @@ public class TestRebalanceLeaders extends AbstractFullDistribZkTestBase {
public TestRebalanceLeaders() { public TestRebalanceLeaders() {
schemaString = "schema15.xml"; // we need a string id schemaString = "schema15.xml"; // we need a string id
}
@Override
@Before
public void setUp() throws Exception {
fixShardCount = true;
sliceCount = 4; sliceCount = 4;
shardCount = 4;
super.setUp();
} }
int reps = 10; int reps = 10;
@ -60,8 +52,9 @@ public class TestRebalanceLeaders extends AbstractFullDistribZkTestBase {
Map<String, Replica> expected = new HashMap<>(); Map<String, Replica> expected = new HashMap<>();
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
CloudSolrClient client = createCloudClient(null); CloudSolrClient client = createCloudClient(null);
reps = random().nextInt(9) + 1; // make sure and do at least one. reps = random().nextInt(9) + 1; // make sure and do at least one.
try { try {

View File

@ -36,7 +36,7 @@ import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.Before; import org.junit.Test;
@Slow @Slow
public class TestReplicaProperties extends ReplicaPropertiesBase { public class TestReplicaProperties extends ReplicaPropertiesBase {
@ -45,19 +45,12 @@ public class TestReplicaProperties extends ReplicaPropertiesBase {
public TestReplicaProperties() { public TestReplicaProperties() {
schemaString = "schema15.xml"; // we need a string id schemaString = "schema15.xml"; // we need a string id
}
@Override
@Before
public void setUp() throws Exception {
fixShardCount = true;
sliceCount = 2; sliceCount = 2;
shardCount = 4;
super.setUp();
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
CloudSolrClient client = createCloudClient(null); CloudSolrClient client = createCloudClient(null);
try { try {
// Mix up a bunch of different combinations of shards and replicas in order to exercise boundary cases. // Mix up a bunch of different combinations of shards and replicas in order to exercise boundary cases.

View File

@ -24,7 +24,7 @@ import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.Before; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
@ -36,14 +36,8 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
schemaString = "schema15.xml"; // we need a string id schemaString = "schema15.xml"; // we need a string id
} }
@Override @Test
@Before public void test() throws Exception {
public void setUp() throws Exception {
super.setUp();
}
public void doTest() {
ModifiableSolrParams params = new ModifiableSolrParams(); ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CollectionParams.ACTION, CollectionParams.CollectionAction.CREATE.toString()); params.set(CollectionParams.ACTION, CollectionParams.CollectionAction.CREATE.toString());

View File

@ -23,18 +23,18 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.params.ShardParams; import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.Test;
public class TestShortCircuitedRequests extends AbstractFullDistribZkTestBase { public class TestShortCircuitedRequests extends AbstractFullDistribZkTestBase {
public TestShortCircuitedRequests() { public TestShortCircuitedRequests() {
schemaString = "schema15.xml"; // we need a string id schemaString = "schema15.xml"; // we need a string id
super.sliceCount = 4; super.sliceCount = 4;
super.shardCount = 4;
super.fixShardCount = true; // we only want to test with exactly 4 slices.
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
waitForRecoveriesToFinish(false); waitForRecoveriesToFinish(false);
assertEquals(4, cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION).getSlices().size()); assertEquals(4, cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION).getSlices().size());
index("id", "a!doc1"); // shard3 index("id", "a!doc1"); // shard3

View File

@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -47,14 +48,12 @@ public class TriLevelCompositeIdRoutingTest extends ShardRoutingTest {
public TriLevelCompositeIdRoutingTest() { public TriLevelCompositeIdRoutingTest() {
schemaString = "schema15.xml"; // we need a string id schemaString = "schema15.xml"; // we need a string id
super.sliceCount = TEST_NIGHTLY ? 12 : 2; // a lot of slices for more ranges and buckets sliceCount = TEST_NIGHTLY ? 12 : 2; // a lot of slices for more ranges and buckets
super.shardCount = TEST_NIGHTLY ? 24 : 3; fixShardCount(TEST_NIGHTLY ? 24 : 3);
super.fixShardCount = true;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
boolean testFinished = false; boolean testFinished = false;
try { try {
handle.clear(); handle.clear();
@ -74,7 +73,6 @@ public class TriLevelCompositeIdRoutingTest extends ShardRoutingTest {
} }
} }
private void doTriLevelHashingTest() throws Exception { private void doTriLevelHashingTest() throws Exception {
log.info("### STARTING doTriLevelHashingTest"); log.info("### STARTING doTriLevelHashingTest");
// for now, we know how ranges will be distributed to shards. // for now, we know how ranges will be distributed to shards.
@ -153,10 +151,4 @@ public class TriLevelCompositeIdRoutingTest extends ShardRoutingTest {
private String getKey(String id) { private String getKey(String id) {
return id.substring(0, id.lastIndexOf('!')); return id.substring(0, id.lastIndexOf('!'));
} }
@Override
public void tearDown() throws Exception {
super.tearDown();
}
} }

View File

@ -31,8 +31,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.solr.util.DefaultSolrThreadFactory;
import org.junit.Before; import org.junit.Test;
import org.junit.BeforeClass;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -48,17 +47,6 @@ import java.util.concurrent.TimeUnit;
@Slow @Slow
@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776") @SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
public class UnloadDistributedZkTest extends BasicDistributedZkTest { public class UnloadDistributedZkTest extends BasicDistributedZkTest {
@BeforeClass
public static void beforeThisClass3() throws Exception {
}
@Before
@Override
public void setUp() throws Exception {
super.setUp();
}
protected String getSolrXml() { protected String getSolrXml() {
return "solr-no-core.xml"; return "solr-no-core.xml";
@ -68,9 +56,9 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
super(); super();
checkCreatedVsState = false; checkCreatedVsState = false;
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
testCoreUnloadAndLeaders(); // long testCoreUnloadAndLeaders(); // long
testUnloadLotsOfCores(); // long testUnloadLotsOfCores(); // long
@ -427,13 +415,4 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
executor.awaitTermination(120, TimeUnit.SECONDS); executor.awaitTermination(120, TimeUnit.SECONDS);
adminClient.shutdown(); adminClient.shutdown();
} }
@Override
public void tearDown() throws Exception {
super.tearDown();
}
} }

View File

@ -23,7 +23,6 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.cloud.ChaosMonkeySafeLeaderTest; import org.apache.solr.cloud.ChaosMonkeySafeLeaderTest;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import com.carrotsearch.randomizedtesting.annotations.Nightly; import com.carrotsearch.randomizedtesting.annotations.Nightly;
@ -47,10 +46,9 @@ public class HdfsChaosMonkeySafeLeaderTest extends ChaosMonkeySafeLeaderTest {
dfsCluster = null; dfsCluster = null;
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
// super class may hard code directory // super class may hard code directory
useFactory("org.apache.solr.core.HdfsDirectoryFactory"); useFactory("org.apache.solr.core.HdfsDirectoryFactory");

View File

@ -23,7 +23,6 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.cloud.SyncSliceTest; import org.apache.solr.cloud.SyncSliceTest;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import com.carrotsearch.randomizedtesting.annotations.Nightly; import com.carrotsearch.randomizedtesting.annotations.Nightly;
@ -46,14 +45,7 @@ public class HdfsSyncSliceTest extends SyncSliceTest {
HdfsTestUtil.teardownClass(dfsCluster); HdfsTestUtil.teardownClass(dfsCluster);
dfsCluster = null; dfsCluster = null;
} }
@Before
@Override
public void setUp() throws Exception {
super.setUp();
}
@Override @Override
protected String getDataDir(String dataDir) throws IOException { protected String getDataDir(String dataDir) throws IOException {
return HdfsTestUtil.getDataDir(dfsCluster, dataDir); return HdfsTestUtil.getDataDir(dfsCluster, dataDir);

View File

@ -40,6 +40,7 @@ import org.apache.solr.store.blockcache.Cache;
import org.apache.solr.util.RefCounted; import org.apache.solr.util.RefCounted;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -77,15 +78,15 @@ public class HdfsWriteToMultipleCollectionsTest extends BasicDistributedZkTest {
public HdfsWriteToMultipleCollectionsTest() { public HdfsWriteToMultipleCollectionsTest() {
super(); super();
sliceCount = 1; sliceCount = 1;
shardCount = 3; fixShardCount(3);
} }
protected String getSolrXml() { protected String getSolrXml() {
return "solr-no-core.xml"; return "solr-no-core.xml";
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
int docCount = random().nextInt(1313) + 1; int docCount = random().nextInt(1313) + 1;
int cnt = random().nextInt(4) + 1; int cnt = random().nextInt(4) + 1;
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {

View File

@ -48,6 +48,7 @@ import org.junit.BeforeClass;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
import org.junit.Test;
@Slow @Slow
@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s) @ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)
@ -80,16 +81,16 @@ public class StressHdfsTest extends BasicDistributedZkTest {
public StressHdfsTest() { public StressHdfsTest() {
super(); super();
sliceCount = 1; sliceCount = 1;
shardCount = TEST_NIGHTLY ? 7 : random().nextInt(2) + 1; fixShardCount(TEST_NIGHTLY ? 7 : random().nextInt(2) + 1);
testRestartIntoSafeMode = random().nextBoolean(); testRestartIntoSafeMode = random().nextBoolean();
} }
protected String getSolrXml() { protected String getSolrXml() {
return "solr-no-core.xml"; return "solr-no-core.xml";
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
randomlyEnableAutoSoftCommit(); randomlyEnableAutoSoftCommit();
int cnt = random().nextInt(2) + 1; int cnt = random().nextInt(2) + 1;
@ -138,11 +139,11 @@ public class StressHdfsTest extends BasicDistributedZkTest {
int nShards; int nShards;
int maxReplicasPerNode; int maxReplicasPerNode;
if (overshard) { if (overshard) {
nShards = shardCount * 2; nShards = getShardCount() * 2;
maxReplicasPerNode = 8; maxReplicasPerNode = 8;
rep = 1; rep = 1;
} else { } else {
nShards = shardCount / 2; nShards = getShardCount() / 2;
maxReplicasPerNode = 1; maxReplicasPerNode = 1;
rep = 2; rep = 2;
if (nShards == 0) nShards = 1; if (nShards == 0) nShards = 1;

View File

@ -26,7 +26,7 @@ import org.apache.solr.handler.TestBlobHandler;
import org.apache.solr.util.RESTfulServerProvider; import org.apache.solr.util.RESTfulServerProvider;
import org.apache.solr.util.RestTestHarness; import org.apache.solr.util.RestTestHarness;
import org.apache.solr.util.SimplePostTool; import org.apache.solr.util.SimplePostTool;
import org.junit.After; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -57,21 +57,17 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
} }
} }
@After @Override
public void testDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
for (RestTestHarness r : restTestHarnesses) { for (RestTestHarness r : restTestHarnesses) {
r.close(); r.close();
} }
} }
@Override @Test
public void doTest() throws Exception { public void testDynamicLoading() throws Exception {
setupHarnesses(); setupHarnesses();
dynamicLoading();
}
private void dynamicLoading() throws Exception {
String payload = "{\n" + String payload = "{\n" +
"'create-requesthandler' : { 'name' : '/test1', 'class': 'org.apache.solr.core.BlobStoreTestRequestHandler' , 'lib':'test','version':'1'}\n" + "'create-requesthandler' : { 'name' : '/test1', 'class': 'org.apache.solr.core.BlobStoreTestRequestHandler' , 'lib':'test','version':'1'}\n" +
"}"; "}";

View File

@ -37,6 +37,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.ConfigOverlay; import org.apache.solr.core.ConfigOverlay;
import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.SimplePostTool; import org.apache.solr.util.SimplePostTool;
import org.junit.Test;
import org.noggit.JSONParser; import org.noggit.JSONParser;
import org.noggit.ObjectBuilder; import org.noggit.ObjectBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -48,17 +49,16 @@ import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
import static org.apache.solr.core.ConfigOverlay.getObjectByPath; import static org.apache.solr.core.ConfigOverlay.getObjectByPath;
public class TestBlobHandler extends AbstractFullDistribZkTestBase { public class TestBlobHandler extends AbstractFullDistribZkTestBase {
static final Logger log = LoggerFactory.getLogger(TestBlobHandler.class); static final Logger log = LoggerFactory.getLogger(TestBlobHandler.class);
private void doBlobHandlerTest() throws Exception { @Test
public void doBlobHandlerTest() throws Exception {
SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0))); SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)));
try { try {
CollectionAdminResponse response1; CollectionAdminResponse response1;
@ -116,8 +116,8 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
} }
@Override @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
System.clearProperty("numShards"); System.clearProperty("numShards");
System.clearProperty("zkHost"); System.clearProperty("zkHost");
@ -194,10 +194,4 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
httpPost.releaseConnection(); httpPost.releaseConnection();
} }
} }
@Override
public void doTest() throws Exception {
doBlobHandlerTest();
}
} }

View File

@ -47,7 +47,7 @@ import org.apache.solr.util.RestTestHarness;
import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat; import org.apache.zookeeper.data.Stat;
import org.junit.After; import org.junit.Test;
import org.noggit.JSONParser; import org.noggit.JSONParser;
import org.noggit.ObjectBuilder; import org.noggit.ObjectBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -71,16 +71,16 @@ public class TestConfigReload extends AbstractFullDistribZkTestBase {
} }
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
for (RestTestHarness h : restTestHarnesses) { for (RestTestHarness h : restTestHarnesses) {
h.close(); h.close();
} }
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
setupHarnesses(); setupHarnesses();
try { try {
reloadTest(); reloadTest();

View File

@ -20,7 +20,6 @@ package org.apache.solr.handler;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -37,7 +36,7 @@ import org.apache.solr.core.RequestParams;
import org.apache.solr.core.TestSolrConfigHandler; import org.apache.solr.core.TestSolrConfigHandler;
import org.apache.solr.util.RESTfulServerProvider; import org.apache.solr.util.RESTfulServerProvider;
import org.apache.solr.util.RestTestHarness; import org.apache.solr.util.RestTestHarness;
import org.junit.After; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -59,17 +58,17 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
for (RestTestHarness r : restTestHarnesses) { for (RestTestHarness r : restTestHarnesses) {
r.close(); r.close();
} }
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
setupHarnesses(); setupHarnesses();
testReqHandlerAPIs(); testReqHandlerAPIs();
testReqParams(); testReqParams();

View File

@ -46,7 +46,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.ConfigOverlay; import org.apache.solr.core.ConfigOverlay;
import org.apache.solr.util.RESTfulServerProvider; import org.apache.solr.util.RESTfulServerProvider;
import org.apache.solr.util.RestTestHarness; import org.apache.solr.util.RestTestHarness;
import org.junit.After; import org.junit.Test;
import org.noggit.JSONParser; import org.noggit.JSONParser;
import org.noggit.ObjectBuilder; import org.noggit.ObjectBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -70,17 +70,17 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
for (RestTestHarness h : restTestHarnesses) { for (RestTestHarness h : restTestHarnesses) {
h.close(); h.close();
} }
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
Map editable_prop_map = (Map) new ObjectBuilder(new JSONParser(new StringReader( Map editable_prop_map = (Map) new ObjectBuilder(new JSONParser(new StringReader(
ConfigOverlay.MAPPING))).getObject(); ConfigOverlay.MAPPING))).getObject();
Map caches = (Map) editable_prop_map.get("query"); Map caches = (Map) editable_prop_map.get("query");

View File

@ -21,12 +21,10 @@ import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.nio.ByteBuffer;
import java.util.Map; import java.util.Map;
import java.util.Iterator; import java.util.Iterator;
@ -38,8 +36,6 @@ import java.util.Iterator;
public class DistributedExpandComponentTest extends BaseDistributedSearchTestCase { public class DistributedExpandComponentTest extends BaseDistributedSearchTestCase {
public DistributedExpandComponentTest() { public DistributedExpandComponentTest() {
fixShardCount = true;
shardCount = 3;
stress = 0; stress = 0;
} }
@ -48,8 +44,9 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCas
initCore("solrconfig-collapseqparser.xml", "schema11.xml"); initCore("solrconfig-collapseqparser.xml", "schema11.xml");
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 3)
public void test() throws Exception {
final String group = (random().nextBoolean() ? "group_s" : "group_s_dv"); final String group = (random().nextBoolean() ? "group_s" : "group_s_dv");
del("*:*"); del("*:*");

View File

@ -32,18 +32,15 @@ import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
import org.junit.Test;
public class DistributedFacetPivotLargeTest extends BaseDistributedSearchTestCase { public class DistributedFacetPivotLargeTest extends BaseDistributedSearchTestCase {
public static final String SPECIAL = ""; public static final String SPECIAL = "";
public DistributedFacetPivotLargeTest() { @Test
this.fixShardCount = true; @ShardsFixed(num = 4)
this.shardCount = 4; // we leave one empty as an edge case public void test() throws Exception {
}
@Override
public void doTest() throws Exception {
this.stress = 0 ; this.stress = 0 ;
handle.clear(); handle.clear();
handle.put("QTime", SKIPVAL); handle.put("QTime", SKIPVAL);

View File

@ -26,6 +26,7 @@ import org.apache.solr.client.solrj.response.PivotField;
import org.apache.solr.common.params.FacetParams; import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.Test;
/** /**
* test demonstrating how overrequesting helps finds top-terms in the "long tail" * test demonstrating how overrequesting helps finds top-terms in the "long tail"
@ -39,11 +40,6 @@ import org.apache.solr.common.params.ModifiableSolrParams;
*/ */
public class DistributedFacetPivotLongTailTest extends BaseDistributedSearchTestCase { public class DistributedFacetPivotLongTailTest extends BaseDistributedSearchTestCase {
public DistributedFacetPivotLongTailTest(){
this.fixShardCount = true;
this.shardCount = 3;
}
private int docNumber = 0; private int docNumber = 0;
public int getDocNum() { public int getDocNum() {
@ -51,8 +47,9 @@ public class DistributedFacetPivotLongTailTest extends BaseDistributedSearchTest
return docNumber; return docNumber;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 3)
public void test() throws Exception {
final SolrClient shard0 = clients.get(0); final SolrClient shard0 = clients.get(0);
final SolrClient shard1 = clients.get(1); final SolrClient shard1 = clients.get(1);

View File

@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.FacetParams; import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.junit.Test;
import java.util.List; import java.util.List;
@ -37,13 +38,9 @@ import java.util.List;
*/ */
public class DistributedFacetPivotSmallAdvancedTest extends BaseDistributedSearchTestCase { public class DistributedFacetPivotSmallAdvancedTest extends BaseDistributedSearchTestCase {
public DistributedFacetPivotSmallAdvancedTest() { @Test
this.fixShardCount = true; @ShardsFixed(num = 2)
this.shardCount = 2; public void test() throws Exception {
}
@Override
public void doTest() throws Exception {
del("*:*"); del("*:*");
final SolrClient shard0 = clients.get(0); final SolrClient shard0 = clients.get(0);

View File

@ -32,16 +32,13 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
import org.junit.Test;
public class DistributedFacetPivotSmallTest extends BaseDistributedSearchTestCase { public class DistributedFacetPivotSmallTest extends BaseDistributedSearchTestCase {
public DistributedFacetPivotSmallTest() { @Test
this.fixShardCount = true; @ShardsFixed(num = 4)
this.shardCount = 4; public void test() throws Exception {
}
@Override
public void doTest() throws Exception {
del("*:*"); del("*:*");

View File

@ -22,18 +22,15 @@ import org.apache.solr.client.solrj.response.PivotField;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.junit.Test;
import java.util.List; import java.util.List;
public class DistributedFacetPivotWhiteBoxTest extends BaseDistributedSearchTestCase { public class DistributedFacetPivotWhiteBoxTest extends BaseDistributedSearchTestCase {
public DistributedFacetPivotWhiteBoxTest() { @Test
this.fixShardCount = true; @ShardsFixed(num = 4)
this.shardCount = 4; public void test() throws Exception {
}
@Override
public void doTest() throws Exception {
del("*:*"); del("*:*");

View File

@ -20,8 +20,8 @@ package org.apache.solr.handler.component;
import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.BaseDistributedSearchTestCase; import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.common.params.MoreLikeThisParams; import org.apache.solr.common.params.MoreLikeThisParams;
import org.junit.BeforeClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test;
/** /**
* Test for distributed MoreLikeThisComponent's * Test for distributed MoreLikeThisComponent's
@ -38,29 +38,18 @@ public class DistributedMLTComponentTest extends BaseDistributedSearchTestCase {
public DistributedMLTComponentTest() public DistributedMLTComponentTest()
{ {
fixShardCount=true;
shardCount=3;
stress=0; stress=0;
} }
@BeforeClass
public static void beforeClass() throws Exception {
}
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
requestHandlerName = "mltrh"; requestHandlerName = "mltrh";
super.setUp(); super.distribSetUp();
} }
@Override @Test
public void tearDown() throws Exception { @ShardsFixed(num = 3)
super.tearDown(); public void test() throws Exception {
}
@Override
public void doTest() throws Exception {
del("*:*"); del("*:*");
index(id, "1", "lowerfilt", "toyota"); index(id, "1", "lowerfilt", "toyota");
index(id, "2", "lowerfilt", "chevrolet"); index(id, "2", "lowerfilt", "chevrolet");

View File

@ -19,9 +19,8 @@ package org.apache.solr.handler.component;
import org.apache.solr.BaseDistributedSearchTestCase; import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -33,8 +32,6 @@ import java.nio.ByteBuffer;
public class DistributedQueryComponentCustomSortTest extends BaseDistributedSearchTestCase { public class DistributedQueryComponentCustomSortTest extends BaseDistributedSearchTestCase {
public DistributedQueryComponentCustomSortTest() { public DistributedQueryComponentCustomSortTest() {
fixShardCount = true;
shardCount = 3;
stress = 0; stress = 0;
} }
@ -43,8 +40,9 @@ public class DistributedQueryComponentCustomSortTest extends BaseDistributedSear
initCore("solrconfig.xml", "schema-custom-field.xml"); initCore("solrconfig.xml", "schema-custom-field.xml");
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 3)
public void test() throws Exception {
del("*:*"); del("*:*");
index(id, "1", "text", "a", "payload", ByteBuffer.wrap(new byte[] { 0x12, 0x62, 0x15 }), // 2 index(id, "1", "text", "a", "payload", ByteBuffer.wrap(new byte[] { 0x12, 0x62, 0x15 }), // 2

View File

@ -20,11 +20,11 @@ package org.apache.solr.handler.component;
import org.apache.solr.BaseDistributedSearchTestCase; import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams; import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.common.util.SimpleOrderedMap;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Map; import java.util.Map;
@ -40,8 +40,6 @@ import java.util.Map;
public class DistributedQueryComponentOptimizationTest extends BaseDistributedSearchTestCase { public class DistributedQueryComponentOptimizationTest extends BaseDistributedSearchTestCase {
public DistributedQueryComponentOptimizationTest() { public DistributedQueryComponentOptimizationTest() {
fixShardCount = true;
shardCount = 3;
stress = 0; stress = 0;
} }
@ -50,8 +48,9 @@ public class DistributedQueryComponentOptimizationTest extends BaseDistributedSe
initCore("solrconfig.xml", "schema-custom-field.xml"); initCore("solrconfig.xml", "schema-custom-field.xml");
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 3)
public void test() throws Exception {
del("*:*"); del("*:*");
index(id, "1", "text", "a", "test_sS", "21", "payload", ByteBuffer.wrap(new byte[] { 0x12, 0x62, 0x15 }), // 2 index(id, "1", "text", "a", "test_sS", "21", "payload", ByteBuffer.wrap(new byte[] { 0x12, 0x62, 0x15 }), // 2

View File

@ -26,6 +26,7 @@ import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
/** /**
* *
@ -39,8 +40,6 @@ public class DistributedQueryElevationComponentTest extends BaseDistributedSearc
} }
public DistributedQueryElevationComponentTest() { public DistributedQueryElevationComponentTest() {
fixShardCount = true;
shardCount = 3;
stress = 0; stress = 0;
// TODO: a better way to do this? // TODO: a better way to do this?
@ -59,8 +58,9 @@ public class DistributedQueryElevationComponentTest extends BaseDistributedSearc
System.clearProperty("elevate.data.file"); System.clearProperty("elevate.data.file");
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 3)
public void test() throws Exception {
del("*:*"); del("*:*");

View File

@ -32,6 +32,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SpellingParams; import org.apache.solr.common.params.SpellingParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
/** /**
* Test for SpellCheckComponent's distributed querying * Test for SpellCheckComponent's distributed querying
@ -57,16 +58,6 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTes
useFactory(null); // need an FS factory useFactory(null); // need an FS factory
} }
@Override
public void setUp() throws Exception {
super.setUp();
}
@Override
public void tearDown() throws Exception {
super.tearDown();
}
private void q(Object... q) throws Exception { private void q(Object... q) throws Exception {
final ModifiableSolrParams params = new ModifiableSolrParams(); final ModifiableSolrParams params = new ModifiableSolrParams();
@ -95,9 +86,9 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTes
Assert.fail("Control data did not return any suggestions."); Assert.fail("Control data did not return any suggestions.");
} }
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
del("*:*"); del("*:*");
index(id, "1", "lowerfilt", "toyota"); index(id, "1", "lowerfilt", "toyota");
index(id, "2", "lowerfilt", "chevrolet"); index(id, "2", "lowerfilt", "chevrolet");

View File

@ -31,6 +31,7 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.spelling.suggest.SuggesterParams; import org.apache.solr.spelling.suggest.SuggesterParams;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
/** /**
* Test for SuggestComponent's distributed querying * Test for SuggestComponent's distributed querying
@ -54,16 +55,6 @@ public class DistributedSuggestComponentTest extends BaseDistributedSearchTestCa
useFactory(null); // need an FS factory useFactory(null); // need an FS factory
} }
@Override
public void setUp() throws Exception {
super.setUp();
}
@Override
public void tearDown() throws Exception {
super.tearDown();
}
@Override @Override
public void validateControlData(QueryResponse control) throws Exception public void validateControlData(QueryResponse control) throws Exception
{ {
@ -74,10 +65,10 @@ public class DistributedSuggestComponentTest extends BaseDistributedSearchTestCa
if(sc.size() == 0 && command == null) { if(sc.size() == 0 && command == null) {
Assert.fail("Control data did not return any suggestions or execute any command"); Assert.fail("Control data did not return any suggestions or execute any command");
} }
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
del("*:*"); del("*:*");
index(id, "1", "cat", "This is another title", "price", "10", "weight", "10"); index(id, "1", "cat", "This is another title", "price", "10", "weight", "10");
index(id, "2", "cat", "Yet another", "price", "15", "weight", "10"); index(id, "2", "cat", "Yet another", "price", "15", "weight", "10");

View File

@ -18,6 +18,7 @@ package org.apache.solr.handler.component;
*/ */
import org.apache.solr.BaseDistributedSearchTestCase; import org.apache.solr.BaseDistributedSearchTestCase;
import org.junit.Test;
/** /**
* Test for TermsComponent distributed querying * Test for TermsComponent distributed querying
@ -27,8 +28,8 @@ import org.apache.solr.BaseDistributedSearchTestCase;
*/ */
public class DistributedTermsComponentTest extends BaseDistributedSearchTestCase { public class DistributedTermsComponentTest extends BaseDistributedSearchTestCase {
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
del("*:*"); del("*:*");
index(id, 18, "b_t", "snake spider shark snail slug seal"); index(id, 18, "b_t", "snake spider shark snail slug seal");
index(id, 19, "b_t", "snake spider shark snail slug"); index(id, 19, "b_t", "snake spider shark snail slug");

View File

@ -22,6 +22,7 @@ import org.apache.lucene.util.Constants;
import org.apache.solr.BaseDistributedSearchTestCase; import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.common.params.TermVectorParams; import org.apache.solr.common.params.TermVectorParams;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
public class TermVectorComponentDistributedTest extends BaseDistributedSearchTestCase { public class TermVectorComponentDistributedTest extends BaseDistributedSearchTestCase {
@BeforeClass @BeforeClass
@ -30,8 +31,8 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
Constants.JAVA_VENDOR.startsWith("IBM")); Constants.JAVA_VENDOR.startsWith("IBM"));
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);

View File

@ -38,8 +38,8 @@ import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.util.RESTfulServerProvider; import org.apache.solr.util.RESTfulServerProvider;
import org.apache.solr.util.RestTestHarness; import org.apache.solr.util.RestTestHarness;
import org.junit.After;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.noggit.JSONParser; import org.noggit.JSONParser;
import org.noggit.ObjectBuilder; import org.noggit.ObjectBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -70,17 +70,17 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
for (RestTestHarness r : restTestHarnesses) { for (RestTestHarness r : restTestHarnesses) {
r.close(); r.close();
} }
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
final int threadCount = 5; final int threadCount = 5;
setupHarnesses(); setupHarnesses();

View File

@ -26,6 +26,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -47,9 +48,9 @@ public class TestCloudManagedSchema extends AbstractFullDistribZkTestBase {
protected String getCloudSolrConfig() { protected String getCloudSolrConfig() {
return "solrconfig-managed-schema.xml"; return "solrconfig-managed-schema.xml";
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams(); ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString()); params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
QueryRequest request = new QueryRequest(params); QueryRequest request = new QueryRequest(params);

View File

@ -36,8 +36,8 @@ import org.apache.solr.util.RESTfulServerProvider;
import org.apache.solr.util.RestTestHarness; import org.apache.solr.util.RestTestHarness;
import org.apache.zookeeper.data.Stat; import org.apache.zookeeper.data.Stat;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.After;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.restlet.ext.servlet.ServerServlet; import org.restlet.ext.servlet.ServerServlet;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -54,10 +54,7 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestB
public TestCloudManagedSchemaConcurrent() { public TestCloudManagedSchemaConcurrent() {
super(); super();
fixShardCount = true;
sliceCount = 4; sliceCount = 4;
shardCount = 8;
} }
@BeforeClass @BeforeClass
@ -65,10 +62,10 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestB
System.setProperty("managed.schema.mutable", "true"); System.setProperty("managed.schema.mutable", "true");
System.setProperty("enable.update.log", "true"); System.setProperty("enable.update.log", "true");
} }
@After @Override
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
for (RestTestHarness h : restTestHarnesses) { for (RestTestHarness h : restTestHarnesses) {
h.close(); h.close();
} }
@ -245,10 +242,11 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestB
return expectedAddFieldTypes; return expectedAddFieldTypes;
} }
@Override
public void doTest() throws Exception { @Test
@ShardsFixed(num = 8)
public void test() throws Exception {
verifyWaitForSchemaUpdateToPropagate(); verifyWaitForSchemaUpdateToPropagate();
setupHarnesses(); setupHarnesses();
concurrentOperationsTest(); concurrentOperationsTest();

View File

@ -29,7 +29,7 @@ import org.apache.solr.util.RestTestHarness;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.After; import org.junit.After;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Before; import org.junit.Test;
import org.restlet.ext.servlet.ServerServlet; import org.restlet.ext.servlet.ServerServlet;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,11 +49,10 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {
private static final Logger log = LoggerFactory.getLogger(TestCloudManagedSchemaConcurrent.class); private static final Logger log = LoggerFactory.getLogger(TestCloudManagedSchemaConcurrent.class);
private static final String SUCCESS_XPATH = "/response/lst[@name='responseHeader']/int[@name='status'][.='0']"; private static final String SUCCESS_XPATH = "/response/lst[@name='responseHeader']/int[@name='status'][.='0']";
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
useJettyDataDir = false; useJettyDataDir = false;
@ -70,10 +69,7 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {
public TestCloudSchemaless() { public TestCloudSchemaless() {
schemaString = "schema-add-schema-fields-update-processor.xml"; schemaString = "schema-add-schema-fields-update-processor.xml";
fixShardCount = true;
sliceCount = 4; sliceCount = 4;
shardCount = 8;
} }
@BeforeClass @BeforeClass
@ -122,8 +118,9 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {
return expectedAddFields; return expectedAddFields;
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 8)
public void test() throws Exception {
setupHarnesses(); setupHarnesses();
// First, add a bunch of documents in a single update with the same new field. // First, add a bunch of documents in a single update with the same new field.

View File

@ -22,6 +22,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
/** /**
* Test for QueryComponent's distributed querying * Test for QueryComponent's distributed querying
@ -31,8 +32,6 @@ import org.junit.BeforeClass;
public class AnalyticsMergeStrategyTest extends BaseDistributedSearchTestCase { public class AnalyticsMergeStrategyTest extends BaseDistributedSearchTestCase {
public AnalyticsMergeStrategyTest() { public AnalyticsMergeStrategyTest() {
fixShardCount = true;
shardCount = 3;
stress = 0; stress = 0;
} }
@ -41,8 +40,9 @@ public class AnalyticsMergeStrategyTest extends BaseDistributedSearchTestCase {
initCore("solrconfig-analytics-query.xml", "schema15.xml"); initCore("solrconfig-analytics-query.xml", "schema15.xml");
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 3)
public void test() throws Exception {
del("*:*"); del("*:*");
index_specific(0,"id","1", "sort_i", "5"); index_specific(0,"id","1", "sort_i", "5");

View File

@ -21,13 +21,12 @@ import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.handler.component.MergeStrategy; import org.apache.solr.handler.component.MergeStrategy;
import org.apache.solr.handler.component.ResponseBuilder; import org.apache.solr.handler.component.ResponseBuilder;
import org.apache.solr.handler.component.ShardRequest; import org.apache.solr.handler.component.ShardRequest;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import java.util.Arrays; import java.util.Arrays;
@ -39,8 +38,6 @@ import java.util.Arrays;
public class MergeStrategyTest extends BaseDistributedSearchTestCase { public class MergeStrategyTest extends BaseDistributedSearchTestCase {
public MergeStrategyTest() { public MergeStrategyTest() {
fixShardCount = true;
shardCount = 3;
stress = 0; stress = 0;
} }
@ -49,8 +46,9 @@ public class MergeStrategyTest extends BaseDistributedSearchTestCase {
initCore("solrconfig-plugcollector.xml", "schema15.xml"); initCore("solrconfig-plugcollector.xml", "schema15.xml");
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 3)
public void test() throws Exception {
del("*:*"); del("*:*");
index_specific(0,"id","1", "sort_i", "5"); index_specific(0,"id","1", "sort_i", "5");

View File

@ -23,6 +23,7 @@ import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -35,8 +36,6 @@ public class CloudMLTQParserTest extends AbstractFullDistribZkTestBase {
static Logger log = LoggerFactory.getLogger(CloudMLTQParserTest.class); static Logger log = LoggerFactory.getLogger(CloudMLTQParserTest.class);
public CloudMLTQParserTest() { public CloudMLTQParserTest() {
fixShardCount = true;
shardCount = 2;
sliceCount = 2; sliceCount = 2;
configString = "solrconfig.xml"; configString = "solrconfig.xml";
@ -47,8 +46,10 @@ public class CloudMLTQParserTest extends AbstractFullDistribZkTestBase {
protected String getCloudSolrConfig() { protected String getCloudSolrConfig() {
return configString; return configString;
} }
public void doTest() throws Exception { @Test
@ShardsFixed(num = 2)
public void test() throws Exception {
waitForRecoveriesToFinish(false); waitForRecoveriesToFinish(false);

View File

@ -30,13 +30,13 @@ public abstract class TestBaseStatsCache extends TestDefaultStatsCache {
protected abstract String getStatsCacheClassName(); protected abstract String getStatsCacheClassName();
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("solr.statsCache", getStatsCacheClassName()); System.setProperty("solr.statsCache", getStatsCacheClassName());
} }
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
System.clearProperty("solr.statsCache"); System.clearProperty("solr.statsCache");
} }

View File

@ -22,23 +22,24 @@ import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.Test;
public class TestDefaultStatsCache extends BaseDistributedSearchTestCase { public class TestDefaultStatsCache extends BaseDistributedSearchTestCase {
private int docId = 0; private int docId = 0;
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
System.setProperty("solr.statsCache", LocalStatsCache.class.getName()); System.setProperty("solr.statsCache", LocalStatsCache.class.getName());
} }
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
super.tearDown(); super.distribTearDown();
System.clearProperty("solr.statsCache"); System.clearProperty("solr.statsCache");
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
del("*:*"); del("*:*");
for (int i = 0; i < clients.size(); i++) { for (int i = 0; i < clients.size(); i++) {
int shard = i + 1; int shard = i + 1;

View File

@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.StrUtils; import org.apache.solr.common.util.StrUtils;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
@ -41,18 +42,16 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
params(DISTRIB_UPDATE_PARAM, FROM_LEADER); params(DISTRIB_UPDATE_PARAM, FROM_LEADER);
public PeerSyncTest() { public PeerSyncTest() {
fixShardCount = true;
shardCount = 3;
stress = 0; stress = 0;
// TODO: a better way to do this? // TODO: a better way to do this?
configString = "solrconfig-tlog.xml"; configString = "solrconfig-tlog.xml";
schemaString = "schema.xml"; schemaString = "schema.xml";
} }
@Test
@Override @ShardsFixed(num = 3)
public void doTest() throws Exception { public void test() throws Exception {
handle.clear(); handle.clear();
handle.put("timestamp", SKIPVAL); handle.put("timestamp", SKIPVAL);
handle.put("score", SKIPVAL); handle.put("score", SKIPVAL);

View File

@ -48,6 +48,7 @@ import org.apache.solr.update.SolrCmdDistributor.RetryNode;
import org.apache.solr.update.SolrCmdDistributor.StdNode; import org.apache.solr.update.SolrCmdDistributor.StdNode;
import org.apache.solr.update.processor.DistributedUpdateProcessor; import org.apache.solr.update.processor.DistributedUpdateProcessor;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -90,8 +91,6 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
} }
}); });
fixShardCount = true;
shardCount = 4;
stress = 0; stress = 0;
} }
@ -136,9 +135,10 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
shards = sb.toString(); shards = sb.toString();
} }
@Override @Test
public void doTest() throws Exception { @ShardsFixed(num = 4)
public void test() throws Exception {
del("*:*"); del("*:*");
SolrCmdDistributor cmdDistrib = new SolrCmdDistributor(updateShardHandler); SolrCmdDistributor cmdDistrib = new SolrCmdDistributor(updateShardHandler);
@ -320,7 +320,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
cmdDistrib.finish(); cmdDistrib.finish();
assertEquals(shardCount, commits.get()); assertEquals(getShardCount(), commits.get());
for (SolrClient c : clients) { for (SolrClient c : clients) {
NamedList<Object> resp = c.request(new LukeRequest()); NamedList<Object> resp = c.request(new LukeRequest());
@ -517,14 +517,9 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
} }
@Override @Override
public void setUp() throws Exception { public void distribTearDown() throws Exception {
super.setUp();
}
@Override
public void tearDown() throws Exception {
updateShardHandler.close(); updateShardHandler.close();
super.tearDown(); super.distribTearDown();
} }
private void testDistribOpenSearcher() { private void testDistribOpenSearcher() {

View File

@ -21,7 +21,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrQuery;
@ -46,10 +45,9 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams; import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -97,31 +95,23 @@ public class CloudSolrClientTest extends AbstractFullDistribZkTestBase {
return SOLR_HOME; return SOLR_HOME;
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
// we expect this time of exception as shards go up and down... // we expect this time of exception as shards go up and down...
//ignoreException(".*"); //ignoreException(".*");
System.setProperty("numShards", Integer.toString(sliceCount)); System.setProperty("numShards", Integer.toString(sliceCount));
} }
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
resetExceptionIgnores();
}
public CloudSolrClientTest() { public CloudSolrClientTest() {
super(); super();
sliceCount = 2; sliceCount = 2;
shardCount = 3; fixShardCount(3);
} }
@Override @Test
public void doTest() throws Exception { public void test() throws Exception {
allTests(); allTests();
stateVersionParamTest(); stateVersionParamTest();
customHttpClientTest(); customHttpClientTest();

View File

@ -39,12 +39,19 @@ import org.apache.solr.schema.TrieDateField;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -63,6 +70,20 @@ import java.util.concurrent.atomic.AtomicInteger;
/** /**
* Helper base class for distributed search test cases * Helper base class for distributed search test cases
* *
* By default, all tests in sub-classes will be executed with
* 1, 2, ... DEFAULT_MAX_SHARD_COUNT number of shards set up repeatedly.
*
* In general, it's preferable to annotate the tests in sub-classes with a
* {@literal @}ShardsFixed(num = N) or a {@literal @}ShardsRepeat(min = M, max = N)
* to indicate whether the test should be called once, with a fixed number of shards,
* or called repeatedly for number of shards = M to N.
*
* In some cases though, if the number of shards has to be fixed, but the number
* itself is dynamic, or if it has to be set as a default for all sub-classes
* of a sub-class, there's a fixShardCount(N) available, which is identical to
* {@literal @}ShardsFixed(num = N) for all tests without annotations in that class
* hierarchy. Ideally this function should be retired in favour of better annotations..
*
* @since solr 1.5 * @since solr 1.5
*/ */
public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 { public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
@ -174,16 +195,19 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
"[ff01::213]:33332" + context}; "[ff01::213]:33332" + context};
} }
protected int shardCount = 4; // the actual number of solr cores that will be created in the cluster private final static int DEFAULT_MAX_SHARD_COUNT = 3;
/** private int shardCount = -1; // the actual number of solr cores that will be created in the cluster
* Sub classes can set this flag in their constructor to true if they public int getShardCount() {
* want to fix the number of shards to 'shardCount' return shardCount;
* }
* The default is false which means that test will be executed with
* 1, 2, 3, ....shardCount number of shards repeatedly private boolean isShardCountFixed = false;
*/
protected boolean fixShardCount = false; public void fixShardCount(int count) {
isShardCountFixed = true;
shardCount = count;
}
protected JettySolrRunner controlJetty; protected JettySolrRunner controlJetty;
protected List<SolrClient> clients = new ArrayList<>(); protected List<SolrClient> clients = new ArrayList<>();
@ -245,13 +269,6 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
public static RandVal rdate = new RandDate(); public static RandVal rdate = new RandDate();
/**
* Perform the actual tests here
*
* @throws Exception on error
*/
public abstract void doTest() throws Exception;
public static String[] fieldNames = new String[]{"n_ti1", "n_f1", "n_tf1", "n_d1", "n_td1", "n_l1", "n_tl1", "n_dt1", "n_tdt1"}; public static String[] fieldNames = new String[]{"n_ti1", "n_f1", "n_tf1", "n_d1", "n_td1", "n_l1", "n_tl1", "n_dt1", "n_tdt1"};
public static RandVal[] randVals = new RandVal[]{rint, rfloat, rfloat, rdouble, rdouble, rlong, rlong, rdate, rdate}; public static RandVal[] randVals = new RandVal[]{rint, rfloat, rfloat, rdouble, rdouble, rlong, rlong, rdate, rdate};
@ -270,20 +287,20 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
public String getSolrHome() { public String getSolrHome() {
return SolrTestCaseJ4.TEST_HOME(); return SolrTestCaseJ4.TEST_HOME();
} }
@Override private boolean distribSetUpCalled = false;
public void setUp() throws Exception { public void distribSetUp() throws Exception {
distribSetUpCalled = true;
SolrTestCaseJ4.resetExceptionIgnores(); // ignore anything with ignore_exception in it SolrTestCaseJ4.resetExceptionIgnores(); // ignore anything with ignore_exception in it
super.setUp();
System.setProperty("solr.test.sys.prop1", "propone"); System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo"); System.setProperty("solr.test.sys.prop2", "proptwo");
testDir = createTempDir().toFile(); testDir = createTempDir().toFile();
} }
@Override private boolean distribTearDownCalled = false;
public void tearDown() throws Exception { public void distribTearDown() throws Exception {
distribTearDownCalled = true;
destroyServers(); destroyServers();
super.tearDown();
} }
protected JettySolrRunner createControlJetty() throws Exception { protected JettySolrRunner createControlJetty() throws Exception {
@ -870,23 +887,107 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
compareSolrResponses(a, b); compareSolrResponses(a, b);
} }
@Test @Retention(RetentionPolicy.RUNTIME)
public void testDistribSearch() throws Exception { @Target(ElementType.METHOD)
if (fixShardCount) { public @interface ShardsRepeat {
createServers(shardCount); public abstract int min() default 1;
RandVal.uniqueValues = new HashSet(); //reset random values public abstract int max() default DEFAULT_MAX_SHARD_COUNT;
doTest(); }
destroyServers();
} else { @Retention(RetentionPolicy.RUNTIME)
for (int nServers = 1; nServers < shardCount; nServers++) { @Target(ElementType.METHOD)
createServers(nServers); public @interface ShardsFixed {
public abstract int num();
}
public class ShardsRepeatRule implements TestRule {
private abstract class ShardsStatement extends Statement {
abstract protected void callStatement() throws Throwable;
@Override
public void evaluate() throws Throwable {
distribSetUp();
if (! distribSetUpCalled) {
Assert.fail("One of the overrides of distribSetUp does not propagate the call.");
}
try {
callStatement();
} finally {
distribTearDown();
if (! distribTearDownCalled) {
Assert.fail("One of the overrides of distribTearDown does not propagate the call.");
}
}
}
}
private class ShardsFixedStatement extends ShardsStatement {
private final int numShards;
private final Statement statement;
private ShardsFixedStatement(int numShards, Statement statement) {
this.numShards = numShards;
this.statement = statement;
}
@Override
public void callStatement() throws Throwable {
fixShardCount(numShards);
createServers(numShards);
RandVal.uniqueValues = new HashSet(); //reset random values RandVal.uniqueValues = new HashSet(); //reset random values
doTest(); statement.evaluate();
destroyServers(); destroyServers();
} }
} }
private class ShardsRepeatStatement extends ShardsStatement {
private final int min;
private final int max;
private final Statement statement;
private ShardsRepeatStatement(int min, int max, Statement statement) {
this.min = min;
this.max = max;
this.statement = statement;
}
@Override
public void callStatement() throws Throwable {
for (shardCount = min; shardCount <= max; shardCount++) {
createServers(shardCount);
RandVal.uniqueValues = new HashSet(); //reset random values
statement.evaluate();
destroyServers();
}
}
}
@Override
public Statement apply(Statement statement, Description description) {
ShardsFixed fixed = description.getAnnotation(ShardsFixed.class);
ShardsRepeat repeat = description.getAnnotation(ShardsRepeat.class);
if (fixed != null && repeat != null) {
throw new RuntimeException("ShardsFixed and ShardsRepeat annotations can't coexist");
}
else if (fixed != null) {
return new ShardsFixedStatement(fixed.num(), statement);
}
else if (repeat != null) {
return new ShardsRepeatStatement(repeat.min(), repeat.max(), statement);
}
else {
return (isShardCountFixed ? new ShardsFixedStatement(shardCount, statement) :
new ShardsRepeatStatement(1, DEFAULT_MAX_SHARD_COUNT, statement));
}
}
} }
@Rule
public ShardsRepeatRule repeatRule = new ShardsRepeatRule();
public static Object[] getRandFields(String[] fields, RandVal[] randVals) { public static Object[] getRandFields(String[] fields, RandVal[] randVals) {
Object[] o = new Object[fields.length * 2]; Object[] o = new Object[fields.length * 2];
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {

View File

@ -33,8 +33,6 @@ import org.apache.solr.core.Diagnostics;
import org.apache.solr.core.MockDirectoryFactory; import org.apache.solr.core.MockDirectoryFactory;
import org.apache.solr.servlet.SolrDispatchFilter; import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTestCase { public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTestCase {
@ -54,11 +52,9 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
//useFactory(null); //useFactory(null);
} }
@Before
@Override @Override
public void setUp() throws Exception { public void distribSetUp() throws Exception {
super.setUp(); super.distribSetUp();
String zkDir = testDir.getAbsolutePath() + File.separator String zkDir = testDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data"; + "zookeeper/server1/data";
@ -212,8 +208,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
} }
@Override @Override
@After public void distribTearDown() throws Exception {
public void tearDown() throws Exception {
if (DEBUG) { if (DEBUG) {
printLayout(); printLayout();
} }
@ -228,7 +223,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
System.clearProperty(MockDirectoryFactory.SOLR_TESTS_ALLOW_READING_FILES_STILL_OPEN_FOR_WRITE); System.clearProperty(MockDirectoryFactory.SOLR_TESTS_ALLOW_READING_FILES_STILL_OPEN_FOR_WRITE);
resetExceptionIgnores(); resetExceptionIgnores();
super.tearDown(); super.distribTearDown();
zkServer.shutdown(); zkServer.shutdown();
} }

View File

@ -424,7 +424,7 @@ public class ZkTestServer {
public void run() throws InterruptedException { public void run() throws InterruptedException {
log.info("STARTING ZK TEST SERVER"); log.info("STARTING ZK TEST SERVER");
// we don't call super.setUp // we don't call super.distribSetUp
zooThread = new Thread() { zooThread = new Thread() {
@Override @Override