|
15 | 15 | import org.elasticsearch.action.support.PlainActionFuture; |
16 | 16 | import org.elasticsearch.cluster.node.DiscoveryNode; |
17 | 17 | import org.elasticsearch.cluster.node.DiscoveryNodeUtils; |
| 18 | +import org.elasticsearch.common.breaker.CircuitBreaker.Durability; |
| 19 | +import org.elasticsearch.common.breaker.CircuitBreakingException; |
18 | 20 | import org.elasticsearch.common.settings.Settings; |
19 | 21 | import org.elasticsearch.common.util.concurrent.ConcurrentCollections; |
20 | 22 | import org.elasticsearch.common.util.concurrent.EsExecutors; |
@@ -123,8 +125,7 @@ public void testMissingShards() { |
123 | 125 | var future = sendRequests(targetShards, false, (node, shardIds, aliasFilters, listener) -> { |
124 | 126 | fail("expect no data-node request is sent when target shards are missing"); |
125 | 127 | }); |
126 | | - var error = expectThrows(NoShardAvailableActionException.class, future::actionGet); |
127 | | - assertThat(error.getMessage(), containsString("no shard copies found")); |
| 128 | + expectThrows(NoShardAvailableActionException.class, containsString("no shard copies found"), future::actionGet); |
128 | 129 | } |
129 | 130 | { |
130 | 131 | var targetShards = List.of(targetShard(shard1, node1), targetShard(shard3), targetShard(shard4, node2, node3)); |
@@ -244,6 +245,17 @@ public void testAllowPartialResults() { |
244 | 245 | assertThat(resp.successfulShards, equalTo(1)); |
245 | 246 | } |
246 | 247 |
|
| 248 | + public void testDoNotRetryCircuitBreakerException() { |
| 249 | + var targetShards = List.of(targetShard(shard1, node1, node2)); |
| 250 | + var sent = ConcurrentCollections.newQueue(); |
| 251 | + var future = sendRequests(targetShards, false, (node, shardIds, aliasFilters, listener) -> { |
| 252 | + sent.add(new NodeRequest(node, shardIds, aliasFilters)); |
| 253 | + runWithDelay(() -> listener.onFailure(new CircuitBreakingException("cbe", randomFrom(Durability.values())), false)); |
| 254 | + }); |
| 255 | + expectThrows(CircuitBreakingException.class, equalTo("cbe"), future::actionGet); |
| 256 | + assertThat(sent.size(), equalTo(1)); |
| 257 | + } |
| 258 | + |
247 | 259 | static DataNodeRequestSender.TargetShard targetShard(ShardId shardId, DiscoveryNode... nodes) { |
248 | 260 | return new DataNodeRequestSender.TargetShard(shardId, new ArrayList<>(Arrays.asList(nodes)), null); |
249 | 261 | } |
|
0 commit comments