cd ES_HOME in elasticsearch-env (#39937)
This commit adds cd $ES_HOME to elasticsearch-env and removes it from elasticsearch. This way, both elasticsearch and elasticsearch-cli are executed with the working directory set to $ES_HOME. The need for the fix arose from the following bug: 1. Explicitly set path.data to relative to ES_HOME path in elasticsearch.yml. 2. Run elasticsearch from any directory. Elasticsearch is able to correctly start. 3. Stop elasticsearch. 4. Run elasticsearch-node unsafe-bootstrap, not from ES_HOME directory. It will fail with an exception. This commit fixes the issue and adds a new test. This PR fixes the issue and adds a new test. Also tests >=100 are renamed because alphabetic order does not work for them. (cherry picked from commit 2ffc29306ff7366efc598e7b4dd2ce528895cd3a with fixes by #40083 and #40118)
This commit is contained in:
parent
5be12e0999
commit
d35d9d1886
|
@ -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 \
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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%"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -328,14 +328,14 @@ public abstract class ArchiveTestCase extends PackagingTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void test100ElasticsearchShardCliPackaging() {
|
||||
public void test91ElasticsearchShardCliPackaging() {
|
||||
assumeThat(installation, is(notNullValue()));
|
||||
|
||||
final Installation.Executables bin = installation.executables();
|
||||
final Shell sh = newShell();
|
||||
|
||||
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"));
|
||||
};
|
||||
|
||||
|
@ -345,7 +345,7 @@ public abstract class ArchiveTestCase extends PackagingTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void test110ElasticsearchNodeCliPackaging() {
|
||||
public void test92ElasticsearchNodeCliPackaging() {
|
||||
assumeThat(installation, is(notNullValue()));
|
||||
|
||||
final Installation.Executables bin = installation.executables();
|
||||
|
@ -363,4 +363,20 @@ public abstract class ArchiveTestCase extends PackagingTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void test93ElasticsearchNodeCustomDataPathAndNotEsHomeWorkDir() throws IOException {
|
||||
assumeThat(installation, is(notNullValue()));
|
||||
|
||||
Path relativeDataPath = installation.data.relativize(installation.home);
|
||||
append(installation.config("elasticsearch.yml"), "path.data: " + relativeDataPath);
|
||||
|
||||
final Shell sh = newShell();
|
||||
sh.setWorkingDirectory(getTempDir());
|
||||
|
||||
Archives.runElasticsearch(installation, sh);
|
||||
Archives.stopElasticsearch(installation);
|
||||
|
||||
Result result = sh.run("echo y | " + installation.executables().elasticsearchNode + " unsafe-bootstrap");
|
||||
assertThat(result.stdout, containsString("Master node was successfully bootstrapped"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue