diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index b13c971cced..70bfaa4ed51 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -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 diff --git a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java index 5856060cfca..64e779633ff 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java @@ -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 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"); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java index a274c397287..e564604e6bf 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java @@ -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); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java index 1183c39b36b..663e89fdf4b 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java @@ -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 createCollection(String name, int numShards, int replicationFactor, String configName, Map collectionProperties) throws SolrServerException, IOException { + return createCollection(name, numShards, replicationFactor, configName, null, collectionProperties); + } + + public NamedList createCollection(String name, int numShards, int replicationFactor, + String configName, String asyncId, Map 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 property : collectionProperties.entrySet()){ params.set(CoreAdminParams.PROPERTY_PREFIX + property.getKey(), property.getValue());