Skip to content

Commit

Permalink
Further tweak AutoFollowIT#testAutoFollowManyIndices:
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
martijnvg committed Mar 11, 2019
1 parent 1bc31ac commit 8925a2c
Showing 1 changed file with 20 additions and 4 deletions.
Expand Up @@ -35,7 +35,9 @@
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 {

Expand Down Expand Up @@ -131,7 +133,7 @@ public void testAutoFollowManyIndices() throws Exception {
.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);
}
Expand All @@ -140,8 +142,12 @@ public void testAutoFollowManyIndices() throws Exception {
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) {
Expand All @@ -155,8 +161,12 @@ public void testAutoFollowManyIndices() throws Exception {
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) {
Expand All @@ -176,8 +186,14 @@ public void testAutoFollowManyIndices() throws Exception {

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:
Expand Down

0 comments on commit 8925a2c

Please sign in to comment.