Skip to content

Commit

Permalink
Wait for ES to be green before deleting configs (#53437)
Browse files Browse the repository at this point in the history
Testing manual creation of a keystore in Docker fails unpredictably on
7.6, possibly indicating a problem with deleting the keystore file
at a particular moment during Elasticsearch startup. In order to cut
this Gordian Knot, we should just wait for Elasticsearch to become green
before messing around with files that it needs for startup.

I'm also backporting a change to how we check whether ES is running. It
doesn't seem to be a problem with this test, but I think it's more
reliable.
  • Loading branch information
williamrandolph committed Mar 12, 2020
1 parent 7ba9cf5 commit 510c799
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,19 @@ public void test020PluginsListWithNoPlugins() {
/**
* Check that a keystore can be manually created using the provided CLI tool.
*/
public void test040CreateKeystoreManually() throws InterruptedException {
public void test040CreateKeystoreManually() throws Exception {
final Installation.Executables bin = installation.executables();

// wait until Elasticsearch is green before messing around with the
// files it needs for startup
waitForElasticsearch(installation);

final Path keystorePath = installation.config("elasticsearch.keystore");

waitForPathToExist(keystorePath);

// Move the auto-created one out of the way, or else the CLI prompts asks us to confirm
sh.run("mv " + keystorePath + " " + keystorePath + ".bak");
sh.run("rm " + keystorePath);

sh.run(bin.keystoreTool + " create");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ public static void waitForElasticsearchToStart() {
// Give the container a chance to crash out
Thread.sleep(1000);

psOutput = dockerShell.run("ps -w ax").stdout;
psOutput = dockerShell.run("ps -ww ax").stdout;

if (psOutput.contains("/usr/share/elasticsearch/jdk/bin/java")) {
if (psOutput.contains("org.elasticsearch.bootstrap.Elasticsearch")) {
isElasticsearchRunning = true;
break;
}
Expand Down

0 comments on commit 510c799

Please sign in to comment.