-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[CCR] Move leader_index and leader_cluster parameters from resume follow to put follow api #34638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
martijnvg
merged 5 commits into
elastic:master
from
martijnvg:ccr_move_leader_index_and_cluster_parameters_from_resume_to_put_follow_api
Oct 23, 2018
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
87b8f60
[CCR] Move leader_index and leader_cluster parameters from resume fol…
martijnvg 21dc7c6
Merge remote-tracking branch 'es/master' into ccr_move_leader_index_a…
martijnvg aa9319c
Merge remote-tracking branch 'es/master' into ccr_move_leader_index_a…
martijnvg 2e72fe9
fixed test compile error
martijnvg 989e335
Merge remote-tracking branch 'es/master' into ccr_move_leader_index_a…
martijnvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,7 @@ public void testFollowIndex() throws Exception { | |
refresh(allowedIndex); | ||
verifyDocuments(adminClient(), allowedIndex, numDocs); | ||
} else { | ||
follow(allowedIndex, allowedIndex); | ||
follow(client(), allowedIndex, allowedIndex); | ||
assertBusy(() -> verifyDocuments(client(), allowedIndex, numDocs)); | ||
assertThat(countCcrNodeTasks(), equalTo(1)); | ||
assertBusy(() -> verifyCcrMonitoring(allowedIndex, allowedIndex)); | ||
|
@@ -93,7 +93,7 @@ public void testFollowIndex() throws Exception { | |
assertThat(countCcrNodeTasks(), equalTo(0)); | ||
}); | ||
|
||
resumeFollow(allowedIndex, allowedIndex); | ||
resumeFollow(allowedIndex); | ||
assertThat(countCcrNodeTasks(), equalTo(1)); | ||
assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/pause_follow"))); | ||
// Make sure that there are no other ccr relates operations running: | ||
|
@@ -106,11 +106,11 @@ public void testFollowIndex() throws Exception { | |
|
||
assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_close"))); | ||
assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/unfollow"))); | ||
Exception e = expectThrows(ResponseException.class, () -> resumeFollow(allowedIndex, allowedIndex)); | ||
Exception e = expectThrows(ResponseException.class, () -> resumeFollow(allowedIndex)); | ||
assertThat(e.getMessage(), containsString("follow index [" + allowedIndex + "] does not have ccr metadata")); | ||
|
||
// User does not have manage_follow_index index privilege for 'unallowedIndex': | ||
e = expectThrows(ResponseException.class, () -> follow(unallowedIndex, unallowedIndex)); | ||
e = expectThrows(ResponseException.class, () -> follow(client(), unallowedIndex, unallowedIndex)); | ||
assertThat(e.getMessage(), | ||
containsString("action [indices:admin/xpack/ccr/put_follow] is unauthorized for user [test_ccr]")); | ||
// Verify that the follow index has not been created and no node tasks are running | ||
|
@@ -119,24 +119,28 @@ public void testFollowIndex() throws Exception { | |
|
||
// User does have manage_follow_index index privilege on 'allowed' index, | ||
// but not read / monitor roles on 'disallowed' index: | ||
e = expectThrows(ResponseException.class, () -> follow(unallowedIndex, allowedIndex)); | ||
e = expectThrows(ResponseException.class, () -> follow(client(), unallowedIndex, allowedIndex)); | ||
assertThat(e.getMessage(), containsString("insufficient privileges to follow index [unallowed-index], " + | ||
"privilege for action [indices:monitor/stats] is missing, " + | ||
"privilege for action [indices:data/read/xpack/ccr/shard_changes] is missing")); | ||
// Verify that the follow index has not been created and no node tasks are running | ||
assertThat(indexExists(adminClient(), unallowedIndex), is(false)); | ||
assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0))); | ||
|
||
e = expectThrows(ResponseException.class, () -> resumeFollow(unallowedIndex, unallowedIndex)); | ||
follow(adminClient(), unallowedIndex, unallowedIndex); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Execute put follow api with admin client, so that we can check whether we fail with the right error when a normal user resumes following an unallowed index. |
||
pauseFollow(adminClient(), unallowedIndex); | ||
|
||
e = expectThrows(ResponseException.class, () -> resumeFollow(unallowedIndex)); | ||
assertThat(e.getMessage(), containsString("insufficient privileges to follow index [unallowed-index], " + | ||
"privilege for action [indices:monitor/stats] is missing, " + | ||
"privilege for action [indices:data/read/xpack/ccr/shard_changes] is missing")); | ||
assertThat(indexExists(adminClient(), unallowedIndex), is(false)); | ||
assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0))); | ||
|
||
e = expectThrows(ResponseException.class, | ||
() -> client().performRequest(new Request("POST", "/" + unallowedIndex + "/_ccr/unfollow"))); | ||
assertThat(e.getMessage(), containsString("action [indices:admin/xpack/ccr/unfollow] is unauthorized for user [test_ccr]")); | ||
assertOK(adminClient().performRequest(new Request("POST", "/" + unallowedIndex + "/_close"))); | ||
assertOK(adminClient().performRequest(new Request("POST", "/" + unallowedIndex + "/_ccr/unfollow"))); | ||
assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0))); | ||
} | ||
} | ||
|
||
|
@@ -187,7 +191,7 @@ public void testAutoFollowPatterns() throws Exception { | |
// Cleanup by deleting auto follow pattern and pause following: | ||
request = new Request("DELETE", "/_ccr/auto_follow/leader_cluster"); | ||
assertOK(client().performRequest(request)); | ||
pauseFollow(allowedIndex); | ||
pauseFollow(client(), allowedIndex); | ||
} | ||
|
||
private int countCcrNodeTasks() throws IOException { | ||
|
@@ -228,18 +232,17 @@ private static void refresh(String index) throws IOException { | |
assertOK(adminClient().performRequest(new Request("POST", "/" + index + "/_refresh"))); | ||
} | ||
|
||
private static void resumeFollow(String leaderIndex, String followIndex) throws IOException { | ||
private static void resumeFollow(String followIndex) throws IOException { | ||
final Request request = new Request("POST", "/" + followIndex + "/_ccr/resume_follow"); | ||
request.setJsonEntity("{\"leader_cluster\": \"leader_cluster\", \"leader_index\": \"" + leaderIndex + | ||
"\", \"poll_timeout\": \"10ms\"}"); | ||
request.setJsonEntity("{\"poll_timeout\": \"10ms\"}"); | ||
assertOK(client().performRequest(request)); | ||
} | ||
|
||
private static void follow(String leaderIndex, String followIndex) throws IOException { | ||
private static void follow(RestClient client, String leaderIndex, String followIndex) throws IOException { | ||
final Request request = new Request("PUT", "/" + followIndex + "/_ccr/follow"); | ||
request.setJsonEntity("{\"leader_cluster\": \"leader_cluster\", \"leader_index\": \"" + leaderIndex + | ||
"\", \"poll_timeout\": \"10ms\"}"); | ||
assertOK(client().performRequest(request)); | ||
assertOK(client.performRequest(request)); | ||
} | ||
|
||
void verifyDocuments(RestClient client, String index, int expectedNumDocs) throws IOException { | ||
|
@@ -302,7 +305,7 @@ private static boolean indexExists(RestClient client, String index) throws IOExc | |
return RestStatus.OK.getStatus() == response.getStatusLine().getStatusCode(); | ||
} | ||
|
||
private static void pauseFollow(String followIndex) throws IOException { | ||
private static void pauseFollow(RestClient client, String followIndex) throws IOException { | ||
assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/pause_follow"))); | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resume api now looks up the follow index metadata in order to get the leader index name and leader cluster name and because of that this fails with a different error. We can't execute a put follow to create the follow index, because the leader cluster runs with a basic license. So I don't see a way how to test this in another way.