-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Use alias name from rollover request to query indices stats #40774
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
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
196aa13
Use alias name from rollover request to query indices stats
5733363
Check whether index is same and only one write index exists for alias
d68a4f5
Revert "Check whether index is same and only one write index exists f…
1d35dd2
Evaluate conditions by looking at source index stats only
3af13dc
Fix the unit test
f78b974
Address review feedback
f0bdff9
fix checkstyle issue
b076a96
fix comment
f9f8bc9
Merge branch 'master' into fix-rollover-authz
e97ceb9
Merge branch 'master' into fix-rollover-authz
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
139 changes: 139 additions & 0 deletions
139
...k/plugin/src/test/resources/rest-api-spec/test/security/authz/31_rollover_using_alias.yml
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 |
---|---|---|
@@ -0,0 +1,139 @@ | ||
--- | ||
|
||
setup: | ||
- skip: | ||
features: headers | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: yellow | ||
|
||
- do: | ||
security.put_role: | ||
name: "alias_write_manage_role" | ||
body: > | ||
{ | ||
"indices": [ | ||
{ "names": ["write_manage_alias"], "privileges": ["write", "manage"] } | ||
] | ||
} | ||
|
||
- do: | ||
security.put_user: | ||
username: "test_user" | ||
body: > | ||
{ | ||
"password" : "x-pack-test-password", | ||
"roles" : [ "alias_write_manage_role" ], | ||
"full_name" : "user with privileges to write, manage via alias" | ||
} | ||
|
||
- do: | ||
indices.create: | ||
index: logs-000001 | ||
body: | ||
settings: | ||
index: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
|
||
- do: | ||
indices.put_alias: | ||
index: logs-000001 | ||
name: write_manage_alias | ||
|
||
--- | ||
teardown: | ||
- do: | ||
security.delete_user: | ||
username: "test_user" | ||
ignore: 404 | ||
|
||
- do: | ||
security.delete_role: | ||
name: "alias_write_role" | ||
ignore: 404 | ||
|
||
- do: | ||
indices.delete_alias: | ||
index: "logs-000001" | ||
name: [ "write_manage_alias" ] | ||
ignore: 404 | ||
|
||
- do: | ||
indices.delete: | ||
index: [ "logs-000001" ] | ||
ignore: 404 | ||
|
||
--- | ||
"Test rollover, index via write alias of index": | ||
talevy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# index using alias | ||
- do: | ||
headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user | ||
create: | ||
id: 1 | ||
index: write_manage_alias | ||
body: > | ||
{ | ||
"name" : "doc1" | ||
} | ||
|
||
- do: | ||
headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user | ||
create: | ||
id: 2 | ||
index: write_manage_alias | ||
body: > | ||
{ | ||
"name" : "doc2" | ||
} | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
# rollover using alias | ||
- do: | ||
headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user | ||
indices.rollover: | ||
alias: "write_manage_alias" | ||
wait_for_active_shards: 1 | ||
body: | ||
conditions: | ||
max_docs: 1 | ||
|
||
- match: { old_index: logs-000001 } | ||
- match: { new_index: logs-000002 } | ||
- match: { rolled_over: true } | ||
- match: { dry_run: false } | ||
- match: { conditions: { "[max_docs: 1]": true } } | ||
|
||
# ensure new index is created | ||
- do: | ||
indices.exists: | ||
index: logs-000002 | ||
|
||
- is_true: '' | ||
|
||
# index using alias | ||
- do: | ||
headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user | ||
create: | ||
id: 3 | ||
index: write_manage_alias | ||
body: > | ||
{ | ||
"name" : "doc3" | ||
} | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
# check alias points to the new index and the doc was indexed | ||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: write_manage_alias | ||
|
||
- match: { hits.total: 1 } | ||
- match: { hits.hits.0._index: "logs-000002"} |
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.
Uh oh!
There was an error while loading. Please reload this page.