From c531a609d17685f7fd977cfbde6280edc19edb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20Casta=C3=B1o?= Date: Wed, 26 May 2021 12:25:36 +0200 Subject: [PATCH] Review comments --- .../GetAutoFollowPatternResponseTests.java | 2 +- .../rest-api-spec/test/ccr/auto_follow.yml | 3 --- .../elasticsearch/xpack/ccr/AutoFollowIT.java | 24 +++++++++---------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ccr/GetAutoFollowPatternResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ccr/GetAutoFollowPatternResponseTests.java index 6113dc9a0cc3e..abd785841f0a2 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ccr/GetAutoFollowPatternResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ccr/GetAutoFollowPatternResponseTests.java @@ -39,7 +39,7 @@ protected GetAutoFollowPatternAction.Response createServerTestInstance(XContentT for (int i = 0; i < numPatterns; i++) { String remoteCluster = randomAlphaOfLength(4); List leaderIndexPatterns = Collections.singletonList(randomAlphaOfLength(4)); - List leaderIndexExclusionsPatterns = Collections.singletonList(randomAlphaOfLength(4)); + List leaderIndexExclusionsPatterns = randomList(0, randomIntBetween(1, 10), () -> randomAlphaOfLength(4)); String followIndexNamePattern = randomAlphaOfLength(4); final Settings settings = Settings.builder().put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), randomIntBetween(0, 4)).build(); diff --git a/x-pack/plugin/ccr/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/ccr/auto_follow.yml b/x-pack/plugin/ccr/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/ccr/auto_follow.yml index c4a86d9fbb1cb..fb094f1b9974b 100644 --- a/x-pack/plugin/ccr/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/ccr/auto_follow.yml +++ b/x-pack/plugin/ccr/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/ccr/auto_follow.yml @@ -204,7 +204,6 @@ body: remote_cluster: local leader_index_patterns: ['logs-*'] - leader_index_exclusion_patterns: ['logs-excluded'] max_outstanding_read_requests: 2 - is_true: acknowledged @@ -233,7 +232,6 @@ - match: { patterns.0.name: 'pattern_test' } - match: { patterns.0.pattern.remote_cluster: 'local' } - match: { patterns.0.pattern.leader_index_patterns: ['logs-*'] } - - match: { patterns.0.pattern.leader_index_exclusion_patterns: ['logs-excluded'] } - match: { patterns.0.pattern.max_outstanding_read_requests: 2 } - match: { patterns.0.pattern.active: false } @@ -253,7 +251,6 @@ - match: { patterns.0.name: 'pattern_test' } - match: { patterns.0.pattern.remote_cluster: 'local' } - match: { patterns.0.pattern.leader_index_patterns: ['logs-*'] } - - match: { patterns.0.pattern.leader_index_exclusion_patterns: ['logs-excluded'] } - match: { patterns.0.pattern.max_outstanding_read_requests: 2 } - match: { patterns.0.pattern.active: true } diff --git a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java index 9f4232ba481c9..8bd26cfcac667 100644 --- a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java +++ b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java @@ -522,23 +522,21 @@ public void testAutoFollowExclusion() throws Exception { putAutoFollowPatterns("my-pattern1", new String[] {"logs-*"}, Collections.singletonList("logs-2018*")); + createLeaderIndex("logs-201801", leaderIndexSettings); + AutoFollowStats autoFollowStats = getAutoFollowStats(); + assertThat(autoFollowStats.getNumberOfSuccessfulFollowIndices(), equalTo(0L)); + assertThat(autoFollowStats.getNumberOfFailedFollowIndices(), equalTo(0L)); + assertThat(autoFollowStats.getNumberOfFailedRemoteClusterStateRequests(), equalTo(0L)); + assertFalse(ESIntegTestCase.indexExists("copy-logs-201801", followerClient())); + createLeaderIndex("logs-201701", leaderIndexSettings); assertLongBusy(() -> { - AutoFollowStats autoFollowStats = getAutoFollowStats(); - assertThat(autoFollowStats.getNumberOfSuccessfulFollowIndices(), equalTo(1L)); - assertThat(autoFollowStats.getNumberOfFailedFollowIndices(), equalTo(0L)); - assertThat(autoFollowStats.getNumberOfFailedRemoteClusterStateRequests(), equalTo(0L)); + AutoFollowStats autoFollowStatsResponse = getAutoFollowStats(); + assertThat(autoFollowStatsResponse.getNumberOfSuccessfulFollowIndices(), equalTo(1L)); + assertThat(autoFollowStatsResponse.getNumberOfFailedFollowIndices(), greaterThanOrEqualTo(0L)); + assertThat(autoFollowStatsResponse.getNumberOfFailedRemoteClusterStateRequests(), equalTo(0L)); }); assertTrue(ESIntegTestCase.indexExists("copy-logs-201701", followerClient())); - - createLeaderIndex("logs-201801", leaderIndexSettings); - assertLongBusy(() -> { - AutoFollowStats autoFollowStats = getAutoFollowStats(); - assertThat(autoFollowStats.getNumberOfSuccessfulFollowIndices(), equalTo(1L)); - assertThat(autoFollowStats.getNumberOfFailedFollowIndices(), greaterThanOrEqualTo(0L)); - assertThat(autoFollowStats.getNumberOfFailedRemoteClusterStateRequests(), equalTo(0L)); - }); - assertFalse(ESIntegTestCase.indexExists("copy-logs-201801", followerClient())); }