diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md index d336d71b2..852d3844b 100644 --- a/TESTING_GUIDE.md +++ b/TESTING_GUIDE.md @@ -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) diff --git a/spec/namespaces/indices.yaml b/spec/namespaces/indices.yaml index d5e13e558..7c0a511c5 100644 --- a/spec/namespaces/indices.yaml +++ b/spec/namespaces/indices.yaml @@ -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 @@ -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 @@ -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: {} diff --git a/tests/default/_core/alias.yaml b/tests/default/_core/alias.yaml new file mode 100644 index 000000000..63621ee73 --- /dev/null +++ b/tests/default/_core/alias.yaml @@ -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 diff --git a/tests/default/_core/aliases.yaml b/tests/default/_core/aliases.yaml new file mode 100644 index 000000000..436e3022b --- /dev/null +++ b/tests/default/_core/aliases.yaml @@ -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 diff --git a/tests/default/indices/alias/alias.yaml b/tests/default/indices/alias/alias.yaml index 2fbba5383..4000dbb13 100644 --- a/tests/default/indices/alias/alias.yaml +++ b/tests/default/indices/alias/alias.yaml @@ -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: @@ -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 diff --git a/tests/default/indices/aliases/aliases.yaml b/tests/default/indices/aliases/aliases.yaml index 805510ae4..75a1918c1 100644 --- a/tests/default/indices/aliases/aliases.yaml +++ b/tests/default/indices/aliases/aliases.yaml @@ -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 diff --git a/tests/default/indices/aliases/put_alias.yaml b/tests/default/indices/aliases/put_alias.yaml deleted file mode 100644 index d7eaa5c99..000000000 --- a/tests/default/indices/aliases/put_alias.yaml +++ /dev/null @@ -1,79 +0,0 @@ -$schema: ../../../../json_schemas/test_story.schema.yaml - -description: Test put_alias variants. -epilogues: - - path: /test_index/_alias/test_alias* - method: DELETE - status: [200, 404] - - path: /test_index - method: DELETE - status: [200, 404] -prologues: - - path: /{index} - method: PUT - parameters: - index: test_index -chapters: - - synopsis: Create an alias - specifying index & alias in path. - path: /{index}/_alias/{name} - method: PUT - parameters: - index: test_index - name: test_alias - response: - status: 200 - payload: - acknowledged: true - - - synopsis: Create an alias - specifying index in path & alias in body. - path: /{index}/_alias - method: PUT - parameters: - index: test_index - request: - payload: - alias: test_alias_1 - response: - status: 200 - payload: - acknowledged: true - - - synopsis: Create an alias - specifying index in body & alias in path. - path: /_alias/{name} - method: PUT - parameters: - name: test_alias_2 - request: - payload: - index: test_index - response: - status: 200 - payload: - acknowledged: true - - - synopsis: Create an alias - specifying index & alias in body. - path: /_alias - method: PUT - request: - payload: - index: test_index - alias: test_alias_3 - response: - status: 200 - payload: - acknowledged: true - - - synopsis: Retrieve aliases. - path: /{index}/_alias - method: GET - parameters: - index: test_index - response: - status: 200 - payload: - test_index: - aliases: - test_alias: {} - test_alias_1: {} - test_alias_2: {} - test_alias_3: {} \ No newline at end of file