Skip to content

Commit

Permalink
Fix: /{index}/_open can return a task.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Jul 3, 2024
1 parent cbc0b08 commit 5c34099
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 11 deletions.
27 changes: 17 additions & 10 deletions spec/namespaces/indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2393,15 +2393,22 @@ components:
content:
application/json:
schema:
type: object
properties:
acknowledged:
type: boolean
shards_acknowledged:
type: boolean
required:
- acknowledged
- shards_acknowledged
oneOf:
- type: object
properties:
task:
$ref: '../schemas/_common.yaml#/components/schemas/TaskId'
additionalProperties: false
- type: object
properties:
acknowledged:
type: boolean
shards_acknowledged:
type: boolean
required:
- acknowledged
- shards_acknowledged
additionalProperties: false
indices.put_alias@200:
description: ''
content:
Expand Down Expand Up @@ -2995,7 +3002,7 @@ components:
To target all data streams in a cluster, omit this parameter or use `*`.
required: true
schema:
$ref: '../schemas/_common.yaml#/components/schemas/Indices'
$ref: '../schemas/_common.yaml#/components/schemas/IndexName'
style: simple
indices.delete::path.index:
in: path
Expand Down
38 changes: 38 additions & 0 deletions tests/indices/close.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test closing an index.
prologues:
- path: /movies
method: PUT
status: [200]
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Close an index.
path: /{index}/_close
method: POST
parameters:
index: movies
allow_no_indices: true
expand_wildcards: all
ignore_unavailable: true
wait_for_active_shards: 0
cluster_manager_timeout: 30s
timeout: 30s
response:
status: 200
payload:
indices:
movies:
closed: true
- synopsis: Close an already closed index.
path: /{index}/_close
method: POST
parameters:
index: movies
response:
status: 200
payload:
indices: {}
File renamed without changes.
63 changes: 63 additions & 0 deletions tests/indices/open.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test opening an index.
prologues:
- path: /movies
method: PUT
status: [200]
- path: /games
method: PUT
status: [200]
- path: /movies/_close
method: POST
status: [200]
- path: /games/_close
method: POST
status: [200]
epilogues:
- path: /movies,games
method: DELETE
status: [200, 404]
chapters:
- synopsis: Open a closed index.
path: /{index}/_open
method: POST
parameters:
index: movies
allow_no_indices: true
expand_wildcards: all
ignore_unavailable: true
wait_for_active_shards: 0
cluster_manager_timeout: 30s
timeout: 30s
wait_for_completion: true
response:
status: 200
payload:
shards_acknowledged: true
acknowledged: true
- synopsis: Open a closed index (wait_for_completion=false).
path: /{index}/_open
method: POST
parameters:
index: movies
allow_no_indices: true
expand_wildcards: all
ignore_unavailable: true
wait_for_active_shards: 0
cluster_manager_timeout: 30s
timeout: 30s
wait_for_completion: false
task_execution_timeout: 1m
response:
status: 200
- synopsis: Open an already opened index.
path: /{index}/_open
method: POST
parameters:
index: movies
response:
status: 200
payload:
shards_acknowledged: true
acknowledged: true
2 changes: 1 addition & 1 deletion tools/src/tester/ChapterReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class ChapterReader {
response.message = payload.error?.reason ?? e.response.statusText
response.error = e

this.logger.info(`<= ${response.status} (${response.content_type}) | ${response.payload ?? response.message}`)
this.logger.info(`<= ${response.status} (${response.content_type}) | ${to_json(response.payload ?? response.message)}`)
})
return response as ActualResponse
}
Expand Down

0 comments on commit 5c34099

Please sign in to comment.