|
7 | 7 |
|
8 | 8 | package org.elasticsearch.compute.operator;
|
9 | 9 |
|
| 10 | +import org.elasticsearch.cluster.node.DiscoveryNodeUtils; |
10 | 11 | import org.elasticsearch.common.Randomness;
|
11 | 12 | import org.elasticsearch.common.breaker.CircuitBreaker;
|
12 | 13 | import org.elasticsearch.common.breaker.CircuitBreakingException;
|
13 | 14 | import org.elasticsearch.tasks.TaskCancelledException;
|
14 | 15 | import org.elasticsearch.test.ESTestCase;
|
| 16 | +import org.elasticsearch.transport.NodeDisconnectedException; |
15 | 17 | import org.elasticsearch.transport.RemoteTransportException;
|
| 18 | +import org.elasticsearch.transport.TransportException; |
16 | 19 | import org.hamcrest.Matchers;
|
17 | 20 |
|
18 | 21 | import java.io.IOException;
|
|
25 | 28 | import java.util.stream.IntStream;
|
26 | 29 | import java.util.stream.Stream;
|
27 | 30 |
|
| 31 | +import static org.hamcrest.Matchers.arrayWithSize; |
| 32 | +import static org.hamcrest.Matchers.equalTo; |
| 33 | +import static org.hamcrest.Matchers.instanceOf; |
28 | 34 | import static org.hamcrest.Matchers.lessThan;
|
29 | 35 |
|
30 | 36 | public class FailureCollectorTests extends ESTestCase {
|
@@ -87,4 +93,17 @@ public void testEmpty() {
|
87 | 93 | assertFalse(collector.hasFailure());
|
88 | 94 | assertNull(collector.getFailure());
|
89 | 95 | }
|
| 96 | + |
| 97 | + public void testTransportExceptions() { |
| 98 | + FailureCollector collector = new FailureCollector(5); |
| 99 | + collector.unwrapAndCollect(new NodeDisconnectedException(DiscoveryNodeUtils.builder("node-1").build(), "/field_caps")); |
| 100 | + collector.unwrapAndCollect(new TransportException(new CircuitBreakingException("too large", CircuitBreaker.Durability.TRANSIENT))); |
| 101 | + Exception failure = collector.getFailure(); |
| 102 | + assertNotNull(failure); |
| 103 | + assertThat(failure, instanceOf(NodeDisconnectedException.class)); |
| 104 | + assertThat(failure.getMessage(), equalTo("[][0.0.0.0:1][/field_caps] disconnected")); |
| 105 | + Throwable[] suppressed = failure.getSuppressed(); |
| 106 | + assertThat(suppressed, arrayWithSize(1)); |
| 107 | + assertThat(suppressed[0], instanceOf(CircuitBreakingException.class)); |
| 108 | + } |
90 | 109 | }
|
0 commit comments