@@ -56,12 +56,14 @@ public void testAutoFollower() {
5656 .build ();
5757
5858 AutoFollowPattern autoFollowPattern =
59- new AutoFollowPattern (Collections .singletonList ("logs-*" ), null , null , null , null , null , null , null , null , null );
59+ new AutoFollowPattern (Collections .singletonList ("logs-*" ), null , null , null , null , null , null , null , null );
6060 Map <String , AutoFollowPattern > patterns = new HashMap <>();
6161 patterns .put ("remote" , autoFollowPattern );
6262 Map <String , List <String >> followedLeaderIndexUUIDS = new HashMap <>();
6363 followedLeaderIndexUUIDS .put ("remote" , new ArrayList <>());
64- AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata (patterns , followedLeaderIndexUUIDS );
64+ Map <String , Map <String , String >> autoFollowHeaders = new HashMap <>();
65+ autoFollowHeaders .put ("remote" , Collections .singletonMap ("key" , "val" ));
66+ AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata (patterns , followedLeaderIndexUUIDS , autoFollowHeaders );
6567
6668 ClusterState currentState = ClusterState .builder (new ClusterName ("name" ))
6769 .metaData (MetaData .builder ().putCustom (AutoFollowMetadata .TYPE , autoFollowMetadata ))
@@ -83,6 +85,7 @@ public void testAutoFollower() {
8385 void getLeaderClusterState (Map <String , String > headers ,
8486 String leaderClusterAlias ,
8587 BiConsumer <ClusterState , Exception > handler ) {
88+ assertThat (headers , sameInstance (autoFollowHeaders .get ("remote" )));
8689 handler .accept (leaderState , null );
8790 }
8891
@@ -91,6 +94,7 @@ void createAndFollow(Map<String, String> headers,
9194 FollowIndexAction .Request followRequest ,
9295 Runnable successHandler ,
9396 Consumer <Exception > failureHandler ) {
97+ assertThat (headers , sameInstance (autoFollowHeaders .get ("remote" )));
9498 assertThat (followRequest .getLeaderIndex (), equalTo ("remote:logs-20190101" ));
9599 assertThat (followRequest .getFollowerIndex (), equalTo ("logs-20190101" ));
96100 successHandler .run ();
@@ -115,12 +119,13 @@ public void testAutoFollowerClusterStateApiFailure() {
115119 when (client .getRemoteClusterClient (anyString ())).thenReturn (client );
116120
117121 AutoFollowPattern autoFollowPattern =
118- new AutoFollowPattern (Collections .singletonList ("logs-*" ), null , null , null , null , null , null , null , null , null );
122+ new AutoFollowPattern (Collections .singletonList ("logs-*" ), null , null , null , null , null , null , null , null );
119123 Map <String , AutoFollowPattern > patterns = new HashMap <>();
120124 patterns .put ("remote" , autoFollowPattern );
121125 Map <String , List <String >> followedLeaderIndexUUIDS = new HashMap <>();
122126 followedLeaderIndexUUIDS .put ("remote" , new ArrayList <>());
123- AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata (patterns , followedLeaderIndexUUIDS );
127+ Map <String , Map <String , String >> headers = new HashMap <>();
128+ AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata (patterns , followedLeaderIndexUUIDS , headers );
124129 ClusterState followerState = ClusterState .builder (new ClusterName ("remote" ))
125130 .metaData (MetaData .builder ().putCustom (AutoFollowMetadata .TYPE , autoFollowMetadata ))
126131 .build ();
@@ -172,12 +177,13 @@ public void testAutoFollowerUpdateClusterStateFailure() {
172177 .build ();
173178
174179 AutoFollowPattern autoFollowPattern =
175- new AutoFollowPattern (Collections .singletonList ("logs-*" ), null , null , null , null , null , null , null , null , null );
180+ new AutoFollowPattern (Collections .singletonList ("logs-*" ), null , null , null , null , null , null , null , null );
176181 Map <String , AutoFollowPattern > patterns = new HashMap <>();
177182 patterns .put ("remote" , autoFollowPattern );
178183 Map <String , List <String >> followedLeaderIndexUUIDS = new HashMap <>();
179184 followedLeaderIndexUUIDS .put ("remote" , new ArrayList <>());
180- AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata (patterns , followedLeaderIndexUUIDS );
185+ Map <String , Map <String , String >> headers = new HashMap <>();
186+ AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata (patterns , followedLeaderIndexUUIDS , headers );
181187 ClusterState followerState = ClusterState .builder (new ClusterName ("remote" ))
182188 .metaData (MetaData .builder ().putCustom (AutoFollowMetadata .TYPE , autoFollowMetadata ))
183189 .build ();
@@ -233,12 +239,13 @@ public void testAutoFollowerCreateAndFollowApiCallFailure() {
233239 .build ();
234240
235241 AutoFollowPattern autoFollowPattern =
236- new AutoFollowPattern (Collections .singletonList ("logs-*" ), null , null , null , null , null , null , null , null , null );
242+ new AutoFollowPattern (Collections .singletonList ("logs-*" ), null , null , null , null , null , null , null , null );
237243 Map <String , AutoFollowPattern > patterns = new HashMap <>();
238244 patterns .put ("remote" , autoFollowPattern );
239245 Map <String , List <String >> followedLeaderIndexUUIDS = new HashMap <>();
240246 followedLeaderIndexUUIDS .put ("remote" , new ArrayList <>());
241- AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata (patterns , followedLeaderIndexUUIDS );
247+ Map <String , Map <String , String >> headers = new HashMap <>();
248+ AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata (patterns , followedLeaderIndexUUIDS , headers );
242249 ClusterState followerState = ClusterState .builder (new ClusterName ("remote" ))
243250 .metaData (MetaData .builder ().putCustom (AutoFollowMetadata .TYPE , autoFollowMetadata ))
244251 .build ();
@@ -285,10 +292,11 @@ void updateAutoFollowMetadata(Function<ClusterState, ClusterState> updateFunctio
285292
286293 public void testGetLeaderIndicesToFollow () {
287294 AutoFollowPattern autoFollowPattern =
288- new AutoFollowPattern (Collections .singletonList ("metrics-*" ), null , null , null , null , null , null , null , null , null );
295+ new AutoFollowPattern (Collections .singletonList ("metrics-*" ), null , null , null , null , null , null , null , null );
296+ Map <String , Map <String , String >> headers = new HashMap <>();
289297 ClusterState followerState = ClusterState .builder (new ClusterName ("remote" ))
290298 .metaData (MetaData .builder ().putCustom (AutoFollowMetadata .TYPE ,
291- new AutoFollowMetadata (Collections .singletonMap ("remote" , autoFollowPattern ), Collections .emptyMap ())))
299+ new AutoFollowMetadata (Collections .singletonMap ("remote" , autoFollowPattern ), Collections .emptyMap (), headers )))
292300 .build ();
293301
294302 MetaData .Builder imdBuilder = MetaData .builder ();
@@ -331,15 +339,15 @@ public void testGetLeaderIndicesToFollow() {
331339
332340 public void testGetFollowerIndexName () {
333341 AutoFollowPattern autoFollowPattern = new AutoFollowPattern (Collections .singletonList ("metrics-*" ), null , null ,
334- null , null , null , null , null , null , null );
342+ null , null , null , null , null , null );
335343 assertThat (AutoFollower .getFollowerIndexName (autoFollowPattern , "metrics-0" ), equalTo ("metrics-0" ));
336344
337345 autoFollowPattern = new AutoFollowPattern (Collections .singletonList ("metrics-*" ), "eu-metrics-0" , null , null ,
338- null , null , null , null , null , null );
346+ null , null , null , null , null );
339347 assertThat (AutoFollower .getFollowerIndexName (autoFollowPattern , "metrics-0" ), equalTo ("eu-metrics-0" ));
340348
341349 autoFollowPattern = new AutoFollowPattern (Collections .singletonList ("metrics-*" ), "eu-{{leader_index}}" , null ,
342- null , null , null , null , null , null , null );
350+ null , null , null , null , null , null );
343351 assertThat (AutoFollower .getFollowerIndexName (autoFollowPattern , "metrics-0" ), equalTo ("eu-metrics-0" ));
344352 }
345353
0 commit comments