This is an automated email from the ASF dual-hosted git repository.
houston pushed a commit to branch branch_9_8
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9_8 by this push:
new cb1a18a6c0b SOLR-17556: Change solr examples --solr-home-dir to
--solr-home
cb1a18a6c0b is described below
commit cb1a18a6c0b8b027ae6ef79e49a9258e29ccb290
Author: Houston Putman <[email protected]>
AuthorDate: Fri Jan 10 11:02:10 2025 -0600
SOLR-17556: Change solr examples --solr-home-dir to --solr-home
---
dev-tools/scripts/smokeTestRelease.py | 4 ++--
solr/bin/solr | 9 +++++++++
.../java/org/apache/solr/cli/RunExampleTool.java | 17 +++++++++--------
.../org/apache/solr/cli/TestSolrCLIRunExample.java | 21 ++++++++++++---------
.../pages/tutorial-techproducts.adoc | 2 +-
5 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/dev-tools/scripts/smokeTestRelease.py
b/dev-tools/scripts/smokeTestRelease.py
index fbeef6375bd..cb342379e26 100755
--- a/dev-tools/scripts/smokeTestRelease.py
+++ b/dev-tools/scripts/smokeTestRelease.py
@@ -668,7 +668,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision,
version, testArgs):
java.run_java11('./gradlew --no-daemon integrationTest
-Dversion.release=%s' % version, '%s/itest.log' % unpackPath)
print(" build binary release w/ Java 11")
java.run_java11('./gradlew --no-daemon dev -Dversion.release=%s' %
version, '%s/assemble.log' % unpackPath)
- testSolrExample("%s/solr/packaging/build/dev" % unpackPath,
java.java11_home)
+ testSolrExample("%s/solr/packaging/build/dev" % unpackPath,
java.java11_home, False)
if java.run_java17:
print(" run tests w/ Java 17 and testArgs='%s'..." % testArgs)
@@ -677,7 +677,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision,
version, testArgs):
java.run_java17('./gradlew --no-daemon integrationTest
-Dversion.release=%s' % version, '%s/itest-java17.log' % unpackPath)
print(" build binary release w/ Java 17")
java.run_java17('./gradlew --no-daemon dev -Dversion.release=%s' %
version, '%s/assemble-java17.log' % unpackPath)
- testSolrExample("%s/solr/packaging/build/dev" % unpackPath,
java.java17_home)
+ testSolrExample("%s/solr/packaging/build/dev" % unpackPath,
java.java17_home, False)
else:
# Binary tarball
diff --git a/solr/bin/solr b/solr/bin/solr
index 0509f465173..0759d8ed7db 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -761,6 +761,7 @@ if [ $# -gt 0 ]; then
fi
SOLR_HOME="$2"
+ PASS_TO_RUN_EXAMPLE+=("--solr-home" "$SOLR_HOME")
shift 2
;;
-t|--data-home|-data.home)
@@ -779,6 +780,14 @@ if [ $# -gt 0 ]; then
FG="true"
shift
;;
+ --example-dir)
+ if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
+ print_usage "$SCRIPT_CMD" "Example directory is required when
using the $1 option!"
+ exit 1
+ fi
+ PASS_TO_RUN_EXAMPLE+=("--example-dir" "$2")
+ shift 2
+ ;;
--host|-host)
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
print_usage "$SCRIPT_CMD" "Hostname is required when using the
$1 option!"
diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
index 44f249aa76d..6bc94d7fbac 100644
--- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
@@ -143,7 +143,7 @@ public class RunExampleTool extends ToolBase {
"Path to the Solr example directory; if not provided,
${serverDir}/../example is expected to exist.")
.build(),
Option.builder()
- .longOpt("solr-home-dir")
+ .longOpt("solr-home")
.hasArg()
.argName("SOLR_HOME_DIR")
.required(false)
@@ -239,8 +239,8 @@ public class RunExampleTool extends ToolBase {
+ exampleDir.getAbsolutePath()
+ " is not a directory!");
- if (cli.hasOption("solr-home-dir")) {
- solrHomeDir = new File(cli.getOptionValue("solr-home-dir"));
+ if (cli.hasOption("solr-home")) {
+ solrHomeDir = new File(cli.getOptionValue("solr-home"));
} else {
String solrHomeProp = EnvUtils.getProperty("solr.home");
if (solrHomeProp != null && !solrHomeProp.isEmpty()) {
@@ -254,7 +254,7 @@ public class RunExampleTool extends ToolBase {
}
if (!solrHomeDir.isDirectory())
throw new IllegalArgumentException(
- "Value of --solr-home-dir option is invalid! "
+ "Value of --solr-home option is invalid! "
+ solrHomeDir.getAbsolutePath()
+ " is not a directory!");
@@ -552,7 +552,7 @@ public class RunExampleTool extends ToolBase {
}
// setup a unique solr.solr.home directory for each node
- File node1Dir = setupExampleDir(serverDir, solrHomeDir, "node1");
+ File node1Dir = setupSolrHomeDir(serverDir, solrHomeDir, "node1");
for (int n = 2; n <= numNodes; n++) {
File nodeNDir = new File(solrHomeDir, "node" + n);
if (!nodeNDir.isDirectory()) {
@@ -674,7 +674,7 @@ public class RunExampleTool extends ToolBase {
String callScript = (!isWindows && cwd.equals(binDir.getParentFile())) ?
"bin/solr" : script;
String cwdPath = cwd.getAbsolutePath();
- String solrHome = solrHomeDir.getAbsolutePath();
+ String solrHome =
solrHomeDir.toPath().toAbsolutePath().toRealPath().toString();
// don't display a huge path for solr home if it is relative to the cwd
if (!isWindows && cwdPath.length() > 1 && solrHome.startsWith(cwdPath))
@@ -688,11 +688,12 @@ public class RunExampleTool extends ToolBase {
String startCmd =
String.format(
Locale.ROOT,
- "\"%s\" start %s -p %d --solr-home \"%s\" %s %s %s %s %s %s %s %s",
+ "\"%s\" start %s -p %d --solr-home \"%s\" --server-dir \"%s\" %s
%s %s %s %s %s %s %s",
callScript,
cloudModeArg,
port,
solrHome,
+ serverDir.getAbsolutePath(),
hostArg,
zkHostArg,
memArg,
@@ -954,7 +955,7 @@ public class RunExampleTool extends ToolBase {
return nodeStatus;
}
- protected File setupExampleDir(File serverDir, File solrHomeParentDir,
String dirName)
+ protected File setupSolrHomeDir(File serverDir, File solrHomeParentDir,
String dirName)
throws IOException {
File solrXml = new File(serverDir, "solr/solr.xml");
if (!solrXml.isFile())
diff --git a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java
b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java
index 004ac834fd0..76b3c7a5d12 100644
--- a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java
+++ b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java
@@ -120,9 +120,12 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {
String solrHomeDir = getArg("--solr-home", args);
int port = Integer.parseInt(getArg("-p", args));
- String solrxml =
- Files.readString(
- Paths.get(solrHomeDir).resolve("solr.xml"),
Charset.defaultCharset());
+ Path solrXmlPath = Paths.get(solrHomeDir).resolve("solr.xml");
+ if (!Files.exists(solrXmlPath)) {
+ String solrServerDir = getArg("--server-dir", args);
+ solrXmlPath =
Paths.get(solrServerDir).resolve("solr").resolve("solr.xml");
+ }
+ String solrxml = Files.readString(solrXmlPath,
Charset.defaultCharset());
JettyConfig jettyConfig =
JettyConfig.builder().setPort(port).build();
try {
@@ -332,13 +335,13 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4
{
}
protected void testExample(String exampleName) throws Exception {
- File solrHomeDir = new File(ExternalPaths.SERVER_HOME);
- if (!solrHomeDir.isDirectory())
- fail(solrHomeDir.getAbsolutePath() + " not found and is required to run
this test!");
+ File defaultSolrHomeDir = new File(ExternalPaths.SERVER_HOME);
+ if (!defaultSolrHomeDir.isDirectory())
+ fail(defaultSolrHomeDir.getAbsolutePath() + " not found and is required
to run this test!");
Path tmpDir = createTempDir();
- File solrExampleDir = tmpDir.toFile();
- File solrServerDir = solrHomeDir.getParentFile();
+ File testSolrHomeDir = tmpDir.toFile();
+ File solrServerDir = defaultSolrHomeDir.getParentFile();
for (int pass = 0; pass < 2; pass++) {
// need a port to start the example server on
@@ -353,7 +356,7 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {
new String[] {
"-e", exampleName,
"--server-dir", solrServerDir.getAbsolutePath(),
- "--solr-home-dir", solrExampleDir.getAbsolutePath(),
+ "--solr-home", testSolrHomeDir.getAbsolutePath(),
"-p", String.valueOf(bindPort)
};
diff --git
a/solr/solr-ref-guide/modules/getting-started/pages/tutorial-techproducts.adoc
b/solr/solr-ref-guide/modules/getting-started/pages/tutorial-techproducts.adoc
index c26987dc2b5..e949282049c 100644
---
a/solr/solr-ref-guide/modules/getting-started/pages/tutorial-techproducts.adoc
+++
b/solr/solr-ref-guide/modules/getting-started/pages/tutorial-techproducts.adoc
@@ -196,7 +196,7 @@ POSTing file sd500.xml (application/xml) to [base]
POSTing file solr-word.pdf (application/pdf) to [base]/extract
POSTing file solr.xml (application/xml) to [base]
POSTing file vidcard.xml (application/xml) to [base]
-20 files indexed.
+19 files indexed.
COMMITting Solr index changes to
http://localhost:8983/solr/techproducts/update...
Time spent: 0:00:00.822
----