forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw error retrieving non-existent SLM policy
Previously when retrieving an SLM policy it would always return a 200 with `{}` in the body, even if the policy did not exist. This changes that behavior to throw an error (similar to our other APIs) if a policy doesn't exist. This also adds a basic CRUD yml test for the behavior. Resolves elastic#47664
- Loading branch information
Showing
2 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
x-pack/plugin/ilm/qa/rest/src/test/resources/rest-api-spec/test/ilm/11_basic_slm.yml
This file contains 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,87 @@ | ||
--- | ||
setup: | ||
- do: | ||
cluster.health: | ||
wait_for_status: yellow | ||
|
||
--- | ||
"Test Basic Policy CRUD": | ||
- do: | ||
catch: missing | ||
slm.get_lifecycle: | ||
policy_id: "daily-snapshots" | ||
|
||
- do: | ||
catch: missing | ||
slm.delete_lifecycle: | ||
policy_id: "daily-snapshots" | ||
|
||
- do: | ||
snapshot.create_repository: | ||
repository: repo | ||
body: | ||
type: fs | ||
settings: | ||
location: "my-snaps" | ||
|
||
- do: | ||
slm.put_lifecycle: | ||
policy_id: "daily-snapshots" | ||
body: | | ||
{ | ||
"schedule": "0 1 2 3 4 ?", | ||
"name": "<production-snap-{now/d}>", | ||
"repository": "repo", | ||
"config": { | ||
"indices": ["foo-*", "important"], | ||
"ignore_unavailable": false, | ||
"include_global_state": false | ||
}, | ||
"retention": { | ||
"expire_after": "30d", | ||
"min_count": 1, | ||
"max_count": 50 | ||
} | ||
} | ||
- do: | ||
slm.get_lifecycle: | ||
policy_id: "daily-snapshots" | ||
- match: { daily-snapshots.version: 1 } | ||
- match: { daily-snapshots.policy.name: "<production-snap-{now/d}>" } | ||
- is_true: daily-snapshots.next_execution_millis | ||
- is_true: daily-snapshots.stats | ||
- match: { daily-snapshots.policy.schedule: "0 1 2 3 4 ?" } | ||
|
||
- do: | ||
slm.put_lifecycle: | ||
policy_id: "daily-snapshots" | ||
body: | | ||
{ | ||
"schedule": "1 1 1 1 1 ?", | ||
"name": "<production-snap-{now/d}>", | ||
"repository": "repo", | ||
"config": { | ||
"indices": ["foo-*", "important"], | ||
"ignore_unavailable": false, | ||
"include_global_state": false | ||
}, | ||
"retention": { | ||
"expire_after": "30d", | ||
"min_count": 1, | ||
"max_count": 50 | ||
} | ||
} | ||
- do: | ||
catch: missing | ||
slm.get_lifecycle: | ||
policy_id: "doesnt-exist" | ||
|
||
- do: | ||
slm.get_lifecycle: | ||
policy_id: "daily-snapshots" | ||
- match: { daily-snapshots.version: 2 } | ||
- match: { daily-snapshots.policy.schedule: "1 1 1 1 1 ?" } | ||
- is_true: daily-snapshots.next_execution_millis | ||
- is_true: daily-snapshots.stats |
This file contains 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