58
58
import static org .hamcrest .Matchers .hasSize ;
59
59
import static org .hamcrest .Matchers .is ;
60
60
import static org .hamcrest .Matchers .notNullValue ;
61
+ import static org .hamcrest .Matchers .nullValue ;
61
62
62
63
public class CCRIT extends ESRestHighLevelClientTestCase {
63
64
@@ -245,8 +246,10 @@ public void testForgetFollower() throws IOException {
245
246
246
247
public void testAutoFollowing () throws Exception {
247
248
CcrClient ccrClient = highLevelClient ().ccr ();
248
- PutAutoFollowPatternRequest putAutoFollowPatternRequest =
249
- new PutAutoFollowPatternRequest ("pattern1" , "local_cluster" , Collections .singletonList ("logs-*" ));
249
+ PutAutoFollowPatternRequest putAutoFollowPatternRequest = new PutAutoFollowPatternRequest ("pattern1" ,
250
+ "local_cluster" ,
251
+ Collections .singletonList ("logs-*" ),
252
+ Collections .singletonList ("logs-excluded" ));
250
253
putAutoFollowPatternRequest .setFollowIndexNamePattern ("copy-{{leader_index}}" );
251
254
final int followerNumberOfReplicas = randomIntBetween (0 , 4 );
252
255
final Settings autoFollowerPatternSettings =
@@ -256,6 +259,11 @@ public void testAutoFollowing() throws Exception {
256
259
execute (putAutoFollowPatternRequest , ccrClient ::putAutoFollowPattern , ccrClient ::putAutoFollowPatternAsync );
257
260
assertThat (putAutoFollowPatternResponse .isAcknowledged (), is (true ));
258
261
262
+ CreateIndexRequest createExcludedIndexRequest = new CreateIndexRequest ("logs-excluded" );
263
+ CreateIndexResponse createExcludedIndexResponse =
264
+ highLevelClient ().indices ().create (createExcludedIndexRequest , RequestOptions .DEFAULT );
265
+ assertThat (createExcludedIndexResponse .isAcknowledged (), is (true ));
266
+
259
267
CreateIndexRequest createIndexRequest = new CreateIndexRequest ("logs-20200101" );
260
268
CreateIndexResponse response = highLevelClient ().indices ().create (createIndexRequest , RequestOptions .DEFAULT );
261
269
assertThat (response .isAcknowledged (), is (true ));
@@ -265,11 +273,13 @@ public void testAutoFollowing() throws Exception {
265
273
CcrStatsResponse ccrStatsResponse = execute (ccrStatsRequest , ccrClient ::getCcrStats , ccrClient ::getCcrStatsAsync );
266
274
assertThat (ccrStatsResponse .getAutoFollowStats ().getNumberOfSuccessfulFollowIndices (), equalTo (1L ));
267
275
assertThat (ccrStatsResponse .getIndicesFollowStats ().getShardFollowStats ("copy-logs-20200101" ), notNullValue ());
276
+ assertThat (ccrStatsResponse .getIndicesFollowStats ().getShardFollowStats ("copy-logs-excluded" ), nullValue ());
268
277
});
269
278
assertThat (indexExists ("copy-logs-20200101" ), is (true ));
270
279
assertThat (
271
280
getIndexSettingsAsMap ("copy-logs-20200101" ),
272
281
hasEntry ("index.number_of_replicas" , Integer .toString (followerNumberOfReplicas )));
282
+ assertThat (indexExists ("copy-logs-excluded" ), is (false ));
273
283
274
284
GetAutoFollowPatternRequest getAutoFollowPatternRequest =
275
285
randomBoolean () ? new GetAutoFollowPatternRequest ("pattern1" ) : new GetAutoFollowPatternRequest ();
@@ -280,6 +290,7 @@ public void testAutoFollowing() throws Exception {
280
290
assertThat (pattern , notNullValue ());
281
291
assertThat (pattern .getRemoteCluster (), equalTo (putAutoFollowPatternRequest .getRemoteCluster ()));
282
292
assertThat (pattern .getLeaderIndexPatterns (), equalTo (putAutoFollowPatternRequest .getLeaderIndexPatterns ()));
293
+ assertThat (pattern .getLeaderIndexExclusionPatterns (), equalTo (putAutoFollowPatternRequest .getLeaderIndexExclusionPatterns ()));
283
294
assertThat (pattern .getFollowIndexNamePattern (), equalTo (putAutoFollowPatternRequest .getFollowIndexNamePattern ()));
284
295
assertThat (pattern .getSettings (), equalTo (autoFollowerPatternSettings ));
285
296
0 commit comments