SOLR-7823: TestMiniSolrCloudCluster.testCollectionCreateSearchDelete async collection-creation (sometimes)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1693616 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christine Poerschke 2015-07-31 15:35:10 +00:00
parent 81df57baa2
commit 22d67a637a
4 changed files with 22 additions and 5 deletions

View File

@ -381,6 +381,9 @@ Other Changes
* SOLR-5022: On Java 7 raise permgen for running tests. (Uwe Schindler)
* SOLR-7823: TestMiniSolrCloudCluster.testCollectionCreateSearchDelete async collection-creation (sometimes)
(Christine Poerschke)
================== 5.2.1 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -95,6 +95,8 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
jettyConfig.waitForLoadingCoresToFinish(null);
MiniSolrCloudCluster miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir().toFile(), solrXml, jettyConfig.build());
final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient();
try {
assertNotNull(miniCluster.getZkServer());
List<JettySolrRunner> jettys = miniCluster.getJettySolrRunners();
@ -127,7 +129,11 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
collectionProperties.put("solr.tests.mergePolicy", "org.apache.lucene.index.TieredMergePolicy");
collectionProperties.put("solr.tests.mergeScheduler", "org.apache.lucene.index.ConcurrentMergeScheduler");
collectionProperties.put("solr.directoryFactory", "solr.RAMDirectoryFactory");
miniCluster.createCollection(collectionName, NUM_SHARDS, REPLICATION_FACTOR, configName, collectionProperties);
final String asyncId = (random().nextBoolean() ? null : "asyncId("+collectionName+".create)="+random().nextInt());
miniCluster.createCollection(collectionName, NUM_SHARDS, REPLICATION_FACTOR, configName, asyncId, collectionProperties);
if (asyncId != null) {
assertEquals("did not see async createCollection completion", "completed", AbstractFullDistribZkTestBase.getRequestStateAfterCompletion(asyncId, 330, cloudSolrClient));
}
try (SolrZkClient zkClient = new SolrZkClient
(miniCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, 45000, null);
@ -135,7 +141,6 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collectionName, zkStateReader, true, true, 330);
// modify/query collection
CloudSolrClient cloudSolrClient = miniCluster.getSolrClient();
cloudSolrClient.setDefaultCollection(collectionName);
SolrInputDocument doc = new SolrInputDocument();
doc.setField("id", "1");

View File

@ -1875,7 +1875,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
}
protected String getRequestStateAfterCompletion(String requestId, int waitForSeconds, SolrClient client)
static String getRequestStateAfterCompletion(String requestId, int waitForSeconds, SolrClient client)
throws IOException, SolrServerException {
String state = null;
long maxWait = System.nanoTime() + TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS);
@ -1893,11 +1893,11 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
return state;
}
protected String getRequestState(int requestId, SolrClient client) throws IOException, SolrServerException {
static String getRequestState(int requestId, SolrClient client) throws IOException, SolrServerException {
return getRequestState(String.valueOf(requestId), client);
}
protected String getRequestState(String requestId, SolrClient client) throws IOException, SolrServerException {
static String getRequestState(String requestId, SolrClient client) throws IOException, SolrServerException {
CollectionAdminRequest.RequestStatus requestStatusRequest = new CollectionAdminRequest.RequestStatus();
requestStatusRequest.setRequestId(requestId);
CollectionAdminResponse response = requestStatusRequest.process(client);

View File

@ -28,6 +28,7 @@ import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkConfigManager;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ExecutorUtil;
@ -306,12 +307,20 @@ public class MiniSolrCloudCluster {
public NamedList<Object> createCollection(String name, int numShards, int replicationFactor,
String configName, Map<String, String> collectionProperties) throws SolrServerException, IOException {
return createCollection(name, numShards, replicationFactor, configName, null, collectionProperties);
}
public NamedList<Object> createCollection(String name, int numShards, int replicationFactor,
String configName, String asyncId, Map<String, String> collectionProperties) throws SolrServerException, IOException {
final ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CoreAdminParams.ACTION, CollectionAction.CREATE.name());
params.set(CoreAdminParams.NAME, name);
params.set("numShards", numShards);
params.set("replicationFactor", replicationFactor);
params.set("collection.configName", configName);
if (null != asyncId) {
params.set(CommonAdminParams.ASYNC, asyncId);
}
if(collectionProperties != null) {
for(Map.Entry<String, String> property : collectionProperties.entrySet()){
params.set(CoreAdminParams.PROPERTY_PREFIX + property.getKey(), property.getValue());