Skip to content

Commit f9ae04c

Browse files
committed
Test: Expect extra Exception in die_with_dignity (#29138)
I did a little digging. It looks like IOException is thrown when the other side closes its connection while we're waiting on our buffer to fill up. We totally expect that in this test. It feels to me like we should throw a `ConnectionClosedException` but upstream does not agree: https://issues.apache.org/jira/browse/HTTPASYNC-134 While we *could* catch the exception and transform it ourselves that seems like a bigger change than is merited at this point. Closes #29136
1 parent 29bbf6a commit f9ae04c

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

qa/die-with-dignity/src/test/java/org/elasticsearch/qa/die_with_dignity/DieWithDignityIT.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,25 @@
2020
package org.elasticsearch.qa.die_with_dignity;
2121

2222
import org.apache.http.ConnectionClosedException;
23-
import org.elasticsearch.client.Response;
24-
import org.elasticsearch.client.ResponseListener;
23+
import org.apache.lucene.util.Constants;
2524
import org.elasticsearch.common.io.PathUtils;
2625
import org.elasticsearch.test.rest.ESRestTestCase;
26+
import org.hamcrest.Matcher;
2727

2828
import java.io.BufferedReader;
29+
import java.io.IOException;
2930
import java.io.InputStream;
3031
import java.io.InputStreamReader;
3132
import java.nio.file.Files;
3233
import java.nio.file.Path;
3334
import java.util.Iterator;
3435
import java.util.List;
35-
import java.util.concurrent.CountDownLatch;
3636

37+
import static org.hamcrest.Matchers.containsString;
38+
import static org.hamcrest.Matchers.either;
3739
import static org.hamcrest.Matchers.equalTo;
3840
import static org.hamcrest.Matchers.hasSize;
41+
import static org.hamcrest.Matchers.hasToString;
3942
import static org.hamcrest.Matchers.instanceOf;
4043
import static org.hamcrest.Matchers.not;
4144

@@ -48,7 +51,22 @@ public void testDieWithDignity() throws Exception {
4851
assertThat(pidFileLines, hasSize(1));
4952
final int pid = Integer.parseInt(pidFileLines.get(0));
5053
Files.delete(pidFile);
51-
expectThrows(ConnectionClosedException.class, () -> client().performRequest("GET", "/_die_with_dignity"));
54+
IOException e = expectThrows(IOException.class, () -> client().performRequest("GET", "/_die_with_dignity"));
55+
Matcher<IOException> failureMatcher = instanceOf(ConnectionClosedException.class);
56+
if (Constants.WINDOWS) {
57+
/*
58+
* If the other side closes the connection while we're waiting to fill our buffer
59+
* we can get IOException with the message below. It seems to only come up on
60+
* Windows and it *feels* like it could be a ConnectionClosedException but
61+
* upstream does not consider this a bug:
62+
* https://issues.apache.org/jira/browse/HTTPASYNC-134
63+
*
64+
* So we catch it here and consider it "ok".
65+
*/
66+
failureMatcher = either(failureMatcher)
67+
.or(hasToString(containsString("An existing connection was forcibly closed by the remote host")));
68+
}
69+
assertThat(e, failureMatcher);
5270

5371
// the Elasticsearch process should die and disappear from the output of jps
5472
assertBusy(() -> {

0 commit comments

Comments
 (0)