diff --git a/test/external-modules/die-with-dignity/src/javaRestTest/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java b/test/external-modules/die-with-dignity/src/javaRestTest/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java index 4f929bf16c522..7e92cd31fc408 100644 --- a/test/external-modules/die-with-dignity/src/javaRestTest/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java +++ b/test/external-modules/die-with-dignity/src/javaRestTest/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java @@ -27,6 +27,24 @@ public class DieWithDignityIT extends ESRestTestCase { public void testDieWithDignity() throws Exception { + // there should be an Elasticsearch process running with the die.with.dignity.test system property + assertBusy(() -> { + final String jpsPath = PathUtils.get(System.getProperty("runtime.java.home"), "bin/jps").toString(); + final Process process = new ProcessBuilder().command(jpsPath, "-v").start(); + + boolean found = false; + try (InputStream is = process.getInputStream(); BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"))) { + String line; + while ((line = in.readLine()) != null) { + if (line.contains("-Ddie.with.dignity.test=true")) { + found = true; + break; + } + } + } + assertTrue(found); + }); + expectThrows(IOException.class, () -> client().performRequest(new Request("GET", "/_die_with_dignity"))); // the Elasticsearch process should die and disappear from the output of jps @@ -37,7 +55,7 @@ public void testDieWithDignity() throws Exception { try (InputStream is = process.getInputStream(); BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"))) { String line; while ((line = in.readLine()) != null) { - assertThat(line, line, not(containsString("-Ddie.with.dignity.test"))); + assertThat(line, line, not(containsString("-Ddie.with.dignity.test=true"))); } } }); diff --git a/test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java b/test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java index be10705fbc542..c17369928a4d1 100644 --- a/test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java +++ b/test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java @@ -25,10 +25,6 @@ public class DieWithDignityPlugin extends Plugin implements ActionPlugin { - public DieWithDignityPlugin() { - assert System.getProperty("die.with.dignity.test").equals("true") : "test should pass the `die.with.dignity.test` property"; - } - @Override public List getRestHandlers( final Settings settings,