Skip to content

Commit

Permalink
Cleanup alias tests.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Aug 20, 2024
1 parent 7409ffb commit e781a04
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 103 deletions.
2 changes: 1 addition & 1 deletion TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ The report is then used by the [test-spec.yml](.github/workflows/test-spec.yml)
### Coverage Report
The test tool can display detailed and hierarchal test coverage with `--coverage-report`. This is useful to identify untested paths. For example, the [put_alias.yaml](tests/default/indices/aliases/put_alias.yaml) test exercises `PUT /_alias/{name}`, but not the other verbs. The report produces the following output with the missing ones.
The test tool can display detailed and hierarchal test coverage with `--coverage-report`. This is useful to identify untested paths. The report produces the following output with the missing ones.
```
/_alias (4)
Expand Down
7 changes: 7 additions & 0 deletions spec/namespaces/indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ paths:
responses:
'200':
$ref: '#/components/responses/indices.exists_alias@200'
'404':
$ref: '#/components/responses/indices.exists_alias@404'
post:
operationId: indices.put_alias.1
x-operation-group: indices.put_alias
Expand Down Expand Up @@ -1107,6 +1109,8 @@ paths:
responses:
'200':
$ref: '#/components/responses/indices.exists_alias@200'
'404':
$ref: '#/components/responses/indices.exists_alias@404'
post:
operationId: indices.put_alias.6
x-operation-group: indices.put_alias
Expand Down Expand Up @@ -2417,6 +2421,9 @@ components:
indices.exists_alias@200:
content:
application/json: {}
indices.exists_alias@404:
content:
application/json: {}
indices.exists_index_template@200:
content:
application/json: {}
Expand Down
58 changes: 58 additions & 0 deletions tests/default/_core/alias.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test /_alias variants.
epilogues:
- path: /movies/_alias/film*
method: DELETE
status: [200, 404]
- path: /movies
method: DELETE
status: [200, 404]
prologues:
- path: /{index}
method: PUT
parameters:
index: movies
chapters:
- synopsis: Create an alias (index in body).
path: /_alias/{name}
method: PUT
parameters:
name: film1
request:
payload:
index: movies
response:
status: 200
payload:
acknowledged: true
- synopsis: Create an alias (index & alias in body).
path: /_alias
method: PUT
request:
payload:
index: movies
alias: film2
response:
status: 200
payload:
acknowledged: true
- synopsis: Get all aliases.
path: /_alias
method: GET
response:
status: 200
- synopsis: Get an alias by name.
path: /_alias/{name}
parameters:
name: film1
method: GET
response:
status: 200
- synopsis: Check that an alias exists.
path: /_alias/{name}
parameters:
name: film1
method: HEAD
response:
status: 200
35 changes: 35 additions & 0 deletions tests/default/_core/aliases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test aliases endpoints.
epilogues:
- path: /games/_alias/*
method: DELETE
status: [200, 404]
- path: /games
method: DELETE
status: [200, 404]
prologues:
- path: games
method: PUT
- path: /games/_aliases/jeux
method: PUT
chapters:
- synopsis: Multiple alias operations.
path: /_aliases
method: POST
request:
payload:
actions:
- remove:
index: games
alias: jeux
- add:
index: games
alias: plays1
- add:
index: games
alias: plays2
response:
status: 200
payload:
acknowledged: true
20 changes: 17 additions & 3 deletions tests/default/indices/alias/alias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,27 @@ chapters:
parameters:
index: games
name: jeux
- synopsis: Create an alias by Create or Update alias endpoint.
- synopsis: Create an alias.
path: /{index}/_alias/{name}
method: PUT
parameters:
index: games
name: jeux
- synopsis: Create an alias with custom settings by Create or Update alias endpoint.
- synopsis: Check if alias exists.
path: /{index}/_alias/{name}
method: HEAD
parameters:
index: games
name: jeux
- synopsis: Check if alias exists.
path: /{index}/_alias/{name}
method: HEAD
parameters:
index: games
name: invalid
response:
status: 404
- synopsis: Create an alias with custom settings.
path: /{index}/_alias/{name}
method: PUT
parameters:
Expand All @@ -56,7 +70,7 @@ chapters:
is_write_index: true
filter:
match_all: {}
- synopsis: Create an alias with is_hidden by Create or Update alias endpoint.
- synopsis: Create an alias with is_hidden.
version: '>= 2.16'
path: /{index}/_alias/{name}
method: PUT
Expand Down
21 changes: 1 addition & 20 deletions tests/default/indices/aliases/aliases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,9 @@ chapters:
parameters:
index: games
name: jeux
- synopsis: Multiple alias operations.
path: /_aliases
method: POST
request:
payload:
actions:
- remove:
index: games
alias: jeux
- add:
index: games
alias: plays1
- add:
index: games
alias: plays2
response:
status: 200
payload:
acknowledged: true
- synopsis: Delete an alias.
path: /{index}/_aliases/{name}
method: DELETE
parameters:
index: games
name: plays1
name: jeux
79 changes: 0 additions & 79 deletions tests/default/indices/aliases/put_alias.yaml

This file was deleted.

0 comments on commit e781a04

Please sign in to comment.