-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added _recovery API tests. Signed-off-by: dblock <[email protected]> * Fix /_scripts endpoints. Signed-off-by: dblock <[email protected]> --------- Signed-off-by: dblock <[email protected]>
- Loading branch information
Showing
10 changed files
with
301 additions
and
4 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -19,4 +19,3 @@ components: | |
required: | ||
- document | ||
- index | ||
- query |
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
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,13 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test _recovery endpoint. | ||
chapters: | ||
- synopsis: Get information about any completed or ongoing shard recoveries for all indexes. | ||
path: /_recovery | ||
warnings: | ||
multiple-paths-detected: false | ||
method: GET | ||
parameters: | ||
human: true | ||
response: | ||
status: 200 |
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,11 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test the _script_context endpoint to retrieve available script contexts. | ||
|
||
chapters: | ||
- synopsis: Retrieve available script languages. | ||
version: '>= 2.1' | ||
path: /_script_language | ||
method: GET | ||
response: | ||
status: 200 |
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,128 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test the _scripts endpoint. | ||
|
||
prologues: | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: books}} | ||
- {author: Harper Lee, title: To Kill a Mockingbird, year: 1960, ratings: [1, 2, 3]} | ||
- {create: {_index: books}} | ||
- {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991, ratings: [3, 4, 5]} | ||
epilogues: | ||
- path: /books | ||
method: DELETE | ||
status: [200, 404] | ||
- path: /_scripts/add_ratings | ||
method: DELETE | ||
status: [200, 404] | ||
- path: /_scripts/average_ratings | ||
method: DELETE | ||
status: [200, 404] | ||
chapters: | ||
- synopsis: Create a painless script that sums the ratings (PUT). | ||
path: /_scripts/{id} | ||
method: PUT | ||
parameters: | ||
id: add_ratings | ||
request: | ||
payload: | ||
script: | ||
lang: painless | ||
source: |- | ||
int total = 0; | ||
for (int i = 0; i < doc['ratings'].length; ++i) { | ||
total += doc['ratings'][i]; | ||
} | ||
return total; | ||
response: | ||
status: 200 | ||
- synopsis: Get ratings sum (PUT). | ||
path: /{index}/_search | ||
method: POST | ||
warnings: | ||
multiple-paths-detected: false | ||
parameters: | ||
index: books | ||
request: | ||
payload: | ||
query: | ||
match_all: {} | ||
script_fields: | ||
ratings_sum: | ||
script: | ||
id: add_ratings | ||
response: | ||
status: 200 | ||
payload: | ||
hits: | ||
hits: | ||
- fields: | ||
ratings_sum: | ||
- 6 | ||
- fields: | ||
ratings_sum: | ||
- 12 | ||
- synopsis: Create a painless script that calculates a ratings average (POST). | ||
path: /_scripts/{id} | ||
method: POST | ||
parameters: | ||
id: average_ratings | ||
request: | ||
payload: | ||
script: | ||
lang: painless | ||
source: |- | ||
if (doc['ratings'].length > 0) { | ||
int total = 0; | ||
for (int i = 0; i < doc['ratings'].length; ++i) { | ||
total += doc['ratings'][i]; | ||
} | ||
return total / doc['ratings'].length; | ||
} else { | ||
return 0; | ||
} | ||
response: | ||
status: 200 | ||
- synopsis: Score results by ratings average (POST). | ||
path: /{index}/_search | ||
method: POST | ||
warnings: | ||
multiple-paths-detected: false | ||
parameters: | ||
index: books | ||
request: | ||
payload: | ||
query: | ||
script_score: | ||
query: | ||
match_all: {} | ||
script: | ||
id: average_ratings | ||
response: | ||
status: 200 | ||
payload: | ||
hits: | ||
hits: | ||
- _score: 4 | ||
- _score: 2 | ||
- synopsis: Get a script. | ||
path: /_scripts/{id} | ||
method: GET | ||
parameters: | ||
id: add_ratings | ||
response: | ||
status: 200 | ||
payload: | ||
_id: add_ratings | ||
found: true | ||
- synopsis: Delete script. | ||
path: /_scripts/{id} | ||
method: DELETE | ||
parameters: | ||
id: add_ratings |
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,41 @@ | ||
$schema: ../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test the _scripts contexts endpoint. | ||
|
||
prologues: | ||
- path: /_scripts/add_ratings | ||
method: DELETE | ||
status: [200, 404] | ||
chapters: | ||
- synopsis: Create a painless script that sums the ratings. | ||
path: /_scripts/{id}/{context} | ||
method: POST | ||
parameters: | ||
id: add_ratings | ||
context: field | ||
request: | ||
payload: | ||
script: | ||
lang: painless | ||
source: |- | ||
int total = 0; | ||
for (int i = 0; i < doc['ratings'].length; ++i) { | ||
total += doc['ratings'][i]; | ||
} | ||
return total; | ||
response: | ||
status: 200 | ||
- synopsis: Update a painless script that sums the ratings. | ||
path: /_scripts/{id}/{context} | ||
method: PUT | ||
parameters: | ||
id: add_ratings | ||
context: field | ||
request: | ||
payload: | ||
script: | ||
lang: painless | ||
source: |- | ||
return 0; | ||
response: | ||
status: 200 |
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,69 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test the _scripts execute endpoint. | ||
|
||
prologues: | ||
- path: /movies | ||
method: PUT | ||
request: | ||
payload: | ||
mappings: | ||
properties: | ||
year: | ||
type: integer | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] | ||
chapters: | ||
- synopsis: Execute a painless script returning a string. | ||
path: /_scripts/painless/_execute | ||
method: GET | ||
request: | ||
payload: | ||
script: | ||
source: |- | ||
(params.x + params.y)/2 | ||
params: | ||
x: 80 | ||
y: 100 | ||
response: | ||
status: 200 | ||
payload: | ||
result: '90' | ||
- synopsis: Execute a painless script returning `false`. | ||
path: /_scripts/painless/_execute | ||
method: POST | ||
request: | ||
payload: | ||
context: filter | ||
context_setup: | ||
index: movies | ||
document: | ||
year: 1976 | ||
script: | ||
source: |- | ||
doc['year'].value > params.year | ||
params: | ||
year: 2000 | ||
response: | ||
status: 200 | ||
payload: | ||
result: false | ||
- synopsis: Execute a painless script returning a number. | ||
path: /_scripts/painless/_execute | ||
method: POST | ||
request: | ||
payload: | ||
context: score | ||
context_setup: | ||
index: movies | ||
document: | ||
year: 1976 | ||
script: | ||
source: |- | ||
doc['year'].value | ||
response: | ||
status: 200 | ||
payload: | ||
result: 1976 |
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,32 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test _recovery endpoint. | ||
prologues: | ||
- path: /movies | ||
method: PUT | ||
status: [200] | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] | ||
chapters: | ||
- synopsis: Get information about any completed or ongoing shard recoveries for an index. | ||
path: /{index}/_recovery | ||
warnings: | ||
multiple-paths-detected: false | ||
method: GET | ||
parameters: | ||
index: movies | ||
response: | ||
status: 200 | ||
payload: | ||
movies: | ||
shards: | ||
- stage: DONE | ||
index: | ||
size: | ||
total_in_bytes: 0 | ||
translog: | ||
total: 0 | ||
verify_index: | ||
total_time_in_millis: 0 |