-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add simulate template composition API _index_template/_simulate_index/{name} #55686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
2be7e19
Add _index_template/_simulate_index/{name} api
andreidan 17a912e
Remove unused logger
andreidan 3025a51
Merge branch 'master' into itv2-simulate-api
elasticmachine 490ca72
Tests
andreidan 20eeea4
Yaml parsing and new line
andreidan 871980a
Fix tests
andreidan f34071d
Fix version restriction
andreidan 8ba793a
Fix response serialisation
andreidan 4b85534
Rename PostSimulateIndexTemplateAction to SimulateIndexTemplateAction
andreidan b98a59b
Rename RestPostSimulateIndexTemplateAction to RestSimulateIndexTempla…
andreidan cbcc977
Remove "post_" prefix
andreidan 3ca7e20
Drop /post from action name
andreidan a436e39
Update rest api spec
andreidan 604936a
Drop "post" from package name
andreidan edc8610
Fix indentation
andreidan 34d7a75
Use the resolveAndValidateAliases method to resolve aliases
andreidan c68ece9
Merge branch 'master' into itv2-simulate-api
elasticmachine 6a319da
Rename overlapping_v1_templates to overlapping
andreidan 4134282
Update methods docs and fix use case where candidate exists
andreidan facb14a
Return overlapping V1 and V2 templates and their patterns
andreidan 651b578
Remove v1 mentions
andreidan 03d9b0f
Drop dynamic keys from response
andreidan 8863d1f
Use additional map
andreidan db5782b
Update remove indexService reason
andreidan 7a6582c
Merge branch 'master' into itv2-simulate-api
elasticmachine ab918fd
Use composed_of in the simulated template
andreidan e368647
Assert overlapping is array
andreidan d3cac66
Merge branch 'master' into itv2-simulate-api
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
35 changes: 35 additions & 0 deletions
35
rest-api-spec/src/main/resources/rest-api-spec/api/indices.simulate_index_template.json
This file contains hidden or 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,35 @@ | ||
{ | ||
"indices.simulate_index_template":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html", | ||
"description": "Simulate matching the given index name against the index templates in the system" | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_index_template/_simulate_index/{name}", | ||
"methods":[ | ||
"POST" | ||
], | ||
"parts":{ | ||
"name":{ | ||
"type":"string", | ||
"description":"The name of the index (it must be a concrete index name)" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
"master_timeout":{ | ||
"type":"time", | ||
"description":"Specify timeout for connection to master" | ||
} | ||
}, | ||
"body":{ | ||
"description":"New index template definition, which will be included in the simulation, as if it already exists in the system", | ||
"required":false | ||
} | ||
} | ||
} |
181 changes: 181 additions & 0 deletions
181
...i-spec/src/main/resources/rest-api-spec/test/indices.simulate_index_template/10_basic.yml
This file contains hidden or 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,181 @@ | ||
--- | ||
"Simulate index template without new template in the body": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "simulate index template API has not been backported" | ||
features: allowed_warnings | ||
|
||
- do: | ||
allowed_warnings: | ||
- "index template [test] has index patterns [te*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [test] will take precedence during new index creation" | ||
indices.put_index_template: | ||
name: test | ||
body: | ||
index_patterns: te* | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
|
||
- do: | ||
indices.simulate_index_template: | ||
name: test | ||
|
||
- match: {template.settings.index.number_of_shards: "1"} | ||
- match: {template.settings.index.number_of_replicas: "0"} | ||
- match: {template.mappings._doc.properties.field.type: "keyword"} | ||
- match: {overlapping: []} | ||
|
||
--- | ||
"Simulate index template specifying a new template": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "simulate index template API has not been backported" | ||
features: allowed_warnings | ||
|
||
- do: | ||
allowed_warnings: | ||
- "index template [test] has index patterns [te*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [test] will take precedence during new index creation" | ||
indices.put_index_template: | ||
name: existing_test | ||
body: | ||
index_patterns: te* | ||
priority: 10 | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
|
||
- do: | ||
cluster.put_component_template: | ||
name: ct | ||
body: | ||
template: | ||
settings: | ||
index.number_of_replicas: 2 | ||
mappings: | ||
properties: | ||
ct_field: | ||
type: keyword | ||
|
||
- do: | ||
indices.simulate_index_template: | ||
name: test | ||
body: | ||
index_patterns: te* | ||
priority: 15 | ||
template: | ||
settings: | ||
index.blocks.write: true | ||
aliases: | ||
test_alias: {} | ||
composed_of: ["ct"] | ||
|
||
- match: {template.settings.index.blocks.write: "true"} | ||
- match: {template.settings.index.number_of_replicas: "2"} | ||
- match: {template.mappings._doc.properties.ct_field.type: "keyword"} | ||
- match: {overlapping.0.name: existing_test} | ||
- match: {overlapping.0.index_patterns: ["te*"]} | ||
- length: {template.aliases: 1} | ||
- is_true: template.aliases.test_alias | ||
|
||
--- | ||
"Simulate index template with index not matching any template": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "simulate index template API has not been backported" | ||
features: allowed_warnings | ||
|
||
- do: | ||
allowed_warnings: | ||
- "index template [test] has index patterns [te*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [test] will take precedence during new index creation" | ||
indices.put_index_template: | ||
name: test | ||
body: | ||
index_patterns: te* | ||
priority: 10 | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
|
||
- do: | ||
indices.simulate_index_template: | ||
name: will_not_match | ||
|
||
- match: {body: null} | ||
|
||
--- | ||
"Simulate index matches overlapping V1 and V2 templates": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "simulate index template API has not been backported" | ||
features: allowed_warnings | ||
|
||
- do: | ||
indices.put_template: | ||
name: v1_template | ||
body: | ||
index_patterns: [t*, t1*] | ||
settings: | ||
number_of_shards: 5 | ||
|
||
- do: | ||
allowed_warnings: | ||
- "index template [v2_template] has index patterns [te*] matching patterns from existing older templates [v1_template] with patterns | ||
(v1_template => [t*, t1*]); this template [v2_template] will take precedence during new index creation" | ||
indices.put_index_template: | ||
name: v2_template | ||
body: | ||
index_patterns: te* | ||
priority: 10 | ||
template: | ||
settings: | ||
number_of_shards: 10 | ||
number_of_replicas: 2 | ||
mappings: | ||
properties: | ||
field: | ||
type: text | ||
|
||
- do: | ||
allowed_warnings: | ||
- "index template [winning_v2_template] has index patterns [te*] matching patterns from existing older templates [v1_template] with patterns | ||
(v1_template => [t*, t1*]); this template [winning_v2_template] will take precedence during new index creation" | ||
indices.put_index_template: | ||
name: winning_v2_template | ||
body: | ||
index_patterns: te* | ||
priority: 20 | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
|
||
- do: | ||
indices.simulate_index_template: | ||
name: test | ||
|
||
- match: {template.settings.index.number_of_shards: "1"} | ||
- match: {template.settings.index.number_of_replicas: "0"} | ||
- match: {template.mappings._doc.properties.field.type: "keyword"} | ||
- match: {overlapping.0.name: v1_template} | ||
- match: {overlapping.0.index_patterns: ["t*", "t1*"]} | ||
- match: {overlapping.1.name: v2_template} | ||
- match: {overlapping.1.index_patterns: ["te*"]} |
This file contains hidden or 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
33 changes: 33 additions & 0 deletions
33
...ava/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateAction.java
This file contains hidden or 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,33 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action.admin.indices.template.post; | ||
|
||
import org.elasticsearch.action.ActionType; | ||
|
||
public class SimulateIndexTemplateAction extends ActionType<SimulateIndexTemplateResponse> { | ||
|
||
public static final SimulateIndexTemplateAction INSTANCE = new SimulateIndexTemplateAction(); | ||
public static final String NAME = "indices:admin/index_template/simulate_index"; | ||
|
||
private SimulateIndexTemplateAction() { | ||
super(NAME, SimulateIndexTemplateResponse::new); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.