|
@@ -620,6 +620,10 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().size(), equalTo(2));
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().get("remote1"), notNullValue());
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().get("remote2"), notNullValue());
|
|
|
+ // Get a reference to auto follower that will get removed, so that we can assert that it has been marked as removed,
|
|
|
+ // when pattern 1 and 3 are moved. (To avoid a edge case where multiple auto follow coordinators for the same remote cluster)
|
|
|
+ AutoFollowCoordinator.AutoFollower removedAutoFollower1 = autoFollowCoordinator.getAutoFollowers().get("remote1");
|
|
|
+ assertThat(removedAutoFollower1.removed, is(false));
|
|
|
// Remove patterns 1 and 3:
|
|
|
patterns.remove("pattern1");
|
|
|
patterns.remove("pattern3");
|
|
@@ -630,6 +634,7 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
|
|
|
autoFollowCoordinator.updateAutoFollowers(clusterState);
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().size(), equalTo(1));
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().get("remote2"), notNullValue());
|
|
|
+ assertThat(removedAutoFollower1.removed, is(true));
|
|
|
// Add pattern 4:
|
|
|
patterns.put("pattern4", new AutoFollowPattern("remote1", Collections.singletonList("metrics-*"), null, null, null,
|
|
|
null, null, null, null, null, null, null, null));
|
|
@@ -641,7 +646,13 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().size(), equalTo(2));
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().get("remote1"), notNullValue());
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().get("remote2"), notNullValue());
|
|
|
+ // Get references to auto followers that will get removed, so that we can assert that those have been marked as removed,
|
|
|
+ // when pattern 2 and 4 are moved. (To avoid a edge case where multiple auto follow coordinators for the same remote cluster)
|
|
|
+ removedAutoFollower1 = autoFollowCoordinator.getAutoFollowers().get("remote1");
|
|
|
+ AutoFollower removedAutoFollower2 = autoFollowCoordinator.getAutoFollowers().get("remote2");
|
|
|
// Remove patterns 2 and 4:
|
|
|
+ assertThat(removedAutoFollower1.removed, is(false));
|
|
|
+ assertThat(removedAutoFollower2.removed, is(false));
|
|
|
patterns.remove("pattern2");
|
|
|
patterns.remove("pattern4");
|
|
|
clusterState = ClusterState.builder(new ClusterName("remote"))
|
|
@@ -650,6 +661,8 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
|
|
|
.build();
|
|
|
autoFollowCoordinator.updateAutoFollowers(clusterState);
|
|
|
assertThat(autoFollowCoordinator.getStats().getAutoFollowedClusters().size(), equalTo(0));
|
|
|
+ assertThat(removedAutoFollower1.removed, is(true));
|
|
|
+ assertThat(removedAutoFollower2.removed, is(true));
|
|
|
}
|
|
|
|
|
|
public void testUpdateAutoFollowersNoPatterns() {
|