You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "janhoy (via GitHub)" <gi...@apache.org> on 2026/10/07 09:05:14 UTC
[PR] PicoCLI: Fix SOLR_CONNECTION fallback and other small improvements [solr]
janhoy opened a new pull request, #5054:
URL: https://github.com/apache/solr/pull/5054
- **`SOLR_CONNECTION` fallback was dead on both parser paths.** `CliDefaultValueProvider` and `CLIUtils.resolveSolrConnectionFromCli` read the `solr-connection` property, but `EnvUtils` maps `SOLR_CONNECTION` to `solr.connection` and its camelCase fallback can't bridge a hyphen, so the documented "unnecessary if SOLR_CONNECTION is defined in solr.in.sh" never worked. Now reads `solr.connection`. Covered by the new `CliDefaultValueProviderTest` (picocli) and two tests in `CLIUtilsTest` (commons-cli).
- **`bin/solr start --help` (picocli) still advertised `--prompt-inputs`**, which was renamed to `--script-inputs` in SOLR-18468; `bin/solr` and `RunExampleTool` already use the new name.
- **`bin/solr create --help` example used `-s 2` for shards**; `-s` is `--solr-connection`, shards is `-sh`.
Ref-guide CLI pages regenerated (`solr-start.adoc`, `solr-create.adoc`). No behaviour change on the commons-cli path other than the `SOLR_CONNECTION` fallback now taking effect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] CLI: Fix SOLR_CONNECTION fallback and other small improvements [solr]
Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy merged PR #5054:
URL: https://github.com/apache/solr/pull/5054
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] CLI: Fix SOLR_CONNECTION fallback and other small improvements [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #5054:
URL: https://github.com/apache/solr/pull/5054#discussion_r4205934160
##########
solr/core/src/test/org/apache/solr/cli/CliDefaultValueProviderTest.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.solr.cli;
+
+import org.apache.solr.SolrTestCase;
+import org.junit.Test;
+import picocli.CommandLine;
+
+public class CliDefaultValueProviderTest extends SolrTestCase {
+
+ private static String defaultFor(String optionName, String paramLabel) throws Exception {
+ var spec = CommandLine.Model.OptionSpec.builder(optionName).paramLabel(paramLabel).build();
+ return new CliDefaultValueProvider().defaultValue(spec);
+ }
+
+ @Test
+ public void testConnectionDefaultsFromSystemProperties() throws Exception {
+ System.setProperty("solr.connection", "zk1:2181/solr");
+ System.setProperty("zkHost", "zk2:2181/solr");
+ System.setProperty("solr.url", "http://solr.local:8983");
+ try {
+ assertEquals("zk1:2181/solr", defaultFor("--solr-connection", "<solrConnection>"));
+ assertEquals("zk2:2181/solr", defaultFor("--zk-host", "<zkHost>"));
+ assertEquals("http://solr.local:8983", defaultFor("--solr-url", "<solrUrl>"));
+ } finally {
+ System.clearProperty("solr.connection");
+ System.clearProperty("zkHost");
+ System.clearProperty("solr.url");
+ }
Review Comment:
Our tests clean up system properties. Do you not know this? LLMs didn't get the memo...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] CLI: Fix SOLR_CONNECTION fallback and other small improvements [solr]
Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #5054:
URL: https://github.com/apache/solr/pull/5054#discussion_r4206484249
##########
solr/core/src/test/org/apache/solr/cli/CliDefaultValueProviderTest.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.solr.cli;
+
+import org.apache.solr.SolrTestCase;
+import org.junit.Test;
+import picocli.CommandLine;
+
+public class CliDefaultValueProviderTest extends SolrTestCase {
+
+ private static String defaultFor(String optionName, String paramLabel) throws Exception {
+ var spec = CommandLine.Model.OptionSpec.builder(optionName).paramLabel(paramLabel).build();
+ return new CliDefaultValueProvider().defaultValue(spec);
+ }
+
+ @Test
+ public void testConnectionDefaultsFromSystemProperties() throws Exception {
+ System.setProperty("solr.connection", "zk1:2181/solr");
+ System.setProperty("zkHost", "zk2:2181/solr");
+ System.setProperty("solr.url", "http://solr.local:8983");
+ try {
+ assertEquals("zk1:2181/solr", defaultFor("--solr-connection", "<solrConnection>"));
+ assertEquals("zk2:2181/solr", defaultFor("--zk-host", "<zkHost>"));
+ assertEquals("http://solr.local:8983", defaultFor("--solr-url", "<solrUrl>"));
+ } finally {
+ System.clearProperty("solr.connection");
+ System.clearProperty("zkHost");
+ System.clearProperty("solr.url");
+ }
Review Comment:
Yea. Note that `SolrTestCase` only cleans up sysprops at the end of the test class, so individual test methods need to handle props individually. But I suppose methods within a test class always runs sequentially so they won't interfere, and since `testNoDefaultWhenPropertiesUnset` clears props itself, there is no need for an explicit cleanup here. Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] CLI: Fix SOLR_CONNECTION fallback and other small improvements [solr]
Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #5054:
URL: https://github.com/apache/solr/pull/5054#discussion_r4206494319
##########
solr/core/src/test/org/apache/solr/cli/CliDefaultValueProviderTest.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.solr.cli;
+
+import org.apache.solr.SolrTestCase;
+import org.junit.Test;
+import picocli.CommandLine;
+
+public class CliDefaultValueProviderTest extends SolrTestCase {
+
+ private static String defaultFor(String optionName, String paramLabel) throws Exception {
+ var spec = CommandLine.Model.OptionSpec.builder(optionName).paramLabel(paramLabel).build();
+ return new CliDefaultValueProvider().defaultValue(spec);
+ }
+
+ @Test
+ public void testConnectionDefaultsFromSystemProperties() throws Exception {
+ System.setProperty("solr.connection", "zk1:2181/solr");
+ System.setProperty("zkHost", "zk2:2181/solr");
+ System.setProperty("solr.url", "http://solr.local:8983");
+ try {
+ assertEquals("zk1:2181/solr", defaultFor("--solr-connection", "<solrConnection>"));
+ assertEquals("zk2:2181/solr", defaultFor("--zk-host", "<zkHost>"));
+ assertEquals("http://solr.local:8983", defaultFor("--solr-url", "<solrUrl>"));
+ } finally {
+ System.clearProperty("solr.connection");
+ System.clearProperty("zkHost");
+ System.clearProperty("solr.url");
+ }
Review Comment:
I added a line to AGENTS...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org