Skip to content

Commit c7130eb

Browse files
authored
Move die with dignity to be a test module (#77136)
This commit moves the die with dignity tests to be a test module. The purpose of this is so the _die_with_dignity endpoint is available in snapshot builds, for the purpose of enabling testing orchestration logic that manages what happens to a node after it dies with an OutOfMemoryError.
1 parent 26dfe02 commit c7130eb

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

qa/die-with-dignity/build.gradle renamed to test/external-modules/die-with-dignity/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ tasks.named("javaRestTest").configure {
2020
}
2121

2222
testClusters.matching { it.name == "javaRestTest" }.configureEach {
23-
systemProperty "die.with.dignity.test", "whatever"
24-
setting 'xpack.security.enabled', 'true'
25-
user username: 'admin', password: 'admin-password', role: 'superuser'
23+
systemProperty "die.with.dignity.test", "true"
2624
}
2725

2826
tasks.named("test").configure {
2927
enabled = false
3028
}
3129

30+
tasks.named("yamlRestTest").configure {
31+
enabled = false
32+
}
33+
3234
tasks.named('splitPackagesAudit').configure {
3335
// these should be moved to an actual package, not the root package
3436
ignoreClasses 'org.elasticsearch.DieWithDignityPlugin',

qa/die-with-dignity/src/javaRestTest/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java renamed to test/external-modules/die-with-dignity/src/javaRestTest/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
import org.elasticsearch.client.Request;
1212
import org.elasticsearch.core.PathUtils;
13-
import org.elasticsearch.common.settings.SecureString;
14-
import org.elasticsearch.common.settings.Settings;
15-
import org.elasticsearch.common.util.concurrent.ThreadContext;
1613
import org.elasticsearch.test.rest.ESRestTestCase;
1714

1815
import java.io.BufferedReader;
@@ -30,6 +27,24 @@
3027
public class DieWithDignityIT extends ESRestTestCase {
3128

3229
public void testDieWithDignity() throws Exception {
30+
// there should be an Elasticsearch process running with the die.with.dignity.test system property
31+
{
32+
final String jpsPath = PathUtils.get(System.getProperty("runtime.java.home"), "bin/jps").toString();
33+
final Process process = new ProcessBuilder().command(jpsPath, "-v").start();
34+
35+
boolean found = false;
36+
try (InputStream is = process.getInputStream(); BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"))) {
37+
String line;
38+
while ((line = in.readLine()) != null) {
39+
if (line.contains("-Ddie.with.dignity.test=true")) {
40+
found = true;
41+
break;
42+
}
43+
}
44+
}
45+
assertTrue(found);
46+
}
47+
3348
expectThrows(IOException.class, () -> client().performRequest(new Request("GET", "/_die_with_dignity")));
3449

3550
// the Elasticsearch process should die and disappear from the output of jps
@@ -40,7 +55,7 @@ public void testDieWithDignity() throws Exception {
4055
try (InputStream is = process.getInputStream(); BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"))) {
4156
String line;
4257
while ((line = in.readLine()) != null) {
43-
assertThat(line, line, not(containsString("-Ddie.with.dignity.test")));
58+
assertThat(line, line, not(containsString("-Ddie.with.dignity.test=true")));
4459
}
4560
}
4661
});
@@ -99,16 +114,4 @@ protected boolean preserveClusterUponCompletion() {
99114
return true;
100115
}
101116

102-
@Override
103-
protected final Settings restClientSettings() {
104-
String token = basicAuthHeaderValue("admin", new SecureString("admin-password".toCharArray()));
105-
return Settings.builder()
106-
.put(super.restClientSettings())
107-
.put(ThreadContext.PREFIX + ".Authorization", token)
108-
// increase the timeout here to 90 seconds to handle long waits for a green
109-
// cluster health. the waits for green need to be longer than a minute to
110-
// account for delayed shards
111-
.put(ESRestTestCase.CLIENT_SOCKET_TIMEOUT, "1s")
112-
.build();
113-
}
114117
}

qa/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java renamed to test/external-modules/die-with-dignity/src/main/java/org/elasticsearch/DieWithDignityPlugin.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525

2626
public class DieWithDignityPlugin extends Plugin implements ActionPlugin {
2727

28-
public DieWithDignityPlugin() {
29-
assert System.getProperty("die.with.dignity.test") != null : "test should pass the `die.with.dignity.test` property";
30-
}
31-
3228
@Override
3329
public List<RestHandler> getRestHandlers(
3430
final Settings settings,

0 commit comments

Comments
 (0)