[
https://issues.apache.org/jira/browse/SOLR-18652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18143960#comment-18143960
]
Eric Pugh commented on SOLR-18652:
----------------------------------
I can believe it! lot of these various solr home things just feel needlessly
complex.
> solr start -e ignores the requested Solr home and writes the example into the
> installation directory
> ----------------------------------------------------------------------------------------------------
>
> Key: SOLR-18652
> URL: https://issues.apache.org/jira/browse/SOLR-18652
> Project: Solr
> Issue Type: Bug
> Components: cli
> Reporter: Jan Høydahl
> Priority: Major
> Labels: cats, windows
>
> *Found by CATS*, the cross-platform CLI test framework proposed in SOLR-18642
> — see [PR #5323|https://github.com/apache/solr/pull/5323]. A fix can land
> before CATS is merged or after; if it lands first, please also drop the gate
> on {{ExampleTest}} on that PR.
> h3. Summary
> {{solr start \-e <example>}} writes the example into the Solr installation
> directory instead of the home the user asked for, and reports nothing. Two
> independent paths lead there: one reachable on every platform through the
> {{SOLR_HOME}} environment variable, one specific to {{solr.cmd}} and the
> {{\-\-solr\-home}} option. On a packaged install the directory written to may
> be read-only or root-owned.
> h3. Steps to reproduce
> Either of these. Neither reports a problem.
> On any platform, with the home given in the environment:
> {code}SOLR_HOME=/var/solr solr start -e techproducts{code}
> On Windows, with the home given as an option:
> {code}bin\solr.cmd start -e cloud --solr-home D:\mydata{code}
> h3. Expected
> The example's cores, index data and — for a cloud example — {{zoo_data}} are
> created under the requested home.
> h3. Actual
> They are created inside the installation: {{%SOLR_TIP%\example\cloud}} for a
> cloud example, {{server\solr}} otherwise. The requested directory is left
> untouched and nothing warns that it was discarded.
> h3. Root cause
> {{RunExampleTool}} chooses the home like this
> ({{RunExampleTool.java:594\-606}}):
> {code:java}
> if (solrHomeArg != null) solrHomeDir = Path.of(solrHomeArg);
> // --solr-home
> else if (solr.home property set) solrHomeDir = Path.of(solrHomeProp);
> else if (cloud example) solrHomeDir = exampleDir.resolve("cloud");
> // $SOLR_TIP/example/cloud
> else solrHomeDir = serverDir.resolve("solr");
> // $SOLR_TIP/server/solr
> {code}
> Three things have to go wrong together, and all three do.
> *The environment variable is never forwarded.* {{bin/solr}} appends the
> option only inside the {{\-\-solr\-home}} command-line branch
> ({{bin/solr:742}}). A {{SOLR_HOME}} inherited from the environment is not
> passed on, on either platform.
> *The property fallback reads the wrong name.* {{SOLR_HOME}} maps to
> {{solr.solr.home}} ({{EnvToSyspropMappings.properties:15}}) while the tool
> reads {{solr.home}}, and {{EnvUtils.getProperty}} only tries camelCase and
> dot-separated spellings of the key it was given — it never consults the
> environment. So the second branch cannot fire from a {{SOLR_HOME}} however it
> was set, which is what leaves the two default branches to decide.
> *{{solr.cmd}} drops the option as well.* {{:set_solr_home_dir}}
> ({{solr.cmd:516\-534}}) sets {{SOLR_HOME}} and jumps back to {{:parse_args}}
> without touching {{PASS_TO_RUN_EXAMPLE}}, so the {{run_example}} invocation
> at {{solr.cmd:811}} never carries {{\-\-solr\-home}}. {{bin/solr}} does carry
> it, which is why the option works under bash but not under cmd.
> h3. Further evidence
> The packaging tests have been hitting this for some time.
> {{configureBatsTask}} sets {{SOLR_HOME}} as an environment variable
> ({{solr/packaging/build.gradle:340}}), so every BATS test using {{solr start
> \-e}} wrote into the unpacked distribution that all the other tests then read
> — a shared build-tree directory a test must not mutate. During the CATS port
> it surfaced as a stray {{zoo_data}} left in
> {{solr/packaging/build/solr\-11.0.0\-SNAPSHOT/server/solr/}}, which is
> neither part of the distribution nor tracked in git.
> The CATS ports avoid it by passing {{\-\-solr\-home "${SOLR_HOME}"}}
> explicitly ({{ExampleTest}}, {{ExportTest}}) or by building the fixture with
> {{solr create}} and {{solr post}} instead of {{\-e}} ({{CompressionTest}},
> {{SnapshotsTest}}, {{StreamTest}}), so it no longer reproduces from the suite
> as it stands.
> 🤖 AI Assisted
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]