diff --git a/qa/die-with-dignity/build.gradle b/test/external-modules/die-with-dignity/build.gradle similarity index 86% rename from qa/die-with-dignity/build.gradle rename to test/external-modules/die-with-dignity/build.gradle index cd7f2b9f738cc..166a9ca6d138e 100644 --- a/qa/die-with-dignity/build.gradle +++ b/test/external-modules/die-with-dignity/build.gradle @@ -20,15 +20,17 @@ tasks.named("javaRestTest").configure { } testClusters.matching { it.name == "javaRestTest" }.configureEach { - systemProperty "die.with.dignity.test", "whatever" - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' + systemProperty "die.with.dignity.test", "true" } tasks.named("test").configure { enabled = false } +tasks.named("yamlRestTest").configure { + enabled = false +} + tasks.named('splitPackagesAudit').configure { // these should be moved to an actual package, not the root package ignoreClasses 'org.elasticsearch.DieWithDignityPlugin', diff --git a/qa/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 similarity index 81% rename from qa/die-with-dignity/src/javaRestTest/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java rename to test/external-modules/die-with-dignity/src/javaRestTest/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java index dc6deac379117..2fa35e10c2cf6 100644 --- a/qa/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 @@ -10,9 +10,6 @@ import org.elasticsearch.client.Request; import org.elasticsearch.core.PathUtils; -import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.test.rest.ESRestTestCase; import java.io.BufferedReader; @@ -30,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 + { + 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 @@ -40,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"))); } } }); @@ -99,16 +114,4 @@ protected boolean preserveClusterUponCompletion() { return true; } - @Override - protected final Settings restClientSettings() { - String token = basicAuthHeaderValue("admin", new SecureString("admin-password".toCharArray())); - return Settings.builder() - .put(super.restClientSettings()) - .put(ThreadContext.PREFIX + ".Authorization", token) - // increase the timeout here to 90 seconds to handle long waits for a green - // cluster health. the waits for green need to be longer than a minute to - // account for delayed shards - .put(ESRestTestCase.CLIENT_SOCKET_TIMEOUT, "1s") - .build(); - } } diff --git a/qa/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java b/test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java similarity index 90% rename from qa/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java rename to test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java index 9c6a8fe95182e..c17369928a4d1 100644 --- a/qa/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") != null : "test should pass the `die.with.dignity.test` property"; - } - @Override public List getRestHandlers( final Settings settings, diff --git a/qa/die-with-dignity/src/main/java/org/elasticsearch/RestDieWithDignityAction.java b/test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/RestDieWithDignityAction.java similarity index 100% rename from qa/die-with-dignity/src/main/java/org/elasticsearch/RestDieWithDignityAction.java rename to test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/RestDieWithDignityAction.java