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