Skip to content

Some elasticsearch-cli tools could not be run not from ES_HOME #39937

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

Merged
merged 6 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion distribution/src/bin/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options
JVM_OPTIONS=`"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_JVM_OPTIONS"`
ES_JAVA_OPTS="${JVM_OPTIONS//\$\{ES_TMPDIR\}/$ES_TMPDIR} $ES_JAVA_OPTS"

cd "$ES_HOME"
# manual parsing to find out, if process should be detached
if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null; then
exec \
Expand Down
2 changes: 2 additions & 0 deletions distribution/src/bin/elasticsearch-env
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ ES_DISTRIBUTION_TYPE=${es.distribution.type}
if [ -z "$ES_TMPDIR" ]; then
ES_TMPDIR=`"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.TempDirectory`
fi

cd "$ES_HOME"
2 changes: 2 additions & 0 deletions distribution/src/bin/elasticsearch-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ set ES_DISTRIBUTION_TYPE=${es.distribution.type}
if not defined ES_TMPDIR (
for /f "tokens=* usebackq" %%a in (`"%JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.TempDirectory""`) do set ES_TMPDIR=%%a
)

cd /d "%ES_HOME%"
1 change: 0 additions & 1 deletion distribution/src/bin/elasticsearch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ if "%MAYBE_JVM_OPTIONS_PARSER_FAILED%" == "jvm_options_parser_failed" (
exit /b 1
)

cd /d "%ES_HOME%"
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!

endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,14 @@ public void test90SecurityCliPackaging() {
}
}

public void test100ElasticsearchShardCliPackaging() {
public void test91ElasticsearchShardCliPackaging() {
assumeThat(installation, is(notNullValue()));

final Installation.Executables bin = installation.executables();
final Shell sh = new Shell();

Platforms.PlatformAction action = () -> {
final Result result = sh.run(bin.elasticsearchShard + " help");
final Result result = sh.run(bin.elasticsearchShard + " -h");
assertThat(result.stdout, containsString("A CLI tool to remove corrupted parts of unrecoverable shards"));
};

Expand All @@ -334,7 +334,7 @@ public void test100ElasticsearchShardCliPackaging() {
}
}

public void test110ElasticsearchNodeCliPackaging() {
public void test92ElasticsearchNodeCliPackaging() {
assumeThat(installation, is(notNullValue()));

final Installation.Executables bin = installation.executables();
Expand All @@ -352,4 +352,19 @@ public void test110ElasticsearchNodeCliPackaging() {
}
}

public void test93ElasticsearchNodeCustomDataPathAndNotEsHomeWorkDir() throws IOException {
assumeThat(installation, is(notNullValue()));

Path relativeDataPath = installation.data.relativize(installation.home);
append(installation.config("elasticsearch.yml"), "path.data: " + relativeDataPath);

Archives.runElasticsearch(installation);
Archives.stopElasticsearch(installation);

final Shell sh = new Shell(getTempDir());

Result result = sh.run("echo y | " + installation.executables().elasticsearchNode + " unsafe-bootstrap");
assertThat(result.stdout, containsString("Master node was successfully bootstrapped"));
}

}