Apache Lucene open-source search software
SOLR-7485: Replace shards.info occurrences with ShardParams.SHARDS_INFO
Ramkumar Aiyengarb9854071cf13
diff --git a/solr/core/src/test/org/apache/solr/TestTolerantSearch.java b/solr/core/src/test/org/apache/solr/TestTolerantSearch.javaindex bdaa6b9b392..1a41861adfd 100644--- a/solr/core/src/test/org/apache/solr/TestTolerantSearch.java+++ b/solr/core/src/test/org/apache/solr/TestTolerantSearch.java@@ -141,7 +141,7 @@ public class TestTolerantSearch extends SolrJettyTestBase {query.set(ShardParams.SHARDS_TOLERANT, "true");QueryResponse response = collection1.query(query);assertTrue(response.getResponseHeader().getBooleanArg("partialResults"));- NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get("shards.info"));+ NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get(ShardParams.SHARDS_INFO));boolean foundError = false;for (int i = 0; i < shardsInfo.size(); i++) {if (shardsInfo.getName(i).contains("collection2")) {@@ -189,7 +189,7 @@ public class TestTolerantSearch extends SolrJettyTestBase {query.set(ShardParams.SHARDS_TOLERANT, "true");QueryResponse response = collection1.query(query);assertTrue(response.getResponseHeader().getBooleanArg("partialResults"));- NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get("shards.info"));+ NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get(ShardParams.SHARDS_INFO));boolean foundError = false;for (int i = 0; i < shardsInfo.size(); i++) {if (shardsInfo.getName(i).contains("collection2")) {diff --git a/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java b/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.javaindex 46a9fc08d90..28f2baa0c27 100644--- a/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java+++ b/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java@@ -19,6 +19,10 @@ package org.apache.solr.common.params;/*** Parameters used for distributed search.+ *+ * When adding a new parameter here, please also add the corresponding+ * one-line test case in the ShardParamsTest class.+ **/public interface ShardParams {/** the shards to use (distributed configuration) */diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.javaindex b4ca40996fe..6476c767c03 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java@@ -423,7 +423,7 @@ public class CloudSolrClientTest extends AbstractFullDistribZkTestBase {ModifiableSolrParams qParams = new ModifiableSolrParams();qParams.add("preferLocalShards", Boolean.toString(preferLocalShards));- qParams.add("shards.info", "true");+ qParams.add(ShardParams.SHARDS_INFO, "true");qRequest.add(qParams);// CloudSolrClient sends the request to some node.@@ -432,8 +432,8 @@ public class CloudSolrClientTest extends AbstractFullDistribZkTestBase {// local shards onlyQueryResponse qResponse = cloudClient.query (qRequest);- Object shardsInfo = qResponse.getResponse().get("shards.info");- assertNotNull("Unable to obtain shards.info", shardsInfo);+ Object shardsInfo = qResponse.getResponse().get(ShardParams.SHARDS_INFO);+ assertNotNull("Unable to obtain "+ShardParams.SHARDS_INFO, shardsInfo);// Iterate over shards-info and check what cores respondedSimpleOrderedMap<?> shardsInfoMap = (SimpleOrderedMap<?>)shardsInfo;@@ -441,9 +441,9 @@ public class CloudSolrClientTest extends AbstractFullDistribZkTestBase {List<String> shardAddresses = new ArrayList<String>();while (itr.hasNext()) {Map.Entry<String, ?> e = itr.next();- assertTrue("Did not find map-type value in shards.info", e.getValue() instanceof Map);+ assertTrue("Did not find map-type value in "+ShardParams.SHARDS_INFO, e.getValue() instanceof Map);String shardAddress = (String)((Map)e.getValue()).get("shardAddress");- assertNotNull("shards.info did not return 'shardAddress' parameter", shardAddress);+ assertNotNull(ShardParams.SHARDS_INFO+" did not return 'shardAddress' parameter", shardAddress);shardAddresses.add(shardAddress);}log.info("Shards giving the response: " + Arrays.toString(shardAddresses.toArray()));diff --git a/solr/solrj/src/test/org/apache/solr/common/params/ShardParamsTest.java b/solr/solrj/src/test/org/apache/solr/common/params/ShardParamsTest.javanew file mode 100644index 00000000000..da6c25dd2f9--- /dev/null+++ b/solr/solrj/src/test/org/apache/solr/common/params/ShardParamsTest.java@@ -0,0 +1,50 @@+package org.apache.solr.common.params;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import org.apache.lucene.util.LuceneTestCase;++/**+ * This class tests backwards compatibility of {@link ShardParams} parameter constants.+ * If someone accidentally changes those constants then this test will flag that up.+ */+public class ShardParamsTest extends LuceneTestCase+{+ public void testShards() { assertEquals(ShardParams.SHARDS, "shards"); }++ public void testShardsRows() { assertEquals(ShardParams.SHARDS_ROWS, "shards.rows"); }+ public void testShardsStart() { assertEquals(ShardParams.SHARDS_START, "shards.start"); }++ public void testIds() { assertEquals(ShardParams.IDS, "ids"); }++ public void testIsShard() { assertEquals(ShardParams.IS_SHARD, "isShard"); }++ public void testShardUrl() { assertEquals(ShardParams.SHARD_URL, "shard.url"); }++ public void testShardsQt() { assertEquals(ShardParams.SHARDS_QT, "shards.qt"); }++ public void testShardsInfo() { assertEquals(ShardParams.SHARDS_INFO, "shards.info"); }++ public void testShardsTolerant() { assertEquals(ShardParams.SHARDS_TOLERANT, "shards.tolerant"); }++ public void testShardsPurpose() { assertEquals(ShardParams.SHARDS_PURPOSE, "shards.purpose"); }++ public void testRoute() { assertEquals(ShardParams._ROUTE_, "_route_"); }++ public void testDistribSinglePass() { assertEquals(ShardParams.DISTRIB_SINGLE_PASS, "distrib.singlePass"); }+}