Skip to content

Commit

Permalink
Fixed /_index_template/_simulate*.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Nov 25, 2024
1 parent c51aa2e commit 9cd13cc
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 24 deletions.
23 changes: 0 additions & 23 deletions spec/namespaces/indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,7 @@ paths:
url: https://opensearch.org/docs/latest
parameters:
- $ref: '#/components/parameters/indices.simulate_index_template::path.name'
- $ref: '#/components/parameters/indices.simulate_index_template::query.cause'
- $ref: '#/components/parameters/indices.simulate_index_template::query.cluster_manager_timeout'
- $ref: '#/components/parameters/indices.simulate_index_template::query.create'
- $ref: '#/components/parameters/indices.simulate_index_template::query.master_timeout'
requestBody:
$ref: '#/components/requestBodies/indices.simulate_index_template'
Expand Down Expand Up @@ -4867,34 +4865,13 @@ components:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/Name'
style: simple
indices.simulate_index_template::query.cause:
name: cause
in: query
description: User defined reason for dry-run creating the new template for simulation purposes.
schema:
type: string
default: 'false'
description: User defined reason for dry-run creating the new template for simulation purposes.
indices.simulate_index_template::query.cluster_manager_timeout:
name: cluster_manager_timeout
in: query
description: Operation timeout for connection to cluster-manager node.
schema:
$ref: '../schemas/_common.yaml#/components/schemas/Duration'
x-version-added: '2.0'
indices.simulate_index_template::query.create:
in: query
name: create
description: |-
If `true`, the template passed in the body is only used if no existing
templates match the same index patterns. If `false`, the simulation uses
the template with the highest priority. Note that the template is not
permanently added or updated in either case; it is only used for the
simulation.
schema:
type: boolean
default: false
style: form
indices.simulate_index_template::query.master_timeout:
in: query
name: master_timeout
Expand Down
1 change: 0 additions & 1 deletion spec/schemas/indices.simulate_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ components:
$ref: 'indices._common.yaml#/components/schemas/IndexSettings'
required:
- aliases
- mappings
- settings
44 changes: 44 additions & 0 deletions tests/default/indices/index_template/simulate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test index configuration that would be applied by a particular index template.
epilogues:
- path: /_index_template/daily_logs
method: DELETE
status: [200, 404]
prologues:
- path: /_index_template/daily_logs
method: POST
request:
payload:
index_patterns:
- 'logs*'
priority: 0
template:
mappings:
properties:
text:
type: text
settings:
number_of_shards: 2
number_of_replicas: 2
chapters:
- synopsis: Simulate a template configuration.
path: /_index_template/_simulate
method: POST
parameters:
cause: Testing.
create: false
request:
payload:
index_patterns:
- 'logs*'
priority: 1
template:
settings:
number_of_shards: 2
number_of_replicas: 2
- synopsis: Get the index configuration that would be applied by the `daily_logs` index template.
path: /_index_template/_simulate/{name}
method: POST
parameters:
name: daily_logs
29 changes: 29 additions & 0 deletions tests/default/indices/index_template/simulate_index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test index configuration that would be applied by a particular index template.
prologues:
- path: /_index_template/daily_logs
method: POST
request:
payload:
index_patterns:
- 'logs*'
priority: 0
template:
mappings:
properties:
text:
type: text
settings:
number_of_shards: 2
number_of_replicas: 2
epilogues:
- path: /_index_template/daily_logs
method: DELETE
status: [200, 404]
chapters:
- synopsis: Simulate matching the `logs-today` name against the `logs*` index template.
path: /_index_template/_simulate_index/{name}
method: POST
parameters:
name: logs-today

0 comments on commit 9cd13cc

Please sign in to comment.