You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kr...@apache.org on 2017/02/01 17:01:00 UTC
[32/35] lucene-solr:jira/solr-8593: SOLR-10065: The Nightly test
ConcurrentDeleteAndCreateCollectionTest appears to be too fragile.
SOLR-10065: The Nightly test ConcurrentDeleteAndCreateCollectionTest appears to be too fragile.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/bc02b0f7
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/bc02b0f7
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/bc02b0f7
Branch: refs/heads/jira/solr-8593
Commit: bc02b0f70d342df00718edf6749ccd707183ffd6
Parents: 730df22
Author: markrmiller <ma...@apache.org>
Authored: Wed Feb 1 08:58:32 2017 -0500
Committer: markrmiller <ma...@apache.org>
Committed: Wed Feb 1 08:58:32 2017 -0500
----------------------------------------------------------------------
...ConcurrentDeleteAndCreateCollectionTest.java | 33 +++++++++++++-------
1 file changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bc02b0f7/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java
index 3e90759..151230d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java
@@ -17,6 +17,7 @@
package org.apache.solr.cloud;
import java.io.IOException;
+import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
@@ -27,14 +28,19 @@ import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.common.util.IOUtils;
import org.apache.solr.util.TimeOut;
import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Nightly
public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
private MiniSolrCloudCluster solrCluster;
@Override
@@ -54,7 +60,7 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
public void testConcurrentCreateAndDeleteDoesNotFail() {
final AtomicReference<Exception> failure = new AtomicReference<>();
final int timeToRunSec = 30;
- final Thread[] threads = new Thread[10];
+ final CreateDeleteCollectionThread[] threads = new CreateDeleteCollectionThread[10];
for (int i = 0; i < threads.length; i++) {
final String collectionName = "collection" + i;
uploadConfig(configset("configset-2"), collectionName);
@@ -74,12 +80,12 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
final String configName = "testconfig";
uploadConfig(configset("configset-2"), configName); // upload config once, to be used by all collections
final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
- final SolrClient solrClient = getHttpSolrClient(baseUrl);
final AtomicReference<Exception> failure = new AtomicReference<>();
final int timeToRunSec = 30;
- final Thread[] threads = new Thread[2];
+ final CreateDeleteCollectionThread[] threads = new CreateDeleteCollectionThread[2];
for (int i = 0; i < threads.length; i++) {
final String collectionName = "collection" + i;
+ final SolrClient solrClient = getHttpSolrClient(baseUrl);
threads[i] = new CreateDeleteCollectionThread("create-delete-" + i, collectionName, configName,
timeToRunSec, solrClient, failure);
}
@@ -88,12 +94,6 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
joinAll(threads);
assertNull("concurrent create and delete collection failed: " + failure.get(), failure.get());
-
- try {
- solrClient.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
}
private void uploadConfig(Path configDir, String configName) {
@@ -104,10 +104,10 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
}
}
- private void joinAll(final Thread[] threads) {
- for (Thread t : threads) {
+ private void joinAll(final CreateDeleteCollectionThread[] threads) {
+ for (CreateDeleteCollectionThread t : threads) {
try {
- t.join();
+ t.joinAndClose();
} catch (InterruptedException e) {
Thread.interrupted();
throw new RuntimeException(e);
@@ -152,6 +152,7 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
}
protected void addFailure(Exception e) {
+ log.error("Add Failure", e);
synchronized (failure) {
if (failure.get() != null) {
failure.get().addSuppressed(e);
@@ -190,6 +191,14 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
addFailure(e);
}
}
+
+ public void joinAndClose() throws InterruptedException {
+ try {
+ super.join(60000);
+ } finally {
+ IOUtils.closeQuietly(solrClient);
+ }
+ }
}
private static class CreateDeleteSearchCollectionThread extends CreateDeleteCollectionThread {