Skip to content

Commit

Permalink
Source additional files correctly in elasticsearch-cli (elastic#40890)
Browse files Browse the repository at this point in the history
Since we only source additional sources from the same dir as our
cli scripts, resolve the path relevant to $ES_HOME
  • Loading branch information
jkakavas authored and jasontedor committed Apr 5, 2019
1 parent 1c026c9 commit b7e28a7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion distribution/src/bin/elasticsearch-cli
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source "`dirname "$0"`"/elasticsearch-env
IFS=';' read -r -a additional_sources <<< "$ES_ADDITIONAL_SOURCES"
for additional_source in "${additional_sources[@]}"
do
source "`dirname "$0"`"/$additional_source
source "$ES_HOME"/bin/$additional_source
done

IFS=';' read -r -a additional_classpath_directories <<< "$ES_ADDITIONAL_CLASSPATH_DIRECTORIES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,33 @@ public void test93ElasticsearchNodeCustomDataPathAndNotEsHomeWorkDir() throws Ex
assertThat(result.stdout, containsString("Master node was successfully bootstrapped"));
}

public void test94ElasticsearchNodeExecuteCliNotEsHomeWorkDir() throws Exception {
assumeThat(installation, is(notNullValue()));

final Installation.Executables bin = installation.executables();
final Shell sh = newShell();
// Run the cli tools from the tmp dir
sh.setWorkingDirectory(getTempDir());

Platforms.PlatformAction action = () -> {
Result result = sh.run(bin.elasticsearchCertutil+ " -h");
assertThat(result.stdout,
containsString("Simplifies certificate creation for use with the Elastic Stack"));
result = sh.run(bin.elasticsearchSyskeygen+ " -h");
assertThat(result.stdout,
containsString("system key tool"));
result = sh.run(bin.elasticsearchSetupPasswords+ " -h");
assertThat(result.stdout,
containsString("Sets the passwords for reserved users"));
result = sh.run(bin.elasticsearchUsers+ " -h");
assertThat(result.stdout,
containsString("Manages elasticsearch file users"));
};

if (distribution().equals(Distribution.DEFAULT_LINUX) || distribution().equals(Distribution.DEFAULT_WINDOWS)) {
Platforms.onLinux(action);
Platforms.onWindows(action);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public class Executables {
public final Path elasticsearchCertutil = platformExecutable("elasticsearch-certutil");
public final Path elasticsearchShard = platformExecutable("elasticsearch-shard");
public final Path elasticsearchNode = platformExecutable("elasticsearch-node");
public final Path elasticsearchSetupPasswords = platformExecutable("elasticsearch-setup-passwords");
public final Path elasticsearchSyskeygen = platformExecutable("elasticsearch-syskeygen");
public final Path elasticsearchUsers = platformExecutable("elasticsearch-users");

private Path platformExecutable(String name) {
final String platformExecutableName = Platforms.WINDOWS
Expand Down

0 comments on commit b7e28a7

Please sign in to comment.