Skip to content

Commit

Permalink
unmuted and tweaked test
Browse files Browse the repository at this point in the history
Relates to #36761
  • Loading branch information
martijnvg committed Mar 8, 2019
1 parent bc689f7 commit 098d7dc
Showing 1 changed file with 31 additions and 18 deletions.
Expand Up @@ -123,7 +123,6 @@ public void testCleanFollowedLeaderIndexUUIDs() throws Exception {
});
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/36761")
public void testAutoFollowManyIndices() throws Exception {
Settings leaderIndexSettings = Settings.builder()
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
Expand All @@ -132,47 +131,61 @@ public void testAutoFollowManyIndices() throws Exception {
.build();

putAutoFollowPatterns("my-pattern", new String[] {"logs-*"});
int numIndices = randomIntBetween(4, 32);
long numIndices = randomIntBetween(4, 16);
for (int i = 0; i < numIndices; i++) {
createLeaderIndex("logs-" + i, leaderIndexSettings);
}
int expectedVal1 = numIndices;
assertBusy(() -> {
AutoFollowStats autoFollowStats = getAutoFollowStats();
assertThat(autoFollowStats.getNumberOfSuccessfulFollowIndices(), equalTo((long) expectedVal1));
});
long expectedVal1 = numIndices;
MetaData[] metaData = new MetaData[1];
AutoFollowStats[] autoFollowStats = new AutoFollowStats[1];
try {
assertBusy(() -> {
metaData[0] = followerClient().admin().cluster().prepareState().get().getState().metaData();
autoFollowStats[0] = getAutoFollowStats();
assertThat(autoFollowStats[0].getNumberOfSuccessfulFollowIndices(), equalTo(expectedVal1));
});
} catch (AssertionError ae) {
logger.warn("indices={}", Arrays.toString(metaData[0].indices().keys().toArray(String.class)));
logger.warn("auto follow stats={}", Strings.toString(autoFollowStats[0]));
throw ae;
}

// Delete auto follow pattern and make sure that in the background the auto follower has stopped
// then the leader index created after that should never be auto followed:
deleteAutoFollowPatternSetting();
assertBusy(() -> {
AutoFollowStats autoFollowStats = getAutoFollowStats();
assertThat(autoFollowStats.getAutoFollowedClusters().size(), equalTo(0));
});
try {
assertBusy(() -> {
metaData[0] = followerClient().admin().cluster().prepareState().get().getState().metaData();
autoFollowStats[0] = getAutoFollowStats();
assertThat(autoFollowStats[0].getAutoFollowedClusters().size(), equalTo(0));
});
} catch (AssertionError ae) {
logger.warn("indices={}", Arrays.toString(metaData[0].indices().keys().toArray(String.class)));
logger.warn("auto follow stats={}", Strings.toString(autoFollowStats[0]));
throw ae;
}
createLeaderIndex("logs-does-not-count", leaderIndexSettings);

putAutoFollowPatterns("my-pattern", new String[] {"logs-*"});
int i = numIndices;
numIndices = numIndices + randomIntBetween(4, 32);
long i = numIndices;
numIndices = numIndices + randomIntBetween(4, 8);
for (; i < numIndices; i++) {
createLeaderIndex("logs-" + i, leaderIndexSettings);
}
int expectedVal2 = numIndices;
long expectedVal2 = numIndices;

MetaData[] metaData = new MetaData[1];
AutoFollowStats[] autoFollowStats = new AutoFollowStats[1];
try {
assertBusy(() -> {
metaData[0] = followerClient().admin().cluster().prepareState().get().getState().metaData();
autoFollowStats[0] = getAutoFollowStats();
int count = (int) Arrays.stream(metaData[0].getConcreteAllIndices()).filter(s -> s.startsWith("copy-")).count();
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:
// (added specifically to see that there are no leader indices auto followed multiple times)
assertThat(autoFollowStats[0].getRecentAutoFollowErrors().size(), equalTo(0));
});
} catch (AssertionError ae) {
logger.warn("metadata={}", Strings.toString(metaData[0]));
logger.warn("indices={}", Arrays.toString(metaData[0].indices().keys().toArray(String.class)));
logger.warn("auto follow stats={}", Strings.toString(autoFollowStats[0]));
throw ae;
}
Expand Down

0 comments on commit 098d7dc

Please sign in to comment.