You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2015/02/06 10:06:00 UTC
svn commit: r1657761 - in
/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler:
TestReqParamsAPI.java TestSolrConfigHandlerCloud.java
Author: noble
Date: Fri Feb 6 09:05:59 2015
New Revision: 1657761
URL: http://svn.apache.org/r1657761
Log:
SOLR-6924: Splitting the testcase because more SolrConfigHandler features and testcases are coming up
Added:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java (with props)
Modified:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java
Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java?rev=1657761&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java (added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReqParamsAPI.java Fri Feb 6 09:05:59 2015
@@ -0,0 +1,250 @@
+package org.apache.solr.handler;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.core.RequestParams;
+import org.apache.solr.core.TestSolrConfigHandler;
+import org.apache.solr.util.RESTfulServerProvider;
+import org.apache.solr.util.RestTestHarness;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static java.util.Arrays.asList;
+import static org.apache.solr.handler.TestSolrConfigHandlerCloud.compareValues;
+
+/*
+ * 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.
+ */
+
+@LuceneTestCase.BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-6924")
+public class TestReqParamsAPI extends AbstractFullDistribZkTestBase {
+ static final Logger log = LoggerFactory.getLogger(TestSolrConfigHandlerCloud.class);
+ private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
+
+ private void setupHarnesses() {
+ for (final SolrClient client : clients) {
+ RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() {
+ @Override
+ public String getBaseURL() {
+ return ((HttpSolrClient) client).getBaseURL();
+ }
+ });
+ restTestHarnesses.add(harness);
+ }
+ }
+
+ @Override
+ public void distribTearDown() throws Exception {
+ super.distribTearDown();
+ for (RestTestHarness r : restTestHarnesses) {
+ r.close();
+ }
+ }
+
+ @Test
+ public void test() throws Exception {
+ setupHarnesses();
+ testReqParams();
+ }
+
+ private void testReqParams() throws Exception {
+ DocCollection coll = cloudClient.getZkStateReader().getClusterState().getCollection("collection1");
+ List<String> urls = new ArrayList<>();
+ for (Slice slice : coll.getSlices()) {
+ for (Replica replica : slice.getReplicas())
+ urls.add("" + replica.get(ZkStateReader.BASE_URL_PROP) + "/" + replica.get(ZkStateReader.CORE_NAME_PROP));
+ }
+
+ RestTestHarness writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
+ String payload = " {\n" +
+ " 'set' : {'x': {" +
+ " 'a':'A val',\n" +
+ " 'b': 'B val'}\n" +
+ " }\n" +
+ " }";
+
+
+ TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
+
+ Map result = TestSolrConfigHandler.testForResponseElement(null,
+ urls.get(random().nextInt(urls.size())),
+ "/config/params?wt=json",
+ cloudClient,
+ asList("response", "params", "x", "a"),
+ "A val",
+ 10);
+ compareValues(result, "B val", asList("response", "params", "x", "b"));
+
+ payload = "{\n" +
+ "'create-requesthandler' : { 'name' : '/dump', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
+ "}";
+
+ TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload);
+
+ TestSolrConfigHandler.testForResponseElement(null,
+ urls.get(random().nextInt(urls.size())),
+ "/config/overlay?wt=json",
+ cloudClient,
+ asList("overlay", "requestHandler", "/dump", "name"),
+ "/dump",
+ 10);
+
+ result = TestSolrConfigHandler.testForResponseElement(null,
+ urls.get(random().nextInt(urls.size())),
+ "/dump?wt=json&useParams=x",
+ cloudClient,
+ asList("params", "a"),
+ "A val",
+ 5);
+ compareValues(result, "", asList("params", RequestParams.USEPARAM));
+
+ TestSolrConfigHandler.testForResponseElement(null,
+ urls.get(random().nextInt(urls.size())),
+ "/dump?wt=json&useParams=x&a=fomrequest",
+ cloudClient,
+ asList("params", "a"),
+ "fomrequest",
+ 5);
+
+ payload = "{\n" +
+ "'create-requesthandler' : { 'name' : '/dump1', 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" +
+ "}";
+
+ TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload);
+
+ result = TestSolrConfigHandler.testForResponseElement(null,
+ urls.get(random().nextInt(urls.size())),
+ "/config/overlay?wt=json",
+ cloudClient,
+ asList("overlay", "requestHandler", "/dump1", "name"),
+ "/dump1",
+ 10);
+
+ result = TestSolrConfigHandler.testForResponseElement(null,
+ urls.get(random().nextInt(urls.size())),
+ "/dump1?wt=json",
+ cloudClient,
+ asList("params", "a"),
+ "A val",
+ 5);
+
+
+ writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
+ payload = " {\n" +
+ " 'set' : {'y':{\n" +
+ " 'c':'CY val',\n" +
+ " 'b': 'BY val', " +
+ " 'i': 20, " +
+ " 'd': ['val 1', 'val 2']}\n" +
+ " }\n" +
+ " }";
+
+
+ TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
+
+ result = TestSolrConfigHandler.testForResponseElement(
+ null,
+ urls.get(random().nextInt(urls.size())),
+ "/config/params?wt=json",
+ cloudClient,
+ asList("response", "params", "y", "c"),
+ "CY val",
+ 10);
+ compareValues(result, 20l, asList("response", "params", "y", "i"));
+
+
+ result = TestSolrConfigHandler.testForResponseElement(null,
+ urls.get(random().nextInt(urls.size())),
+ "/dump?wt=json&useParams=y",
+ cloudClient,
+ asList("params", "c"),
+ "CY val",
+ 5);
+ compareValues(result, "BY val", asList("params", "b"));
+ compareValues(result, null, asList("params", "a"));
+ compareValues(result, Arrays.asList("val 1", "val 2"), asList("params", "d"));
+ compareValues(result, "20", asList("params", "i"));
+ payload = " {\n" +
+ " 'update' : {'y': {\n" +
+ " 'c':'CY val modified',\n" +
+ " 'e':'EY val',\n" +
+ " 'b': 'BY val'" +
+ "}\n" +
+ " }\n" +
+ " }";
+
+
+ TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
+
+ result = TestSolrConfigHandler.testForResponseElement(
+ null,
+ urls.get(random().nextInt(urls.size())),
+ "/config/params?wt=json",
+ cloudClient,
+ asList("response", "params", "y", "c"),
+ "CY val modified",
+ 10);
+ compareValues(result, "EY val", asList("response", "params", "y", "e"));
+
+
+ payload = " {\n" +
+ " 'set' : {'y': {\n" +
+ " 'p':'P val',\n" +
+ " 'q': 'Q val'" +
+ "}\n" +
+ " }\n" +
+ " }";
+
+
+ TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
+ result = TestSolrConfigHandler.testForResponseElement(
+ null,
+ urls.get(random().nextInt(urls.size())),
+ "/config/params?wt=json",
+ cloudClient,
+ asList("response", "params", "y", "p"),
+ "P val",
+ 10);
+ compareValues(result, null, asList("response", "params", "y", "c"));
+
+ payload = " {'delete' : 'y'}";
+ TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
+ TestSolrConfigHandler.testForResponseElement(
+ null,
+ urls.get(random().nextInt(urls.size())),
+ "/config/params?wt=json",
+ cloudClient,
+ asList("response", "params", "y", "p"),
+ null,
+ 10);
+
+
+ }
+
+
+}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java?rev=1657761&r1=1657760&r2=1657761&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java Fri Feb 6 09:05:59 2015
@@ -46,7 +46,6 @@ import org.slf4j.LoggerFactory;
import static java.util.Arrays.asList;
import static org.apache.solr.handler.TestBlobHandler.getAsString;
-@BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-6924")
public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
static final Logger log = LoggerFactory.getLogger(TestSolrConfigHandlerCloud.class);
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();