Further tweak AutoFollowIT#testAutoFollowManyIndices:

* reduce the number of leader indices to be auto followed
* also check the number of follower indices being created
* also check the whether leader indices are marked as auto followed

Relates to #36761
This commit is contained in:
Martijn van Groningen 2019-03-11 09:46:42 +01:00
parent 1bc31aca03
commit 8925a2c6c2
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
1 changed files with 20 additions and 4 deletions

View File

@ -35,7 +35,9 @@ import java.util.List;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class AutoFollowIT extends CcrIntegTestCase {
@ -131,7 +133,7 @@ public class AutoFollowIT extends CcrIntegTestCase {
.build();
putAutoFollowPatterns("my-pattern", new String[] {"logs-*"});
long numIndices = randomIntBetween(4, 16);
long numIndices = randomIntBetween(4, 8);
for (int i = 0; i < numIndices; i++) {
createLeaderIndex("logs-" + i, leaderIndexSettings);
}
@ -140,8 +142,12 @@ public class AutoFollowIT extends CcrIntegTestCase {
AutoFollowStats[] autoFollowStats = new AutoFollowStats[1];
try {
assertBusy(() -> {
metaData[0] = followerClient().admin().cluster().prepareState().get().getState().metaData();
metaData[0] = getFollowerCluster().clusterService().state().metaData();
autoFollowStats[0] = getAutoFollowStats();
assertThat(metaData[0].indices().size(), equalTo((int) expectedVal1));
AutoFollowMetadata autoFollowMetadata = metaData[0].custom(AutoFollowMetadata.TYPE);
assertThat(autoFollowMetadata.getFollowedLeaderIndexUUIDs().get("my-pattern"), hasSize((int) expectedVal1));
assertThat(autoFollowStats[0].getNumberOfSuccessfulFollowIndices(), equalTo(expectedVal1));
});
} catch (AssertionError ae) {
@ -155,8 +161,12 @@ public class AutoFollowIT extends CcrIntegTestCase {
deleteAutoFollowPatternSetting();
try {
assertBusy(() -> {
metaData[0] = followerClient().admin().cluster().prepareState().get().getState().metaData();
metaData[0] = getFollowerCluster().clusterService().state().metaData();
autoFollowStats[0] = getAutoFollowStats();
assertThat(metaData[0].indices().size(), equalTo((int )expectedVal1));
AutoFollowMetadata autoFollowMetadata = metaData[0].custom(AutoFollowMetadata.TYPE);
assertThat(autoFollowMetadata.getFollowedLeaderIndexUUIDs().get("my-pattern"), nullValue());
assertThat(autoFollowStats[0].getAutoFollowedClusters().size(), equalTo(0));
});
} catch (AssertionError ae) {
@ -176,8 +186,14 @@ public class AutoFollowIT extends CcrIntegTestCase {
try {
assertBusy(() -> {
metaData[0] = followerClient().admin().cluster().prepareState().get().getState().metaData();
metaData[0] = getFollowerCluster().clusterService().state().metaData();
autoFollowStats[0] = getAutoFollowStats();
assertThat(metaData[0].indices().size(), equalTo((int) expectedVal2));
AutoFollowMetadata autoFollowMetadata = metaData[0].custom(AutoFollowMetadata.TYPE);
// expectedVal2 + 1, because logs-does-not-count is also marked as auto followed.
// (This is because indices created before a pattern exists are not auto followed and are just marked as such.)
assertThat(autoFollowMetadata.getFollowedLeaderIndexUUIDs().get("my-pattern"), hasSize((int) expectedVal2 + 1));
long count = Arrays.stream(metaData[0].getConcreteAllIndices()).filter(s -> s.startsWith("copy-")).count();
assertThat(count, equalTo(expectedVal2));
// Ensure that there are no auto follow errors: