mirror of https://github.com/apache/lucene.git
SOLR-6770 Optimize tests to avoid duplicate RE[BST calls
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1651308 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d492a3b1b4
commit
2b1d34dfd9
|
@ -229,7 +229,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void testForResponseElement(RestTestHarness harness,
|
public static Map testForResponseElement(RestTestHarness harness,
|
||||||
String testServerBaseUrl,
|
String testServerBaseUrl,
|
||||||
String uri,
|
String uri,
|
||||||
CloudSolrClient cloudSolrServer,List<String> jsonPath,
|
CloudSolrClient cloudSolrServer,List<String> jsonPath,
|
||||||
|
@ -257,6 +257,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(MessageFormat.format("Could not get expected value {0} for path {1} full output {2}", expected, jsonPath, getAsString(m)), success);
|
assertTrue(MessageFormat.format("Could not get expected value {0} for path {1} full output {2}", expected, jsonPath, getAsString(m)), success);
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReqParams() throws Exception{
|
public void testReqParams() throws Exception{
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.solr.handler;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -39,6 +40,9 @@ import org.junit.After;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static org.apache.solr.handler.TestBlobHandler.getAsString;
|
||||||
|
|
||||||
public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
static final Logger log = LoggerFactory.getLogger(TestSolrConfigHandlerCloud.class);
|
static final Logger log = LoggerFactory.getLogger(TestSolrConfigHandlerCloud.class);
|
||||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||||
|
@ -102,23 +106,14 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(
|
Map result = TestSolrConfigHandler.testForResponseElement(null,
|
||||||
null,
|
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/config/params?wt=json",
|
"/config/params?wt=json",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("response", "params", "x", "a"),
|
asList("response", "params", "x", "a"),
|
||||||
"A val",
|
"A val",
|
||||||
10);
|
10);
|
||||||
|
compareValues(result, "B val", asList("response", "params", "x", "b"));
|
||||||
TestSolrConfigHandler.testForResponseElement(
|
|
||||||
null,
|
|
||||||
urls.get(random().nextInt(urls.size())),
|
|
||||||
"/config/params?wt=json",
|
|
||||||
cloudClient,
|
|
||||||
Arrays.asList("response", "params", "x", "b"),
|
|
||||||
"B val",
|
|
||||||
10);
|
|
||||||
|
|
||||||
payload = "{\n" +
|
payload = "{\n" +
|
||||||
"'create-requesthandler' : { 'name' : '/dump', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
|
"'create-requesthandler' : { 'name' : '/dump', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
|
||||||
|
@ -130,7 +125,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/config/overlay?wt=json",
|
"/config/overlay?wt=json",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("overlay", "requestHandler", "/dump", "name"),
|
asList("overlay", "requestHandler", "/dump", "name"),
|
||||||
"/dump",
|
"/dump",
|
||||||
10);
|
10);
|
||||||
|
|
||||||
|
@ -138,14 +133,14 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/dump?wt=json&useParams=x",
|
"/dump?wt=json&useParams=x",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("params", "a"),
|
asList("params", "a"),
|
||||||
"A val",
|
"A val",
|
||||||
5);
|
5);
|
||||||
TestSolrConfigHandler.testForResponseElement(null,
|
TestSolrConfigHandler.testForResponseElement(null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/dump?wt=json&useParams=x&a=fomrequest",
|
"/dump?wt=json&useParams=x&a=fomrequest",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("params", "a"),
|
asList("params", "a"),
|
||||||
"fomrequest",
|
"fomrequest",
|
||||||
5);
|
5);
|
||||||
|
|
||||||
|
@ -155,19 +150,19 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config?wt=json", payload);
|
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config?wt=json", payload);
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(null,
|
result = TestSolrConfigHandler.testForResponseElement(null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/config/overlay?wt=json",
|
"/config/overlay?wt=json",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("overlay", "requestHandler", "/dump1", "name"),
|
asList("overlay", "requestHandler", "/dump1", "name"),
|
||||||
"/dump1",
|
"/dump1",
|
||||||
10);
|
10);
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(null,
|
result = TestSolrConfigHandler.testForResponseElement(null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/dump1?wt=json",
|
"/dump1?wt=json",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("params", "a"),
|
asList("params", "a"),
|
||||||
"A val",
|
"A val",
|
||||||
5);
|
5);
|
||||||
|
|
||||||
|
@ -184,40 +179,24 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(
|
result = TestSolrConfigHandler.testForResponseElement(
|
||||||
null,
|
null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/config/params?wt=json",
|
"/config/params?wt=json",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("response", "params", "y", "c"),
|
asList("response", "params", "y", "c"),
|
||||||
"CY val",
|
"CY val",
|
||||||
10);
|
10);
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(null,
|
result = TestSolrConfigHandler.testForResponseElement(null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/dump?wt=json&useParams=y",
|
"/dump?wt=json&useParams=y",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("params", "c"),
|
asList("params", "c"),
|
||||||
"CY val",
|
"CY val",
|
||||||
5);
|
5);
|
||||||
|
compareValues(result, "BY val", asList("params", "b"));
|
||||||
|
compareValues(result, null, asList("params", "a"));
|
||||||
TestSolrConfigHandler.testForResponseElement(null,
|
|
||||||
urls.get(random().nextInt(urls.size())),
|
|
||||||
"/dump1?wt=json&useParams=y",
|
|
||||||
cloudClient,
|
|
||||||
Arrays.asList("params", "b"),
|
|
||||||
"BY val",
|
|
||||||
5);
|
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(null,
|
|
||||||
urls.get(random().nextInt(urls.size())),
|
|
||||||
"/dump1?wt=json&useParams=y",
|
|
||||||
cloudClient,
|
|
||||||
Arrays.asList("params", "a"),
|
|
||||||
null,
|
|
||||||
5);
|
|
||||||
|
|
||||||
payload = " {\n" +
|
payload = " {\n" +
|
||||||
" 'update' : {'y': {\n" +
|
" 'update' : {'y': {\n" +
|
||||||
" 'c':'CY val modified',\n" +
|
" 'c':'CY val modified',\n" +
|
||||||
|
@ -230,23 +209,16 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(
|
result = TestSolrConfigHandler.testForResponseElement(
|
||||||
null,
|
null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/config/params?wt=json",
|
"/config/params?wt=json",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("response", "params", "y", "c"),
|
asList("response", "params", "y", "c"),
|
||||||
"CY val modified",
|
"CY val modified",
|
||||||
10);
|
10);
|
||||||
|
compareValues(result, "EY val", asList("response", "params", "y", "e"));
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(
|
|
||||||
null,
|
|
||||||
urls.get(random().nextInt(urls.size())),
|
|
||||||
"/config/params?wt=json",
|
|
||||||
cloudClient,
|
|
||||||
Arrays.asList("response", "params", "y", "e"),
|
|
||||||
"EY val",
|
|
||||||
10);
|
|
||||||
|
|
||||||
payload = " {\n" +
|
payload = " {\n" +
|
||||||
" 'set' : {'y': {\n" +
|
" 'set' : {'y': {\n" +
|
||||||
|
@ -258,23 +230,16 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
|
|
||||||
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
||||||
TestSolrConfigHandler.testForResponseElement(
|
result = TestSolrConfigHandler.testForResponseElement(
|
||||||
null,
|
null,
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/config/params?wt=json",
|
"/config/params?wt=json",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("response", "params", "y", "p"),
|
asList("response", "params", "y", "p"),
|
||||||
"P val",
|
"P val",
|
||||||
10);
|
10);
|
||||||
|
compareValues(result, null, asList("response", "params", "y", "c"));
|
||||||
|
|
||||||
TestSolrConfigHandler.testForResponseElement(
|
|
||||||
null,
|
|
||||||
urls.get(random().nextInt(urls.size())),
|
|
||||||
"/config/params?wt=json",
|
|
||||||
cloudClient,
|
|
||||||
Arrays.asList("response", "params", "y", "c"),
|
|
||||||
null,
|
|
||||||
10);
|
|
||||||
payload = " {'delete' : 'y'}";
|
payload = " {'delete' : 'y'}";
|
||||||
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload);
|
||||||
TestSolrConfigHandler.testForResponseElement(
|
TestSolrConfigHandler.testForResponseElement(
|
||||||
|
@ -282,11 +247,16 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||||
urls.get(random().nextInt(urls.size())),
|
urls.get(random().nextInt(urls.size())),
|
||||||
"/config/params?wt=json",
|
"/config/params?wt=json",
|
||||||
cloudClient,
|
cloudClient,
|
||||||
Arrays.asList("response", "params", "y", "p"),
|
asList("response", "params", "y", "p"),
|
||||||
null,
|
null,
|
||||||
10);
|
10);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void compareValues(Map result, String expected, List<String> jsonPath) {
|
||||||
|
assertTrue(MessageFormat.format("Could not get expected value {0} for path {1} full output {2}", expected, jsonPath, getAsString(result)),
|
||||||
|
Objects.equals(expected, ConfigOverlay.getObjectByPath(result, false, jsonPath)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue