Skip to content

Commit

Permalink
Can no longer assert
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed Sep 1, 2021
1 parent 5bc9ec9 commit 15005b2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RestHandler> getRestHandlers(
final Settings settings,
Expand Down

0 comments on commit 15005b2

Please sign in to comment.