You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2020/09/16 21:25:17 UTC
[lucene-solr] branch reference_impl_dev updated: Re-enable
collection related tests in core
This is an automated email from the ASF dual-hosted git repository.
thelabdude pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl_dev by this push:
new 83c07f6 Re-enable collection related tests in core
new 2dd15ba Merge branch 'reference_impl_dev' of https://github.com/apache/lucene-solr into reference_impl_dev
83c07f6 is described below
commit 83c07f6d612b83d23fcf1eeddbd586dbb9ccb4d2
Author: Timothy Potter <th...@gmail.com>
AuthorDate: Wed Sep 16 15:13:14 2020 -0600
Re-enable collection related tests in core
---
.../cloud/api/collections/CreateCollectionCmd.java | 7 ++++-
.../src/java/org/apache/solr/core/SolrCore.java | 2 +-
.../apache/solr/rest/ManagedResourceStorage.java | 24 +++-------------
.../CollectionsAPIAsyncDistributedZkTest.java | 2 --
.../CollectionsAPIDistClusterPerZkTest.java | 32 ++++++++++++++--------
.../CollectionsAPIDistributedZkTest.java | 1 -
.../TestCollectionsAPIViaSolrCloudCluster.java | 1 -
.../apache/solr/common/cloud/ZkStateReader.java | 11 +++++++-
8 files changed, 41 insertions(+), 39 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
index 9af66f9..600afe5 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
@@ -142,7 +142,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
}
String configName = getConfigName(collectionName, message);
- log.info("configName={} colleciton={}", configName, collectionName);
+ log.info("configName={} collection={}", configName, collectionName);
if (configName == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No config set found to associate with the collection.");
}
@@ -171,6 +171,11 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
collectionParams.put(propName.substring(ZkController.COLLECTION_PARAM_PREFIX.length()), (String) entry.getValue());
}
}
+
+ if (zkStateReader.getClusterState().getCollectionOrNull(collectionName) != null) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection '"+collectionName+"' already exists!");
+ }
+
createCollectionZkNode(stateManager, collectionName, collectionParams, configName);
OverseerCollectionMessageHandler.createConfNode(stateManager, configName, collectionName, isLegacyCloud);
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 13e0ed3..d616de3 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -3040,7 +3040,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
String collection = cd.getCollectionName();
StorageIO storageIO =
- ManagedResourceStorage.newStorageIO(collection, resourceLoader, initArgs);
+ ManagedResourceStorage.newStorageIO(collection, cd.getConfigSet(), resourceLoader, initArgs);
mgr.init(resourceLoader, initArgs, storageIO);
return mgr;
diff --git a/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java b/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java
index 512a32a..b8e96eb 100644
--- a/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java
+++ b/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java
@@ -84,32 +84,16 @@ public abstract class ManagedResourceStorage {
* Creates a new StorageIO instance for a Solr core, taking into account
* whether the core is running in cloud mode as well as initArgs.
*/
- public static StorageIO newStorageIO(String collection, SolrResourceLoader resourceLoader, NamedList<String> initArgs) {
+ public static StorageIO newStorageIO(String collection, String configSet, SolrResourceLoader resourceLoader, NamedList<String> initArgs) {
StorageIO storageIO;
- SolrZkClient zkClient = null;
- String zkConfigName = null;
- if (resourceLoader instanceof ZkSolrResourceLoader) {
- zkClient = ((ZkSolrResourceLoader)resourceLoader).getZkController().getZkClient();
- try {
- zkConfigName = ((ZkSolrResourceLoader)resourceLoader).getZkController().
- getZkStateReader().readConfigName(collection);
- } catch (Exception e) {
- log.error("Failed to get config name due to", e);
- throw new SolrException(ErrorCode.SERVER_ERROR,
- "Failed to load config name for collection:" + collection + " due to: ", e);
- }
- if (zkConfigName == null) {
- throw new SolrException(ErrorCode.SERVER_ERROR,
- "Could not find config name for collection:" + collection);
- }
- }
-
if (initArgs.get(STORAGE_IO_CLASS_INIT_ARG) != null) {
storageIO = resourceLoader.newInstance(initArgs.get(STORAGE_IO_CLASS_INIT_ARG), StorageIO.class);
} else {
+ SolrZkClient zkClient = (resourceLoader instanceof ZkSolrResourceLoader) ?
+ ((ZkSolrResourceLoader)resourceLoader).getZkController().getZkClient() : null;
if (zkClient != null) {
- String znodeBase = "/configs/"+zkConfigName;
+ String znodeBase = "/configs/"+configSet;
log.debug("Setting up ZooKeeper-based storage for the RestManager with znodeBase: {}", znodeBase);
storageIO = new ManagedResourceStorage.ZooKeeperStorageIO(zkClient, znodeBase);
} else {
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIAsyncDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIAsyncDistributedZkTest.java
index e343340..4f5ad9d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIAsyncDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIAsyncDistributedZkTest.java
@@ -33,7 +33,6 @@ import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.RequestStatusState;
@@ -75,7 +74,6 @@ public class CollectionsAPIAsyncDistributedZkTest extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit harden
public void testSolrJAPICalls() throws Exception {
final CloudHttp2SolrClient client = cluster.getSolrClient();
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistClusterPerZkTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistClusterPerZkTest.java
index b3910b2..b0d8ae2 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistClusterPerZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistClusterPerZkTest.java
@@ -70,6 +70,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
@@ -118,7 +119,6 @@ public class CollectionsAPIDistClusterPerZkTest extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit look at this again
public void deleteCollectionOnlyInZk() throws Exception {
final String collectionName = "onlyinzk";
@@ -137,21 +137,23 @@ public class CollectionsAPIDistClusterPerZkTest extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit - fix fast fail
+ @SuppressWarnings("rawtypes")
public void testTooManyReplicas() {
CollectionAdminRequest req = CollectionAdminRequest.createCollection("collection", "conf", 2, 10);
-
try {
cluster.getSolrClient().request(req);
- fail("Expected excetpion");
+ fail("Expected exception");
} catch (Exception e) {
- // expected
+ assertTrue(e instanceof BaseHttpSolrClient.RemoteSolrException);
+ BaseHttpSolrClient.RemoteSolrException rse = (BaseHttpSolrClient.RemoteSolrException)e;
+ assertEquals(400,rse.code());
+ assertTrue(rse.getMessage().contains("maxShardsPerNode"));
}
}
@Test
- @Ignore // nocommit we can speed this up
+ @Ignore // nocommit we can speed this up, TJP ~ WIP: fails
public void testCreateShouldFailOnExistingCore() throws Exception {
assertEquals(0, CollectionAdminRequest.createCollection("halfcollectionblocker", "conf", 1, 1)
.setCreateNodeSet("")
@@ -200,7 +202,6 @@ public class CollectionsAPIDistClusterPerZkTest extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit slow
public void testSpecificConfigsets() throws Exception {
CollectionAdminRequest.createCollection("withconfigset2", "conf2", 1, 1).process(cluster.getSolrClient());
byte[] data = zkClient().getData(ZkStateReader.COLLECTIONS_ZKNODE + "/" + "withconfigset2", null, null);
@@ -211,7 +212,6 @@ public class CollectionsAPIDistClusterPerZkTest extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit - fix fast fail
public void testMaxNodesPerShard() {
int numLiveNodes = cluster.getJettySolrRunners().size();
int numShards = (numLiveNodes/2) + 1;
@@ -224,10 +224,19 @@ public class CollectionsAPIDistClusterPerZkTest extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit debug seems to random fail
public void testCreateNodeSet() throws Exception {
- JettySolrRunner jetty1 = cluster.getRandomJetty(random());
- JettySolrRunner jetty2 = cluster.getRandomJetty(random());
+ JettySolrRunner jetty1 = null;
+ JettySolrRunner jetty2 = null;
+ final List<JettySolrRunner> runners = cluster.getJettySolrRunners();
+ if (runners.size() == 2) {
+ jetty1 = runners.get(0);
+ jetty2 = runners.get(1);
+ } else if (runners.size() > 2) {
+ jetty1 = cluster.getRandomJetty(random());
+ jetty2 = cluster.getRandomJetty(random(), jetty1);
+ } else {
+ fail("This test requires at least 2 Jetty runners!");
+ }
List<String> baseUrls = ImmutableList.of(jetty1.getCoreContainer().getZkController().getNodeName(), jetty2.getCoreContainer().getZkController().getNodeName());
@@ -446,7 +455,6 @@ public class CollectionsAPIDistClusterPerZkTest extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit - this is flakey on colection delete - add replica prob has to wait for itself better
public void addReplicaTest() throws Exception {
String collectionName = "addReplicaColl";
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistributedZkTest.java
index 6a89fb6..dd8c4b6 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIDistributedZkTest.java
@@ -289,7 +289,6 @@ public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit
public void testDeleteNonExistentCollection() throws Exception {
expectThrows(Exception.class, () -> {
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java
index ea45b68..d018655 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java
@@ -117,7 +117,6 @@ public class TestCollectionsAPIViaSolrCloudCluster extends SolrCloudTestCase {
}
@Test
- @Ignore // nocommit harden
public void testCollectionCreateSearchDelete() throws Exception {
final CloudHttp2SolrClient client = cluster.getSolrClient();
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index eb3ab87..655a9ae 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -281,14 +281,23 @@ public class ZkStateReader implements SolrCloseable {
String configName = null;
+ DocCollection docCollection = watchedCollectionStates.get(collection);
+ if (docCollection != null) {
+ configName = docCollection.getStr(CONFIGNAME_PROP);
+ if (configName != null) {
+ return configName;
+ }
+ }
+
String path = COLLECTIONS_ZKNODE + "/" + collection;
log.debug("Loading collection config from: [{}]", path);
try {
+
byte[] data = zkClient.getData(path, null, null);
if (data == null) {
log.warn("No config data found at path {}.", path);
- throw new KeeperException.NoNodeException("No config data found at path: " + path);
+ throw new KeeperException.NoNodeException(path);
}
ZkNodeProps props = ZkNodeProps.load(data);