mirror of https://github.com/apache/lucene.git
SOLR-8045: Deploy V2 API at /v2 instead of /solr/v2
This commit is contained in:
parent
6415d912ca
commit
0fb386a864
|
@ -855,6 +855,10 @@ def testSolrExample(unpackPath, javaPath, isSrc):
|
|||
if s.find('<result name="response" numFound="3" start="0">') == -1:
|
||||
print('FAILED: response is:\n%s' % s)
|
||||
raise RuntimeError('query on solr example instance failed')
|
||||
s = load('http://localhost:8983/v2/cores')
|
||||
if s.find('"responseHeader":{"status":0,"QTime":1}') == -1:
|
||||
print('FAILED: response is:\n%s' % s)
|
||||
raise RuntimeError('query api v2 on solr example instance failed')
|
||||
finally:
|
||||
# Stop server:
|
||||
print(' stop server using: bin/solr stop -p 8983')
|
||||
|
|
|
@ -164,6 +164,8 @@ New Features
|
|||
|
||||
* SOLR-9986: Implement DatePointField (Cao Manh Dat, Tomás Fernández Löbbe)
|
||||
|
||||
* SOLR-8045: Deploy V2 API at /v2 instead of /solr/v2 (Cao Manh Dat, Noble Paul)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class V2HttpCall extends HttpSolrCall {
|
|||
|
||||
protected void init() throws Exception {
|
||||
String path = this.path;
|
||||
String fullPath = path = path.substring(3);//strip off '/v2'
|
||||
String fullPath = path = path.substring(7);//strip off '/____v2'
|
||||
try {
|
||||
pieces = getPathSegments(path);
|
||||
if (pieces.size() == 0) {
|
||||
|
|
|
@ -194,7 +194,7 @@ public class PluginBag<T> implements AutoCloseable {
|
|||
String registerAt = plugin.pluginInfo.attributes.get("registerPath");
|
||||
if (registerAt != null) {
|
||||
List<String> strs = StrUtils.splitSmart(registerAt, ',');
|
||||
disableHandler = !strs.contains("/");
|
||||
disableHandler = !strs.contains("/solr");
|
||||
registerApi = strs.contains("/v2");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -388,7 +388,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
|||
path += request.getPathInfo();
|
||||
}
|
||||
|
||||
if (isV2Enabled && (path.startsWith("/v2/") || path.equals("/v2"))) {
|
||||
if (isV2Enabled && (path.startsWith("/____v2/") || path.equals("/____v2"))) {
|
||||
return new V2HttpCall(this, cores, request, response, false);
|
||||
} else {
|
||||
return new HttpSolrCall(this, cores, request, response, retry);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
</requestHandler>
|
||||
|
||||
|
||||
<requestHandler name="/dump" class="DumpRequestHandler" initParams="a" registerPath="/,/v2">
|
||||
<requestHandler name="/dump" class="DumpRequestHandler" initParams="a" registerPath="/solr,/v2">
|
||||
<lst name="defaults">
|
||||
<str name="a">${my.custom.variable.a:A}</str>
|
||||
<str name="b">${my.custom.variable.b:B}</str>
|
||||
|
|
|
@ -168,7 +168,7 @@ public class RulesTest extends SolrCloudTestCase {
|
|||
public void testInvokeApi() throws Exception {
|
||||
JettySolrRunner jetty = cluster.getRandomJetty(random());
|
||||
try (SolrClient client = getHttpSolrClient(jetty.getBaseUrl().toString())) {
|
||||
GenericSolrRequest req = new GenericSolrRequest(GET, "/v2/node/invoke", new ModifiableSolrParams()
|
||||
GenericSolrRequest req = new GenericSolrRequest(GET, "/____v2/node/invoke", new ModifiableSolrParams()
|
||||
.add("class", ImplicitSnitch.class.getName())
|
||||
.add("cores", "1")
|
||||
.add("freedisk", "1")
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
|
|||
|
||||
|
||||
payload = "{\n" +
|
||||
"'create-requesthandler' : { 'name' : '/test1', 'class': 'org.apache.solr.core.BlobStoreTestRequestHandler' ,registerPath: '/,/v2', 'runtimeLib' : true }\n" +
|
||||
"'create-requesthandler' : { 'name' : '/test1', 'class': 'org.apache.solr.core.BlobStoreTestRequestHandler' ,registerPath: '/solr,/v2', 'runtimeLib' : true }\n" +
|
||||
"}";
|
||||
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
"/solr", true, extraServlets);
|
||||
if (random().nextBoolean()) {
|
||||
log.info("These tests are run with V2 API");
|
||||
restTestHarness.setServerProvider(() -> jetty.getBaseUrl().toString() + "/v2/cores/" + DEFAULT_TEST_CORENAME);
|
||||
restTestHarness.setServerProvider(() -> jetty.getBaseUrl().toString() + "/____v2/cores/" + DEFAULT_TEST_CORENAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
10);
|
||||
|
||||
payload = "{\n" +
|
||||
"'update-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' ,registerPath :'/,/v2', " +
|
||||
"'update-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' ,registerPath :'/solr,/v2', " +
|
||||
" 'startup' : 'lazy' , 'a':'b' , 'defaults': {'def_a':'def A val', 'multival':['a','b','c']}}\n" +
|
||||
"}";
|
||||
runConfigCommand(writeHarness, "/config?wt=json", payload);
|
||||
|
@ -442,7 +442,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
payload = "{\n" +
|
||||
" 'add-requesthandler': {\n" +
|
||||
" name : '/dump100',\n" +
|
||||
" registerPath :'/,/v2',"+
|
||||
" registerPath :'/solr,/v2',"+
|
||||
" class : 'org.apache.solr.handler.DumpRequestHandler'," +
|
||||
" suggester: [{name: s1,lookupImpl: FuzzyLookupFactory, dictionaryImpl : DocumentDictionaryFactory}," +
|
||||
" {name: s2,lookupImpl: FuzzyLookupFactory , dictionaryImpl : DocumentExpressionDictionaryFactory}]" +
|
||||
|
@ -467,7 +467,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
payload = "{\n" +
|
||||
"'add-requesthandler' : { 'name' : '/dump101', 'class': " +
|
||||
"'" + CacheTest.class.getName() + "', " +
|
||||
" registerPath :'/,/v2'"+
|
||||
" registerPath :'/solr,/v2'"+
|
||||
", 'startup' : 'lazy'}\n" +
|
||||
"}";
|
||||
runConfigCommand(writeHarness, "/config?wt=json", payload);
|
||||
|
@ -589,7 +589,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
10);
|
||||
|
||||
payload = "{\n" +
|
||||
"'create-requesthandler' : { 'name' : '/d', registerPath :'/,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
|
||||
"'create-requesthandler' : { 'name' : '/d', registerPath :'/solr,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
|
||||
"}";
|
||||
|
||||
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload);
|
||||
|
@ -619,7 +619,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
5);
|
||||
|
||||
payload = "{\n" +
|
||||
"'create-requesthandler' : { 'name' : '/dump1', registerPath :'/,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" +
|
||||
"'create-requesthandler' : { 'name' : '/dump1', registerPath :'/solr,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" +
|
||||
"}";
|
||||
|
||||
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload);
|
||||
|
@ -794,7 +794,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
"org.apache.solr.handler.DumpRequestHandler",
|
||||
10);
|
||||
RESTfulServerProvider oldProvider = restTestHarness.getServerProvider();
|
||||
restTestHarness.setServerProvider(() -> jetty.getBaseUrl().toString() + "/v2/cores/" + DEFAULT_TEST_CORENAME);
|
||||
restTestHarness.setServerProvider(() -> jetty.getBaseUrl().toString() + "/____v2/cores/" + DEFAULT_TEST_CORENAME);
|
||||
|
||||
Map rsp = TestSolrConfigHandler.testForResponseElement(
|
||||
harness,
|
||||
|
|
|
@ -50,6 +50,9 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,10 +86,10 @@ public class V2ApiIntegrationTest extends SolrCloudTestCase {
|
|||
private void testApis() throws Exception {
|
||||
RestTestHarness restHarness = restTestHarnesses.get(0);
|
||||
ServerProvider serverProvider = (ServerProvider) restHarness.getServerProvider();
|
||||
serverProvider.baseurl = serverProvider.jettySolrRunner.getBaseUrl()+"/v2/c/"+ COLL_NAME;
|
||||
serverProvider.baseurl = serverProvider.jettySolrRunner.getBaseUrl()+"/____v2/c/"+ COLL_NAME;
|
||||
Map result = TestSolrConfigHandler.getRespMap("/get/_introspect", restHarness);
|
||||
assertEquals("/c/collection1/get", Utils.getObjectByPath(result, true, "/spec[0]/url/paths[0]"));
|
||||
serverProvider.baseurl = serverProvider.jettySolrRunner.getBaseUrl()+"/v2/collections/"+ COLL_NAME;
|
||||
serverProvider.baseurl = serverProvider.jettySolrRunner.getBaseUrl()+"/____v2/collections/"+ COLL_NAME;
|
||||
result = TestSolrConfigHandler.getRespMap("/get/_introspect", restHarness);
|
||||
assertEquals("/collections/collection1/get", Utils.getObjectByPath(result, true, "/spec[0]/url/paths[0]"));
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
|
|||
restTestHarness.setServerProvider(new RESTfulServerProvider() {
|
||||
@Override
|
||||
public String getBaseURL() {
|
||||
return jetty.getBaseUrl().toString() + "/v2/cores/" + DEFAULT_TEST_CORENAME;
|
||||
return jetty.getBaseUrl().toString() + "/____v2/cores/" + DEFAULT_TEST_CORENAME;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -86,8 +86,8 @@ public class BasicAuthIntegrationTest extends SolrCloudTestCase {
|
|||
String authcPrefix = "/admin/authentication";
|
||||
String authzPrefix = "/admin/authorization";
|
||||
if(random().nextBoolean()){
|
||||
authcPrefix = "/v2/cluster/security/authentication";
|
||||
authzPrefix = "/v2/cluster/security/authorization";
|
||||
authcPrefix = "/____v2/cluster/security/authentication";
|
||||
authzPrefix = "/____v2/cluster/security/authorization";
|
||||
}
|
||||
|
||||
NamedList<Object> rsp;
|
||||
|
|
|
@ -97,35 +97,43 @@
|
|||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
|
||||
<Set name="pattern">/v2/*</Set>
|
||||
<Set name="replacement">/solr/____v2</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="InstrumentedHandler" class="com.codahale.metrics.jetty9.InstrumentedHandler">
|
||||
<Arg><Ref refid="solrJettyMetricRegistry"/></Arg>
|
||||
<Set name="handler">
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<Ref id="RewriteHandler"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="InstrumentedHandler" class="com.codahale.metrics.jetty9.InstrumentedHandler">
|
||||
<Arg><Ref refid="solrJettyMetricRegistry"/></Arg>
|
||||
<Set name="handler">
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<Ref id="RewriteHandler"/>
|
||||
</Set>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
|
|
|
@ -850,7 +850,7 @@
|
|||
</requestHandler>
|
||||
|
||||
<!-- A request handler that returns indented JSON by default -->
|
||||
<requestHandler name="/query" class="solr.SearchHandler" registerPath="/,/v2">
|
||||
<requestHandler name="/query" class="solr.SearchHandler" registerPath="/solr,/v2">
|
||||
<lst name="defaults">
|
||||
<str name="echoParams">explicit</str>
|
||||
<str name="wt">json</str>
|
||||
|
|
|
@ -1047,8 +1047,8 @@ public class CloudSolrClient extends SolrClient {
|
|||
CONFIGSETS_HANDLER_PATH,
|
||||
AUTHC_PATH,
|
||||
AUTHZ_PATH,
|
||||
"/v2/cluster/security/authentication",
|
||||
"/v2/cluster/security/authorization"
|
||||
"/____v2/cluster/security/authentication",
|
||||
"/____v2/cluster/security/authorization"
|
||||
));
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,7 +98,7 @@ public class SolrExampleJettyTest extends SolrExampleTests {
|
|||
private String getUri(HttpSolrClient client) {
|
||||
String baseURL = client.getBaseURL();
|
||||
return random().nextBoolean() ?
|
||||
baseURL.replace("/collection1", "/v2/cores/collection1/update") :
|
||||
baseURL.replace("/collection1", "/____v2/cores/collection1/update") :
|
||||
baseURL + "/update/json/docs";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue