Skip to content

Commit 4ec45bd

Browse files
committed
Cleanup changes
1 parent 8c17107 commit 4ec45bd

File tree

1 file changed

+7
-8
lines changed
  • qa/packaging/src/test/java/org/elasticsearch/packaging/util/docker

1 file changed

+7
-8
lines changed

qa/packaging/src/test/java/org/elasticsearch/packaging/util/docker/Docker.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ public class Docker {
7575
public static final int STARTUP_SLEEP_INTERVAL_MILLISECONDS = 1000;
7676
public static final int STARTUP_ATTEMPTS_MAX = 30;
7777

78+
private static final String ELASTICSEARCH_FULL_CLASSNAME = "org.elasticsearch.bootstrap.Elasticsearch";
79+
private static final String FIND_ELASTICSEARCH_PROCESS = "for pid in $(ps -eo pid,comm | grep java | awk '\\''{print $1}'\\''); "
80+
+ "do cmdline=$(tr \"\\0\" \" \" < /proc/$pid/cmdline 2>/dev/null); [[ $cmdline == *"
81+
+ ELASTICSEARCH_FULL_CLASSNAME + "* ]] && echo \"$pid: $cmdline\"; done";
82+
// The length of the command exceeds what we can use for COLUMNS so we use a pipe to detect the process we're looking for
83+
7884
/**
7985
* Tracks the currently running Docker image. An earlier implementation used a fixed container name,
8086
* but that appeared to cause problems with repeatedly destroying and recreating containers with
@@ -185,14 +191,7 @@ public static void waitForElasticsearchToStart() {
185191
try {
186192
// Give the container enough time for security auto-configuration or a chance to crash out
187193
Thread.sleep(STARTUP_SLEEP_INTERVAL_MILLISECONDS);
188-
String detectCommand =
189-
"for pid in $(ps -eo pid,comm | grep java | awk '\\''{print $1}'\\''); do cmdline=$(tr \"\\0\" \" \" < /proc/$pid/cmdline 2>/dev/null); [[ $cmdline == *org.elasticsearch.bootstrap.Elasticsearch* ]] && echo \"PID $pid: $cmdline\"; done | wc -l";
190-
// The length of the command exceeds what we can use for COLUMNS so we use a pipe to detect the process we're looking for
191-
psOutput = dockerShell.run("bash -c '" + detectCommand + "'").stdout();
192-
// System.out.println("psOutput = " + psOutput);
193-
// psOutput = dockerShell.run(
194-
// "bash -c 'COLUMNS=4000 ps w | grep org.elasticsearch.bootstrap.Elasticsearch | grep -v grep | wc -l'"
195-
// ).stdout();
194+
psOutput = dockerShell.run("bash -c '" + FIND_ELASTICSEARCH_PROCESS + " | wc -l'").stdout();
196195
if (psOutput.contains("1")) {
197196
isElasticsearchRunning = true;
198197
break;

0 commit comments

Comments
 (0)