[TEST] Fix testReplicaTermIncrementWithConcurrentPrimaryPromotion

The assertion in the test was not broad enough. If the timing is very unlucky, the
shard is already promoted to primary before the indexOnReplica even gets to execute.

Closes #32645
This commit is contained in:
Yannick Welsch 2018-08-06 18:35:18 +02:00
parent e641fccfe3
commit 014b2772db

View File

@ -67,6 +67,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static org.elasticsearch.index.translog.SnapshotMatchers.containsOperationsInAnyOrder;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.instanceOf;
@ -261,7 +262,7 @@ public class IndexLevelReplicationTests extends ESIndexLevelReplicationTestCase
barrier.await();
indexOnReplica(replicationRequest, shards, replica2, newReplica1Term);
} catch (IllegalStateException ise) {
assertThat(ise.getMessage(), containsString("is too old"));
assertThat(ise.getMessage(), either(containsString("is too old")).or(containsString("cannot be a replication target")));
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -303,7 +304,7 @@ public class IndexLevelReplicationTests extends ESIndexLevelReplicationTestCase
indexOnReplica(replicationRequest, shards, replica, primaryPrimaryTerm);
successFullyIndexed.set(true);
} catch (IllegalStateException ise) {
assertThat(ise.getMessage(), containsString("is too old"));
assertThat(ise.getMessage(), either(containsString("is too old")).or(containsString("cannot be a replication target")));
} catch (Exception e) {
throw new RuntimeException(e);
}