|
52 | 52 | import java.util.Map;
|
53 | 53 | import java.util.Set;
|
54 | 54 | import java.util.concurrent.ExecutionException;
|
| 55 | +import java.util.concurrent.TimeUnit; |
55 | 56 | import java.util.concurrent.atomic.AtomicBoolean;
|
56 | 57 | import java.util.concurrent.atomic.AtomicInteger;
|
57 | 58 | import java.util.concurrent.atomic.AtomicReference;
|
58 | 59 | import java.util.function.Supplier;
|
59 | 60 |
|
60 | 61 | import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.state;
|
61 | 62 | import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithActivePrimary;
|
| 63 | +import static org.hamcrest.Matchers.anyOf; |
62 | 64 | import static org.hamcrest.Matchers.arrayWithSize;
|
| 65 | +import static org.hamcrest.Matchers.containsString; |
63 | 66 | import static org.hamcrest.Matchers.equalTo;
|
64 | 67 | import static org.hamcrest.Matchers.instanceOf;
|
65 | 68 | import static org.hamcrest.Matchers.notNullValue;
|
@@ -266,7 +269,6 @@ private void addTrackingInfo(
|
266 | 269 | }
|
267 | 270 | }
|
268 | 271 |
|
269 |
| - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/84610") |
270 | 272 | public void testNoLongerPrimary() throws Exception {
|
271 | 273 | final String index = "test";
|
272 | 274 | final ShardId shardId = new ShardId(index, "_na_", 0);
|
@@ -360,13 +362,19 @@ public void failShard(String message, Exception exception) {
|
360 | 362 | op.execute();
|
361 | 363 |
|
362 | 364 | assertThat("request was not processed on primary", request.processedOnPrimary.get(), equalTo(true));
|
363 |
| - assertTrue("listener is not marked as done", listener.isDone()); |
| 365 | + assertThat( |
| 366 | + expectThrows( |
| 367 | + ExecutionException.class, |
| 368 | + ReplicationOperation.RetryOnPrimaryException.class, |
| 369 | + () -> listener.get(10, TimeUnit.SECONDS) |
| 370 | + ).getMessage(), |
| 371 | + anyOf(containsString("demoted while failing replica shard"), containsString("shutting down while failing replica shard")) |
| 372 | + ); |
364 | 373 | if (shardActionFailure instanceof ShardStateAction.NoLongerPrimaryShardException) {
|
365 | 374 | assertTrue(primaryFailed.get());
|
366 | 375 | } else {
|
367 | 376 | assertFalse(primaryFailed.get());
|
368 | 377 | }
|
369 |
| - assertListenerThrows("should throw exception to trigger retry", listener, ReplicationOperation.RetryOnPrimaryException.class); |
370 | 378 | }
|
371 | 379 |
|
372 | 380 | public void testAddedReplicaAfterPrimaryOperation() throws Exception {
|
|
0 commit comments