use of org.apache.solr.util.RestTestHarness in project lucene-solr by apache.
the class TestCryptoKeys method setupHarnesses.
private void setupHarnesses() {
for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
restTestHarnesses.add(harness);
}
}
use of org.apache.solr.util.RestTestHarness in project lucene-solr by apache.
the class TestReqParamsAPI method setupHarnesses.
private void setupHarnesses() {
for (final JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {
RestTestHarness harness = new RestTestHarness(() -> jettySolrRunner.getBaseUrl().toString() + "/" + COLL_NAME);
if (true) {
harness.setServerProvider(() -> jettySolrRunner.getBaseUrl().toString() + "/____v2/c/" + COLL_NAME);
}
restTestHarnesses.add(harness);
}
}
use of org.apache.solr.util.RestTestHarness in project lucene-solr by apache.
the class TestReqParamsAPI method testReqParams.
private void testReqParams() throws Exception {
CloudSolrClient cloudClient = cluster.getSolrClient();
DocCollection coll = cloudClient.getZkStateReader().getClusterState().getCollection(COLL_NAME);
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" + "'create-requesthandler' : { 'name' : '/dump0', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" + "}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload);
payload = "{\n" + "'create-requesthandler' : { 'name' : '/dump1', 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" + "}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload);
AbstractFullDistribZkTestBase.waitForRecoveriesToFinish(COLL_NAME, cloudClient.getZkStateReader(), false, true, 90);
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"));
TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/overlay?wt=json", cloudClient, asList("overlay", "requestHandler", "/dump0", "name"), "/dump0", 10);
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/dump0?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())), "/dump0?wt=json&useParams=x&a=fomrequest", cloudClient, asList("params", "a"), "fomrequest", 5);
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"));
compareValues(result, null, asList("response", "params", "y", "a"));
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/dump1?wt=json&useParams=y", cloudClient, asList("params", "c"), "CY val", 5);
compareValues(result, "BY val", asList("params", "b"));
compareValues(result, "A val", asList("params", "a"));
compareValues(result, Arrays.asList("val 1", "val 2"), asList("params", "d"));
compareValues(result, "20", asList("params", "i"));
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/requestHandler?componentName=/dump1&expandParams=true&wt=json&useParams=y&c=CC", cloudClient, asList("config", "requestHandler", "/dump1", "_useParamsExpanded_", "x", "a"), "A val", 5);
compareValues(result, "B val", asList("config", "requestHandler", "/dump1", "_useParamsExpanded_", "x", "b"));
compareValues(result, "CY val", asList("config", "requestHandler", "/dump1", "_useParamsExpanded_", "y", "c"));
compareValues(result, "BY val", asList("config", "requestHandler", "/dump1", "_useParamsExpanded_", "y", "b"));
compareValues(result, "A val", asList("config", "requestHandler", "/dump1", "_effectiveParams_", "a"));
compareValues(result, "BY val", asList("config", "requestHandler", "/dump1", "_effectiveParams_", "b"));
compareValues(result, "CC", asList("config", "requestHandler", "/dump1", "_effectiveParams_", "c"));
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"));
compareValues(result, 2l, asList("response", "params", "y", "", "v"));
compareValues(result, 0l, asList("response", "params", "x", "", "v"));
payload = "{update :{x : {_appends_ :{ add : 'first' }, _invariants_ : {fixed: f }}}}";
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", "x", "_appends_", "add"), "first", 10);
compareValues(result, "f", asList("response", "params", "x", "_invariants_", "fixed"));
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/dump1?wt=json&fixed=changeit&add=second", cloudClient, asList("params", "fixed"), "f", 5);
compareValues(result, new Predicate() {
@Override
public boolean test(Object o) {
List l = (List) o;
return l.contains("first") && l.contains("second");
}
}, asList("params", "add"));
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);
}
use of org.apache.solr.util.RestTestHarness in project lucene-solr by apache.
the class TestSolrConfigHandlerCloud method testAdminPath.
private void testAdminPath() throws Exception {
String testServerBaseUrl = getRandomServer(cloudClient, "collection1");
RestTestHarness writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
String payload = "{\n" + "'create-requesthandler' : { 'name' : '/admin/luke', " + "'class': 'org.apache.solr.handler.DumpRequestHandler'}}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(writeHarness, testServerBaseUrl, "/config/overlay?wt=json", cloudClient, Arrays.asList("overlay", "requestHandler", "/admin/luke", "class"), "org.apache.solr.handler.DumpRequestHandler", 10);
NamedList<Object> rsp = cloudClient.request(new LukeRequest());
System.out.println(rsp);
}
use of org.apache.solr.util.RestTestHarness in project lucene-solr by apache.
the class TestSolrConfigHandlerCloud method 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" + "'update-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);
}
Aggregations