-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bin/solr in branch_9_7 has commands that fail #2710
Changes from 14 commits
b0da37e
2b18333
5c0d208
777aefd
872d79e
49ffeb4
bf4c495
3ae097d
b1bb0ab
7a5a51f
74f66d8
394a7b1
ad7ebb8
e8ee34b
edbff4b
f90ce33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,6 +22,7 @@ | |||||||||||
import java.io.PrintStream; | ||||||||||||
import java.lang.invoke.MethodHandles; | ||||||||||||
import java.util.List; | ||||||||||||
import java.util.Locale; | ||||||||||||
import java.util.Map; | ||||||||||||
import java.util.Optional; | ||||||||||||
import java.util.Set; | ||||||||||||
|
@@ -40,6 +41,7 @@ | |||||||||||
import org.apache.solr.client.solrj.request.CoreAdminRequest; | ||||||||||||
import org.apache.solr.client.solrj.request.GenericSolrRequest; | ||||||||||||
import org.apache.solr.common.cloud.ZkStateReader; | ||||||||||||
import org.apache.solr.common.util.EnvUtils; | ||||||||||||
import org.apache.solr.common.util.NamedList; | ||||||||||||
import org.noggit.CharArr; | ||||||||||||
import org.noggit.JSONWriter; | ||||||||||||
|
@@ -122,16 +124,36 @@ public List<Option> getOptions() { | |||||||||||
.desc( | ||||||||||||
"Skip safety checks when deleting the configuration directory used by a collection.") | ||||||||||||
.build(), | ||||||||||||
Option.builder("p") | ||||||||||||
.longOpt("port") | ||||||||||||
.deprecated( | ||||||||||||
DeprecatedAttributes.builder() | ||||||||||||
.setForRemoval(true) | ||||||||||||
.setSince("9.7") | ||||||||||||
.setDescription("Use --solr-url instead") | ||||||||||||
.get()) | ||||||||||||
.argName("PORT") | ||||||||||||
.hasArg() | ||||||||||||
.required(false) | ||||||||||||
.desc("Port of a local Solr instance where you want to create the new core.") | ||||||||||||
.build(), | ||||||||||||
SolrCLI.OPTION_SOLRURL, | ||||||||||||
SolrCLI.OPTION_SOLRURL_DEPRECATED, | ||||||||||||
SolrCLI.OPTION_ZKHOST, | ||||||||||||
SolrCLI.OPTION_ZKHOST_DEPRECATED); | ||||||||||||
SolrCLI.OPTION_ZKHOST_DEPRECATED, | ||||||||||||
SolrCLI.OPTION_VERBOSE_DEPRECATED); | ||||||||||||
Comment on lines
+143
to
+144
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here:
Suggested change
|
||||||||||||
} | ||||||||||||
|
||||||||||||
@Override | ||||||||||||
public void runImpl(CommandLine cli) throws Exception { | ||||||||||||
SolrCLI.raiseLogLevelUnlessVerbose(cli); | ||||||||||||
|
||||||||||||
// If a port is provided, inject it into the environment variables so | ||||||||||||
// that {@link SolrCLI#getDefaultSolrUrl()} can use it instead of the default 8983. | ||||||||||||
if (cli.hasOption("p")) { | ||||||||||||
EnvUtils.setProperty("jetty.port", cli.getOptionValue("p")); | ||||||||||||
} | ||||||||||||
|
||||||||||||
try (var solrClient = SolrCLI.getSolrClient(cli)) { | ||||||||||||
Map<String, Object> systemInfo = | ||||||||||||
solrClient | ||||||||||||
|
@@ -248,21 +270,22 @@ protected void deleteCollection(CloudSolrClient cloudSolrClient, CommandLine cli | |||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
if (response != null) { | ||||||||||||
// pretty-print the response to stdout | ||||||||||||
CharArr arr = new CharArr(); | ||||||||||||
new JSONWriter(arr, 2).write(response.asMap()); | ||||||||||||
echo(arr.toString()); | ||||||||||||
echo("\n"); | ||||||||||||
if (isVerbose()) { | ||||||||||||
if (response != null) { | ||||||||||||
// pretty-print the response to stdout | ||||||||||||
CharArr arr = new CharArr(); | ||||||||||||
new JSONWriter(arr, 2).write(response.asMap()); | ||||||||||||
echo(arr.toString()); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
echo("Deleted collection '" + collectionName + "' using CollectionAdminRequest"); | ||||||||||||
echo(String.format(Locale.ROOT, "\nDeleted collection '%s'", collectionName)); | ||||||||||||
} | ||||||||||||
|
||||||||||||
protected void deleteCore(CommandLine cli, SolrClient solrClient) throws Exception { | ||||||||||||
String coreName = cli.getOptionValue(NAME); | ||||||||||||
|
||||||||||||
echo("\nDeleting core '" + coreName + "' using CoreAdminRequest\n"); | ||||||||||||
echoIfVerbose("\nDeleting core '" + coreName + "'", cli); | ||||||||||||
|
||||||||||||
NamedList<Object> response; | ||||||||||||
try { | ||||||||||||
|
@@ -281,5 +304,6 @@ protected void deleteCore(CommandLine cli, SolrClient solrClient) throws Excepti | |||||||||||
echoIfVerbose((String) response.get("response"), cli); | ||||||||||||
echoIfVerbose("\n", cli); | ||||||||||||
} | ||||||||||||
echo(String.format(Locale.ROOT, "\nDeleted core '%s'", coreName)); | ||||||||||||
} | ||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,14 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.TimeUnit; | ||
import org.apache.commons.cli.CommandLine; | ||
import org.apache.commons.cli.Option; | ||
import org.apache.solr.client.solrj.SolrQuery; | ||
import org.apache.solr.client.solrj.SolrRequest; | ||
import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient; | ||
import org.apache.solr.client.solrj.impl.CloudSolrClient; | ||
import org.apache.solr.client.solrj.impl.Http2SolrClient; | ||
import org.apache.solr.client.solrj.request.GenericSolrRequest; | ||
import org.apache.solr.client.solrj.response.QueryResponse; | ||
import org.apache.solr.common.cloud.ClusterState; | ||
|
@@ -92,8 +94,8 @@ public void runImpl(CommandLine cli) throws Exception { | |
CLIO.err("Healthcheck tool only works in Solr Cloud mode."); | ||
System.exit(1); | ||
} | ||
echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli); | ||
try (CloudHttp2SolrClient cloudSolrClient = SolrCLI.getCloudHttp2SolrClient(zkHost)) { | ||
echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli); | ||
cloudSolrClient.connect(); | ||
runCloudTool(cloudSolrClient, cli); | ||
} | ||
|
@@ -170,7 +172,15 @@ protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) th | |
q = new SolrQuery("*:*"); | ||
q.setRows(0); | ||
q.set(DISTRIB, "false"); | ||
try (var solrClientForCollection = SolrCLI.getSolrClient(coreUrl)) { | ||
|
||
// SolrCLI.getSolrClient converts the coreUrl back into a root Solr url, but we need to | ||
// talk to specific core so manually creating the client. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, would you say this is a bug, or is it well documented in the javadoc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Humm..... I read it and it says:
I think this is the only place we need a core specific url... Do you think it should support that use case as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked a bit more at the code, and decided to go with the javadoc approach! |
||
// try (var solrClientForCollection = SolrCLI.getSolrClient(coreUrl)) { | ||
try (var solrClientForCollection = | ||
new Http2SolrClient.Builder(coreUrl) | ||
.withMaxConnectionsPerHost(32) | ||
.withKeyStoreReloadInterval(-1, TimeUnit.SECONDS) | ||
.build()) { | ||
qr = solrClientForCollection.query(q); | ||
numDocs = qr.getResults().getNumFound(); | ||
try (var solrClient = SolrCLI.getSolrClient(replicaCoreProps.getBaseUrl())) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,31 @@ teardown() { | |
assert_output --partial "Created new core 'COLL_NAME'" | ||
} | ||
|
||
@test "create_core works" { | ||
run solr start | ||
run solr create_core -c COLL_NAME | ||
assert_output --partial "Created new core 'COLL_NAME'" | ||
} | ||
|
||
@test "create for cloud mode" { | ||
run solr start -c | ||
run solr create -c COLL_NAME | ||
assert_output --partial "Created collection 'COLL_NAME'" | ||
} | ||
|
||
@test "ensure -p port parameter is supported" { | ||
solr start -p ${SOLR2_PORT} | ||
solr assert --not-started http://localhost:${SOLR_PORT} --timeout 5000 | ||
solr assert --started http://localhost:${SOLR2_PORT} --timeout 5000 | ||
|
||
run solr create -c COLL_NAME -p ${SOLR2_PORT} | ||
assert_output --partial "Created new core 'COLL_NAME'" | ||
} | ||
|
||
@test "ensure -V verbose parameter is supported" { | ||
solr start | ||
solr assert --started http://localhost:${SOLR_PORT} --timeout 5000 | ||
|
||
run solr create -c COLL_NAME -V | ||
assert_output --partial "Created new core 'COLL_NAME'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not this assert a string that is only printed in verbose mode? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question... I think for core, you got this message, and for collection, you got a different dump (that was more like the api response). I changed it so that both core and collection output a short message like this, and then if you add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I just expected the assert to fail without the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I finally understand what you mean, and am looking at it and then will merge. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be eventually