mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
Use indices admin client shortcut in most integration tests (#96946)
Replacing the remaining usages that I could automatically replace and a couple that I did by hand in this PR. Also, added the same shortcut to the single node tests to save some duplication there.
This commit is contained in:
parent
c8e676aea8
commit
3f8ee82ef8
328 changed files with 1677 additions and 2466 deletions
|
@ -524,7 +524,7 @@ public class TimeSeriesAggregationsIT extends AggregationIntegTestCase {
|
||||||
response = client().prepareSearch("test").setQuery(queryBuilder).setSize(10).addAggregation(timeSeries("by_ts")).get();
|
response = client().prepareSearch("test").setQuery(queryBuilder).setSize(10).addAggregation(timeSeries("by_ts")).get();
|
||||||
assertSearchResponse(response);
|
assertSearchResponse(response);
|
||||||
|
|
||||||
assertAcked(client().admin().indices().delete(new DeleteIndexRequest("test")).actionGet());
|
assertAcked(indicesAdmin().delete(new DeleteIndexRequest("test")).actionGet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TimeSeriesAggregationBuilder timeSeries(String name) {
|
public static TimeSeriesAggregationBuilder timeSeries(String name) {
|
||||||
|
|
|
@ -32,9 +32,7 @@ public class QueryStringWithAnalyzersIT extends ESIntegTestCase {
|
||||||
*/
|
*/
|
||||||
public void testCustomWordDelimiterQueryString() {
|
public void testCustomWordDelimiterQueryString() {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
Settings.builder()
|
Settings.builder()
|
||||||
.put("analysis.analyzer.my_analyzer.type", "custom")
|
.put("analysis.analyzer.my_analyzer.type", "custom")
|
||||||
|
|
|
@ -53,9 +53,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
final String synonymAnalyzerName = "synonym_analyzer";
|
final String synonymAnalyzerName = "synonym_analyzer";
|
||||||
final String synonymGraphAnalyzerName = "synonym_graph_analyzer";
|
final String synonymGraphAnalyzerName = "synonym_graph_analyzer";
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate(indexName)
|
||||||
.indices()
|
|
||||||
.prepareCreate(indexName)
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
indexSettings(5, 0).put("analysis.analyzer." + synonymAnalyzerName + ".tokenizer", "standard")
|
indexSettings(5, 0).put("analysis.analyzer." + synonymAnalyzerName + ".tokenizer", "standard")
|
||||||
.putList("analysis.analyzer." + synonymAnalyzerName + ".filter", "lowercase", "synonym_filter")
|
.putList("analysis.analyzer." + synonymAnalyzerName + ".filter", "lowercase", "synonym_filter")
|
||||||
|
@ -72,7 +70,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
client().prepareIndex(indexName).setId("1").setSource("field", "Foo").get();
|
client().prepareIndex(indexName).setId("1").setSource("field", "Foo").get();
|
||||||
assertNoFailures(client().admin().indices().prepareRefresh(indexName).execute().actionGet());
|
assertNoFailures(indicesAdmin().prepareRefresh(indexName).execute().actionGet());
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch(indexName).setQuery(QueryBuilders.matchQuery("field", "baz")).get();
|
SearchResponse response = client().prepareSearch(indexName).setQuery(QueryBuilders.matchQuery("field", "baz")).get();
|
||||||
assertHitCount(response, 1L);
|
assertHitCount(response, 1L);
|
||||||
|
@ -81,7 +79,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
{
|
{
|
||||||
for (String analyzerName : new String[] { synonymAnalyzerName, synonymGraphAnalyzerName }) {
|
for (String analyzerName : new String[] { synonymAnalyzerName, synonymGraphAnalyzerName }) {
|
||||||
Response analyzeResponse = client().admin().indices().prepareAnalyze(indexName, "foo").setAnalyzer(analyzerName).get();
|
Response analyzeResponse = indicesAdmin().prepareAnalyze(indexName, "foo").setAnalyzer(analyzerName).get();
|
||||||
assertEquals(2, analyzeResponse.getTokens().size());
|
assertEquals(2, analyzeResponse.getTokens().size());
|
||||||
Set<String> tokens = new HashSet<>();
|
Set<String> tokens = new HashSet<>();
|
||||||
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
||||||
|
@ -108,7 +106,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
{
|
{
|
||||||
for (String analyzerName : new String[] { synonymAnalyzerName, synonymGraphAnalyzerName }) {
|
for (String analyzerName : new String[] { synonymAnalyzerName, synonymGraphAnalyzerName }) {
|
||||||
Response analyzeResponse = client().admin().indices().prepareAnalyze(indexName, "foo").setAnalyzer(analyzerName).get();
|
Response analyzeResponse = indicesAdmin().prepareAnalyze(indexName, "foo").setAnalyzer(analyzerName).get();
|
||||||
assertEquals(3, analyzeResponse.getTokens().size());
|
assertEquals(3, analyzeResponse.getTokens().size());
|
||||||
Set<String> tokens = new HashSet<>();
|
Set<String> tokens = new HashSet<>();
|
||||||
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
||||||
|
@ -131,9 +129,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
final String indexName = "test";
|
final String indexName = "test";
|
||||||
final String synonymAnalyzerName = "synonym_in_multiplexer_analyzer";
|
final String synonymAnalyzerName = "synonym_in_multiplexer_analyzer";
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate(indexName)
|
||||||
.indices()
|
|
||||||
.prepareCreate(indexName)
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
indexSettings(5, 0).put("analysis.analyzer." + synonymAnalyzerName + ".tokenizer", "whitespace")
|
indexSettings(5, 0).put("analysis.analyzer." + synonymAnalyzerName + ".tokenizer", "whitespace")
|
||||||
.putList("analysis.analyzer." + synonymAnalyzerName + ".filter", "my_multiplexer")
|
.putList("analysis.analyzer." + synonymAnalyzerName + ".filter", "my_multiplexer")
|
||||||
|
@ -147,14 +143,14 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
client().prepareIndex(indexName).setId("1").setSource("field", "foo").get();
|
client().prepareIndex(indexName).setId("1").setSource("field", "foo").get();
|
||||||
assertNoFailures(client().admin().indices().prepareRefresh(indexName).execute().actionGet());
|
assertNoFailures(indicesAdmin().prepareRefresh(indexName).execute().actionGet());
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch(indexName).setQuery(QueryBuilders.matchQuery("field", "baz")).get();
|
SearchResponse response = client().prepareSearch(indexName).setQuery(QueryBuilders.matchQuery("field", "baz")).get();
|
||||||
assertHitCount(response, 1L);
|
assertHitCount(response, 1L);
|
||||||
response = client().prepareSearch(indexName).setQuery(QueryBuilders.matchQuery("field", "buzz")).get();
|
response = client().prepareSearch(indexName).setQuery(QueryBuilders.matchQuery("field", "buzz")).get();
|
||||||
assertHitCount(response, 0L);
|
assertHitCount(response, 0L);
|
||||||
|
|
||||||
Response analyzeResponse = client().admin().indices().prepareAnalyze(indexName, "foo").setAnalyzer(synonymAnalyzerName).get();
|
Response analyzeResponse = indicesAdmin().prepareAnalyze(indexName, "foo").setAnalyzer(synonymAnalyzerName).get();
|
||||||
assertEquals(2, analyzeResponse.getTokens().size());
|
assertEquals(2, analyzeResponse.getTokens().size());
|
||||||
final Set<String> tokens = new HashSet<>();
|
final Set<String> tokens = new HashSet<>();
|
||||||
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
||||||
|
@ -176,7 +172,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
assertEquals(1, reloadedAnalyzers.size());
|
assertEquals(1, reloadedAnalyzers.size());
|
||||||
assertTrue(reloadedAnalyzers.contains(synonymAnalyzerName));
|
assertTrue(reloadedAnalyzers.contains(synonymAnalyzerName));
|
||||||
|
|
||||||
analyzeResponse = client().admin().indices().prepareAnalyze(indexName, "foo").setAnalyzer(synonymAnalyzerName).get();
|
analyzeResponse = indicesAdmin().prepareAnalyze(indexName, "foo").setAnalyzer(synonymAnalyzerName).get();
|
||||||
assertEquals(3, analyzeResponse.getTokens().size());
|
assertEquals(3, analyzeResponse.getTokens().size());
|
||||||
tokens.clear();
|
tokens.clear();
|
||||||
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
||||||
|
@ -214,9 +210,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
MapperException ex = expectThrows(
|
MapperException ex = expectThrows(
|
||||||
MapperException.class,
|
MapperException.class,
|
||||||
() -> client().admin()
|
() -> indicesAdmin().prepareCreate(indexName)
|
||||||
.indices()
|
|
||||||
.prepareCreate(indexName)
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
indexSettings(5, 0).put("analysis.analyzer." + analyzerName + ".tokenizer", "standard")
|
indexSettings(5, 0).put("analysis.analyzer." + analyzerName + ".tokenizer", "standard")
|
||||||
.putList("analysis.analyzer." + analyzerName + ".filter", "lowercase", "synonym_filter")
|
.putList("analysis.analyzer." + analyzerName + ".filter", "lowercase", "synonym_filter")
|
||||||
|
@ -237,9 +231,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
// same for synonym filters in multiplexer chain
|
// same for synonym filters in multiplexer chain
|
||||||
ex = expectThrows(
|
ex = expectThrows(
|
||||||
MapperException.class,
|
MapperException.class,
|
||||||
() -> client().admin()
|
() -> indicesAdmin().prepareCreate(indexName)
|
||||||
.indices()
|
|
||||||
.prepareCreate(indexName)
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
indexSettings(5, 0).put("analysis.analyzer." + analyzerName + ".tokenizer", "whitespace")
|
indexSettings(5, 0).put("analysis.analyzer." + analyzerName + ".tokenizer", "whitespace")
|
||||||
.putList("analysis.analyzer." + analyzerName + ".filter", "my_multiplexer")
|
.putList("analysis.analyzer." + analyzerName + ".filter", "my_multiplexer")
|
||||||
|
@ -267,9 +259,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
final String indexName = "test";
|
final String indexName = "test";
|
||||||
final String analyzerName = "keyword_maker_analyzer";
|
final String analyzerName = "keyword_maker_analyzer";
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate(indexName)
|
||||||
.indices()
|
|
||||||
.prepareCreate(indexName)
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
indexSettings(5, 0).put("analysis.analyzer." + analyzerName + ".tokenizer", "whitespace")
|
indexSettings(5, 0).put("analysis.analyzer." + analyzerName + ".tokenizer", "whitespace")
|
||||||
.putList("analysis.analyzer." + analyzerName + ".filter", "keyword_marker_filter", "stemmer")
|
.putList("analysis.analyzer." + analyzerName + ".filter", "keyword_marker_filter", "stemmer")
|
||||||
|
@ -280,11 +270,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
.setMapping("field", "type=text,analyzer=standard,search_analyzer=" + analyzerName)
|
.setMapping("field", "type=text,analyzer=standard,search_analyzer=" + analyzerName)
|
||||||
);
|
);
|
||||||
|
|
||||||
AnalyzeAction.Response analysisResponse = client().admin()
|
AnalyzeAction.Response analysisResponse = indicesAdmin().prepareAnalyze("test", "running jumping").setAnalyzer(analyzerName).get();
|
||||||
.indices()
|
|
||||||
.prepareAnalyze("test", "running jumping")
|
|
||||||
.setAnalyzer(analyzerName)
|
|
||||||
.get();
|
|
||||||
List<AnalyzeToken> tokens = analysisResponse.getTokens();
|
List<AnalyzeToken> tokens = analysisResponse.getTokens();
|
||||||
assertEquals("running", tokens.get(0).getTerm());
|
assertEquals("running", tokens.get(0).getTerm());
|
||||||
assertEquals("jump", tokens.get(1).getTerm());
|
assertEquals("jump", tokens.get(1).getTerm());
|
||||||
|
@ -306,7 +292,7 @@ public class ReloadAnalyzerTests extends ESSingleNodeTestCase {
|
||||||
assertEquals(1, reloadedAnalyzers.size());
|
assertEquals(1, reloadedAnalyzers.size());
|
||||||
assertTrue(reloadedAnalyzers.contains(analyzerName));
|
assertTrue(reloadedAnalyzers.contains(analyzerName));
|
||||||
|
|
||||||
analysisResponse = client().admin().indices().prepareAnalyze("test", "running jumping").setAnalyzer(analyzerName).get();
|
analysisResponse = indicesAdmin().prepareAnalyze("test", "running jumping").setAnalyzer(analyzerName).get();
|
||||||
tokens = analysisResponse.getTokens();
|
tokens = analysisResponse.getTokens();
|
||||||
assertEquals("running", tokens.get(0).getTerm());
|
assertEquals("running", tokens.get(0).getTerm());
|
||||||
assertEquals("jumping", tokens.get(1).getTerm());
|
assertEquals("jumping", tokens.get(1).getTerm());
|
||||||
|
|
|
@ -62,9 +62,7 @@ public class ReloadSynonymAnalyzerIT extends ESIntegTestCase {
|
||||||
out.println("foo, baz");
|
out.println("foo, baz");
|
||||||
}
|
}
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
indexSettings(cluster().numDataNodes() * 2, 1).put("analysis.analyzer.my_synonym_analyzer.tokenizer", "standard")
|
indexSettings(cluster().numDataNodes() * 2, 1).put("analysis.analyzer.my_synonym_analyzer.tokenizer", "standard")
|
||||||
.put("analysis.analyzer.my_synonym_analyzer.filter", "my_synonym_filter")
|
.put("analysis.analyzer.my_synonym_analyzer.filter", "my_synonym_filter")
|
||||||
|
@ -76,13 +74,13 @@ public class ReloadSynonymAnalyzerIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
client().prepareIndex("test").setId("1").setSource("field", "foo").get();
|
client().prepareIndex("test").setId("1").setSource("field", "foo").get();
|
||||||
assertNoFailures(client().admin().indices().prepareRefresh("test").execute().actionGet());
|
assertNoFailures(indicesAdmin().prepareRefresh("test").execute().actionGet());
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("test").setQuery(QueryBuilders.matchQuery("field", "baz")).get();
|
SearchResponse response = client().prepareSearch("test").setQuery(QueryBuilders.matchQuery("field", "baz")).get();
|
||||||
assertHitCount(response, 1L);
|
assertHitCount(response, 1L);
|
||||||
response = client().prepareSearch("test").setQuery(QueryBuilders.matchQuery("field", "buzz")).get();
|
response = client().prepareSearch("test").setQuery(QueryBuilders.matchQuery("field", "buzz")).get();
|
||||||
assertHitCount(response, 0L);
|
assertHitCount(response, 0L);
|
||||||
Response analyzeResponse = client().admin().indices().prepareAnalyze("test", "foo").setAnalyzer("my_synonym_analyzer").get();
|
Response analyzeResponse = indicesAdmin().prepareAnalyze("test", "foo").setAnalyzer("my_synonym_analyzer").get();
|
||||||
assertEquals(2, analyzeResponse.getTokens().size());
|
assertEquals(2, analyzeResponse.getTokens().size());
|
||||||
assertEquals("foo", analyzeResponse.getTokens().get(0).getTerm());
|
assertEquals("foo", analyzeResponse.getTokens().get(0).getTerm());
|
||||||
assertEquals("baz", analyzeResponse.getTokens().get(1).getTerm());
|
assertEquals("baz", analyzeResponse.getTokens().get(1).getTerm());
|
||||||
|
@ -108,7 +106,7 @@ public class ReloadSynonymAnalyzerIT extends ESIntegTestCase {
|
||||||
reloadResponse.getReloadDetails().get("test").getReloadedAnalyzers()
|
reloadResponse.getReloadDetails().get("test").getReloadedAnalyzers()
|
||||||
);
|
);
|
||||||
|
|
||||||
analyzeResponse = client().admin().indices().prepareAnalyze("test", "foo").setAnalyzer("my_synonym_analyzer").get();
|
analyzeResponse = indicesAdmin().prepareAnalyze("test", "foo").setAnalyzer("my_synonym_analyzer").get();
|
||||||
assertEquals(3, analyzeResponse.getTokens().size());
|
assertEquals(3, analyzeResponse.getTokens().size());
|
||||||
Set<String> tokens = new HashSet<>();
|
Set<String> tokens = new HashSet<>();
|
||||||
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
analyzeResponse.getTokens().stream().map(AnalyzeToken::getTerm).forEach(t -> tokens.add(t));
|
||||||
|
|
|
@ -27,9 +27,7 @@ public class MassiveWordListTests extends ESSingleNodeTestCase {
|
||||||
for (int i = 0; i < wordList.length; i++) {
|
for (int i = 0; i < wordList.length; i++) {
|
||||||
wordList[i] = "hello world";
|
wordList[i] = "hello world";
|
||||||
}
|
}
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
Settings.builder()
|
Settings.builder()
|
||||||
.put("index.number_of_shards", 1)
|
.put("index.number_of_shards", 1)
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
|
|
||||||
String backingIndex = barDataStream.getIndices().get(0).getName();
|
String backingIndex = barDataStream.getIndices().get(0).getName();
|
||||||
backingIndices.add(backingIndex);
|
backingIndices.add(backingIndex);
|
||||||
GetIndexResponse getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
GetIndexResponse getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
||||||
Map<?, ?> mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
Map<?, ?> mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
||||||
|
@ -184,7 +184,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
|
|
||||||
backingIndex = fooDataStream.getIndices().get(0).getName();
|
backingIndex = fooDataStream.getIndices().get(0).getName();
|
||||||
backingIndices.add(backingIndex);
|
backingIndices.add(backingIndex);
|
||||||
getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
||||||
mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
||||||
|
@ -198,17 +198,17 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
verifyDocs("metrics-bar", numDocsBar, 1, 1);
|
verifyDocs("metrics-bar", numDocsBar, 1, 1);
|
||||||
verifyDocs("metrics-foo", numDocsFoo, 1, 1);
|
verifyDocs("metrics-foo", numDocsFoo, 1, 1);
|
||||||
|
|
||||||
RolloverResponse fooRolloverResponse = client().admin().indices().rolloverIndex(new RolloverRequest("metrics-foo", null)).get();
|
RolloverResponse fooRolloverResponse = indicesAdmin().rolloverIndex(new RolloverRequest("metrics-foo", null)).get();
|
||||||
assertThat(fooRolloverResponse.getNewIndex(), backingIndexEqualTo("metrics-foo", 2));
|
assertThat(fooRolloverResponse.getNewIndex(), backingIndexEqualTo("metrics-foo", 2));
|
||||||
assertTrue(fooRolloverResponse.isRolledOver());
|
assertTrue(fooRolloverResponse.isRolledOver());
|
||||||
|
|
||||||
RolloverResponse barRolloverResponse = client().admin().indices().rolloverIndex(new RolloverRequest("metrics-bar", null)).get();
|
RolloverResponse barRolloverResponse = indicesAdmin().rolloverIndex(new RolloverRequest("metrics-bar", null)).get();
|
||||||
assertThat(barRolloverResponse.getNewIndex(), backingIndexEqualTo("metrics-bar", 2));
|
assertThat(barRolloverResponse.getNewIndex(), backingIndexEqualTo("metrics-bar", 2));
|
||||||
assertTrue(barRolloverResponse.isRolledOver());
|
assertTrue(barRolloverResponse.isRolledOver());
|
||||||
|
|
||||||
backingIndex = fooRolloverResponse.getNewIndex();
|
backingIndex = fooRolloverResponse.getNewIndex();
|
||||||
backingIndices.add(backingIndex);
|
backingIndices.add(backingIndex);
|
||||||
getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
||||||
mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
||||||
|
@ -216,7 +216,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
|
|
||||||
backingIndex = barRolloverResponse.getNewIndex();
|
backingIndex = barRolloverResponse.getNewIndex();
|
||||||
backingIndices.add(backingIndex);
|
backingIndices.add(backingIndex);
|
||||||
getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
||||||
mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
||||||
|
@ -239,7 +239,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
expectThrows(
|
expectThrows(
|
||||||
IndexNotFoundException.class,
|
IndexNotFoundException.class,
|
||||||
"Backing index '" + index + "' should have been deleted.",
|
"Backing index '" + index + "' should have been deleted.",
|
||||||
() -> client().admin().indices().getIndex(new GetIndexRequest().indices(index)).actionGet()
|
() -> indicesAdmin().getIndex(new GetIndexRequest().indices(index)).actionGet()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
String backingIndex = getDataStreamResponse.getDataStreams().get(0).getDataStream().getIndices().get(0).getName();
|
String backingIndex = getDataStreamResponse.getDataStreams().get(0).getDataStream().getIndices().get(0).getName();
|
||||||
assertThat(backingIndex, backingIndexEqualTo(dataStreamName, 1));
|
assertThat(backingIndex, backingIndexEqualTo(dataStreamName, 1));
|
||||||
|
|
||||||
GetIndexResponse getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(dataStreamName)).actionGet();
|
GetIndexResponse getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(dataStreamName)).actionGet();
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -475,12 +475,12 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
equalTo("keyword")
|
equalTo("keyword")
|
||||||
);
|
);
|
||||||
|
|
||||||
RolloverResponse rolloverResponse = client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).get();
|
RolloverResponse rolloverResponse = indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).get();
|
||||||
backingIndex = rolloverResponse.getNewIndex();
|
backingIndex = rolloverResponse.getNewIndex();
|
||||||
assertThat(backingIndex, backingIndexEqualTo(dataStreamName, 2));
|
assertThat(backingIndex, backingIndexEqualTo(dataStreamName, 2));
|
||||||
assertTrue(rolloverResponse.isRolledOver());
|
assertTrue(rolloverResponse.isRolledOver());
|
||||||
|
|
||||||
getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -506,7 +506,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
expectThrows(
|
expectThrows(
|
||||||
IndexNotFoundException.class,
|
IndexNotFoundException.class,
|
||||||
"Backing index '" + index.getName() + "' should have been deleted.",
|
"Backing index '" + index.getName() + "' should have been deleted.",
|
||||||
() -> client().admin().indices().getIndex(new GetIndexRequest().indices(index.getName())).actionGet()
|
() -> indicesAdmin().getIndex(new GetIndexRequest().indices(index.getName())).actionGet()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,7 +553,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest();
|
||||||
String aliasToDataStream = "logs";
|
String aliasToDataStream = "logs";
|
||||||
aliasesRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).alias(aliasToDataStream).index("logs-foobar"));
|
aliasesRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).alias(aliasToDataStream).index("logs-foobar"));
|
||||||
assertAcked(client().admin().indices().aliases(aliasesRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesRequest).actionGet());
|
||||||
|
|
||||||
verifyResolvability(
|
verifyResolvability(
|
||||||
dataStreamName,
|
dataStreamName,
|
||||||
|
@ -562,43 +562,40 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.setOpType(DocWriteRequest.OpType.CREATE),
|
.setOpType(DocWriteRequest.OpType.CREATE),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareRefresh(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareRefresh(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().prepareSearch(dataStreamName), false, 1);
|
verifyResolvability(dataStreamName, client().prepareSearch(dataStreamName), false, 1);
|
||||||
verifyResolvability(
|
verifyResolvability(
|
||||||
dataStreamName,
|
dataStreamName,
|
||||||
client().prepareMultiSearch().add(client().prepareSearch(dataStreamName).setQuery(matchAllQuery())),
|
client().prepareMultiSearch().add(client().prepareSearch(dataStreamName).setQuery(matchAllQuery())),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareClearCache(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareClearCache(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareFlush(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareFlush(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareSegments(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareSegments(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareStats(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareStats(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareForceMerge(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareForceMerge(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareValidateQuery(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareValidateQuery(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareRecoveries(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareRecoveries(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareGetAliases("dummy").addIndices(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareGetAliases("dummy").addIndices(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareGetFieldMappings(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareGetFieldMappings(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().preparePutMapping(dataStreamName).setSource("""
|
verifyResolvability(dataStreamName, indicesAdmin().preparePutMapping(dataStreamName).setSource("""
|
||||||
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false);
|
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareGetMappings(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareGetMappings(dataStreamName), false);
|
||||||
verifyResolvability(
|
verifyResolvability(
|
||||||
dataStreamName,
|
dataStreamName,
|
||||||
client().admin()
|
indicesAdmin().prepareUpdateSettings(dataStreamName).setSettings(Settings.builder().put("index.number_of_replicas", 0)),
|
||||||
.indices()
|
|
||||||
.prepareUpdateSettings(dataStreamName)
|
|
||||||
.setSettings(Settings.builder().put("index.number_of_replicas", 0)),
|
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareGetSettings(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareGetSettings(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().cluster().prepareHealth(dataStreamName), false);
|
verifyResolvability(dataStreamName, client().admin().cluster().prepareHealth(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().cluster().prepareState().setIndices(dataStreamName), false);
|
verifyResolvability(dataStreamName, client().admin().cluster().prepareState().setIndices(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().prepareFieldCaps(dataStreamName).setFields("*"), false);
|
verifyResolvability(dataStreamName, client().prepareFieldCaps(dataStreamName).setFields("*"), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareGetIndex().addIndices(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareGetIndex().addIndices(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareOpen(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareOpen(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareClose(dataStreamName), true);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareClose(dataStreamName), true);
|
||||||
verifyResolvability(aliasToDataStream, client().admin().indices().prepareClose(aliasToDataStream), true);
|
verifyResolvability(aliasToDataStream, indicesAdmin().prepareClose(aliasToDataStream), true);
|
||||||
verifyResolvability(dataStreamName, client().admin().cluster().prepareSearchShards(dataStreamName), false);
|
verifyResolvability(dataStreamName, client().admin().cluster().prepareSearchShards(dataStreamName), false);
|
||||||
verifyResolvability(dataStreamName, client().admin().indices().prepareShardStores(dataStreamName), false);
|
verifyResolvability(dataStreamName, indicesAdmin().prepareShardStores(dataStreamName), false);
|
||||||
|
|
||||||
request = new CreateDataStreamAction.Request("logs-barbaz");
|
request = new CreateDataStreamAction.Request("logs-barbaz");
|
||||||
client().execute(CreateDataStreamAction.INSTANCE, request).actionGet();
|
client().execute(CreateDataStreamAction.INSTANCE, request).actionGet();
|
||||||
|
@ -611,42 +608,39 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
String wildcardExpression = "logs*";
|
String wildcardExpression = "logs*";
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareRefresh(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareRefresh(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().prepareSearch(wildcardExpression), false, 2);
|
verifyResolvability(wildcardExpression, client().prepareSearch(wildcardExpression), false, 2);
|
||||||
verifyResolvability(
|
verifyResolvability(
|
||||||
wildcardExpression,
|
wildcardExpression,
|
||||||
client().prepareMultiSearch().add(client().prepareSearch(wildcardExpression).setQuery(matchAllQuery())),
|
client().prepareMultiSearch().add(client().prepareSearch(wildcardExpression).setQuery(matchAllQuery())),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareClearCache(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareClearCache(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareFlush(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareFlush(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareSegments(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareSegments(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareStats(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareStats(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareForceMerge(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareForceMerge(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareValidateQuery(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareValidateQuery(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareRecoveries(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareRecoveries(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareGetAliases(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetAliases(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareGetFieldMappings(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetFieldMappings(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().preparePutMapping(wildcardExpression).setSource("""
|
verifyResolvability(wildcardExpression, indicesAdmin().preparePutMapping(wildcardExpression).setSource("""
|
||||||
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false);
|
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareGetMappings(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetMappings(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareGetSettings(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetSettings(wildcardExpression), false);
|
||||||
verifyResolvability(
|
verifyResolvability(
|
||||||
wildcardExpression,
|
wildcardExpression,
|
||||||
client().admin()
|
indicesAdmin().prepareUpdateSettings(wildcardExpression).setSettings(Settings.builder().put("index.number_of_replicas", 0)),
|
||||||
.indices()
|
|
||||||
.prepareUpdateSettings(wildcardExpression)
|
|
||||||
.setSettings(Settings.builder().put("index.number_of_replicas", 0)),
|
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
verifyResolvability(wildcardExpression, client().admin().cluster().prepareHealth(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, client().admin().cluster().prepareHealth(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().cluster().prepareState().setIndices(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, client().admin().cluster().prepareState().setIndices(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().prepareFieldCaps(wildcardExpression).setFields("*"), false);
|
verifyResolvability(wildcardExpression, client().prepareFieldCaps(wildcardExpression).setFields("*"), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareGetIndex().addIndices(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetIndex().addIndices(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareOpen(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareOpen(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareClose(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareClose(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().cluster().prepareSearchShards(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, client().admin().cluster().prepareSearchShards(wildcardExpression), false);
|
||||||
verifyResolvability(wildcardExpression, client().admin().indices().prepareShardStores(wildcardExpression), false);
|
verifyResolvability(wildcardExpression, indicesAdmin().prepareShardStores(wildcardExpression), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCannotDeleteComposableTemplateUsedByDataStream() throws Exception {
|
public void testCannotDeleteComposableTemplateUsedByDataStream() throws Exception {
|
||||||
|
@ -715,8 +709,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index(dataStreamName).aliases("foo");
|
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index(dataStreamName).aliases("foo");
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
response.getDataStreamAliases(),
|
response.getDataStreamAliases(),
|
||||||
equalTo(Map.of("metrics-foo", List.of(new DataStreamAlias("foo", List.of("metrics-foo"), null, null))))
|
equalTo(Map.of("metrics-foo", List.of(new DataStreamAlias("foo", List.of("metrics-foo"), null, null))))
|
||||||
|
@ -743,8 +737,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.filter(Map.of("term", Map.of("type", Map.of("value", "y"))));
|
.filter(Map.of("term", Map.of("type", Map.of("value", "y"))));
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
response.getDataStreamAliases(),
|
response.getDataStreamAliases(),
|
||||||
equalTo(
|
equalTo(
|
||||||
|
@ -775,8 +769,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.filter(Map.of("term", Map.of("type", Map.of("value", "x"))));
|
.filter(Map.of("term", Map.of("type", Map.of("value", "x"))));
|
||||||
aliasesAddRequest = new IndicesAliasesRequest();
|
aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
response.getDataStreamAliases(),
|
response.getDataStreamAliases(),
|
||||||
equalTo(
|
equalTo(
|
||||||
|
@ -825,8 +819,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addFilteredAliasAction);
|
aliasesAddRequest.addAliasAction(addFilteredAliasAction);
|
||||||
aliasesAddRequest.addAliasAction(addUnfilteredAliasAction);
|
aliasesAddRequest.addAliasAction(addUnfilteredAliasAction);
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(response.getDataStreamAliases(), hasKey("logs-foobar"));
|
assertThat(response.getDataStreamAliases(), hasKey("logs-foobar"));
|
||||||
assertThat(
|
assertThat(
|
||||||
response.getDataStreamAliases().get("logs-foobar"),
|
response.getDataStreamAliases().get("logs-foobar"),
|
||||||
|
@ -863,12 +857,12 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
Map<String, Object> indexFilters = Map.of("term", Map.of("type", Map.of("value", "y")));
|
Map<String, Object> indexFilters = Map.of("term", Map.of("type", Map.of("value", "y")));
|
||||||
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).aliases(alias).indices(dataStreams).filter(indexFilters);
|
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).aliases(alias).indices(dataStreams).filter(indexFilters);
|
||||||
assertAcked(client().admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(addAction)).actionGet());
|
assertAcked(indicesAdmin().aliases(new IndicesAliasesRequest().addAliasAction(addAction)).actionGet());
|
||||||
|
|
||||||
addAction = new AliasActions(AliasActions.Type.ADD).aliases(alias).indices(dataStreams[0]).filter(indexFilters).writeIndex(true);
|
addAction = new AliasActions(AliasActions.Type.ADD).aliases(alias).indices(dataStreams[0]).filter(indexFilters).writeIndex(true);
|
||||||
assertAcked(client().admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(addAction)).actionGet());
|
assertAcked(indicesAdmin().aliases(new IndicesAliasesRequest().addAliasAction(addAction)).actionGet());
|
||||||
|
|
||||||
GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(response.getDataStreamAliases().size(), equalTo(dataStreams.length));
|
assertThat(response.getDataStreamAliases().size(), equalTo(dataStreams.length));
|
||||||
List<DataStreamAlias> result = response.getDataStreamAliases()
|
List<DataStreamAlias> result = response.getDataStreamAliases()
|
||||||
.values()
|
.values()
|
||||||
|
@ -910,10 +904,10 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
Exception e = expectThrows(
|
Exception e = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> client().admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(addAction)).actionGet()
|
() -> indicesAdmin().aliases(new IndicesAliasesRequest().addAliasAction(addAction)).actionGet()
|
||||||
);
|
);
|
||||||
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [" + alias + "]"));
|
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [" + alias + "]"));
|
||||||
GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(response.getDataStreamAliases(), anEmptyMap());
|
assertThat(response.getDataStreamAliases(), anEmptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,7 +921,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index(backingIndex).aliases("first_gen");
|
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index(backingIndex).aliases("first_gen");
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
Exception e = expectThrows(IllegalArgumentException.class, () -> client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
Exception e = expectThrows(IllegalArgumentException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
assertThat(
|
assertThat(
|
||||||
e.getMessage(),
|
e.getMessage(),
|
||||||
equalTo(
|
equalTo(
|
||||||
|
@ -951,7 +945,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index("metrics-*").aliases("my-alias");
|
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index("metrics-*").aliases("my-alias");
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
Exception e = expectThrows(IllegalArgumentException.class, () -> client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
Exception e = expectThrows(IllegalArgumentException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
assertThat(e.getMessage(), equalTo("expressions [metrics-*] that match with both data streams and regular indices are disallowed"));
|
assertThat(e.getMessage(), equalTo("expressions [metrics-*] that match with both data streams and regular indices are disallowed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,8 +959,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("metrics-foo").aliases("my-alias1"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("metrics-foo").aliases("my-alias1"));
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("metrics-myindex").aliases("my-alias2"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("metrics-myindex").aliases("my-alias2"));
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(
|
assertThat(
|
||||||
response.getDataStreamAliases(),
|
response.getDataStreamAliases(),
|
||||||
equalTo(Map.of("metrics-foo", List.of(new DataStreamAlias("my-alias1", List.of("metrics-foo"), null, null))))
|
equalTo(Map.of("metrics-foo", List.of(new DataStreamAlias("my-alias1", List.of("metrics-foo"), null, null))))
|
||||||
|
@ -980,8 +974,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
} else {
|
} else {
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).index("_all").aliases("my-*"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).index("_all").aliases("my-*"));
|
||||||
}
|
}
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(response.getDataStreamAliases(), anEmptyMap());
|
assertThat(response.getDataStreamAliases(), anEmptyMap());
|
||||||
assertThat(response.getAliases().get("metrics-myindex").size(), equalTo(0));
|
assertThat(response.getAliases().get("metrics-myindex").size(), equalTo(0));
|
||||||
assertThat(response.getAliases().size(), equalTo(1));
|
assertThat(response.getAliases().size(), equalTo(1));
|
||||||
|
@ -997,8 +991,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
aliasesAddRequest.addAliasAction(
|
aliasesAddRequest.addAliasAction(
|
||||||
new AliasActions(AliasActions.Type.ADD).index("metrics-foo").aliases("my-alias1", "my-alias2")
|
new AliasActions(AliasActions.Type.ADD).index("metrics-foo").aliases("my-alias1", "my-alias2")
|
||||||
);
|
);
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(response.getDataStreamAliases().keySet(), containsInAnyOrder("metrics-foo"));
|
assertThat(response.getDataStreamAliases().keySet(), containsInAnyOrder("metrics-foo"));
|
||||||
assertThat(
|
assertThat(
|
||||||
response.getDataStreamAliases().get("metrics-foo"),
|
response.getDataStreamAliases().get("metrics-foo"),
|
||||||
|
@ -1013,7 +1007,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
{
|
{
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("metrics-foo").aliases("my-alias*"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("metrics-foo").aliases("my-alias*"));
|
||||||
expectThrows(InvalidAliasNameException.class, () -> client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
expectThrows(InvalidAliasNameException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
}
|
}
|
||||||
// REMOVE does resolve wildcards:
|
// REMOVE does resolve wildcards:
|
||||||
{
|
{
|
||||||
|
@ -1023,8 +1017,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
} else {
|
} else {
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).index("_all").aliases("_all"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).index("_all").aliases("_all"));
|
||||||
}
|
}
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest()).actionGet();
|
GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet();
|
||||||
assertThat(response.getDataStreamAliases(), anEmptyMap());
|
assertThat(response.getDataStreamAliases(), anEmptyMap());
|
||||||
assertThat(response.getAliases().size(), equalTo(0));
|
assertThat(response.getAliases().size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
@ -1039,10 +1033,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index("metrics-*").aliases("my-alias").routing("[routing]");
|
AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index("metrics-*").aliases("my-alias").routing("[routing]");
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
Exception e = expectThrows(
|
Exception e = expectThrows(IllegalArgumentException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
IllegalArgumentException.class,
|
|
||||||
() -> client().admin().indices().aliases(aliasesAddRequest).actionGet()
|
|
||||||
);
|
|
||||||
assertThat(e.getMessage(), equalTo("aliases that point to data streams don't support routing"));
|
assertThat(e.getMessage(), equalTo("aliases that point to data streams don't support routing"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -1051,10 +1042,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.indexRouting("[index_routing]");
|
.indexRouting("[index_routing]");
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
Exception e = expectThrows(
|
Exception e = expectThrows(IllegalArgumentException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
IllegalArgumentException.class,
|
|
||||||
() -> client().admin().indices().aliases(aliasesAddRequest).actionGet()
|
|
||||||
);
|
|
||||||
assertThat(e.getMessage(), equalTo("aliases that point to data streams don't support index_routing"));
|
assertThat(e.getMessage(), equalTo("aliases that point to data streams don't support index_routing"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -1063,10 +1051,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.searchRouting("[search_routing]");
|
.searchRouting("[search_routing]");
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
Exception e = expectThrows(
|
Exception e = expectThrows(IllegalArgumentException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
IllegalArgumentException.class,
|
|
||||||
() -> client().admin().indices().aliases(aliasesAddRequest).actionGet()
|
|
||||||
);
|
|
||||||
assertThat(e.getMessage(), equalTo("aliases that point to data streams don't support search_routing"));
|
assertThat(e.getMessage(), equalTo("aliases that point to data streams don't support search_routing"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -1075,10 +1060,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.isHidden(randomBoolean());
|
.isHidden(randomBoolean());
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(addAction);
|
aliasesAddRequest.addAliasAction(addAction);
|
||||||
Exception e = expectThrows(
|
Exception e = expectThrows(IllegalArgumentException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
IllegalArgumentException.class,
|
|
||||||
() -> client().admin().indices().aliases(aliasesAddRequest).actionGet()
|
|
||||||
);
|
|
||||||
assertThat(e.getMessage(), equalTo("aliases that point to data streams don't support is_hidden"));
|
assertThat(e.getMessage(), equalTo("aliases that point to data streams don't support is_hidden"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1127,7 +1109,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
String backingIndex1 = getDataStreamResponse.getDataStreams().get(0).getDataStream().getIndices().get(0).getName();
|
String backingIndex1 = getDataStreamResponse.getDataStreams().get(0).getDataStream().getIndices().get(0).getName();
|
||||||
assertThat(backingIndex1, backingIndexEqualTo("logs-foobar", 1));
|
assertThat(backingIndex1, backingIndexEqualTo("logs-foobar", 1));
|
||||||
|
|
||||||
RolloverResponse rolloverResponse = client().admin().indices().rolloverIndex(new RolloverRequest("logs-foobar", null)).get();
|
RolloverResponse rolloverResponse = indicesAdmin().rolloverIndex(new RolloverRequest("logs-foobar", null)).get();
|
||||||
String backingIndex2 = rolloverResponse.getNewIndex();
|
String backingIndex2 = rolloverResponse.getNewIndex();
|
||||||
assertThat(backingIndex2, backingIndexEqualTo("logs-foobar", 2));
|
assertThat(backingIndex2, backingIndexEqualTo("logs-foobar", 2));
|
||||||
assertTrue(rolloverResponse.isRolledOver());
|
assertTrue(rolloverResponse.isRolledOver());
|
||||||
|
@ -1138,7 +1120,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
DataStreamTimestampFieldMapper.NAME,
|
DataStreamTimestampFieldMapper.NAME,
|
||||||
Map.of("enabled", true)
|
Map.of("enabled", true)
|
||||||
);
|
);
|
||||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("logs-foobar").get();
|
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("logs-foobar").get();
|
||||||
assertThat(getMappingsResponse.getMappings().size(), equalTo(2));
|
assertThat(getMappingsResponse.getMappings().size(), equalTo(2));
|
||||||
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
|
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
|
||||||
assertThat(getMappingsResponse.getMappings().get(backingIndex2).getSourceAsMap(), equalTo(expectedMapping));
|
assertThat(getMappingsResponse.getMappings().get(backingIndex2).getSourceAsMap(), equalTo(expectedMapping));
|
||||||
|
@ -1149,13 +1131,11 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
DataStreamTimestampFieldMapper.NAME,
|
DataStreamTimestampFieldMapper.NAME,
|
||||||
Map.of("enabled", true)
|
Map.of("enabled", true)
|
||||||
);
|
);
|
||||||
client().admin()
|
indicesAdmin().preparePutMapping("logs-foobar")
|
||||||
.indices()
|
|
||||||
.preparePutMapping("logs-foobar")
|
|
||||||
.setSource("{\"properties\":{\"my_field\":{\"type\":\"keyword\"}}}", XContentType.JSON)
|
.setSource("{\"properties\":{\"my_field\":{\"type\":\"keyword\"}}}", XContentType.JSON)
|
||||||
.get();
|
.get();
|
||||||
// The mappings of all backing indices should be updated:
|
// The mappings of all backing indices should be updated:
|
||||||
getMappingsResponse = client().admin().indices().prepareGetMappings("logs-foobar").get();
|
getMappingsResponse = indicesAdmin().prepareGetMappings("logs-foobar").get();
|
||||||
assertThat(getMappingsResponse.getMappings().size(), equalTo(2));
|
assertThat(getMappingsResponse.getMappings().size(), equalTo(2));
|
||||||
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
|
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
|
||||||
assertThat(getMappingsResponse.getMappings().get(backingIndex2).getSourceAsMap(), equalTo(expectedMapping));
|
assertThat(getMappingsResponse.getMappings().get(backingIndex2).getSourceAsMap(), equalTo(expectedMapping));
|
||||||
|
@ -1175,19 +1155,19 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
String backingIndex1 = getDataStreamResponse.getDataStreams().get(0).getDataStream().getIndices().get(0).getName();
|
String backingIndex1 = getDataStreamResponse.getDataStreams().get(0).getDataStream().getIndices().get(0).getName();
|
||||||
assertThat(backingIndex1, backingIndexEqualTo("logs-foobar", 1));
|
assertThat(backingIndex1, backingIndexEqualTo("logs-foobar", 1));
|
||||||
|
|
||||||
RolloverResponse rolloverResponse = client().admin().indices().rolloverIndex(new RolloverRequest("logs-foobar", null)).get();
|
RolloverResponse rolloverResponse = indicesAdmin().rolloverIndex(new RolloverRequest("logs-foobar", null)).get();
|
||||||
String backingIndex2 = rolloverResponse.getNewIndex();
|
String backingIndex2 = rolloverResponse.getNewIndex();
|
||||||
assertThat(backingIndex2, backingIndexEqualTo("logs-foobar", 2));
|
assertThat(backingIndex2, backingIndexEqualTo("logs-foobar", 2));
|
||||||
assertTrue(rolloverResponse.isRolledOver());
|
assertTrue(rolloverResponse.isRolledOver());
|
||||||
|
|
||||||
// The index settings of all backing indices should be updated:
|
// The index settings of all backing indices should be updated:
|
||||||
GetSettingsResponse getSettingsResponse = client().admin().indices().prepareGetSettings("logs-foobar").get();
|
GetSettingsResponse getSettingsResponse = indicesAdmin().prepareGetSettings("logs-foobar").get();
|
||||||
assertThat(getSettingsResponse.getIndexToSettings().size(), equalTo(2));
|
assertThat(getSettingsResponse.getIndexToSettings().size(), equalTo(2));
|
||||||
assertThat(getSettingsResponse.getSetting(backingIndex1, "index.number_of_replicas"), equalTo("1"));
|
assertThat(getSettingsResponse.getSetting(backingIndex1, "index.number_of_replicas"), equalTo("1"));
|
||||||
assertThat(getSettingsResponse.getSetting(backingIndex2, "index.number_of_replicas"), equalTo("1"));
|
assertThat(getSettingsResponse.getSetting(backingIndex2, "index.number_of_replicas"), equalTo("1"));
|
||||||
|
|
||||||
setReplicaCount(0, "logs-foobar");
|
setReplicaCount(0, "logs-foobar");
|
||||||
getSettingsResponse = client().admin().indices().prepareGetSettings("logs-foobar").get();
|
getSettingsResponse = indicesAdmin().prepareGetSettings("logs-foobar").get();
|
||||||
assertThat(getSettingsResponse.getIndexToSettings().size(), equalTo(2));
|
assertThat(getSettingsResponse.getIndexToSettings().size(), equalTo(2));
|
||||||
assertThat(getSettingsResponse.getSetting(backingIndex1, "index.number_of_replicas"), equalTo("0"));
|
assertThat(getSettingsResponse.getSetting(backingIndex1, "index.number_of_replicas"), equalTo("0"));
|
||||||
assertThat(getSettingsResponse.getSetting(backingIndex2, "index.number_of_replicas"), equalTo("0"));
|
assertThat(getSettingsResponse.getSetting(backingIndex2, "index.number_of_replicas"), equalTo("0"));
|
||||||
|
@ -1319,7 +1299,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
int numDocsFoo = randomIntBetween(2, 16);
|
int numDocsFoo = randomIntBetween(2, 16);
|
||||||
indexDocs("metrics-foo", numDocsFoo);
|
indexDocs("metrics-foo", numDocsFoo);
|
||||||
|
|
||||||
RolloverResponse rolloverResponse = client().admin().indices().rolloverIndex(new RolloverRequest("metrics-foo", null)).get();
|
RolloverResponse rolloverResponse = indicesAdmin().rolloverIndex(new RolloverRequest("metrics-foo", null)).get();
|
||||||
assertThat(rolloverResponse.getNewIndex(), backingIndexEqualTo("metrics-foo", 2));
|
assertThat(rolloverResponse.getNewIndex(), backingIndexEqualTo("metrics-foo", 2));
|
||||||
|
|
||||||
// ingest some more data in the rolled data stream
|
// ingest some more data in the rolled data stream
|
||||||
|
@ -1352,7 +1332,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertBackingIndex(String backingIndex, String timestampFieldPathInMapping, Map<?, ?> expectedMapping) {
|
private static void assertBackingIndex(String backingIndex, String timestampFieldPathInMapping, Map<?, ?> expectedMapping) {
|
||||||
GetIndexResponse getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
GetIndexResponse getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(backingIndex)).actionGet();
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
assertThat(getIndexResponse.getSettings().get(backingIndex), notNullValue());
|
||||||
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
assertThat(getIndexResponse.getSettings().get(backingIndex).getAsBoolean("index.hidden", null), is(true));
|
||||||
Map<?, ?> mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
Map<?, ?> mappings = getIndexResponse.getMappings().get(backingIndex).getSourceAsMap();
|
||||||
|
@ -1434,7 +1414,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
assertThat(getDataStreamsResponse.getDataStreams().get(2).getDataStream().getName(), equalTo("logs-foobaz2"));
|
assertThat(getDataStreamsResponse.getDataStreams().get(2).getDataStream().getName(), equalTo("logs-foobaz2"));
|
||||||
assertThat(getDataStreamsResponse.getDataStreams().get(3).getDataStream().getName(), equalTo("logs-foobaz3"));
|
assertThat(getDataStreamsResponse.getDataStreams().get(3).getDataStream().getName(), equalTo("logs-foobaz3"));
|
||||||
|
|
||||||
GetIndexResponse getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices("logs-bar*")).actionGet();
|
GetIndexResponse getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices("logs-bar*")).actionGet();
|
||||||
assertThat(getIndexResponse.getIndices(), arrayWithSize(4));
|
assertThat(getIndexResponse.getIndices(), arrayWithSize(4));
|
||||||
assertThat(getIndexResponse.getIndices(), hasItemInArray("logs-barbaz"));
|
assertThat(getIndexResponse.getIndices(), hasItemInArray("logs-barbaz"));
|
||||||
assertThat(getIndexResponse.getIndices(), hasItemInArray("logs-barfoo"));
|
assertThat(getIndexResponse.getIndices(), hasItemInArray("logs-barfoo"));
|
||||||
|
@ -1454,7 +1434,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
v1Request.patterns(List.of("logs-foo*"));
|
v1Request.patterns(List.of("logs-foo*"));
|
||||||
v1Request.settings(settings);
|
v1Request.settings(settings);
|
||||||
v1Request.order(Integer.MAX_VALUE); // in order to avoid number_of_replicas being overwritten by random_template
|
v1Request.order(Integer.MAX_VALUE); // in order to avoid number_of_replicas being overwritten by random_template
|
||||||
client().admin().indices().putTemplate(v1Request).actionGet();
|
indicesAdmin().putTemplate(v1Request).actionGet();
|
||||||
|
|
||||||
BulkRequest bulkRequest = new BulkRequest();
|
BulkRequest bulkRequest = new BulkRequest();
|
||||||
bulkRequest.add(new IndexRequest("logs-foobar").opType(CREATE).source("{}", XContentType.JSON));
|
bulkRequest.add(new IndexRequest("logs-foobar").opType(CREATE).source("{}", XContentType.JSON));
|
||||||
|
@ -1466,7 +1446,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.actionGet();
|
.actionGet();
|
||||||
assertThat(getDataStreamsResponse.getDataStreams(), hasSize(0));
|
assertThat(getDataStreamsResponse.getDataStreams(), hasSize(0));
|
||||||
|
|
||||||
GetIndexResponse getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices("logs-foobar")).actionGet();
|
GetIndexResponse getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices("logs-foobar")).actionGet();
|
||||||
assertThat(getIndexResponse.getIndices(), arrayWithSize(1));
|
assertThat(getIndexResponse.getIndices(), arrayWithSize(1));
|
||||||
assertThat(getIndexResponse.getIndices(), hasItemInArray("logs-foobar"));
|
assertThat(getIndexResponse.getIndices(), hasItemInArray("logs-foobar"));
|
||||||
assertThat(getIndexResponse.getSettings().get("logs-foobar").get(IndexMetadata.SETTING_NUMBER_OF_REPLICAS), equalTo("0"));
|
assertThat(getIndexResponse.getSettings().get("logs-foobar").get(IndexMetadata.SETTING_NUMBER_OF_REPLICAS), equalTo("0"));
|
||||||
|
@ -1554,9 +1534,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
logger.info("--> [{}] waiting for all the other threads before starting", i);
|
logger.info("--> [{}] waiting for all the other threads before starting", i);
|
||||||
barrier.await();
|
barrier.await();
|
||||||
while (running.get()) {
|
while (running.get()) {
|
||||||
RolloverResponse resp = client().admin()
|
RolloverResponse resp = indicesAdmin().prepareRolloverIndex(dsName)
|
||||||
.indices()
|
|
||||||
.prepareRolloverIndex(dsName)
|
|
||||||
.setConditions(RolloverConditions.newBuilder().addMaxIndexDocsCondition(2L))
|
.setConditions(RolloverConditions.newBuilder().addMaxIndexDocsCondition(2L))
|
||||||
.get();
|
.get();
|
||||||
if (resp.isRolledOver()) {
|
if (resp.isRolledOver()) {
|
||||||
|
@ -1587,7 +1565,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.actionGet();
|
.actionGet();
|
||||||
String newBackingIndexName = getDataStreamResponse.getDataStreams().get(0).getDataStream().getWriteIndex().getName();
|
String newBackingIndexName = getDataStreamResponse.getDataStreams().get(0).getDataStream().getWriteIndex().getName();
|
||||||
assertThat(newBackingIndexName, backingIndexEqualTo("potato-biscuit", 2));
|
assertThat(newBackingIndexName, backingIndexEqualTo("potato-biscuit", 2));
|
||||||
client().admin().indices().prepareGetIndex().addIndices(newBackingIndexName).get();
|
indicesAdmin().prepareGetIndex().addIndices(newBackingIndexName).get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("--> expecting second index to be created but it has not yet been created");
|
logger.info("--> expecting second index to be created but it has not yet been created");
|
||||||
fail("expecting second index to exist");
|
fail("expecting second index to exist");
|
||||||
|
@ -1650,7 +1628,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testCreateDataStreamWithSameNameAsIndexAlias() throws Exception {
|
public void testCreateDataStreamWithSameNameAsIndexAlias() throws Exception {
|
||||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index").alias(new Alias("my-alias"));
|
CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index").alias(new Alias("my-alias"));
|
||||||
assertAcked(client().admin().indices().create(createIndexRequest).actionGet());
|
assertAcked(indicesAdmin().create(createIndexRequest).actionGet());
|
||||||
|
|
||||||
// Important detail: create template with data stream template after the index has been created
|
// Important detail: create template with data stream template after the index has been created
|
||||||
DataStreamIT.putComposableIndexTemplate("my-template", List.of("my-*"));
|
DataStreamIT.putComposableIndexTemplate("my-template", List.of("my-*"));
|
||||||
|
@ -1663,7 +1641,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testCreateDataStreamWithSameNameAsIndex() throws Exception {
|
public void testCreateDataStreamWithSameNameAsIndex() throws Exception {
|
||||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index").alias(new Alias("my-alias"));
|
CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index").alias(new Alias("my-alias"));
|
||||||
assertAcked(client().admin().indices().create(createIndexRequest).actionGet());
|
assertAcked(indicesAdmin().create(createIndexRequest).actionGet());
|
||||||
|
|
||||||
// Important detail: create template with data stream template after the index has been created
|
// Important detail: create template with data stream template after the index has been created
|
||||||
DataStreamIT.putComposableIndexTemplate("my-template", List.of("my-*"));
|
DataStreamIT.putComposableIndexTemplate("my-template", List.of("my-*"));
|
||||||
|
@ -1680,7 +1658,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
||||||
var aliasesAddRequest = new IndicesAliasesRequest();
|
var aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("my-ds").aliases("my-alias"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("my-ds").aliases("my-alias"));
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
|
|
||||||
var request2 = new CreateDataStreamAction.Request("my-alias");
|
var request2 = new CreateDataStreamAction.Request("my-alias");
|
||||||
var e = expectThrows(
|
var e = expectThrows(
|
||||||
|
@ -1716,13 +1694,13 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
{
|
{
|
||||||
DataStreamIT.putComposableIndexTemplate("my-template", List.of("logs-*"));
|
DataStreamIT.putComposableIndexTemplate("my-template", List.of("logs-*"));
|
||||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest("es-logs").alias(new Alias("logs"));
|
CreateIndexRequest createIndexRequest = new CreateIndexRequest("es-logs").alias(new Alias("logs"));
|
||||||
assertAcked(client().admin().indices().create(createIndexRequest).actionGet());
|
assertAcked(indicesAdmin().create(createIndexRequest).actionGet());
|
||||||
|
|
||||||
var request = new CreateDataStreamAction.Request("logs-es");
|
var request = new CreateDataStreamAction.Request("logs-es");
|
||||||
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("logs-es").aliases("logs"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("logs-es").aliases("logs"));
|
||||||
var e = expectThrows(IllegalStateException.class, () -> client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
var e = expectThrows(IllegalStateException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
assertThat(e.getMessage(), containsString("data stream alias and indices alias have the same name (logs)"));
|
assertThat(e.getMessage(), containsString("data stream alias and indices alias have the same name (logs)"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -1747,14 +1725,14 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
DataStreamIT.putComposableIndexTemplate("my-template", List.of("logs-*"));
|
DataStreamIT.putComposableIndexTemplate("my-template", List.of("logs-*"));
|
||||||
|
|
||||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest("logs");
|
CreateIndexRequest createIndexRequest = new CreateIndexRequest("logs");
|
||||||
assertAcked(client().admin().indices().create(createIndexRequest).actionGet());
|
assertAcked(indicesAdmin().create(createIndexRequest).actionGet());
|
||||||
|
|
||||||
{
|
{
|
||||||
var request = new CreateDataStreamAction.Request("logs-es");
|
var request = new CreateDataStreamAction.Request("logs-es");
|
||||||
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("logs-es").aliases("logs"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("logs-es").aliases("logs"));
|
||||||
var e = expectThrows(InvalidAliasNameException.class, () -> client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
var e = expectThrows(InvalidAliasNameException.class, () -> indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
assertThat(
|
assertThat(
|
||||||
e.getMessage(),
|
e.getMessage(),
|
||||||
equalTo("Invalid alias name [logs]: an index or data stream exists with the same name as the alias")
|
equalTo("Invalid alias name [logs]: an index or data stream exists with the same name as the alias")
|
||||||
|
@ -1788,10 +1766,10 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("logs-es").aliases("logs"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("logs-es").aliases("logs"));
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
|
|
||||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest("logs");
|
CreateIndexRequest createIndexRequest = new CreateIndexRequest("logs");
|
||||||
var e = expectThrows(InvalidIndexNameException.class, () -> client().admin().indices().create(createIndexRequest).actionGet());
|
var e = expectThrows(InvalidIndexNameException.class, () -> indicesAdmin().create(createIndexRequest).actionGet());
|
||||||
assertThat(e.getMessage(), equalTo("Invalid index name [logs], already exists as alias"));
|
assertThat(e.getMessage(), equalTo("Invalid index name [logs], already exists as alias"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1802,19 +1780,19 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
||||||
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest();
|
||||||
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("logs-es").aliases("logs"));
|
aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("logs-es").aliases("logs"));
|
||||||
assertAcked(client().admin().indices().aliases(aliasesAddRequest).actionGet());
|
assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet());
|
||||||
|
|
||||||
{
|
{
|
||||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index").alias(new Alias("logs"));
|
CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index").alias(new Alias("logs"));
|
||||||
var e = expectThrows(IllegalStateException.class, () -> client().admin().indices().create(createIndexRequest).actionGet());
|
var e = expectThrows(IllegalStateException.class, () -> indicesAdmin().create(createIndexRequest).actionGet());
|
||||||
assertThat(e.getMessage(), containsString("data stream alias and indices alias have the same name (logs)"));
|
assertThat(e.getMessage(), containsString("data stream alias and indices alias have the same name (logs)"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index");
|
CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index");
|
||||||
assertAcked(client().admin().indices().create(createIndexRequest).actionGet());
|
assertAcked(indicesAdmin().create(createIndexRequest).actionGet());
|
||||||
IndicesAliasesRequest addAliasRequest = new IndicesAliasesRequest();
|
IndicesAliasesRequest addAliasRequest = new IndicesAliasesRequest();
|
||||||
addAliasRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("my-index").aliases("logs"));
|
addAliasRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("my-index").aliases("logs"));
|
||||||
var e = expectThrows(IllegalStateException.class, () -> client().admin().indices().aliases(addAliasRequest).actionGet());
|
var e = expectThrows(IllegalStateException.class, () -> indicesAdmin().aliases(addAliasRequest).actionGet());
|
||||||
assertThat(e.getMessage(), containsString("data stream alias and indices alias have the same name (logs)"));
|
assertThat(e.getMessage(), containsString("data stream alias and indices alias have the same name (logs)"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1824,8 +1802,8 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
DataStreamIT.putComposableIndexTemplate("my-template", List.of("logs-*"));
|
DataStreamIT.putComposableIndexTemplate("my-template", List.of("logs-*"));
|
||||||
var request = new CreateDataStreamAction.Request(dataStreamName);
|
var request = new CreateDataStreamAction.Request(dataStreamName);
|
||||||
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
|
||||||
assertAcked(client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
assertAcked(indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
||||||
var indicesStatsResponse = client().admin().indices().stats(new IndicesStatsRequest()).actionGet();
|
var indicesStatsResponse = indicesAdmin().stats(new IndicesStatsRequest()).actionGet();
|
||||||
assertThat(indicesStatsResponse.getIndices().size(), equalTo(2));
|
assertThat(indicesStatsResponse.getIndices().size(), equalTo(2));
|
||||||
ClusterState before = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
ClusterState before = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
||||||
assertThat(before.getMetadata().dataStreams().get(dataStreamName).getIndices(), hasSize(2));
|
assertThat(before.getMetadata().dataStreams().get(dataStreamName).getIndices(), hasSize(2));
|
||||||
|
@ -1870,7 +1848,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
var ghostReference = brokenDataStreamHolder.get().getIndices().get(0);
|
var ghostReference = brokenDataStreamHolder.get().getIndices().get(0);
|
||||||
|
|
||||||
// Many APIs fail with NPE, because of broken data stream:
|
// Many APIs fail with NPE, because of broken data stream:
|
||||||
expectThrows(NullPointerException.class, () -> client().admin().indices().stats(new IndicesStatsRequest()).actionGet());
|
expectThrows(NullPointerException.class, () -> indicesAdmin().stats(new IndicesStatsRequest()).actionGet());
|
||||||
expectThrows(NullPointerException.class, () -> client().search(new SearchRequest()).actionGet());
|
expectThrows(NullPointerException.class, () -> client().search(new SearchRequest()).actionGet());
|
||||||
|
|
||||||
assertAcked(
|
assertAcked(
|
||||||
|
@ -1884,7 +1862,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
// Data stream resolves now to one backing index.
|
// Data stream resolves now to one backing index.
|
||||||
// Note, that old backing index still exists and has been unhidden.
|
// Note, that old backing index still exists and has been unhidden.
|
||||||
// The modify data stream api only fixed the data stream by removing a broken reference to a backing index.
|
// The modify data stream api only fixed the data stream by removing a broken reference to a backing index.
|
||||||
indicesStatsResponse = client().admin().indices().stats(new IndicesStatsRequest()).actionGet();
|
indicesStatsResponse = indicesAdmin().stats(new IndicesStatsRequest()).actionGet();
|
||||||
assertThat(indicesStatsResponse.getIndices().size(), equalTo(2));
|
assertThat(indicesStatsResponse.getIndices().size(), equalTo(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1942,7 +1920,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
assertThat(itemResponse.status(), equalTo(RestStatus.CREATED));
|
assertThat(itemResponse.status(), equalTo(RestStatus.CREATED));
|
||||||
assertThat(itemResponse.getIndex(), startsWith(backingIndexPrefix));
|
assertThat(itemResponse.getIndex(), startsWith(backingIndexPrefix));
|
||||||
}
|
}
|
||||||
client().admin().indices().refresh(new RefreshRequest(dataStream)).actionGet();
|
indicesAdmin().refresh(new RefreshRequest(dataStream)).actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verifyDocs(String dataStream, long expectedNumHits, List<String> expectedIndices) {
|
static void verifyDocs(String dataStream, long expectedNumHits, List<String> expectedIndices) {
|
||||||
|
@ -2099,7 +2077,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
|
|
||||||
indexDocsAndEnsureThereIsCapturedWriteLoad(dataStreamName);
|
indexDocsAndEnsureThereIsCapturedWriteLoad(dataStreamName);
|
||||||
|
|
||||||
assertAcked(client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
assertAcked(indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
||||||
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
||||||
final DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
|
final DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
|
||||||
|
|
||||||
|
@ -2176,7 +2154,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
currentDataStreamWriteIndexRoutingTable.shard(1).replicaShards().get(0)
|
currentDataStreamWriteIndexRoutingTable.shard(1).replicaShards().get(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
assertAcked(client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
assertAcked(indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
||||||
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
||||||
final DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
|
final DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
|
||||||
|
|
||||||
|
@ -2238,7 +2216,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
(handler, request, channel, task) -> channel.sendResponse(new RuntimeException("Unable to get stats"))
|
(handler, request, channel, task) -> channel.sendResponse(new RuntimeException("Unable to get stats"))
|
||||||
);
|
);
|
||||||
|
|
||||||
assertAcked(client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
assertAcked(indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
||||||
|
|
||||||
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
||||||
final DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
|
final DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
|
||||||
|
@ -2264,11 +2242,11 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// Ensure that we get a stable size to compare against the expected size
|
// Ensure that we get a stable size to compare against the expected size
|
||||||
assertThat(
|
assertThat(
|
||||||
client().admin().indices().prepareForceMerge().setFlush(true).setMaxNumSegments(1).get().getSuccessfulShards(),
|
indicesAdmin().prepareForceMerge().setFlush(true).setMaxNumSegments(1).get().getSuccessfulShards(),
|
||||||
is(greaterThanOrEqualTo(numberOfShards))
|
is(greaterThanOrEqualTo(numberOfShards))
|
||||||
);
|
);
|
||||||
|
|
||||||
assertAcked(client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
assertAcked(indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).actionGet());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
||||||
|
@ -2280,11 +2258,9 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
.map(Index::getName)
|
.map(Index::getName)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
final IndicesStatsResponse indicesStatsResponse = client().admin()
|
final IndicesStatsResponse indicesStatsResponse = indicesAdmin().prepareStats(
|
||||||
.indices()
|
dataStreamReadIndices.toArray(new String[dataStreamReadIndices.size()])
|
||||||
.prepareStats(dataStreamReadIndices.toArray(new String[dataStreamReadIndices.size()]))
|
).setStore(true).get();
|
||||||
.setStore(true)
|
|
||||||
.get();
|
|
||||||
long expectedTotalSizeInBytes = 0;
|
long expectedTotalSizeInBytes = 0;
|
||||||
int shardCount = 0;
|
int shardCount = 0;
|
||||||
for (ShardStats shard : indicesStatsResponse.getShards()) {
|
for (ShardStats shard : indicesStatsResponse.getShards()) {
|
||||||
|
@ -2310,7 +2286,7 @@ public class DataStreamIT extends ESIntegTestCase {
|
||||||
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
final ClusterState clusterState = internalCluster().getCurrentMasterNodeInstance(ClusterService.class).state();
|
||||||
final DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
|
final DataStream dataStream = clusterState.getMetadata().dataStreams().get(dataStreamName);
|
||||||
final String writeIndex = dataStream.getWriteIndex().getName();
|
final String writeIndex = dataStream.getWriteIndex().getName();
|
||||||
final IndicesStatsResponse indicesStatsResponse = client().admin().indices().prepareStats(writeIndex).get();
|
final IndicesStatsResponse indicesStatsResponse = indicesAdmin().prepareStats(writeIndex).get();
|
||||||
for (IndexShardStats indexShardStats : indicesStatsResponse.getIndex(writeIndex).getIndexShards().values()) {
|
for (IndexShardStats indexShardStats : indicesStatsResponse.getIndex(writeIndex).getIndexShards().values()) {
|
||||||
for (ShardStats shard : indexShardStats.getShards()) {
|
for (ShardStats shard : indexShardStats.getShards()) {
|
||||||
final IndexingStats.Stats shardIndexingStats = shard.getStats().getIndexing().getTotal();
|
final IndexingStats.Stats shardIndexingStats = shard.getStats().getIndexing().getTotal();
|
||||||
|
|
|
@ -47,8 +47,8 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
public void testBasicMigration() throws Exception {
|
public void testBasicMigration() throws Exception {
|
||||||
putComposableIndexTemplate("id1", List.of("migrate*"));
|
putComposableIndexTemplate("id1", List.of("migrate*"));
|
||||||
|
|
||||||
admin().indices().create(new CreateIndexRequest("index1")).get();
|
indicesAdmin().create(new CreateIndexRequest("index1")).get();
|
||||||
admin().indices().create(new CreateIndexRequest("index2")).get();
|
indicesAdmin().create(new CreateIndexRequest("index2")).get();
|
||||||
|
|
||||||
int numDocs1 = randomIntBetween(2, 16);
|
int numDocs1 = randomIntBetween(2, 16);
|
||||||
indexDocs("index1", numDocs1);
|
indexDocs("index1", numDocs1);
|
||||||
|
@ -59,13 +59,13 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(true));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(true));
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
||||||
assertAcked(admin().indices().aliases(request).get());
|
assertAcked(indicesAdmin().aliases(request).get());
|
||||||
|
|
||||||
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
||||||
new String[] { "*" },
|
new String[] { "*" },
|
||||||
IndicesOptions.fromOptions(true, true, true, true, true)
|
IndicesOptions.fromOptions(true, true, true, true, true)
|
||||||
);
|
);
|
||||||
ResolveIndexAction.Response resolveResponse = admin().indices().resolveIndex(resolveRequest).get();
|
ResolveIndexAction.Response resolveResponse = indicesAdmin().resolveIndex(resolveRequest).get();
|
||||||
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
||||||
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
||||||
|
@ -73,7 +73,7 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
client().execute(MigrateToDataStreamAction.INSTANCE, new MigrateToDataStreamAction.Request(alias)).get();
|
client().execute(MigrateToDataStreamAction.INSTANCE, new MigrateToDataStreamAction.Request(alias)).get();
|
||||||
|
|
||||||
resolveResponse = admin().indices().resolveIndex(resolveRequest).get();
|
resolveResponse = indicesAdmin().resolveIndex(resolveRequest).get();
|
||||||
assertThat(resolveResponse.getAliases().size(), equalTo(0));
|
assertThat(resolveResponse.getAliases().size(), equalTo(0));
|
||||||
assertThat(resolveResponse.getDataStreams().size(), equalTo(1));
|
assertThat(resolveResponse.getDataStreams().size(), equalTo(1));
|
||||||
assertThat(resolveResponse.getDataStreams().get(0).getName(), equalTo(alias));
|
assertThat(resolveResponse.getDataStreams().get(0).getName(), equalTo(alias));
|
||||||
|
@ -86,8 +86,8 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMigrationWithoutTemplate() throws Exception {
|
public void testMigrationWithoutTemplate() throws Exception {
|
||||||
admin().indices().create(new CreateIndexRequest("index1")).get();
|
indicesAdmin().create(new CreateIndexRequest("index1")).get();
|
||||||
admin().indices().create(new CreateIndexRequest("index2")).get();
|
indicesAdmin().create(new CreateIndexRequest("index2")).get();
|
||||||
|
|
||||||
int numDocs1 = randomIntBetween(2, 16);
|
int numDocs1 = randomIntBetween(2, 16);
|
||||||
indexDocs("index1", numDocs1);
|
indexDocs("index1", numDocs1);
|
||||||
|
@ -98,13 +98,13 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(true));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(true));
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
||||||
assertAcked(admin().indices().aliases(request).get());
|
assertAcked(indicesAdmin().aliases(request).get());
|
||||||
|
|
||||||
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
||||||
new String[] { "*" },
|
new String[] { "*" },
|
||||||
IndicesOptions.fromOptions(true, true, true, true, true)
|
IndicesOptions.fromOptions(true, true, true, true, true)
|
||||||
);
|
);
|
||||||
ResolveIndexAction.Response resolveResponse = admin().indices().resolveIndex(resolveRequest).get();
|
ResolveIndexAction.Response resolveResponse = indicesAdmin().resolveIndex(resolveRequest).get();
|
||||||
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
||||||
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
||||||
|
@ -123,20 +123,20 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
public void testMigrationWithoutIndexMappings() throws Exception {
|
public void testMigrationWithoutIndexMappings() throws Exception {
|
||||||
putComposableIndexTemplate("id1", List.of("migrate*"));
|
putComposableIndexTemplate("id1", List.of("migrate*"));
|
||||||
|
|
||||||
admin().indices().create(new CreateIndexRequest("index1")).get();
|
indicesAdmin().create(new CreateIndexRequest("index1")).get();
|
||||||
admin().indices().create(new CreateIndexRequest("index2")).get();
|
indicesAdmin().create(new CreateIndexRequest("index2")).get();
|
||||||
|
|
||||||
String alias = "migrate-to-data-stream";
|
String alias = "migrate-to-data-stream";
|
||||||
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(true));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(true));
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
||||||
assertAcked(admin().indices().aliases(request).get());
|
assertAcked(indicesAdmin().aliases(request).get());
|
||||||
|
|
||||||
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
||||||
new String[] { "*" },
|
new String[] { "*" },
|
||||||
IndicesOptions.fromOptions(true, true, true, true, true)
|
IndicesOptions.fromOptions(true, true, true, true, true)
|
||||||
);
|
);
|
||||||
ResolveIndexAction.Response resolveResponse = admin().indices().resolveIndex(resolveRequest).get();
|
ResolveIndexAction.Response resolveResponse = indicesAdmin().resolveIndex(resolveRequest).get();
|
||||||
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
||||||
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
||||||
|
@ -153,8 +153,8 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
public void testMigrationWithoutTimestampMapping() throws Exception {
|
public void testMigrationWithoutTimestampMapping() throws Exception {
|
||||||
putComposableIndexTemplate("id1", List.of("migrate*"));
|
putComposableIndexTemplate("id1", List.of("migrate*"));
|
||||||
|
|
||||||
admin().indices().create(new CreateIndexRequest("index1")).get();
|
indicesAdmin().create(new CreateIndexRequest("index1")).get();
|
||||||
admin().indices().create(new CreateIndexRequest("index2")).get();
|
indicesAdmin().create(new CreateIndexRequest("index2")).get();
|
||||||
|
|
||||||
int numDocs1 = randomIntBetween(2, 16);
|
int numDocs1 = randomIntBetween(2, 16);
|
||||||
indexDocs("index1", numDocs1, "foo");
|
indexDocs("index1", numDocs1, "foo");
|
||||||
|
@ -165,13 +165,13 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(true));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(true));
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
||||||
assertAcked(admin().indices().aliases(request).get());
|
assertAcked(indicesAdmin().aliases(request).get());
|
||||||
|
|
||||||
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
||||||
new String[] { "*" },
|
new String[] { "*" },
|
||||||
IndicesOptions.fromOptions(true, true, true, true, true)
|
IndicesOptions.fromOptions(true, true, true, true, true)
|
||||||
);
|
);
|
||||||
ResolveIndexAction.Response resolveResponse = admin().indices().resolveIndex(resolveRequest).get();
|
ResolveIndexAction.Response resolveResponse = indicesAdmin().resolveIndex(resolveRequest).get();
|
||||||
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
||||||
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
||||||
|
@ -188,8 +188,8 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
public void testMigrationWithoutWriteIndex() throws Exception {
|
public void testMigrationWithoutWriteIndex() throws Exception {
|
||||||
putComposableIndexTemplate("id1", List.of("migrate*"));
|
putComposableIndexTemplate("id1", List.of("migrate*"));
|
||||||
|
|
||||||
admin().indices().create(new CreateIndexRequest("index1")).get();
|
indicesAdmin().create(new CreateIndexRequest("index1")).get();
|
||||||
admin().indices().create(new CreateIndexRequest("index2")).get();
|
indicesAdmin().create(new CreateIndexRequest("index2")).get();
|
||||||
|
|
||||||
int numDocs1 = randomIntBetween(2, 16);
|
int numDocs1 = randomIntBetween(2, 16);
|
||||||
indexDocs("index1", numDocs1);
|
indexDocs("index1", numDocs1);
|
||||||
|
@ -200,13 +200,13 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(false));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index1").alias(alias).writeIndex(false));
|
||||||
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index2").alias(alias).writeIndex(false));
|
||||||
assertAcked(admin().indices().aliases(request).get());
|
assertAcked(indicesAdmin().aliases(request).get());
|
||||||
|
|
||||||
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
ResolveIndexAction.Request resolveRequest = new ResolveIndexAction.Request(
|
||||||
new String[] { "*" },
|
new String[] { "*" },
|
||||||
IndicesOptions.fromOptions(true, true, true, true, true)
|
IndicesOptions.fromOptions(true, true, true, true, true)
|
||||||
);
|
);
|
||||||
ResolveIndexAction.Response resolveResponse = admin().indices().resolveIndex(resolveRequest).get();
|
ResolveIndexAction.Response resolveResponse = indicesAdmin().resolveIndex(resolveRequest).get();
|
||||||
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
assertThat(resolveResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
assertThat(resolveResponse.getAliases().get(0).getName(), equalTo(alias));
|
||||||
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
assertThat(resolveResponse.getDataStreams().size(), equalTo(0));
|
||||||
|
@ -249,7 +249,7 @@ public class DataStreamMigrationIT extends ESIntegTestCase {
|
||||||
assertThat(itemResponse.getFailureMessage(), nullValue());
|
assertThat(itemResponse.getFailureMessage(), nullValue());
|
||||||
assertThat(itemResponse.status(), equalTo(RestStatus.CREATED));
|
assertThat(itemResponse.status(), equalTo(RestStatus.CREATED));
|
||||||
}
|
}
|
||||||
client().admin().indices().refresh(new RefreshRequest(index)).actionGet();
|
indicesAdmin().refresh(new RefreshRequest(index)).actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -953,7 +953,7 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase {
|
||||||
.execute();
|
.execute();
|
||||||
waitForBlockOnAnyDataNode(repoName);
|
waitForBlockOnAnyDataNode(repoName);
|
||||||
awaitNumberOfSnapshotsInProgress(1);
|
awaitNumberOfSnapshotsInProgress(1);
|
||||||
final ActionFuture<RolloverResponse> rolloverResponse = client().admin().indices().rolloverIndex(new RolloverRequest("ds", null));
|
final ActionFuture<RolloverResponse> rolloverResponse = indicesAdmin().rolloverIndex(new RolloverRequest("ds", null));
|
||||||
|
|
||||||
if (partial) {
|
if (partial) {
|
||||||
assertTrue(rolloverResponse.get().isRolledOver());
|
assertTrue(rolloverResponse.get().isRolledOver());
|
||||||
|
@ -995,11 +995,11 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase {
|
||||||
.execute();
|
.execute();
|
||||||
waitForBlockOnAnyDataNode(repoName);
|
waitForBlockOnAnyDataNode(repoName);
|
||||||
awaitNumberOfSnapshotsInProgress(1);
|
awaitNumberOfSnapshotsInProgress(1);
|
||||||
final RolloverResponse rolloverResponse = client().admin().indices().rolloverIndex(new RolloverRequest("ds", null)).get();
|
final RolloverResponse rolloverResponse = indicesAdmin().rolloverIndex(new RolloverRequest("ds", null)).get();
|
||||||
assertTrue(rolloverResponse.isRolledOver());
|
assertTrue(rolloverResponse.isRolledOver());
|
||||||
|
|
||||||
logger.info("--> deleting former write index");
|
logger.info("--> deleting former write index");
|
||||||
assertAcked(client().admin().indices().prepareDelete(rolloverResponse.getOldIndex()));
|
assertAcked(indicesAdmin().prepareDelete(rolloverResponse.getOldIndex()));
|
||||||
|
|
||||||
unblockAllDataNodes(repoName);
|
unblockAllDataNodes(repoName);
|
||||||
final SnapshotInfo snapshotInfo = assertSuccessful(snapshotFuture);
|
final SnapshotInfo snapshotInfo = assertSuccessful(snapshotFuture);
|
||||||
|
|
|
@ -55,19 +55,19 @@ public class DataTierDataStreamIT extends ESIntegTestCase {
|
||||||
.setWaitForActiveShards(0)
|
.setWaitForActiveShards(0)
|
||||||
.get()
|
.get()
|
||||||
.getIndex();
|
.getIndex();
|
||||||
var idxSettings = client().admin().indices().prepareGetIndex().addIndices(index).get().getSettings().get(dsIndexName);
|
var idxSettings = indicesAdmin().prepareGetIndex().addIndices(index).get().getSettings().get(dsIndexName);
|
||||||
assertThat(DataTier.TIER_PREFERENCE_SETTING.get(idxSettings), equalTo(DataTier.DATA_HOT));
|
assertThat(DataTier.TIER_PREFERENCE_SETTING.get(idxSettings), equalTo(DataTier.DATA_HOT));
|
||||||
|
|
||||||
logger.info("--> waiting for {} to be yellow", index);
|
logger.info("--> waiting for {} to be yellow", index);
|
||||||
ensureYellow(index);
|
ensureYellow(index);
|
||||||
|
|
||||||
// Roll over index and ensure the second index also went to the "hot" tier
|
// Roll over index and ensure the second index also went to the "hot" tier
|
||||||
var rolledOverIndexName = client().admin().indices().prepareRolloverIndex(index).get().getNewIndex();
|
var rolledOverIndexName = indicesAdmin().prepareRolloverIndex(index).get().getNewIndex();
|
||||||
|
|
||||||
// new index name should have the rolled over name
|
// new index name should have the rolled over name
|
||||||
assertNotEquals(dsIndexName, rolledOverIndexName);
|
assertNotEquals(dsIndexName, rolledOverIndexName);
|
||||||
|
|
||||||
idxSettings = client().admin().indices().prepareGetIndex().addIndices(index).get().getSettings().get(rolledOverIndexName);
|
idxSettings = indicesAdmin().prepareGetIndex().addIndices(index).get().getSettings().get(rolledOverIndexName);
|
||||||
assertThat(DataTier.TIER_PREFERENCE_SETTING.get(idxSettings), equalTo(DataTier.DATA_HOT));
|
assertThat(DataTier.TIER_PREFERENCE_SETTING.get(idxSettings), equalTo(DataTier.DATA_HOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class SystemDataStreamSnapshotIT extends AbstractSnapshotIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
GetIndexResponse indicesRemaining = client().admin().indices().prepareGetIndex().addIndices("_all").get();
|
GetIndexResponse indicesRemaining = indicesAdmin().prepareGetIndex().addIndices("_all").get();
|
||||||
assertThat(indicesRemaining.indices(), arrayWithSize(0));
|
assertThat(indicesRemaining.indices(), arrayWithSize(0));
|
||||||
assertSystemDataStreamDoesNotExist();
|
assertSystemDataStreamDoesNotExist();
|
||||||
}
|
}
|
||||||
|
@ -216,10 +216,10 @@ public class SystemDataStreamSnapshotIT extends AbstractSnapshotIntegTestCase {
|
||||||
assertTrue(response.isAcknowledged());
|
assertTrue(response.isAcknowledged());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareDelete("my-index"));
|
assertAcked(indicesAdmin().prepareDelete("my-index"));
|
||||||
|
|
||||||
{
|
{
|
||||||
GetIndexResponse indicesRemaining = client().admin().indices().prepareGetIndex().addIndices("_all").get();
|
GetIndexResponse indicesRemaining = indicesAdmin().prepareGetIndex().addIndices("_all").get();
|
||||||
assertThat(indicesRemaining.indices(), arrayWithSize(0));
|
assertThat(indicesRemaining.indices(), arrayWithSize(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class TSDBIndexingIT extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch end time
|
// fetch end time
|
||||||
var getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(backingIndexName)).actionGet();
|
var getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(backingIndexName)).actionGet();
|
||||||
Instant endTime = IndexSettings.TIME_SERIES_END_TIME.get(getIndexResponse.getSettings().get(backingIndexName));
|
Instant endTime = IndexSettings.TIME_SERIES_END_TIME.get(getIndexResponse.getSettings().get(backingIndexName));
|
||||||
|
|
||||||
// index another doc and verify index
|
// index another doc and verify index
|
||||||
|
@ -177,11 +177,11 @@ public class TSDBIndexingIT extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
// rollover
|
// rollover
|
||||||
var rolloverRequest = new RolloverRequest("k8s", null);
|
var rolloverRequest = new RolloverRequest("k8s", null);
|
||||||
var rolloverResponse = client().admin().indices().rolloverIndex(rolloverRequest).actionGet();
|
var rolloverResponse = indicesAdmin().rolloverIndex(rolloverRequest).actionGet();
|
||||||
var newBackingIndexName = rolloverResponse.getNewIndex();
|
var newBackingIndexName = rolloverResponse.getNewIndex();
|
||||||
|
|
||||||
// index and check target index is new
|
// index and check target index is new
|
||||||
getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest().indices(newBackingIndexName)).actionGet();
|
getIndexResponse = indicesAdmin().getIndex(new GetIndexRequest().indices(newBackingIndexName)).actionGet();
|
||||||
Instant newStartTime = IndexSettings.TIME_SERIES_START_TIME.get(getIndexResponse.getSettings().get(newBackingIndexName));
|
Instant newStartTime = IndexSettings.TIME_SERIES_START_TIME.get(getIndexResponse.getSettings().get(newBackingIndexName));
|
||||||
Instant newEndTime = IndexSettings.TIME_SERIES_END_TIME.get(getIndexResponse.getSettings().get(newBackingIndexName));
|
Instant newEndTime = IndexSettings.TIME_SERIES_END_TIME.get(getIndexResponse.getSettings().get(newBackingIndexName));
|
||||||
|
|
||||||
|
|
|
@ -127,10 +127,8 @@ public class DataStreamsStatsTests extends ESSingleNodeTestCase {
|
||||||
public void testStatsClosedBackingIndexDataStream() throws Exception {
|
public void testStatsClosedBackingIndexDataStream() throws Exception {
|
||||||
String dataStreamName = createDataStream();
|
String dataStreamName = createDataStream();
|
||||||
createDocument(dataStreamName);
|
createDocument(dataStreamName);
|
||||||
assertTrue(client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).get().isAcknowledged());
|
assertTrue(indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).get().isAcknowledged());
|
||||||
assertTrue(
|
assertTrue(indicesAdmin().close(new CloseIndexRequest(".ds-" + dataStreamName + "-*-000001")).actionGet().isAcknowledged());
|
||||||
client().admin().indices().close(new CloseIndexRequest(".ds-" + dataStreamName + "-*-000001")).actionGet().isAcknowledged()
|
|
||||||
);
|
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
assertNotEquals(ClusterHealthStatus.RED, client().admin().cluster().health(new ClusterHealthRequest()).actionGet().getStatus());
|
assertNotEquals(ClusterHealthStatus.RED, client().admin().cluster().health(new ClusterHealthRequest()).actionGet().getStatus());
|
||||||
|
@ -169,7 +167,7 @@ public class DataStreamsStatsTests extends ESSingleNodeTestCase {
|
||||||
public void testStatsRolledDataStream() throws Exception {
|
public void testStatsRolledDataStream() throws Exception {
|
||||||
String dataStreamName = createDataStream();
|
String dataStreamName = createDataStream();
|
||||||
long timestamp = createDocument(dataStreamName);
|
long timestamp = createDocument(dataStreamName);
|
||||||
assertTrue(client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).get().isAcknowledged());
|
assertTrue(indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).get().isAcknowledged());
|
||||||
timestamp = max(timestamp, createDocument(dataStreamName));
|
timestamp = max(timestamp, createDocument(dataStreamName));
|
||||||
|
|
||||||
DataStreamsStatsAction.Response stats = getDataStreamsStats();
|
DataStreamsStatsAction.Response stats = getDataStreamsStats();
|
||||||
|
@ -264,9 +262,7 @@ public class DataStreamsStatsTests extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
).get();
|
).get();
|
||||||
client().admin()
|
indicesAdmin().refresh(new RefreshRequest(".ds-" + dataStreamName + "*").indicesOptions(IndicesOptions.lenientExpandOpenHidden()))
|
||||||
.indices()
|
|
||||||
.refresh(new RefreshRequest(".ds-" + dataStreamName + "*").indicesOptions(IndicesOptions.lenientExpandOpenHidden()))
|
|
||||||
.get();
|
.get();
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class LookAHeadTimeTests extends ESSingleNodeTestCase {
|
||||||
} catch (ResourceAlreadyExistsException e) {
|
} catch (ResourceAlreadyExistsException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
client().admin().indices().updateSettings(new UpdateSettingsRequest(settings)).actionGet();
|
indicesAdmin().updateSettings(new UpdateSettingsRequest(settings)).actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,7 +305,7 @@ public class DataLifecycleServiceIT extends ESIntegTestCase {
|
||||||
for (int i = 0; i < randomIntBetween(10, 50); i++) {
|
for (int i = 0; i < randomIntBetween(10, 50); i++) {
|
||||||
indexDocs(dataStreamName, randomIntBetween(1, 300));
|
indexDocs(dataStreamName, randomIntBetween(1, 300));
|
||||||
// Make sure the segments get written:
|
// Make sure the segments get written:
|
||||||
FlushResponse flushResponse = client().admin().indices().flush(new FlushRequest(toBeRolledOverIndex)).actionGet();
|
FlushResponse flushResponse = indicesAdmin().flush(new FlushRequest(toBeRolledOverIndex)).actionGet();
|
||||||
assertThat(flushResponse.getStatus(), equalTo(RestStatus.OK));
|
assertThat(flushResponse.getStatus(), equalTo(RestStatus.OK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ public class DataLifecycleServiceIT extends ESIntegTestCase {
|
||||||
assertThat(itemResponse.status(), equalTo(RestStatus.CREATED));
|
assertThat(itemResponse.status(), equalTo(RestStatus.CREATED));
|
||||||
assertThat(itemResponse.getIndex(), startsWith(backingIndexPrefix));
|
assertThat(itemResponse.getIndex(), startsWith(backingIndexPrefix));
|
||||||
}
|
}
|
||||||
client().admin().indices().refresh(new RefreshRequest(dataStream)).actionGet();
|
indicesAdmin().refresh(new RefreshRequest(dataStream)).actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void putComposableIndexTemplate(
|
static void putComposableIndexTemplate(
|
||||||
|
|
|
@ -290,7 +290,7 @@ public class ExplainDataLifecycleIT extends ESIntegTestCase {
|
||||||
assertThat(itemResponse.status(), equalTo(RestStatus.CREATED));
|
assertThat(itemResponse.status(), equalTo(RestStatus.CREATED));
|
||||||
assertThat(itemResponse.getIndex(), startsWith(backingIndexPrefix));
|
assertThat(itemResponse.getIndex(), startsWith(backingIndexPrefix));
|
||||||
}
|
}
|
||||||
client().admin().indices().refresh(new RefreshRequest(dataStream)).actionGet();
|
indicesAdmin().refresh(new RefreshRequest(dataStream)).actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void putComposableIndexTemplate(
|
static void putComposableIndexTemplate(
|
||||||
|
|
|
@ -305,21 +305,21 @@ public class GeoIpDownloaderIT extends AbstractGeoIpIT {
|
||||||
|
|
||||||
// Creating an index which does not reference the pipeline should not trigger the database download.
|
// Creating an index which does not reference the pipeline should not trigger the database download.
|
||||||
String indexIdentifier = randomIdentifier();
|
String indexIdentifier = randomIdentifier();
|
||||||
assertAcked(client().admin().indices().prepareCreate(indexIdentifier).get());
|
assertAcked(indicesAdmin().prepareCreate(indexIdentifier).get());
|
||||||
assertNull(getTask().getState());
|
assertNull(getTask().getState());
|
||||||
|
|
||||||
// Set the pipeline as default_pipeline or final_pipeline for the index.
|
// Set the pipeline as default_pipeline or final_pipeline for the index.
|
||||||
// This should trigger the database download.
|
// This should trigger the database download.
|
||||||
Setting<String> pipelineSetting = randomFrom(IndexSettings.FINAL_PIPELINE, IndexSettings.DEFAULT_PIPELINE);
|
Setting<String> pipelineSetting = randomFrom(IndexSettings.FINAL_PIPELINE, IndexSettings.DEFAULT_PIPELINE);
|
||||||
Settings indexSettings = Settings.builder().put(pipelineSetting.getKey(), pipelineId).build();
|
Settings indexSettings = Settings.builder().put(pipelineSetting.getKey(), pipelineId).build();
|
||||||
assertAcked(client().admin().indices().prepareUpdateSettings(indexIdentifier).setSettings(indexSettings).get());
|
assertAcked(indicesAdmin().prepareUpdateSettings(indexIdentifier).setSettings(indexSettings).get());
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
GeoIpTaskState state = getGeoIpTaskState();
|
GeoIpTaskState state = getGeoIpTaskState();
|
||||||
assertEquals(Set.of("GeoLite2-ASN.mmdb", "GeoLite2-City.mmdb", "GeoLite2-Country.mmdb"), state.getDatabases().keySet());
|
assertEquals(Set.of("GeoLite2-ASN.mmdb", "GeoLite2-City.mmdb", "GeoLite2-Country.mmdb"), state.getDatabases().keySet());
|
||||||
}, 2, TimeUnit.MINUTES);
|
}, 2, TimeUnit.MINUTES);
|
||||||
|
|
||||||
// Remove the created index.
|
// Remove the created index.
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexIdentifier).get());
|
assertAcked(indicesAdmin().prepareDelete(indexIdentifier).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestLogging(value = "org.elasticsearch.ingest.geoip:TRACE", reason = "https://github.com/elastic/elasticsearch/issues/69972")
|
@TestLogging(value = "org.elasticsearch.ingest.geoip:TRACE", reason = "https://github.com/elastic/elasticsearch/issues/69972")
|
||||||
|
|
|
@ -504,7 +504,7 @@ public class MoreExpressionIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testStringSpecialValueVariable() throws Exception {
|
public void testStringSpecialValueVariable() throws Exception {
|
||||||
// i.e. expression script for term aggregations, which is not allowed
|
// i.e. expression script for term aggregations, which is not allowed
|
||||||
assertAcked(client().admin().indices().prepareCreate("test").setMapping("text", "type=keyword").get());
|
assertAcked(indicesAdmin().prepareCreate("test").setMapping("text", "type=keyword").get());
|
||||||
ensureGreen("test");
|
ensureGreen("test");
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
|
||||||
createIndex("test");
|
createIndex("test");
|
||||||
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("text", "value1").endObject()).get();
|
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("text", "value1").endObject()).get();
|
||||||
client().prepareIndex("test").setId("2").setSource(jsonBuilder().startObject().field("text", "value2").endObject()).get();
|
client().prepareIndex("test").setId("2").setSource(jsonBuilder().startObject().field("text", "value2").endObject()).get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relates to #6318
|
// Relates to #6318
|
||||||
|
@ -172,7 +172,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
|
||||||
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
|
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
|
||||||
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
|
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
|
||||||
bulkRequestBuilder.get();
|
bulkRequestBuilder.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
Map<String, Object> templateParams = new HashMap<>();
|
Map<String, Object> templateParams = new HashMap<>();
|
||||||
templateParams.put("fieldParam", "foo");
|
templateParams.put("fieldParam", "foo");
|
||||||
|
@ -218,7 +218,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
|
||||||
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
|
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
|
||||||
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
|
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
|
||||||
bulkRequestBuilder.get();
|
bulkRequestBuilder.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
Map<String, Object> templateParams = new HashMap<>();
|
Map<String, Object> templateParams = new HashMap<>();
|
||||||
templateParams.put("fieldParam", "foo");
|
templateParams.put("fieldParam", "foo");
|
||||||
|
@ -254,7 +254,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
|
||||||
ensureGreen("testindex");
|
ensureGreen("testindex");
|
||||||
|
|
||||||
client().prepareIndex("testindex").setId("1").setSource(jsonBuilder().startObject().field("searchtext", "dev1").endObject()).get();
|
client().prepareIndex("testindex").setId("1").setSource(jsonBuilder().startObject().field("searchtext", "dev1").endObject()).get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
int iterations = randomIntBetween(2, 11);
|
int iterations = randomIntBetween(2, 11);
|
||||||
String query = """
|
String query = """
|
||||||
|
@ -343,7 +343,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase {
|
||||||
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
|
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
|
||||||
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
|
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
|
||||||
bulkRequestBuilder.get();
|
bulkRequestBuilder.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
Map<String, Object> arrayTemplateParams = new HashMap<>();
|
Map<String, Object> arrayTemplateParams = new HashMap<>();
|
||||||
String[] fieldParams = { "foo", "bar" };
|
String[] fieldParams = { "foo", "bar" };
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class LegacyGeoShapeQueryTests extends GeoShapeQueryTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
client().admin().indices().prepareCreate(indexName).setMapping(xcb).setSettings(settings).get();
|
indicesAdmin().prepareCreate(indexName).setMapping(xcb).setSettings(settings).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,7 +81,7 @@ public class LegacyGeoShapeQueryTests extends GeoShapeQueryTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
);
|
);
|
||||||
|
|
||||||
client().admin().indices().prepareCreate("geo_points_only").setMapping(mapping).get();
|
indicesAdmin().prepareCreate("geo_points_only").setMapping(mapping).get();
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
// MULTIPOINT
|
// MULTIPOINT
|
||||||
|
@ -122,7 +122,7 @@ public class LegacyGeoShapeQueryTests extends GeoShapeQueryTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
);
|
);
|
||||||
|
|
||||||
client().admin().indices().prepareCreate("geo_points_only").setMapping(mapping).get();
|
indicesAdmin().prepareCreate("geo_points_only").setMapping(mapping).get();
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
Geometry geometry = GeometryTestUtils.randomGeometry(false);
|
Geometry geometry = GeometryTestUtils.randomGeometry(false);
|
||||||
|
@ -162,7 +162,7 @@ public class LegacyGeoShapeQueryTests extends GeoShapeQueryTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
);
|
);
|
||||||
|
|
||||||
client().admin().indices().prepareCreate(defaultIndexName).setMapping(mapping).get();
|
indicesAdmin().prepareCreate(defaultIndexName).setMapping(mapping).get();
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
MultiPoint multiPoint = GeometryTestUtils.randomMultiPoint(false);
|
MultiPoint multiPoint = GeometryTestUtils.randomMultiPoint(false);
|
||||||
|
|
|
@ -30,9 +30,9 @@ public class BWCTemplateTests extends ESSingleNodeTestCase {
|
||||||
byte[] metricBeat = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/extras/metricbeat-6.0.template.json");
|
byte[] metricBeat = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/extras/metricbeat-6.0.template.json");
|
||||||
byte[] packetBeat = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/extras/packetbeat-6.0.template.json");
|
byte[] packetBeat = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/extras/packetbeat-6.0.template.json");
|
||||||
byte[] fileBeat = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/extras/filebeat-6.0.template.json");
|
byte[] fileBeat = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/extras/filebeat-6.0.template.json");
|
||||||
client().admin().indices().preparePutTemplate("metricbeat").setSource(metricBeat, XContentType.JSON).get();
|
indicesAdmin().preparePutTemplate("metricbeat").setSource(metricBeat, XContentType.JSON).get();
|
||||||
client().admin().indices().preparePutTemplate("packetbeat").setSource(packetBeat, XContentType.JSON).get();
|
indicesAdmin().preparePutTemplate("packetbeat").setSource(packetBeat, XContentType.JSON).get();
|
||||||
client().admin().indices().preparePutTemplate("filebeat").setSource(fileBeat, XContentType.JSON).get();
|
indicesAdmin().preparePutTemplate("filebeat").setSource(fileBeat, XContentType.JSON).get();
|
||||||
|
|
||||||
client().prepareIndex("metricbeat-foo").setId("1").setSource("message", "foo").get();
|
client().prepareIndex("metricbeat-foo").setId("1").setSource("message", "foo").get();
|
||||||
client().prepareIndex("packetbeat-foo").setId("1").setSource("message", "foo").get();
|
client().prepareIndex("packetbeat-foo").setId("1").setSource("message", "foo").get();
|
||||||
|
|
|
@ -312,17 +312,17 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
|
|
||||||
// index simple data with flushes, so we have many segments
|
// index simple data with flushes, so we have many segments
|
||||||
createIndexRequest("test", "parent", "p1", null, "p_field", "p_value1").get();
|
createIndexRequest("test", "parent", "p1", null, "p_field", "p_value1").get();
|
||||||
client().admin().indices().prepareFlush().get();
|
indicesAdmin().prepareFlush().get();
|
||||||
createIndexRequest("test", "child", "c1", "p1", "c_field", "red").get();
|
createIndexRequest("test", "child", "c1", "p1", "c_field", "red").get();
|
||||||
client().admin().indices().prepareFlush().get();
|
indicesAdmin().prepareFlush().get();
|
||||||
createIndexRequest("test", "child", "c2", "p1", "c_field", "yellow").get();
|
createIndexRequest("test", "child", "c2", "p1", "c_field", "yellow").get();
|
||||||
client().admin().indices().prepareFlush().get();
|
indicesAdmin().prepareFlush().get();
|
||||||
createIndexRequest("test", "parent", "p2", null, "p_field", "p_value2").get();
|
createIndexRequest("test", "parent", "p2", null, "p_field", "p_value2").get();
|
||||||
client().admin().indices().prepareFlush().get();
|
indicesAdmin().prepareFlush().get();
|
||||||
createIndexRequest("test", "child", "c3", "p2", "c_field", "blue").get();
|
createIndexRequest("test", "child", "c3", "p2", "c_field", "blue").get();
|
||||||
client().admin().indices().prepareFlush().get();
|
indicesAdmin().prepareFlush().get();
|
||||||
createIndexRequest("test", "child", "c4", "p2", "c_field", "red").get();
|
createIndexRequest("test", "child", "c4", "p2", "c_field", "red").get();
|
||||||
client().admin().indices().prepareFlush().get();
|
indicesAdmin().prepareFlush().get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// HAS CHILD QUERY
|
// HAS CHILD QUERY
|
||||||
|
@ -446,7 +446,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
// update p1 and see what that we get updated values...
|
// update p1 and see what that we get updated values...
|
||||||
|
|
||||||
createIndexRequest("test", "parent", "p1", null, "p_field", "p_value1_updated").get();
|
createIndexRequest("test", "parent", "p1", null, "p_field", "p_value1_updated").get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "yellow"), ScoreMode.None)))
|
.setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "yellow"), ScoreMode.None)))
|
||||||
|
@ -748,7 +748,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
|
|
||||||
createIndexRequest("test", "parent", "1", null, "p_field", 1).get();
|
createIndexRequest("test", "parent", "1", null, "p_field", 1).get();
|
||||||
createIndexRequest("test", "child", "2", "1", "c_field", 1).get();
|
createIndexRequest("test", "child", "2", "1", "c_field", 1).get();
|
||||||
client().admin().indices().prepareFlush("test").get();
|
indicesAdmin().prepareFlush("test").get();
|
||||||
|
|
||||||
client().prepareIndex("test").setId("3").setSource("p_field", 2).get();
|
client().prepareIndex("test").setId("3").setSource("p_field", 2).get();
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
|
|
||||||
// query filter in case for p/c shouldn't execute per segment, but rather
|
// query filter in case for p/c shouldn't execute per segment, but rather
|
||||||
createIndexRequest("test", "parent", "1", null, "p_field", 1).get();
|
createIndexRequest("test", "parent", "1", null, "p_field", 1).get();
|
||||||
client().admin().indices().prepareFlush("test").setForce(true).get();
|
indicesAdmin().prepareFlush("test").setForce(true).get();
|
||||||
createIndexRequest("test", "child", "2", "1", "c_field", 1).get();
|
createIndexRequest("test", "child", "2", "1", "c_field", 1).get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
@ -924,7 +924,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
createIndexRequest("test", "child", "d" + i, "p1", "c_field", "red").get();
|
createIndexRequest("test", "child", "d" + i, "p1", "c_field", "red").get();
|
||||||
createIndexRequest("test", "parent", "p2", null, "p_field", "p_value2").get();
|
createIndexRequest("test", "parent", "p2", null, "p_field", "p_value2").get();
|
||||||
createIndexRequest("test", "child", "c3", "p2", "c_field", "x").get();
|
createIndexRequest("test", "child", "c3", "p2", "c_field", "x").get();
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
|
@ -1038,8 +1038,8 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
createIndexRequest("test", "parent", "p9", null, "p_field", "p_value9").get();
|
createIndexRequest("test", "parent", "p9", null, "p_field", "p_value9").get();
|
||||||
createIndexRequest("test", "parent", "p10", null, "p_field", "p_value10").get();
|
createIndexRequest("test", "parent", "p10", null, "p_field", "p_value10").get();
|
||||||
createIndexRequest("test", "child", "c1", "p1", "c_field", "blue").get();
|
createIndexRequest("test", "child", "c1", "p1", "c_field", "blue").get();
|
||||||
client().admin().indices().prepareFlush("test").get();
|
indicesAdmin().prepareFlush("test").get();
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("test")
|
SearchResponse searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "blue"), ScoreMode.None)))
|
.setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "blue"), ScoreMode.None)))
|
||||||
|
@ -1048,7 +1048,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
createIndexRequest("test", "child", "c2", "p2", "c_field", "blue").get();
|
createIndexRequest("test", "child", "c2", "p2", "c_field", "blue").get();
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "blue"), ScoreMode.None)))
|
.setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "blue"), ScoreMode.None)))
|
||||||
|
@ -1312,14 +1312,14 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
createIndexRequest("test", "child", "c1", "p1", "c_field", "blue").get();
|
createIndexRequest("test", "child", "c1", "p1", "c_field", "blue").get();
|
||||||
createIndexRequest("test", "child", "c2", "p1", "c_field", "red").get();
|
createIndexRequest("test", "child", "c2", "p1", "c_field", "red").get();
|
||||||
createIndexRequest("test", "child", "c3", "p2", "c_field", "red").get();
|
createIndexRequest("test", "child", "c3", "p2", "c_field", "red").get();
|
||||||
client().admin().indices().prepareForceMerge("test").setMaxNumSegments(1).setFlush(true).get();
|
indicesAdmin().prepareForceMerge("test").setMaxNumSegments(1).setFlush(true).get();
|
||||||
createIndexRequest("test", "parent", "p3", null, "p_field", "p_value3").get();
|
createIndexRequest("test", "parent", "p3", null, "p_field", "p_value3").get();
|
||||||
createIndexRequest("test", "parent", "p4", null, "p_field", "p_value4").get();
|
createIndexRequest("test", "parent", "p4", null, "p_field", "p_value4").get();
|
||||||
createIndexRequest("test", "child", "c4", "p3", "c_field", "green").get();
|
createIndexRequest("test", "child", "c4", "p3", "c_field", "green").get();
|
||||||
createIndexRequest("test", "child", "c5", "p3", "c_field", "blue").get();
|
createIndexRequest("test", "child", "c5", "p3", "c_field", "blue").get();
|
||||||
createIndexRequest("test", "child", "c6", "p4", "c_field", "blue").get();
|
createIndexRequest("test", "child", "c6", "p4", "c_field", "blue").get();
|
||||||
client().admin().indices().prepareFlush("test").get();
|
indicesAdmin().prepareFlush("test").get();
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = client().prepareSearch()
|
||||||
|
@ -1334,7 +1334,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
createIndexRequest("test", "child", "c3", "p2", "c_field", "blue").get();
|
createIndexRequest("test", "child", "c3", "p2", "c_field", "blue").get();
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = client().prepareSearch()
|
||||||
.setQuery(
|
.setQuery(
|
||||||
|
@ -1781,9 +1781,9 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices().prepareAliases().addAlias("my-index", "filter1", hasChildQuery("child", matchAllQuery(), ScoreMode.None))
|
indicesAdmin().prepareAliases().addAlias("my-index", "filter1", hasChildQuery("child", matchAllQuery(), ScoreMode.None))
|
||||||
);
|
);
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias("my-index", "filter2", hasParentQuery("parent", matchAllQuery(), false)));
|
assertAcked(indicesAdmin().prepareAliases().addAlias("my-index", "filter2", hasParentQuery("parent", matchAllQuery(), false)));
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("filter1").get();
|
SearchResponse response = client().prepareSearch("filter1").get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
|
|
|
@ -68,9 +68,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testPercolatorQuery() throws Exception {
|
public void testPercolatorQuery() throws Exception {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator")
|
.setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -91,7 +89,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().endObject());
|
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().endObject());
|
||||||
logger.info("percolating empty doc");
|
logger.info("percolating empty doc");
|
||||||
|
@ -150,9 +148,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testPercolatorRangeQueries() throws Exception {
|
public void testPercolatorRangeQueries() throws Exception {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping(
|
.setMapping(
|
||||||
"field1",
|
"field1",
|
||||||
"type=long",
|
"type=long",
|
||||||
|
@ -183,7 +179,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("4")
|
.setId("4")
|
||||||
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field2").from(10).to(12)).endObject())
|
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field2").from(10).to(12)).endObject())
|
||||||
|
@ -200,7 +196,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("7")
|
.setId("7")
|
||||||
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field3").from("192.168.1.0").to("192.168.1.5")).endObject())
|
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field3").from("192.168.1.0").to("192.168.1.5")).endObject())
|
||||||
|
@ -233,7 +229,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
// Test long range:
|
// Test long range:
|
||||||
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field1", 12).endObject());
|
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field1", 12).endObject());
|
||||||
|
@ -281,10 +277,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testPercolatorGeoQueries() throws Exception {
|
public void testPercolatorGeoQueries() throws Exception {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test").setMapping("id", "type=keyword", "field1", "type=geo_point", "query", "type=percolator")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping("id", "type=keyword", "field1", "type=geo_point", "query", "type=percolator")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
|
@ -339,9 +332,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testPercolatorQueryExistingDocument() throws Exception {
|
public void testPercolatorQueryExistingDocument() throws Exception {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator")
|
.setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -366,7 +357,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test").setId("4").setSource("{\"id\": \"4\"}", XContentType.JSON).get();
|
client().prepareIndex("test").setId("4").setSource("{\"id\": \"4\"}", XContentType.JSON).get();
|
||||||
client().prepareIndex("test").setId("5").setSource(XContentType.JSON, "id", "5", "field1", "value").get();
|
client().prepareIndex("test").setId("5").setSource(XContentType.JSON, "id", "5", "field1", "value").get();
|
||||||
client().prepareIndex("test").setId("6").setSource(XContentType.JSON, "id", "6", "field1", "value", "field2", "value").get();
|
client().prepareIndex("test").setId("6").setSource(XContentType.JSON, "id", "6", "field1", "value", "field2", "value").get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
logger.info("percolating empty doc");
|
logger.info("percolating empty doc");
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = client().prepareSearch()
|
||||||
|
@ -397,16 +388,14 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception {
|
public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping("_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator")
|
.setMapping("_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator")
|
||||||
);
|
);
|
||||||
|
|
||||||
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject()).get();
|
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject()).get();
|
||||||
|
|
||||||
client().prepareIndex("test").setId("2").setSource("{}", XContentType.JSON).get();
|
client().prepareIndex("test").setId("2").setSource("{}", XContentType.JSON).get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
logger.info("percolating empty doc with source disabled");
|
logger.info("percolating empty doc with source disabled");
|
||||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
|
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
|
||||||
|
@ -417,9 +406,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testPercolatorSpecificQueries() throws Exception {
|
public void testPercolatorSpecificQueries() throws Exception {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping("id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator")
|
.setMapping("id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -446,7 +433,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("3")
|
.setId("3")
|
||||||
|
@ -488,7 +475,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
BytesReference source = BytesReference.bytes(
|
BytesReference source = BytesReference.bytes(
|
||||||
jsonBuilder().startObject()
|
jsonBuilder().startObject()
|
||||||
|
@ -517,9 +504,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
fieldMapping.append(",index_options=offsets");
|
fieldMapping.append(",index_options=offsets");
|
||||||
}
|
}
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping("id", "type=keyword", "field1", fieldMapping.toString(), "query", "type=percolator")
|
.setMapping("id", "type=keyword", "field1", fieldMapping.toString(), "query", "type=percolator")
|
||||||
);
|
);
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
|
@ -547,7 +532,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.setSource(jsonBuilder().startObject().field("id", "5").field("query", termQuery("field1", "fox")).endObject())
|
.setSource(jsonBuilder().startObject().field("id", "5").field("query", termQuery("field1", "fox")).endObject())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet();
|
.actionGet();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
BytesReference document = BytesReference.bytes(
|
BytesReference document = BytesReference.bytes(
|
||||||
jsonBuilder().startObject().field("field1", "The quick brown fox jumps over the lazy dog").endObject()
|
jsonBuilder().startObject().field("field1", "The quick brown fox jumps over the lazy dog").endObject()
|
||||||
|
@ -762,10 +747,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testTakePositionOffsetGapIntoAccount() throws Exception {
|
public void testTakePositionOffsetGapIntoAccount() throws Exception {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test").setMapping("field", "type=text,position_increment_gap=5", "query", "type=percolator")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping("field", "type=text,position_increment_gap=5", "query", "type=percolator")
|
|
||||||
);
|
);
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("1")
|
.setId("1")
|
||||||
|
@ -775,7 +757,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.setId("2")
|
.setId("2")
|
||||||
.setSource(jsonBuilder().startObject().field("query", new MatchPhraseQueryBuilder("field", "brown fox").slop(5)).endObject())
|
.setSource(jsonBuilder().startObject().field("query", new MatchPhraseQueryBuilder("field", "brown fox").slop(5)).endObject())
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = client().prepareSearch()
|
||||||
.setQuery(new PercolateQueryBuilder("query", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}"), XContentType.JSON))
|
.setQuery(new PercolateQueryBuilder("query", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}"), XContentType.JSON))
|
||||||
|
@ -786,19 +768,13 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testManyPercolatorFields() throws Exception {
|
public void testManyPercolatorFields() throws Exception {
|
||||||
String queryFieldName = randomAlphaOfLength(8);
|
String queryFieldName = randomAlphaOfLength(8);
|
||||||
|
assertAcked(indicesAdmin().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword"));
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin().indices().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword")
|
indicesAdmin().prepareCreate("test2")
|
||||||
);
|
|
||||||
assertAcked(
|
|
||||||
client().admin()
|
|
||||||
.indices()
|
|
||||||
.prepareCreate("test2")
|
|
||||||
.setMapping(queryFieldName, "type=percolator", "second_query_field", "type=percolator", "field", "type=keyword")
|
.setMapping(queryFieldName, "type=percolator", "second_query_field", "type=percolator", "field", "type=keyword")
|
||||||
);
|
);
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test3")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test3")
|
|
||||||
.setMapping(
|
.setMapping(
|
||||||
jsonBuilder().startObject()
|
jsonBuilder().startObject()
|
||||||
.startObject("_doc")
|
.startObject("_doc")
|
||||||
|
@ -823,13 +799,9 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testWithMultiplePercolatorFields() throws Exception {
|
public void testWithMultiplePercolatorFields() throws Exception {
|
||||||
String queryFieldName = randomAlphaOfLength(8);
|
String queryFieldName = randomAlphaOfLength(8);
|
||||||
|
assertAcked(indicesAdmin().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword"));
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin().indices().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword")
|
indicesAdmin().prepareCreate("test2")
|
||||||
);
|
|
||||||
assertAcked(
|
|
||||||
client().admin()
|
|
||||||
.indices()
|
|
||||||
.prepareCreate("test2")
|
|
||||||
.setMapping(
|
.setMapping(
|
||||||
jsonBuilder().startObject()
|
jsonBuilder().startObject()
|
||||||
.startObject("_doc")
|
.startObject("_doc")
|
||||||
|
@ -866,7 +838,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field", "value").endObject());
|
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field", "value").endObject());
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = client().prepareSearch()
|
||||||
|
@ -930,7 +902,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
assertAcked(client().admin().indices().prepareCreate("test").setMapping(mapping));
|
assertAcked(indicesAdmin().prepareCreate("test").setMapping(mapping));
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("q1")
|
.setId("q1")
|
||||||
.setSource(
|
.setSource(
|
||||||
|
@ -957,13 +929,13 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("q3")
|
.setId("q3")
|
||||||
.setSource(jsonBuilder().startObject().field("id", "q3").field("query", QueryBuilders.matchAllQuery()).endObject())
|
.setSource(jsonBuilder().startObject().field("id", "q3").field("query", QueryBuilders.matchAllQuery()).endObject())
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = client().prepareSearch()
|
||||||
.setQuery(
|
.setQuery(
|
||||||
|
@ -1089,7 +1061,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPercolatorQueryViaMultiSearch() throws Exception {
|
public void testPercolatorQueryViaMultiSearch() throws Exception {
|
||||||
assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=text", "query", "type=percolator"));
|
assertAcked(indicesAdmin().prepareCreate("test").setMapping("field1", "type=text", "query", "type=percolator"));
|
||||||
|
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("1")
|
.setId("1")
|
||||||
|
@ -1120,7 +1092,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.setSource(jsonBuilder().startObject().field("field1", "c").endObject())
|
.setSource(jsonBuilder().startObject().field("field1", "c").endObject())
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet();
|
.actionGet();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
MultiSearchResponse response = client().prepareMultiSearch()
|
MultiSearchResponse response = client().prepareMultiSearch()
|
||||||
.add(
|
.add(
|
||||||
|
@ -1204,10 +1176,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
public void testDisallowExpensiveQueries() throws IOException {
|
public void testDisallowExpensiveQueries() throws IOException {
|
||||||
try {
|
try {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test").setMapping("id", "type=keyword", "field1", "type=keyword", "query", "type=percolator")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
.setMapping("id", "type=keyword", "field1", "type=keyword", "query", "type=percolator")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
|
@ -1251,7 +1220,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testWrappedWithConstantScore() throws Exception {
|
public void testWrappedWithConstantScore() throws Exception {
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate("test").setMapping("d", "type=date", "q", "type=percolator"));
|
assertAcked(indicesAdmin().prepareCreate("test").setMapping("d", "type=date", "q", "type=percolator"));
|
||||||
|
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("1")
|
.setId("1")
|
||||||
|
@ -1265,7 +1234,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
|
||||||
.execute()
|
.execute()
|
||||||
.actionGet();
|
.actionGet();
|
||||||
|
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("test")
|
SearchResponse response = client().prepareSearch("test")
|
||||||
.setQuery(
|
.setQuery(
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPercolateScriptQuery() throws IOException {
|
public void testPercolateScriptQuery() throws IOException {
|
||||||
client().admin().indices().prepareCreate("index").setMapping("query", "type=percolator").get();
|
indicesAdmin().prepareCreate("index").setMapping("query", "type=percolator").get();
|
||||||
client().prepareIndex("index")
|
client().prepareIndex("index")
|
||||||
.setId("1")
|
.setId("1")
|
||||||
.setSource(
|
.setSource(
|
||||||
|
@ -122,9 +122,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase {
|
||||||
.endObject();
|
.endObject();
|
||||||
createIndex(
|
createIndex(
|
||||||
"test",
|
"test",
|
||||||
client().admin()
|
indicesAdmin().prepareCreate("test")
|
||||||
.indices()
|
|
||||||
.prepareCreate("test")
|
|
||||||
// to avoid normal document from being cached by BitsetFilterCache
|
// to avoid normal document from being cached by BitsetFilterCache
|
||||||
.setSettings(Settings.builder().put(BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING.getKey(), false))
|
.setSettings(Settings.builder().put(BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING.getKey(), false))
|
||||||
.setMapping(mapping)
|
.setMapping(mapping)
|
||||||
|
@ -144,7 +142,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
for (int i = 0; i < 32; i++) {
|
for (int i = 0; i < 32; i++) {
|
||||||
SearchResponse response = client().prepareSearch()
|
SearchResponse response = client().prepareSearch()
|
||||||
|
@ -215,7 +213,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase {
|
||||||
mapping.endObject();
|
mapping.endObject();
|
||||||
}
|
}
|
||||||
mapping.endObject();
|
mapping.endObject();
|
||||||
createIndex("test", client().admin().indices().prepareCreate("test").setMapping(mapping));
|
createIndex("test", indicesAdmin().prepareCreate("test").setMapping(mapping));
|
||||||
Script script = new Script(ScriptType.INLINE, MockScriptPlugin.NAME, "use_fielddata_please", Collections.emptyMap());
|
Script script = new Script(ScriptType.INLINE, MockScriptPlugin.NAME, "use_fielddata_please", Collections.emptyMap());
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("q1")
|
.setId("q1")
|
||||||
|
@ -225,7 +223,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
XContentBuilder doc = jsonBuilder();
|
XContentBuilder doc = jsonBuilder();
|
||||||
doc.startObject();
|
doc.startObject();
|
||||||
{
|
{
|
||||||
|
@ -263,7 +261,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase {
|
||||||
.setId("1")
|
.setId("1")
|
||||||
.setSource(jsonBuilder().startObject().field("query", matchQuery("field1", "value")).endObject())
|
.setSource(jsonBuilder().startObject().field("query", matchQuery("field1", "value")).endObject())
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("test")
|
SearchResponse response = client().prepareSearch("test")
|
||||||
.setQuery(
|
.setQuery(
|
||||||
|
@ -316,7 +314,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
client().admin().indices().prepareRefresh().get();
|
indicesAdmin().prepareRefresh().get();
|
||||||
|
|
||||||
try (Engine.Searcher searcher = indexService.getShard(0).acquireSearcher("test")) {
|
try (Engine.Searcher searcher = indexService.getShard(0).acquireSearcher("test")) {
|
||||||
long[] currentTime = new long[] { System.currentTimeMillis() };
|
long[] currentTime = new long[] { System.currentTimeMillis() };
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class RankEvalRequestIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
// set up an alias that can also be used in tests
|
// set up an alias that can also be used in tests
|
||||||
assertAcked(client().admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(TEST_INDEX).alias(INDEX_ALIAS)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(TEST_INDEX).alias(INDEX_ALIAS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,7 +274,7 @@ public class RankEvalRequestIT extends ESIntegTestCase {
|
||||||
assertEquals(6, details.getRelevantRetrieved());
|
assertEquals(6, details.getRelevantRetrieved());
|
||||||
|
|
||||||
// test that ignore_unavailable=true works but returns one result less
|
// test that ignore_unavailable=true works but returns one result less
|
||||||
assertTrue(client().admin().indices().prepareClose("test2").get().isAcknowledged());
|
assertTrue(indicesAdmin().prepareClose("test2").get().isAcknowledged());
|
||||||
|
|
||||||
request.indicesOptions(IndicesOptions.fromParameters(null, "true", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
|
request.indicesOptions(IndicesOptions.fromParameters(null, "true", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
|
||||||
response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
|
response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
|
||||||
|
@ -283,7 +283,7 @@ public class RankEvalRequestIT extends ESIntegTestCase {
|
||||||
assertEquals(5, details.getRelevantRetrieved());
|
assertEquals(5, details.getRelevantRetrieved());
|
||||||
|
|
||||||
// test that ignore_unavailable=false or default settings throw an IndexClosedException
|
// test that ignore_unavailable=false or default settings throw an IndexClosedException
|
||||||
assertTrue(client().admin().indices().prepareClose("test2").get().isAcknowledged());
|
assertTrue(indicesAdmin().prepareClose("test2").get().isAcknowledged());
|
||||||
request.indicesOptions(IndicesOptions.fromParameters(null, "false", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
|
request.indicesOptions(IndicesOptions.fromParameters(null, "false", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
|
||||||
response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
|
response = client().execute(RankEvalAction.INSTANCE, request).actionGet();
|
||||||
assertEquals(1, response.getFailures().size());
|
assertEquals(1, response.getFailures().size());
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ReindexDocumentationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
client().admin().indices().prepareCreate(INDEX_NAME).get();
|
indicesAdmin().prepareCreate(INDEX_NAME).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|
|
@ -190,7 +190,7 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase
|
||||||
docs.add(ESIntegTestCase.client().prepareIndex(indexName).setId(Integer.toString(i)).setSource("some_field", "words words"));
|
docs.add(ESIntegTestCase.client().prepareIndex(indexName).setId(Integer.toString(i)).setSource("some_field", "words words"));
|
||||||
}
|
}
|
||||||
indexRandom(true, docs);
|
indexRandom(true, docs);
|
||||||
IndicesStatsResponse indexStats = ESIntegTestCase.client().admin().indices().prepareStats(indexName).setDocs(true).get();
|
IndicesStatsResponse indexStats = ESIntegTestCase.indicesAdmin().prepareStats(indexName).setDocs(true).get();
|
||||||
Assert.assertThat(indexStats.getIndex(indexName).getTotal().getDocs().getCount(), is((long) INDEX_DOC_COUNT));
|
Assert.assertThat(indexStats.getIndex(indexName).getTotal().getDocs().getCount(), is((long) INDEX_DOC_COUNT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase
|
||||||
Set<String> actualAliasNames = imd.getAliases().keySet();
|
Set<String> actualAliasNames = imd.getAliases().keySet();
|
||||||
assertThat(actualAliasNames, containsInAnyOrder(aliasNames.toArray()));
|
assertThat(actualAliasNames, containsInAnyOrder(aliasNames.toArray()));
|
||||||
|
|
||||||
IndicesStatsResponse indexStats = client().admin().indices().prepareStats(imd.getIndex().getName()).setDocs(true).get();
|
IndicesStatsResponse indexStats = indicesAdmin().prepareStats(imd.getIndex().getName()).setDocs(true).get();
|
||||||
assertNotNull(indexStats);
|
assertNotNull(indexStats);
|
||||||
final IndexStats thisIndexStats = indexStats.getIndex(imd.getIndex().getName());
|
final IndexStats thisIndexStats = indexStats.getIndex(imd.getIndex().getName());
|
||||||
assertNotNull(thisIndexStats);
|
assertNotNull(thisIndexStats);
|
||||||
|
|
|
@ -330,9 +330,7 @@ public class FeatureMigrationIT extends AbstractFeatureMigrationIntegTest {
|
||||||
createSystemIndexForDescriptor(descriptor);
|
createSystemIndexForDescriptor(descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
client().admin()
|
indicesAdmin().preparePutTemplate("bad_template")
|
||||||
.indices()
|
|
||||||
.preparePutTemplate("bad_template")
|
|
||||||
.setPatterns(Collections.singletonList(templatePrefix + "*"))
|
.setPatterns(Collections.singletonList(templatePrefix + "*"))
|
||||||
.addAlias(new Alias(templatePrefix + "-legacy-alias"))
|
.addAlias(new Alias(templatePrefix + "-legacy-alias"))
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class ReindexFailureTests extends ReindexTestCase {
|
||||||
ReindexRequestBuilder copy = reindex().source("source").destination("dest");
|
ReindexRequestBuilder copy = reindex().source("source").destination("dest");
|
||||||
copy.source().setSize(10);
|
copy.source().setSize(10);
|
||||||
Future<BulkByScrollResponse> response = copy.execute();
|
Future<BulkByScrollResponse> response = copy.execute();
|
||||||
client().admin().indices().prepareDelete("source").get();
|
indicesAdmin().prepareDelete("source").get();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response.get();
|
response.get();
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class ReindexSingleNodeTests extends ESSingleNodeTestCase {
|
||||||
client().prepareIndex("source").setId(Integer.toString(i)).setSource("foo", i).get();
|
client().prepareIndex("source").setId(Integer.toString(i)).setSource("foo", i).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
client().admin().indices().prepareRefresh("source").get();
|
indicesAdmin().prepareRefresh("source").get();
|
||||||
assertHitCount(client().prepareSearch("source").setSize(0).get(), max);
|
assertHitCount(client().prepareSearch("source").setSize(0).get(), max);
|
||||||
|
|
||||||
// Copy a subset of the docs sorted
|
// Copy a subset of the docs sorted
|
||||||
|
|
|
@ -175,9 +175,9 @@ public class RetryTests extends ESIntegTestCase {
|
||||||
final Settings indexSettings = indexSettings(1, 0).put("index.routing.allocation.include.color", "blue").build();
|
final Settings indexSettings = indexSettings(1, 0).put("index.routing.allocation.include.color", "blue").build();
|
||||||
|
|
||||||
// Create the source index on the node with small thread pools so we can block them.
|
// Create the source index on the node with small thread pools so we can block them.
|
||||||
client().admin().indices().prepareCreate("source").setSettings(indexSettings).execute().actionGet();
|
indicesAdmin().prepareCreate("source").setSettings(indexSettings).execute().actionGet();
|
||||||
// Not all test cases use the dest index but those that do require that it be on the node will small thread pools
|
// Not all test cases use the dest index but those that do require that it be on the node will small thread pools
|
||||||
client().admin().indices().prepareCreate("dest").setSettings(indexSettings).execute().actionGet();
|
indicesAdmin().prepareCreate("dest").setSettings(indexSettings).execute().actionGet();
|
||||||
// Build the test data. Don't use indexRandom because that won't work consistently with such small thread pools.
|
// Build the test data. Don't use indexRandom because that won't work consistently with such small thread pools.
|
||||||
BulkRequestBuilder bulk = client().prepareBulk();
|
BulkRequestBuilder bulk = client().prepareBulk();
|
||||||
for (int i = 0; i < DOC_COUNT; i++) {
|
for (int i = 0; i < DOC_COUNT; i++) {
|
||||||
|
@ -187,7 +187,7 @@ public class RetryTests extends ESIntegTestCase {
|
||||||
Retry retry = new Retry(BackoffPolicy.exponentialBackoff(), client().threadPool());
|
Retry retry = new Retry(BackoffPolicy.exponentialBackoff(), client().threadPool());
|
||||||
BulkResponse initialBulkResponse = retry.withBackoff(client()::bulk, bulk.request()).actionGet();
|
BulkResponse initialBulkResponse = retry.withBackoff(client()::bulk, bulk.request()).actionGet();
|
||||||
assertFalse(initialBulkResponse.buildFailureMessage(), initialBulkResponse.hasFailures());
|
assertFalse(initialBulkResponse.buildFailureMessage(), initialBulkResponse.hasFailures());
|
||||||
client().admin().indices().prepareRefresh("source").get();
|
indicesAdmin().prepareRefresh("source").get();
|
||||||
|
|
||||||
AbstractBulkByScrollRequestBuilder<?, ?> builder = request.apply(internalCluster().masterClient());
|
AbstractBulkByScrollRequestBuilder<?, ?> builder = request.apply(internalCluster().masterClient());
|
||||||
// Make sure we use more than one batch so we have to scroll
|
// Make sure we use more than one batch so we have to scroll
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
// both values should collate to same value
|
// both values should collate to same value
|
||||||
indexRandom(
|
indexRandom(
|
||||||
|
@ -105,7 +105,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
// everything should be indexed fine, no exceptions
|
// everything should be indexed fine, no exceptions
|
||||||
indexRandom(
|
indexRandom(
|
||||||
|
@ -169,7 +169,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
|
@ -214,7 +214,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
|
@ -259,7 +259,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
|
@ -304,7 +304,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
|
@ -345,7 +345,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
indexRandom(true, client().prepareIndex(index).setId("1").setSource("""
|
indexRandom(true, client().prepareIndex(index).setId("1").setSource("""
|
||||||
{"collate":"foobar-10"}""", XContentType.JSON), client().prepareIndex(index).setId("2").setSource("""
|
{"collate":"foobar-10"}""", XContentType.JSON), client().prepareIndex(index).setId("2").setSource("""
|
||||||
|
@ -382,7 +382,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
indexRandom(true, client().prepareIndex(index).setId("1").setSource("""
|
indexRandom(true, client().prepareIndex(index).setId("1").setSource("""
|
||||||
{"id":"1","collate":"résumé"}""", XContentType.JSON), client().prepareIndex(index).setId("2").setSource("""
|
{"id":"1","collate":"résumé"}""", XContentType.JSON), client().prepareIndex(index).setId("2").setSource("""
|
||||||
|
@ -418,7 +418,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
|
@ -466,7 +466,7 @@ public class ICUCollationKeywordFieldMapperIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class SizeMappingIT extends ESIntegTestCase {
|
||||||
String index = "foo";
|
String index = "foo";
|
||||||
|
|
||||||
XContentBuilder builder = jsonBuilder().startObject().startObject("_size").field("enabled", true).endObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().startObject("_size").field("enabled", true).endObject().endObject();
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
// check mapping again
|
// check mapping again
|
||||||
assertSizeMappingEnabled(index, true);
|
assertSizeMappingEnabled(index, true);
|
||||||
|
@ -54,7 +54,7 @@ public class SizeMappingIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
AcknowledgedResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setSource(updateMappingBuilder).get();
|
AcknowledgedResponse putMappingResponse = indicesAdmin().preparePutMapping(index).setSource(updateMappingBuilder).get();
|
||||||
assertAcked(putMappingResponse);
|
assertAcked(putMappingResponse);
|
||||||
|
|
||||||
// make sure size field is still in mapping
|
// make sure size field is still in mapping
|
||||||
|
@ -65,7 +65,7 @@ public class SizeMappingIT extends ESIntegTestCase {
|
||||||
String index = "foo";
|
String index = "foo";
|
||||||
|
|
||||||
XContentBuilder builder = jsonBuilder().startObject().startObject("_size").field("enabled", true).endObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().startObject("_size").field("enabled", true).endObject().endObject();
|
||||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
assertAcked(indicesAdmin().prepareCreate(index).setMapping(builder));
|
||||||
|
|
||||||
// check mapping again
|
// check mapping again
|
||||||
assertSizeMappingEnabled(index, true);
|
assertSizeMappingEnabled(index, true);
|
||||||
|
@ -76,7 +76,7 @@ public class SizeMappingIT extends ESIntegTestCase {
|
||||||
.field("enabled", false)
|
.field("enabled", false)
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
AcknowledgedResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setSource(updateMappingBuilder).get();
|
AcknowledgedResponse putMappingResponse = indicesAdmin().preparePutMapping(index).setSource(updateMappingBuilder).get();
|
||||||
assertAcked(putMappingResponse);
|
assertAcked(putMappingResponse);
|
||||||
|
|
||||||
// make sure size field is still in mapping
|
// make sure size field is still in mapping
|
||||||
|
@ -89,7 +89,7 @@ public class SizeMappingIT extends ESIntegTestCase {
|
||||||
"Expected size field mapping to be " + (enabled ? "enabled" : "disabled") + " for %s",
|
"Expected size field mapping to be " + (enabled ? "enabled" : "disabled") + " for %s",
|
||||||
index
|
index
|
||||||
);
|
);
|
||||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings(index).get();
|
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
|
||||||
Map<String, Object> mappingSource = getMappingsResponse.getMappings().get(index).getSourceAsMap();
|
Map<String, Object> mappingSource = getMappingsResponse.getMappings().get(index).getSourceAsMap();
|
||||||
assertThat(errMsg, mappingSource, hasKey("_size"));
|
assertThat(errMsg, mappingSource, hasKey("_size"));
|
||||||
String sizeAsString = mappingSource.get("_size").toString();
|
String sizeAsString = mappingSource.get("_size").toString();
|
||||||
|
|
|
@ -1061,7 +1061,7 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase {
|
||||||
indexData();
|
indexData();
|
||||||
} else {
|
} else {
|
||||||
logger.info("--> close the index, now the replica is stale");
|
logger.info("--> close the index, now the replica is stale");
|
||||||
assertAcked(admin().indices().prepareClose("idx"));
|
assertAcked(indicesAdmin().prepareClose("idx"));
|
||||||
|
|
||||||
final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth("idx")
|
final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth("idx")
|
||||||
.setTimeout(TimeValue.timeValueSeconds(30))
|
.setTimeout(TimeValue.timeValueSeconds(30))
|
||||||
|
@ -1203,8 +1203,7 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> creating a {} index with {} primary, {} replicas", state, numPrimaries, numReplicas);
|
logger.info("--> creating a {} index with {} primary, {} replicas", state, numPrimaries, numReplicas);
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareCreate("idx")
|
||||||
.prepareCreate("idx")
|
|
||||||
.setSettings(indexSettings(numPrimaries, numReplicas).put(settings))
|
.setSettings(indexSettings(numPrimaries, numReplicas).put(settings))
|
||||||
.setWaitForActiveShards(activeShardCount)
|
.setWaitForActiveShards(activeShardCount)
|
||||||
.get()
|
.get()
|
||||||
|
@ -1214,7 +1213,7 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase {
|
||||||
indexData();
|
indexData();
|
||||||
}
|
}
|
||||||
if (state == IndexMetadata.State.CLOSE) {
|
if (state == IndexMetadata.State.CLOSE) {
|
||||||
assertAcked(admin().indices().prepareClose("idx"));
|
assertAcked(indicesAdmin().prepareClose("idx"));
|
||||||
|
|
||||||
final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth("idx")
|
final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth("idx")
|
||||||
.setTimeout(TimeValue.timeValueSeconds(30))
|
.setTimeout(TimeValue.timeValueSeconds(30))
|
||||||
|
|
|
@ -51,13 +51,13 @@ public class ForceMergeIT extends ESIntegTestCase {
|
||||||
assertThat(getForceMergeUUID(primary), nullValue());
|
assertThat(getForceMergeUUID(primary), nullValue());
|
||||||
assertThat(getForceMergeUUID(replica), nullValue());
|
assertThat(getForceMergeUUID(replica), nullValue());
|
||||||
|
|
||||||
final ForceMergeResponse forceMergeResponse = client().admin().indices().prepareForceMerge(index).setMaxNumSegments(1).get();
|
final ForceMergeResponse forceMergeResponse = indicesAdmin().prepareForceMerge(index).setMaxNumSegments(1).get();
|
||||||
|
|
||||||
assertThat(forceMergeResponse.getFailedShards(), is(0));
|
assertThat(forceMergeResponse.getFailedShards(), is(0));
|
||||||
assertThat(forceMergeResponse.getSuccessfulShards(), is(2));
|
assertThat(forceMergeResponse.getSuccessfulShards(), is(2));
|
||||||
|
|
||||||
// Force flush to force a new commit that contains the force flush UUID
|
// Force flush to force a new commit that contains the force flush UUID
|
||||||
final FlushResponse flushResponse = client().admin().indices().prepareFlush(index).setForce(true).get();
|
final FlushResponse flushResponse = indicesAdmin().prepareFlush(index).setForce(true).get();
|
||||||
assertThat(flushResponse.getFailedShards(), is(0));
|
assertThat(flushResponse.getFailedShards(), is(0));
|
||||||
assertThat(flushResponse.getSuccessfulShards(), is(2));
|
assertThat(flushResponse.getSuccessfulShards(), is(2));
|
||||||
|
|
||||||
|
|
|
@ -57,38 +57,38 @@ public class ValidateMappingRequestPluginIT extends ESSingleNodeTestCase {
|
||||||
{
|
{
|
||||||
String origin = randomFrom("", "3", "4", "5");
|
String origin = randomFrom("", "3", "4", "5");
|
||||||
PutMappingRequest request = new PutMappingRequest().indices("index_1").source("t1", "type=keyword").origin(origin);
|
PutMappingRequest request = new PutMappingRequest().indices("index_1").source("t1", "type=keyword").origin(origin);
|
||||||
Exception e = expectThrows(IllegalStateException.class, () -> client().admin().indices().putMapping(request).actionGet());
|
Exception e = expectThrows(IllegalStateException.class, () -> indicesAdmin().putMapping(request).actionGet());
|
||||||
assertThat(e.getMessage(), equalTo("not allowed: index[index_1] origin[" + origin + "]"));
|
assertThat(e.getMessage(), equalTo("not allowed: index[index_1] origin[" + origin + "]"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PutMappingRequest request = new PutMappingRequest().indices("index_1")
|
PutMappingRequest request = new PutMappingRequest().indices("index_1")
|
||||||
.origin(randomFrom("1", "2"))
|
.origin(randomFrom("1", "2"))
|
||||||
.source("t1", "type=keyword");
|
.source("t1", "type=keyword");
|
||||||
assertAcked(client().admin().indices().putMapping(request).actionGet());
|
assertAcked(indicesAdmin().putMapping(request).actionGet());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
String origin = randomFrom("", "1", "4", "5");
|
String origin = randomFrom("", "1", "4", "5");
|
||||||
PutMappingRequest request = new PutMappingRequest().indices("index_2").source("t2", "type=keyword").origin(origin);
|
PutMappingRequest request = new PutMappingRequest().indices("index_2").source("t2", "type=keyword").origin(origin);
|
||||||
Exception e = expectThrows(IllegalStateException.class, () -> client().admin().indices().putMapping(request).actionGet());
|
Exception e = expectThrows(IllegalStateException.class, () -> indicesAdmin().putMapping(request).actionGet());
|
||||||
assertThat(e.getMessage(), equalTo("not allowed: index[index_2] origin[" + origin + "]"));
|
assertThat(e.getMessage(), equalTo("not allowed: index[index_2] origin[" + origin + "]"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PutMappingRequest request = new PutMappingRequest().indices("index_2")
|
PutMappingRequest request = new PutMappingRequest().indices("index_2")
|
||||||
.origin(randomFrom("2", "3"))
|
.origin(randomFrom("2", "3"))
|
||||||
.source("t1", "type=keyword");
|
.source("t1", "type=keyword");
|
||||||
assertAcked(client().admin().indices().putMapping(request).actionGet());
|
assertAcked(indicesAdmin().putMapping(request).actionGet());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
String origin = randomFrom("", "1", "3", "4");
|
String origin = randomFrom("", "1", "3", "4");
|
||||||
PutMappingRequest request = new PutMappingRequest().indices("*").source("t3", "type=keyword").origin(origin);
|
PutMappingRequest request = new PutMappingRequest().indices("*").source("t3", "type=keyword").origin(origin);
|
||||||
Exception e = expectThrows(IllegalStateException.class, () -> client().admin().indices().putMapping(request).actionGet());
|
Exception e = expectThrows(IllegalStateException.class, () -> indicesAdmin().putMapping(request).actionGet());
|
||||||
assertThat(e.getMessage(), containsString("not allowed:"));
|
assertThat(e.getMessage(), containsString("not allowed:"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PutMappingRequest request = new PutMappingRequest().indices("index_2").origin("2").source("t3", "type=keyword");
|
PutMappingRequest request = new PutMappingRequest().indices("index_2").origin("2").source("t3", "type=keyword");
|
||||||
assertAcked(client().admin().indices().putMapping(request).actionGet());
|
assertAcked(indicesAdmin().putMapping(request).actionGet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class RefreshBlocksIT extends ESIntegTestCase {
|
||||||
)) {
|
)) {
|
||||||
try {
|
try {
|
||||||
enableIndexBlock("test", blockSetting);
|
enableIndexBlock("test", blockSetting);
|
||||||
RefreshResponse response = client().admin().indices().prepareRefresh("test").execute().actionGet();
|
RefreshResponse response = indicesAdmin().prepareRefresh("test").execute().actionGet();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
assertThat(response.getSuccessfulShards(), equalTo(numShards.totalNumShards));
|
assertThat(response.getSuccessfulShards(), equalTo(numShards.totalNumShards));
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class IndicesStatsBlocksIT extends ESIntegTestCase {
|
||||||
)) {
|
)) {
|
||||||
try {
|
try {
|
||||||
enableIndexBlock("ro", blockSetting);
|
enableIndexBlock("ro", blockSetting);
|
||||||
IndicesStatsResponse indicesStatsResponse = client().admin().indices().prepareStats("ro").execute().actionGet();
|
IndicesStatsResponse indicesStatsResponse = indicesAdmin().prepareStats("ro").execute().actionGet();
|
||||||
assertNotNull(indicesStatsResponse.getIndex("ro"));
|
assertNotNull(indicesStatsResponse.getIndex("ro"));
|
||||||
} finally {
|
} finally {
|
||||||
disableIndexBlock("ro", blockSetting);
|
disableIndexBlock("ro", blockSetting);
|
||||||
|
@ -46,7 +46,7 @@ public class IndicesStatsBlocksIT extends ESIntegTestCase {
|
||||||
// Request is blocked
|
// Request is blocked
|
||||||
try {
|
try {
|
||||||
enableIndexBlock("ro", IndexMetadata.SETTING_BLOCKS_METADATA);
|
enableIndexBlock("ro", IndexMetadata.SETTING_BLOCKS_METADATA);
|
||||||
client().admin().indices().prepareStats("ro").execute().actionGet();
|
indicesAdmin().prepareStats("ro").execute().actionGet();
|
||||||
fail("Exists should fail when " + IndexMetadata.SETTING_BLOCKS_METADATA + " is true");
|
fail("Exists should fail when " + IndexMetadata.SETTING_BLOCKS_METADATA + " is true");
|
||||||
} catch (ClusterBlockException e) {
|
} catch (ClusterBlockException e) {
|
||||||
// Ok, a ClusterBlockException is expected
|
// Ok, a ClusterBlockException is expected
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class BulkIntegrationIT extends ESIntegTestCase {
|
||||||
bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
|
bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
|
||||||
bulkBuilder.get();
|
bulkBuilder.get();
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings().get();
|
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings().get();
|
||||||
assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30"));
|
assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ public class BulkIntegrationIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
ensureGreen(index);
|
ensureGreen(index);
|
||||||
assertBusy(() -> assertThat(docID.get(), greaterThanOrEqualTo(1)));
|
assertBusy(() -> assertThat(docID.get(), greaterThanOrEqualTo(1)));
|
||||||
assertAcked(client().admin().indices().prepareDelete(index));
|
assertAcked(indicesAdmin().prepareDelete(index));
|
||||||
stopped.set(true);
|
stopped.set(true);
|
||||||
for (Thread thread : threads) {
|
for (Thread thread : threads) {
|
||||||
thread.join(ReplicationRequest.DEFAULT_TIMEOUT.millis() / 2);
|
thread.join(ReplicationRequest.DEFAULT_TIMEOUT.millis() / 2);
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class BulkProcessor2RetryIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client().admin().indices().refresh(new RefreshRequest()).get();
|
indicesAdmin().refresh(new RefreshRequest()).get();
|
||||||
|
|
||||||
SearchResponse results = client().prepareSearch(INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).setSize(0).get();
|
SearchResponse results = client().prepareSearch(INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).setSize(0).get();
|
||||||
assertThat(bulkProcessor.getTotalBytesInFlight(), equalTo(0L));
|
assertThat(bulkProcessor.getTotalBytesInFlight(), equalTo(0L));
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class BulkProcessorRetryIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client().admin().indices().refresh(new RefreshRequest()).get();
|
indicesAdmin().refresh(new RefreshRequest()).get();
|
||||||
|
|
||||||
SearchResponse results = client().prepareSearch(INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).setSize(0).get();
|
SearchResponse results = client().prepareSearch(INDEX_NAME).setQuery(QueryBuilders.matchAllQuery()).setSize(0).get();
|
||||||
|
|
||||||
|
|
|
@ -640,7 +640,7 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
|
||||||
SearchResponse searchResponse = client().prepareSearch("bulkindex*").get();
|
SearchResponse searchResponse = client().prepareSearch("bulkindex*").get();
|
||||||
assertHitCount(searchResponse, 3);
|
assertHitCount(searchResponse, 3);
|
||||||
|
|
||||||
assertBusy(() -> assertAcked(client().admin().indices().prepareClose("bulkindex2")));
|
assertBusy(() -> assertAcked(indicesAdmin().prepareClose("bulkindex2")));
|
||||||
|
|
||||||
BulkRequest bulkRequest2 = new BulkRequest();
|
BulkRequest bulkRequest2 = new BulkRequest();
|
||||||
bulkRequest2.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
bulkRequest2.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
||||||
|
@ -660,7 +660,7 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
|
||||||
createIndex("bulkindex1");
|
createIndex("bulkindex1");
|
||||||
|
|
||||||
client().prepareIndex("bulkindex1").setId("1").setSource("text", "test").get();
|
client().prepareIndex("bulkindex1").setId("1").setSource("text", "test").get();
|
||||||
assertBusy(() -> assertAcked(client().admin().indices().prepareClose("bulkindex1")));
|
assertBusy(() -> assertAcked(indicesAdmin().prepareClose("bulkindex1")));
|
||||||
|
|
||||||
BulkRequest bulkRequest = new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE);
|
BulkRequest bulkRequest = new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE);
|
||||||
bulkRequest.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
bulkRequest.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class LookupRuntimeFieldIT extends ESIntegTestCase {
|
||||||
for (Map<String, String> author : authors) {
|
for (Map<String, String> author : authors) {
|
||||||
client().prepareIndex("authors").setSource(author).setRefreshPolicy(randomFrom(WriteRequest.RefreshPolicy.values())).get();
|
client().prepareIndex("authors").setSource(author).setRefreshPolicy(randomFrom(WriteRequest.RefreshPolicy.values())).get();
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareRefresh("authors").get();
|
indicesAdmin().prepareRefresh("authors").get();
|
||||||
|
|
||||||
indicesAdmin().prepareCreate("publishers")
|
indicesAdmin().prepareCreate("publishers")
|
||||||
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5)))
|
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5)))
|
||||||
|
|
|
@ -209,7 +209,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
assertHitCount(resp1, index1);
|
assertHitCount(resp1, index1);
|
||||||
if (rarely()) {
|
if (rarely()) {
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
final CommonStats stats = client().admin().indices().prepareStats().setSearch(true).get().getTotal();
|
final CommonStats stats = indicesAdmin().prepareStats().setSearch(true).get().getTotal();
|
||||||
assertThat(stats.search.getOpenContexts(), equalTo(0L));
|
assertThat(stats.search.getOpenContexts(), equalTo(0L));
|
||||||
}, 60, TimeUnit.SECONDS);
|
}, 60, TimeUnit.SECONDS);
|
||||||
} else {
|
} else {
|
||||||
|
@ -245,7 +245,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
SearchResponse resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pit)).get();
|
SearchResponse resp = client().prepareSearch().setPreference(null).setPointInTime(new PointInTimeBuilder(pit)).get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
assertHitCount(resp, index1 + index2);
|
assertHitCount(resp, index1 + index2);
|
||||||
client().admin().indices().prepareDelete("index-1").get();
|
indicesAdmin().prepareDelete("index-1").get();
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
resp = client().prepareSearch("index-*").get();
|
resp = client().prepareSearch("index-*").get();
|
||||||
assertNoFailures(resp);
|
assertNoFailures(resp);
|
||||||
|
@ -381,7 +381,7 @@ public class PointInTimeIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPITTiebreak() throws Exception {
|
public void testPITTiebreak() throws Exception {
|
||||||
assertAcked(client().admin().indices().prepareDelete("index-*").get());
|
assertAcked(indicesAdmin().prepareDelete("index-*").get());
|
||||||
int numIndex = randomIntBetween(2, 10);
|
int numIndex = randomIntBetween(2, 10);
|
||||||
int expectedNumDocs = 0;
|
int expectedNumDocs = 0;
|
||||||
for (int i = 0; i < numIndex; i++) {
|
for (int i = 0; i < numIndex; i++) {
|
||||||
|
|
|
@ -43,19 +43,19 @@ public class SearchShardsIT extends ESIntegTestCase {
|
||||||
for (int i = 0; i < indicesWithData; i++) {
|
for (int i = 0; i < indicesWithData; i++) {
|
||||||
String index = "index-with-data-" + i;
|
String index = "index-with-data-" + i;
|
||||||
ElasticsearchAssertions.assertAcked(
|
ElasticsearchAssertions.assertAcked(
|
||||||
admin().indices().prepareCreate(index).setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1))
|
indicesAdmin().prepareCreate(index).setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1))
|
||||||
);
|
);
|
||||||
int numDocs = randomIntBetween(1, 10);
|
int numDocs = randomIntBetween(1, 10);
|
||||||
for (int j = 0; j < numDocs; j++) {
|
for (int j = 0; j < numDocs; j++) {
|
||||||
client().prepareIndex(index).setSource("value", i).setId(Integer.toString(i)).get();
|
client().prepareIndex(index).setSource("value", i).setId(Integer.toString(i)).get();
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareRefresh(index).get();
|
indicesAdmin().prepareRefresh(index).get();
|
||||||
}
|
}
|
||||||
int indicesWithoutData = between(1, 10);
|
int indicesWithoutData = between(1, 10);
|
||||||
for (int i = 0; i < indicesWithoutData; i++) {
|
for (int i = 0; i < indicesWithoutData; i++) {
|
||||||
String index = "index-without-data-" + i;
|
String index = "index-without-data-" + i;
|
||||||
ElasticsearchAssertions.assertAcked(
|
ElasticsearchAssertions.assertAcked(
|
||||||
admin().indices().prepareCreate(index).setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1))
|
indicesAdmin().prepareCreate(index).setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Range query
|
// Range query
|
||||||
|
@ -110,15 +110,14 @@ public class SearchShardsIT extends ESIntegTestCase {
|
||||||
for (int i = 0; i < numIndices; i++) {
|
for (int i = 0; i < numIndices; i++) {
|
||||||
String index = "index-" + i;
|
String index = "index-" + i;
|
||||||
ElasticsearchAssertions.assertAcked(
|
ElasticsearchAssertions.assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareCreate(index)
|
||||||
.prepareCreate(index)
|
|
||||||
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5)))
|
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5)))
|
||||||
);
|
);
|
||||||
int numDocs = randomIntBetween(10, 1000);
|
int numDocs = randomIntBetween(10, 1000);
|
||||||
for (int j = 0; j < numDocs; j++) {
|
for (int j = 0; j < numDocs; j++) {
|
||||||
client().prepareIndex(index).setSource("value", i).setId(Integer.toString(i)).get();
|
client().prepareIndex(index).setSource("value", i).setId(Integer.toString(i)).get();
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareRefresh(index).get();
|
indicesAdmin().prepareRefresh(index).get();
|
||||||
}
|
}
|
||||||
int iterations = iterations(2, 10);
|
int iterations = iterations(2, 10);
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
|
@ -164,8 +163,7 @@ public class SearchShardsIT extends ESIntegTestCase {
|
||||||
String index = "index-" + i;
|
String index = "index-" + i;
|
||||||
int numShards = between(1, 5);
|
int numShards = between(1, 5);
|
||||||
ElasticsearchAssertions.assertAcked(
|
ElasticsearchAssertions.assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareCreate(index)
|
||||||
.prepareCreate(index)
|
|
||||||
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards))
|
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards))
|
||||||
);
|
);
|
||||||
totalShards += numShards;
|
totalShards += numShards;
|
||||||
|
@ -173,7 +171,7 @@ public class SearchShardsIT extends ESIntegTestCase {
|
||||||
for (int j = 0; j < numDocs; j++) {
|
for (int j = 0; j < numDocs; j++) {
|
||||||
client().prepareIndex(index).setSource("value", i).setId(Integer.toString(i)).get();
|
client().prepareIndex(index).setSource("value", i).setId(Integer.toString(i)).get();
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareRefresh(index).get();
|
indicesAdmin().prepareRefresh(index).get();
|
||||||
}
|
}
|
||||||
SearchShardsRequest request = new SearchShardsRequest(
|
SearchShardsRequest request = new SearchShardsRequest(
|
||||||
new String[] { "index-*" },
|
new String[] { "index-*" },
|
||||||
|
|
|
@ -259,7 +259,7 @@ public class TransportSearchIT extends ESIntegTestCase {
|
||||||
IndexResponse indexResponse = client().index(indexRequest).actionGet();
|
IndexResponse indexResponse = client().index(indexRequest).actionGet();
|
||||||
assertEquals(RestStatus.CREATED, indexResponse.status());
|
assertEquals(RestStatus.CREATED, indexResponse.status());
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
SearchRequest originalRequest = new SearchRequest();
|
SearchRequest originalRequest = new SearchRequest();
|
||||||
SearchSourceBuilder source = new SearchSourceBuilder();
|
SearchSourceBuilder source = new SearchSourceBuilder();
|
||||||
|
@ -302,8 +302,8 @@ public class TransportSearchIT extends ESIntegTestCase {
|
||||||
assertAcked(prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)));
|
assertAcked(prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)));
|
||||||
assertAcked(prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)));
|
assertAcked(prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)));
|
||||||
assertAcked(prepareCreate("test3").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)));
|
assertAcked(prepareCreate("test3").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)));
|
||||||
client().admin().indices().prepareAliases().addAlias("test1", "testAlias").get();
|
indicesAdmin().prepareAliases().addAlias("test1", "testAlias").get();
|
||||||
client().admin().indices().prepareAliases().addAlias(new String[] { "test2", "test3" }, "testFailedAlias").get();
|
indicesAdmin().prepareAliases().addAlias(new String[] { "test2", "test3" }, "testFailedAlias").get();
|
||||||
|
|
||||||
long[] validCheckpoints = new long[numberOfShards];
|
long[] validCheckpoints = new long[numberOfShards];
|
||||||
Arrays.fill(validCheckpoints, SequenceNumbers.UNASSIGNED_SEQ_NO);
|
Arrays.fill(validCheckpoints, SequenceNumbers.UNASSIGNED_SEQ_NO);
|
||||||
|
@ -554,7 +554,7 @@ public class TransportSearchIT extends ESIntegTestCase {
|
||||||
IndexResponse indexResponse = client().prepareIndex(indexName).setSource("number", randomInt()).get();
|
IndexResponse indexResponse = client().prepareIndex(indexName).setSource("number", randomInt()).get();
|
||||||
assertEquals(RestStatus.CREATED, indexResponse.status());
|
assertEquals(RestStatus.CREATED, indexResponse.status());
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareRefresh(indexName).get();
|
indicesAdmin().prepareRefresh(indexName).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private long requestBreakerUsed() {
|
private long requestBreakerUsed() {
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class ActiveShardsObserverIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
waitForIndexCreationToComplete(indexName);
|
waitForIndexCreationToComplete(indexName);
|
||||||
if (indexExists(indexName)) {
|
if (indexExists(indexName)) {
|
||||||
client().admin().indices().prepareDelete(indexName).get();
|
indicesAdmin().prepareDelete(indexName).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// enough data nodes, all shards are active
|
// enough data nodes, all shards are active
|
||||||
|
@ -139,7 +139,7 @@ public class ActiveShardsObserverIT extends ESIntegTestCase {
|
||||||
assertBusy(() -> assertTrue(clusterAdmin().prepareState().get().getState().metadata().hasIndex(indexName)));
|
assertBusy(() -> assertTrue(clusterAdmin().prepareState().get().getState().metadata().hasIndex(indexName)));
|
||||||
|
|
||||||
logger.info("--> delete the index");
|
logger.info("--> delete the index");
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(indicesAdmin().prepareDelete(indexName));
|
||||||
|
|
||||||
logger.info("--> ensure the create index request completes");
|
logger.info("--> ensure the create index request completes");
|
||||||
assertAcked(responseListener.get());
|
assertAcked(responseListener.get());
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionIncreases("test", () -> {
|
assertAliasesVersionIncreases("test", () -> {
|
||||||
logger.info("--> aliasing index [test] with [alias1]");
|
logger.info("--> aliasing index [test] with [alias1]");
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1", false));
|
assertAcked(indicesAdmin().prepareAliases().addAlias("test", "alias1", false));
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info("--> indexing against [alias1], should fail now");
|
logger.info("--> indexing against [alias1], should fail now");
|
||||||
|
@ -103,7 +103,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionIncreases("test", () -> {
|
assertAliasesVersionIncreases("test", () -> {
|
||||||
logger.info("--> aliasing index [test] with [alias1]");
|
logger.info("--> aliasing index [test] with [alias1]");
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1"));
|
assertAcked(indicesAdmin().prepareAliases().addAlias("test", "alias1"));
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info("--> indexing against [alias1], should work now");
|
logger.info("--> indexing against [alias1], should work now");
|
||||||
|
@ -118,7 +118,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionIncreases("test_x", () -> {
|
assertAliasesVersionIncreases("test_x", () -> {
|
||||||
logger.info("--> add index [test_x] with [alias1]");
|
logger.info("--> add index [test_x] with [alias1]");
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias("test_x", "alias1"));
|
assertAcked(indicesAdmin().prepareAliases().addAlias("test_x", "alias1"));
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info("--> indexing against [alias1], should fail now");
|
logger.info("--> indexing against [alias1], should fail now");
|
||||||
|
@ -148,7 +148,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionIncreases("test_x", () -> {
|
assertAliasesVersionIncreases("test_x", () -> {
|
||||||
logger.info("--> remove aliasing index [test_x] with [alias1]");
|
logger.info("--> remove aliasing index [test_x] with [alias1]");
|
||||||
assertAcked(admin().indices().prepareAliases().removeAlias("test_x", "alias1"));
|
assertAcked(indicesAdmin().prepareAliases().removeAlias("test_x", "alias1"));
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info("--> indexing against [alias1], should work now");
|
logger.info("--> indexing against [alias1], should work now");
|
||||||
|
@ -157,7 +157,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionIncreases("test_x", () -> {
|
assertAliasesVersionIncreases("test_x", () -> {
|
||||||
logger.info("--> add index [test_x] with [alias1] as write-index");
|
logger.info("--> add index [test_x] with [alias1] as write-index");
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias("test_x", "alias1", true));
|
assertAcked(indicesAdmin().prepareAliases().addAlias("test_x", "alias1", true));
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info("--> indexing against [alias1], should work now");
|
logger.info("--> indexing against [alias1], should work now");
|
||||||
|
@ -170,7 +170,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionIncreases("test_x", () -> {
|
assertAliasesVersionIncreases("test_x", () -> {
|
||||||
logger.info("--> remove [alias1], Aliasing index [test_x] with [alias1]");
|
logger.info("--> remove [alias1], Aliasing index [test_x] with [alias1]");
|
||||||
assertAcked(admin().indices().prepareAliases().removeAlias("test", "alias1").addAlias("test_x", "alias1"));
|
assertAcked(indicesAdmin().prepareAliases().removeAlias("test", "alias1").addAlias("test_x", "alias1"));
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info("--> indexing against [alias1], should work against [test_x]");
|
logger.info("--> indexing against [alias1], should work against [test_x]");
|
||||||
|
@ -185,14 +185,14 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
// invalid filter, invalid json
|
// invalid filter, invalid json
|
||||||
Exception e = expectThrows(
|
Exception e = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> admin().indices().prepareAliases().addAlias("test", "alias1", "abcde").get()
|
() -> indicesAdmin().prepareAliases().addAlias("test", "alias1", "abcde").get()
|
||||||
);
|
);
|
||||||
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [alias1]"));
|
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [alias1]"));
|
||||||
|
|
||||||
// valid json , invalid filter
|
// valid json , invalid filter
|
||||||
e = expectThrows(
|
e = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> admin().indices().prepareAliases().addAlias("test", "alias1", "{ \"test\": {} }").get()
|
() -> indicesAdmin().prepareAliases().addAlias("test", "alias1", "{ \"test\": {} }").get()
|
||||||
);
|
);
|
||||||
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [alias1]"));
|
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [alias1]"));
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> aliasing index [test] with [alias1] and filter [user:kimchy]");
|
logger.info("--> aliasing index [test] with [alias1] and filter [user:kimchy]");
|
||||||
QueryBuilder filter = termQuery("user", "kimchy");
|
QueryBuilder filter = termQuery("user", "kimchy");
|
||||||
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1", filter)));
|
assertAliasesVersionIncreases("test", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "alias1", filter)));
|
||||||
|
|
||||||
// For now just making sure that filter was stored with the alias
|
// For now just making sure that filter was stored with the alias
|
||||||
logger.info("--> making sure that filter was stored with alias [alias1] and filter [user:kimchy]");
|
logger.info("--> making sure that filter was stored with alias [alias1] and filter [user:kimchy]");
|
||||||
|
@ -224,7 +224,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
logger.info("--> aliasing index [test] with [alias1] and empty filter");
|
logger.info("--> aliasing index [test] with [alias1] and empty filter");
|
||||||
IllegalArgumentException iae = expectThrows(
|
IllegalArgumentException iae = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> admin().indices().prepareAliases().addAlias("test", "alias1", "{}").get()
|
() -> indicesAdmin().prepareAliases().addAlias("test", "alias1", "{}").get()
|
||||||
);
|
);
|
||||||
assertEquals("failed to parse filter for alias [alias1]", iae.getMessage());
|
assertEquals("failed to parse filter for alias [alias1]", iae.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -237,19 +237,19 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("--> adding filtering aliases to index [test]");
|
logger.info("--> adding filtering aliases to index [test]");
|
||||||
|
|
||||||
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1")));
|
assertAliasesVersionIncreases("test", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "alias1")));
|
||||||
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", "alias2")));
|
assertAliasesVersionIncreases("test", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "alias2")));
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test", "foos", termQuery("name", "foo")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "foos", termQuery("name", "foo")))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test", "bars", termQuery("name", "bar")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "bars", termQuery("name", "bar")))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test", "tests", termQuery("name", "test")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "tests", termQuery("name", "test")))
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> indexing against [test]");
|
logger.info("--> indexing against [test]");
|
||||||
|
@ -342,23 +342,23 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
logger.info("--> adding filtering aliases to index [test1]");
|
logger.info("--> adding filtering aliases to index [test1]");
|
||||||
assertAliasesVersionIncreases("test1", () -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "aliasToTest1")));
|
assertAliasesVersionIncreases("test1", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "aliasToTest1")));
|
||||||
assertAliasesVersionIncreases("test1", () -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "aliasToTests")));
|
assertAliasesVersionIncreases("test1", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "aliasToTests")));
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test1",
|
"test1",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "foos", termQuery("name", "foo")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "foos", termQuery("name", "foo")))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test1",
|
"test1",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "bars", termQuery("name", "bar")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "bars", termQuery("name", "bar")))
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> adding filtering aliases to index [test2]");
|
logger.info("--> adding filtering aliases to index [test2]");
|
||||||
assertAliasesVersionIncreases("test2", () -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "aliasToTest2")));
|
assertAliasesVersionIncreases("test2", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "aliasToTest2")));
|
||||||
assertAliasesVersionIncreases("test2", () -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "aliasToTests")));
|
assertAliasesVersionIncreases("test2", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "aliasToTests")));
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test2",
|
"test2",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "foos", termQuery("name", "foo")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "foos", termQuery("name", "foo")))
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> indexing against [test1]");
|
logger.info("--> indexing against [test1]");
|
||||||
|
@ -448,31 +448,31 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
logger.info("--> adding aliases to indices");
|
logger.info("--> adding aliases to indices");
|
||||||
assertAliasesVersionIncreases("test1", () -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "alias12")));
|
assertAliasesVersionIncreases("test1", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "alias12")));
|
||||||
assertAliasesVersionIncreases("test2", () -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "alias12")));
|
assertAliasesVersionIncreases("test2", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "alias12")));
|
||||||
|
|
||||||
logger.info("--> adding filtering aliases to indices");
|
logger.info("--> adding filtering aliases to indices");
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test1",
|
"test1",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "filter1", termQuery("name", "test1")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "filter1", termQuery("name", "test1")))
|
||||||
);
|
);
|
||||||
|
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test2",
|
"test2",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "filter23", termQuery("name", "foo")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "filter23", termQuery("name", "foo")))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test3",
|
"test3",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test3", "filter23", termQuery("name", "foo")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test3", "filter23", termQuery("name", "foo")))
|
||||||
);
|
);
|
||||||
|
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test1",
|
"test1",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "filter13", termQuery("name", "baz")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "filter13", termQuery("name", "baz")))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test3",
|
"test3",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test3", "filter13", termQuery("name", "baz")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test3", "filter13", termQuery("name", "baz")))
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> indexing against [test1]");
|
logger.info("--> indexing against [test1]");
|
||||||
|
@ -571,31 +571,31 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
logger.info("--> adding filtering aliases to index [test1]");
|
logger.info("--> adding filtering aliases to index [test1]");
|
||||||
assertAliasesVersionIncreases("test1", () -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "aliasToTest1")));
|
assertAliasesVersionIncreases("test1", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "aliasToTest1")));
|
||||||
assertAliasesVersionIncreases("test1", () -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "aliasToTests")));
|
assertAliasesVersionIncreases("test1", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "aliasToTests")));
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test1",
|
"test1",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "foos", termQuery("name", "foo")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "foos", termQuery("name", "foo")))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test1",
|
"test1",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "bars", termQuery("name", "bar")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "bars", termQuery("name", "bar")))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test1",
|
"test1",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test1", "tests", termQuery("name", "test")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "tests", termQuery("name", "test")))
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> adding filtering aliases to index [test2]");
|
logger.info("--> adding filtering aliases to index [test2]");
|
||||||
assertAliasesVersionIncreases("test2", () -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "aliasToTest2")));
|
assertAliasesVersionIncreases("test2", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "aliasToTest2")));
|
||||||
assertAliasesVersionIncreases("test2", () -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "aliasToTests")));
|
assertAliasesVersionIncreases("test2", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "aliasToTests")));
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test2",
|
"test2",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "foos", termQuery("name", "foo")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "foos", termQuery("name", "foo")))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test2",
|
"test2",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "tests", termQuery("name", "test")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test2", "tests", termQuery("name", "test")))
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> indexing against [test1]");
|
logger.info("--> indexing against [test1]");
|
||||||
|
@ -629,8 +629,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test1",
|
"test1",
|
||||||
() -> assertAcked(
|
() -> assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAlias("test1", "aliasToTest1")
|
.addAlias("test1", "aliasToTest1")
|
||||||
.addAlias("test1", "aliasToTests")
|
.addAlias("test1", "aliasToTests")
|
||||||
.addAlias("test1", "foos", termQuery("name", "foo"))
|
.addAlias("test1", "foos", termQuery("name", "foo"))
|
||||||
|
@ -643,8 +642,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test2",
|
"test2",
|
||||||
() -> assertAcked(
|
() -> assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAlias("test2", "aliasToTest2")
|
.addAlias("test2", "aliasToTest2")
|
||||||
.addAlias("test2", "aliasToTests")
|
.addAlias("test2", "aliasToTests")
|
||||||
.addAlias("test2", "foos", termQuery("name", "foo"))
|
.addAlias("test2", "foos", termQuery("name", "foo"))
|
||||||
|
@ -655,10 +653,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
String[] indices = { "test1", "test2" };
|
String[] indices = { "test1", "test2" };
|
||||||
String[] aliases = { "aliasToTest1", "foos", "bars", "tests", "aliasToTest2", "aliasToTests" };
|
String[] aliases = { "aliasToTest1", "foos", "bars", "tests", "aliasToTest2", "aliasToTests" };
|
||||||
|
|
||||||
assertAliasesVersionIncreases(indices, () -> admin().indices().prepareAliases().removeAlias(indices, aliases).get());
|
assertAliasesVersionIncreases(indices, () -> indicesAdmin().prepareAliases().removeAlias(indices, aliases).get());
|
||||||
|
|
||||||
for (String alias : aliases) {
|
for (String alias : aliases) {
|
||||||
assertTrue(admin().indices().prepareGetAliases(alias).get().getAliases().isEmpty());
|
assertTrue(indicesAdmin().prepareGetAliases(alias).get().getAliases().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("--> creating index [foo_foo] and [bar_bar]");
|
logger.info("--> creating index [foo_foo] and [bar_bar]");
|
||||||
|
@ -667,20 +665,20 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
logger.info("--> adding [foo] alias to [foo_foo] and [bar_bar]");
|
logger.info("--> adding [foo] alias to [foo_foo] and [bar_bar]");
|
||||||
assertAliasesVersionIncreases("foo_foo", () -> assertAcked(admin().indices().prepareAliases().addAlias("foo_foo", "foo")));
|
assertAliasesVersionIncreases("foo_foo", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("foo_foo", "foo")));
|
||||||
assertAliasesVersionIncreases("bar_bar", () -> assertAcked(admin().indices().prepareAliases().addAlias("bar_bar", "foo")));
|
assertAliasesVersionIncreases("bar_bar", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("bar_bar", "foo")));
|
||||||
|
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"foo_foo",
|
"foo_foo",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.remove().index("foo*").alias("foo")))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.remove().index("foo*").alias("foo")))
|
||||||
);
|
);
|
||||||
|
|
||||||
assertFalse(admin().indices().prepareGetAliases("foo").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("foo").get().getAliases().isEmpty());
|
||||||
assertTrue(admin().indices().prepareGetAliases("foo").setIndices("foo_foo").get().getAliases().isEmpty());
|
assertTrue(indicesAdmin().prepareGetAliases("foo").setIndices("foo_foo").get().getAliases().isEmpty());
|
||||||
assertFalse(admin().indices().prepareGetAliases("foo").setIndices("bar_bar").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("foo").setIndices("bar_bar").get().getAliases().isEmpty());
|
||||||
IllegalArgumentException iae = expectThrows(
|
IllegalArgumentException iae = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> admin().indices().prepareAliases().addAliasAction(AliasActions.remove().index("foo").alias("foo")).execute().actionGet()
|
() -> indicesAdmin().prepareAliases().addAliasAction(AliasActions.remove().index("foo").alias("foo")).execute().actionGet()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"The provided expression [foo] matches an alias, specify the corresponding concrete indices instead.",
|
"The provided expression [foo] matches an alias, specify the corresponding concrete indices instead.",
|
||||||
|
@ -696,20 +694,20 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
final String aliasName = "alias" + i;
|
final String aliasName = "alias" + i;
|
||||||
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName)));
|
assertAliasesVersionIncreases("test", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", aliasName)));
|
||||||
client().index(new IndexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get();
|
client().index(new IndexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWaitForAliasCreationSingleShard() throws Exception {
|
public void testWaitForAliasCreationSingleShard() throws Exception {
|
||||||
logger.info("--> creating index [test]");
|
logger.info("--> creating index [test]");
|
||||||
assertAcked(admin().indices().create(new CreateIndexRequest("test").settings(indexSettings(1, 0))).get());
|
assertAcked(indicesAdmin().create(new CreateIndexRequest("test").settings(indexSettings(1, 0))).get());
|
||||||
|
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
final String aliasName = "alias" + i;
|
final String aliasName = "alias" + i;
|
||||||
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName)));
|
assertAliasesVersionIncreases("test", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", aliasName)));
|
||||||
client().index(new IndexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get();
|
client().index(new IndexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -728,10 +726,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
executor.submit(new Runnable() {
|
executor.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases("test", () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", aliasName)));
|
||||||
"test",
|
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName))
|
|
||||||
);
|
|
||||||
client().index(new IndexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
|
client().index(new IndexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -750,14 +745,14 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
logger.info("--> creating alias1 ");
|
logger.info("--> creating alias1 ");
|
||||||
assertAliasesVersionIncreases("test", () -> assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1"))));
|
assertAliasesVersionIncreases("test", () -> assertAcked((indicesAdmin().prepareAliases().addAlias("test", "alias1"))));
|
||||||
TimeValue timeout = TimeValue.timeValueSeconds(2);
|
TimeValue timeout = TimeValue.timeValueSeconds(2);
|
||||||
logger.info("--> recreating alias1 ");
|
logger.info("--> recreating alias1 ");
|
||||||
StopWatch stopWatch = new StopWatch();
|
StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
assertAliasesVersionUnchanged(
|
assertAliasesVersionUnchanged(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1").setTimeout(timeout)))
|
() -> assertAcked((indicesAdmin().prepareAliases().addAlias("test", "alias1").setTimeout(timeout)))
|
||||||
);
|
);
|
||||||
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
||||||
|
|
||||||
|
@ -766,7 +761,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
final TermQueryBuilder fooFilter = termQuery("name", "foo");
|
final TermQueryBuilder fooFilter = termQuery("name", "foo");
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1", fooFilter).setTimeout(timeout))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "alias1", fooFilter).setTimeout(timeout))
|
||||||
);
|
);
|
||||||
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
||||||
|
|
||||||
|
@ -774,7 +769,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
assertAliasesVersionUnchanged(
|
assertAliasesVersionUnchanged(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", fooFilter).setTimeout(timeout)))
|
() -> assertAcked((indicesAdmin().prepareAliases().addAlias("test", "alias1", fooFilter).setTimeout(timeout)))
|
||||||
);
|
);
|
||||||
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
||||||
|
|
||||||
|
@ -783,7 +778,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
final TermQueryBuilder barFilter = termQuery("name", "bar");
|
final TermQueryBuilder barFilter = termQuery("name", "bar");
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", barFilter).setTimeout(timeout)))
|
() -> assertAcked((indicesAdmin().prepareAliases().addAlias("test", "alias1", barFilter).setTimeout(timeout)))
|
||||||
);
|
);
|
||||||
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
||||||
|
|
||||||
|
@ -798,7 +793,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked((admin().indices().prepareAliases().removeAlias("test", "alias1").setTimeout(timeout)))
|
() -> assertAcked((indicesAdmin().prepareAliases().removeAlias("test", "alias1").setTimeout(timeout)))
|
||||||
);
|
);
|
||||||
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
|
||||||
}
|
}
|
||||||
|
@ -809,7 +804,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
logger.info("--> deleting alias1 which does not exist");
|
logger.info("--> deleting alias1 which does not exist");
|
||||||
try {
|
try {
|
||||||
admin().indices().prepareAliases().removeAlias("test", "alias1").get();
|
indicesAdmin().prepareAliases().removeAlias("test", "alias1").get();
|
||||||
fail("Expected AliasesNotFoundException");
|
fail("Expected AliasesNotFoundException");
|
||||||
} catch (AliasesNotFoundException e) {
|
} catch (AliasesNotFoundException e) {
|
||||||
assertThat(e.getMessage(), containsString("[alias1] missing"));
|
assertThat(e.getMessage(), containsString("[alias1] missing"));
|
||||||
|
@ -830,11 +825,11 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
logger.info("--> creating aliases [alias1, alias2]");
|
logger.info("--> creating aliases [alias1, alias2]");
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"foobar",
|
"foobar",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("foobar", "alias1").addAlias("foobar", "alias2"))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("foobar", "alias1").addAlias("foobar", "alias2"))
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> getting alias1");
|
logger.info("--> getting alias1");
|
||||||
GetAliasesResponse getResponse = admin().indices().prepareGetAliases("alias1").get();
|
GetAliasesResponse getResponse = indicesAdmin().prepareGetAliases("alias1").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1));
|
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1));
|
||||||
|
@ -843,10 +838,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
||||||
assertFalse(admin().indices().prepareGetAliases("alias1").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("alias1").get().getAliases().isEmpty());
|
||||||
|
|
||||||
logger.info("--> getting all aliases that start with alias*");
|
logger.info("--> getting all aliases that start with alias*");
|
||||||
getResponse = admin().indices().prepareGetAliases("alias*").get();
|
getResponse = indicesAdmin().prepareGetAliases("alias*").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(2));
|
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(2));
|
||||||
|
@ -860,14 +855,13 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(1).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(1).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(1).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(1).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(1).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(1).getSearchRouting(), nullValue());
|
||||||
assertFalse(admin().indices().prepareGetAliases("alias*").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("alias*").get().getAliases().isEmpty());
|
||||||
|
|
||||||
logger.info("--> creating aliases [bar, baz, foo]");
|
logger.info("--> creating aliases [bar, baz, foo]");
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
new String[] { "bazbar", "foobar" },
|
new String[] { "bazbar", "foobar" },
|
||||||
() -> assertAcked(
|
() -> assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAlias("bazbar", "bar")
|
.addAlias("bazbar", "bar")
|
||||||
.addAlias("bazbar", "bac", termQuery("field", "value"))
|
.addAlias("bazbar", "bac", termQuery("field", "value"))
|
||||||
.addAlias("foobar", "foo")
|
.addAlias("foobar", "foo")
|
||||||
|
@ -877,12 +871,12 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"foobar",
|
"foobar",
|
||||||
() -> assertAcked(
|
() -> assertAcked(
|
||||||
admin().indices().prepareAliases().addAliasAction(AliasActions.add().index("foobar").alias("bac").routing("bla"))
|
indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index("foobar").alias("bac").routing("bla"))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> getting bar and baz for index bazbar");
|
logger.info("--> getting bar and baz for index bazbar");
|
||||||
getResponse = admin().indices().prepareGetAliases("bar", "bac").addIndices("bazbar").get();
|
getResponse = indicesAdmin().prepareGetAliases("bar", "bac").addIndices("bazbar").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
|
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
|
||||||
|
@ -898,13 +892,13 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("bazbar").get(1).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("bazbar").get(1).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("bazbar").get(1).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("bazbar").get(1).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("bazbar").get(1).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("bazbar").get(1).getSearchRouting(), nullValue());
|
||||||
assertFalse(admin().indices().prepareGetAliases("bar").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("bar").get().getAliases().isEmpty());
|
||||||
assertFalse(admin().indices().prepareGetAliases("bac").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("bac").get().getAliases().isEmpty());
|
||||||
assertFalse(admin().indices().prepareGetAliases("bar").addIndices("bazbar").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("bar").addIndices("bazbar").get().getAliases().isEmpty());
|
||||||
assertFalse(admin().indices().prepareGetAliases("bac").addIndices("bazbar").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("bac").addIndices("bazbar").get().getAliases().isEmpty());
|
||||||
|
|
||||||
logger.info("--> getting *b* for index baz*");
|
logger.info("--> getting *b* for index baz*");
|
||||||
getResponse = admin().indices().prepareGetAliases("*b*").addIndices("baz*").get();
|
getResponse = indicesAdmin().prepareGetAliases("*b*").addIndices("baz*").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
|
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
|
||||||
|
@ -920,10 +914,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("bazbar").get(1).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("bazbar").get(1).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("bazbar").get(1).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("bazbar").get(1).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("bazbar").get(1).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("bazbar").get(1).getSearchRouting(), nullValue());
|
||||||
assertFalse(admin().indices().prepareGetAliases("*b*").addIndices("baz*").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("*b*").addIndices("baz*").get().getAliases().isEmpty());
|
||||||
|
|
||||||
logger.info("--> getting *b* for index *bar");
|
logger.info("--> getting *b* for index *bar");
|
||||||
getResponse = admin().indices().prepareGetAliases("b*").addIndices("*bar").get();
|
getResponse = indicesAdmin().prepareGetAliases("b*").addIndices("*bar").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(2));
|
assertThat(getResponse.getAliases().size(), equalTo(2));
|
||||||
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
|
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
|
||||||
|
@ -944,10 +938,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), equalTo("bla"));
|
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), equalTo("bla"));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), equalTo("bla"));
|
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), equalTo("bla"));
|
||||||
assertFalse(admin().indices().prepareGetAliases("b*").addIndices("*bar").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("b*").addIndices("*bar").get().getAliases().isEmpty());
|
||||||
|
|
||||||
logger.info("--> getting f* for index *bar");
|
logger.info("--> getting f* for index *bar");
|
||||||
getResponse = admin().indices().prepareGetAliases("f*").addIndices("*bar").get();
|
getResponse = indicesAdmin().prepareGetAliases("f*").addIndices("*bar").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
||||||
|
@ -955,11 +949,11 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
||||||
assertFalse(admin().indices().prepareGetAliases("f*").addIndices("*bar").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("f*").addIndices("*bar").get().getAliases().isEmpty());
|
||||||
|
|
||||||
// alias at work
|
// alias at work
|
||||||
logger.info("--> getting f* for index *bac");
|
logger.info("--> getting f* for index *bac");
|
||||||
getResponse = admin().indices().prepareGetAliases("foo").addIndices("*bac").get();
|
getResponse = indicesAdmin().prepareGetAliases("foo").addIndices("*bac").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1));
|
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1));
|
||||||
|
@ -968,10 +962,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
||||||
assertFalse(admin().indices().prepareGetAliases("foo").addIndices("*bac").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("foo").addIndices("*bac").get().getAliases().isEmpty());
|
||||||
|
|
||||||
logger.info("--> getting foo for index foobar");
|
logger.info("--> getting foo for index foobar");
|
||||||
getResponse = admin().indices().prepareGetAliases("foo").addIndices("foobar").get();
|
getResponse = indicesAdmin().prepareGetAliases("foo").addIndices("foobar").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
||||||
|
@ -979,13 +973,13 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
||||||
assertFalse(admin().indices().prepareGetAliases("foo").addIndices("foobar").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("foo").addIndices("foobar").get().getAliases().isEmpty());
|
||||||
|
|
||||||
for (String aliasName : new String[] { null, "_all", "*" }) {
|
for (String aliasName : new String[] { null, "_all", "*" }) {
|
||||||
logger.info("--> getting {} alias for index foobar", aliasName);
|
logger.info("--> getting {} alias for index foobar", aliasName);
|
||||||
getResponse = aliasName != null
|
getResponse = aliasName != null
|
||||||
? admin().indices().prepareGetAliases(aliasName).addIndices("foobar").get()
|
? indicesAdmin().prepareGetAliases(aliasName).addIndices("foobar").get()
|
||||||
: admin().indices().prepareGetAliases().addIndices("foobar").get();
|
: indicesAdmin().prepareGetAliases().addIndices("foobar").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(4));
|
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(4));
|
||||||
|
@ -997,20 +991,20 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// alias at work again
|
// alias at work again
|
||||||
logger.info("--> getting * for index *bac");
|
logger.info("--> getting * for index *bac");
|
||||||
getResponse = admin().indices().prepareGetAliases("*").addIndices("*bac").get();
|
getResponse = indicesAdmin().prepareGetAliases("*").addIndices("*bac").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(2));
|
assertThat(getResponse.getAliases().size(), equalTo(2));
|
||||||
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(4));
|
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(4));
|
||||||
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
|
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
|
||||||
assertFalse(admin().indices().prepareGetAliases("*").addIndices("*bac").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("*").addIndices("*bac").get().getAliases().isEmpty());
|
||||||
|
|
||||||
assertAcked(admin().indices().prepareAliases().removeAlias("foobar", "foo"));
|
assertAcked(indicesAdmin().prepareAliases().removeAlias("foobar", "foo"));
|
||||||
|
|
||||||
getResponse = admin().indices().prepareGetAliases("foo").addIndices("foobar").get();
|
getResponse = indicesAdmin().prepareGetAliases("foo").addIndices("foobar").get();
|
||||||
for (final Map.Entry<String, List<AliasMetadata>> entry : getResponse.getAliases().entrySet()) {
|
for (final Map.Entry<String, List<AliasMetadata>> entry : getResponse.getAliases().entrySet()) {
|
||||||
assertTrue(entry.getValue().isEmpty());
|
assertTrue(entry.getValue().isEmpty());
|
||||||
}
|
}
|
||||||
assertTrue(admin().indices().prepareGetAliases("foo").addIndices("foobar").get().getAliases().isEmpty());
|
assertTrue(indicesAdmin().prepareGetAliases("foo").addIndices("foobar").get().getAliases().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetAllAliasesWorks() {
|
public void testGetAllAliasesWorks() {
|
||||||
|
@ -1019,10 +1013,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
new String[] { "index1", "index2" },
|
new String[] { "index1", "index2" },
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("index1", "alias1").addAlias("index2", "alias2"))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("index1", "alias1").addAlias("index2", "alias2"))
|
||||||
);
|
);
|
||||||
|
|
||||||
GetAliasesResponse response = admin().indices().prepareGetAliases().get();
|
GetAliasesResponse response = indicesAdmin().prepareGetAliases().get();
|
||||||
assertThat(response.getAliases(), hasKey("index1"));
|
assertThat(response.getAliases(), hasKey("index1"));
|
||||||
assertThat(response.getAliases(), hasKey("index1"));
|
assertThat(response.getAliases(), hasKey("index1"));
|
||||||
}
|
}
|
||||||
|
@ -1093,17 +1087,17 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
logger.info("--> adding [week_20] alias to [2017-05-20]");
|
logger.info("--> adding [week_20] alias to [2017-05-20]");
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias("2017-05-20", "week_20"));
|
assertAcked(indicesAdmin().prepareAliases().addAlias("2017-05-20", "week_20"));
|
||||||
|
|
||||||
IllegalArgumentException iae = expectThrows(
|
IllegalArgumentException iae = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> admin().indices().prepareAliases().addAliasAction(AliasActions.add().index("week_20").alias("tmp")).execute().actionGet()
|
() -> indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index("week_20").alias("tmp")).execute().actionGet()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"The provided expression [week_20] matches an alias, specify the corresponding concrete indices instead.",
|
"The provided expression [week_20] matches an alias, specify the corresponding concrete indices instead.",
|
||||||
iae.getMessage()
|
iae.getMessage()
|
||||||
);
|
);
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index("2017-05-20").alias("tmp")).execute().get());
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index("2017-05-20").alias("tmp")).execute().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before 2.0 alias filters were parsed at alias creation time, in order
|
// Before 2.0 alias filters were parsed at alias creation time, in order
|
||||||
|
@ -1132,17 +1126,13 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"my-index",
|
"my-index",
|
||||||
() -> assertAcked(
|
() -> assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases().addAlias("my-index", "filter1", rangeQuery("timestamp").from("2016-12-01").to("2016-12-31"))
|
||||||
.prepareAliases()
|
|
||||||
.addAlias("my-index", "filter1", rangeQuery("timestamp").from("2016-12-01").to("2016-12-31"))
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"my-index",
|
"my-index",
|
||||||
() -> assertAcked(
|
() -> assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases().addAlias("my-index", "filter2", rangeQuery("timestamp").from("2016-01-01").to("2016-12-31"))
|
||||||
.prepareAliases()
|
|
||||||
.addAlias("my-index", "filter2", rangeQuery("timestamp").from("2016-01-01").to("2016-12-31"))
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1170,11 +1160,11 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionIncreases(
|
assertAliasesVersionIncreases(
|
||||||
"test",
|
"test",
|
||||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1").addAlias("test", "alias2"))
|
() -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "alias1").addAlias("test", "alias2"))
|
||||||
);
|
);
|
||||||
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().removeAlias("test", "alias1")));
|
assertAliasesVersionIncreases("test", () -> assertAcked(indicesAdmin().prepareAliases().removeAlias("test", "alias1")));
|
||||||
assertThat(admin().indices().prepareGetAliases("alias2").execute().actionGet().getAliases().get("test").size(), equalTo(1));
|
assertThat(indicesAdmin().prepareGetAliases("alias2").execute().actionGet().getAliases().get("test").size(), equalTo(1));
|
||||||
assertFalse(admin().indices().prepareGetAliases("alias2").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("alias2").get().getAliases().isEmpty());
|
||||||
} finally {
|
} finally {
|
||||||
disableIndexBlock("test", block);
|
disableIndexBlock("test", block);
|
||||||
}
|
}
|
||||||
|
@ -1185,14 +1175,14 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionUnchanged(
|
assertAliasesVersionUnchanged(
|
||||||
"test",
|
"test",
|
||||||
() -> assertBlocked(admin().indices().prepareAliases().addAlias("test", "alias3"), INDEX_READ_ONLY_BLOCK)
|
() -> assertBlocked(indicesAdmin().prepareAliases().addAlias("test", "alias3"), INDEX_READ_ONLY_BLOCK)
|
||||||
);
|
);
|
||||||
assertAliasesVersionUnchanged(
|
assertAliasesVersionUnchanged(
|
||||||
"test",
|
"test",
|
||||||
() -> assertBlocked(admin().indices().prepareAliases().removeAlias("test", "alias2"), INDEX_READ_ONLY_BLOCK)
|
() -> assertBlocked(indicesAdmin().prepareAliases().removeAlias("test", "alias2"), INDEX_READ_ONLY_BLOCK)
|
||||||
);
|
);
|
||||||
assertThat(admin().indices().prepareGetAliases("alias2").execute().actionGet().getAliases().get("test").size(), equalTo(1));
|
assertThat(indicesAdmin().prepareGetAliases("alias2").execute().actionGet().getAliases().get("test").size(), equalTo(1));
|
||||||
assertFalse(admin().indices().prepareGetAliases("alias2").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("alias2").get().getAliases().isEmpty());
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
disableIndexBlock("test", SETTING_READ_ONLY);
|
disableIndexBlock("test", SETTING_READ_ONLY);
|
||||||
|
@ -1203,14 +1193,14 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAliasesVersionUnchanged(
|
assertAliasesVersionUnchanged(
|
||||||
"test",
|
"test",
|
||||||
() -> assertBlocked(admin().indices().prepareAliases().addAlias("test", "alias3"), INDEX_METADATA_BLOCK)
|
() -> assertBlocked(indicesAdmin().prepareAliases().addAlias("test", "alias3"), INDEX_METADATA_BLOCK)
|
||||||
);
|
);
|
||||||
assertAliasesVersionUnchanged(
|
assertAliasesVersionUnchanged(
|
||||||
"test",
|
"test",
|
||||||
() -> assertBlocked(admin().indices().prepareAliases().removeAlias("test", "alias2"), INDEX_METADATA_BLOCK)
|
() -> assertBlocked(indicesAdmin().prepareAliases().removeAlias("test", "alias2"), INDEX_METADATA_BLOCK)
|
||||||
);
|
);
|
||||||
assertBlocked(admin().indices().prepareGetAliases("alias2"), INDEX_METADATA_BLOCK);
|
assertBlocked(indicesAdmin().prepareGetAliases("alias2"), INDEX_METADATA_BLOCK);
|
||||||
assertBlocked(admin().indices().prepareGetAliases("alias2"), INDEX_METADATA_BLOCK);
|
assertBlocked(indicesAdmin().prepareGetAliases("alias2"), INDEX_METADATA_BLOCK);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
disableIndexBlock("test", SETTING_BLOCKS_METADATA);
|
disableIndexBlock("test", SETTING_BLOCKS_METADATA);
|
||||||
|
@ -1221,8 +1211,8 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertAcked(prepareCreate("foo_foo"));
|
assertAcked(prepareCreate("foo_foo"));
|
||||||
assertAcked(prepareCreate("bar_bar"));
|
assertAcked(prepareCreate("bar_bar"));
|
||||||
assertAliasesVersionIncreases(new String[] { "foo_foo", "bar_bar" }, () -> {
|
assertAliasesVersionIncreases(new String[] { "foo_foo", "bar_bar" }, () -> {
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias("foo_foo", "foo"));
|
assertAcked(indicesAdmin().prepareAliases().addAlias("foo_foo", "foo"));
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias("bar_bar", "foo"));
|
assertAcked(indicesAdmin().prepareAliases().addAlias("bar_bar", "foo"));
|
||||||
});
|
});
|
||||||
|
|
||||||
IllegalArgumentException iae = expectThrows(
|
IllegalArgumentException iae = expectThrows(
|
||||||
|
@ -1236,12 +1226,12 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertAcked(indicesAdmin().prepareAliases().removeIndex("foo*"));
|
assertAcked(indicesAdmin().prepareAliases().removeIndex("foo*"));
|
||||||
assertFalse(indexExists("foo_foo"));
|
assertFalse(indexExists("foo_foo"));
|
||||||
assertFalse(admin().indices().prepareGetAliases("foo").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("foo").get().getAliases().isEmpty());
|
||||||
assertTrue(indexExists("bar_bar"));
|
assertTrue(indexExists("bar_bar"));
|
||||||
assertFalse(admin().indices().prepareGetAliases("foo").setIndices("bar_bar").get().getAliases().isEmpty());
|
assertFalse(indicesAdmin().prepareGetAliases("foo").setIndices("bar_bar").get().getAliases().isEmpty());
|
||||||
|
|
||||||
assertAcked(indicesAdmin().prepareAliases().removeIndex("bar_bar"));
|
assertAcked(indicesAdmin().prepareAliases().removeIndex("bar_bar"));
|
||||||
assertTrue(admin().indices().prepareGetAliases("foo").get().getAliases().isEmpty());
|
assertTrue(indicesAdmin().prepareGetAliases("foo").get().getAliases().isEmpty());
|
||||||
assertFalse(indexExists("bar_bar"));
|
assertFalse(indexExists("bar_bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1261,61 +1251,57 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
final String alias = randomAlphaOfLength(7).toLowerCase(Locale.ROOT);
|
final String alias = randomAlphaOfLength(7).toLowerCase(Locale.ROOT);
|
||||||
createIndex(index1, index2);
|
createIndex(index1, index2);
|
||||||
|
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias)));
|
||||||
|
|
||||||
IllegalStateException ex = expectThrows(IllegalStateException.class, () -> {
|
IllegalStateException ex = expectThrows(IllegalStateException.class, () -> {
|
||||||
AcknowledgedResponse res = admin().indices()
|
AcknowledgedResponse res = indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(true))
|
.addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(true))
|
||||||
.get();
|
.get();
|
||||||
});
|
});
|
||||||
logger.error("exception: {}", ex.getMessage());
|
logger.error("exception: {}", ex.getMessage());
|
||||||
assertThat(ex.getMessage(), containsString("has is_hidden set to true on indices"));
|
assertThat(ex.getMessage(), containsString("has is_hidden set to true on indices"));
|
||||||
|
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.remove().index(index1).alias(alias)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.remove().index(index1).alias(alias)));
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(false)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(false)));
|
||||||
expectThrows(
|
expectThrows(
|
||||||
IllegalStateException.class,
|
IllegalStateException.class,
|
||||||
() -> admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(true)).get()
|
() -> indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(true)).get()
|
||||||
);
|
);
|
||||||
|
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.remove().index(index1).alias(alias)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.remove().index(index1).alias(alias)));
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(true)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(true)));
|
||||||
expectThrows(
|
expectThrows(
|
||||||
IllegalStateException.class,
|
IllegalStateException.class,
|
||||||
() -> admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(false)).get()
|
() -> indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(false)).get()
|
||||||
);
|
);
|
||||||
expectThrows(
|
expectThrows(
|
||||||
IllegalStateException.class,
|
IllegalStateException.class,
|
||||||
() -> admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias)).get()
|
() -> indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias)).get()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Both visible
|
// Both visible
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.remove().index(index1).alias(alias)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.remove().index(index1).alias(alias)));
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(false)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(false)));
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(false)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(false)));
|
||||||
|
|
||||||
// Both hidden
|
// Both hidden
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAliasAction(AliasActions.remove().index(index1).alias(alias))
|
.addAliasAction(AliasActions.remove().index(index1).alias(alias))
|
||||||
.addAliasAction(AliasActions.remove().index(index2).alias(alias))
|
.addAliasAction(AliasActions.remove().index(index2).alias(alias))
|
||||||
);
|
);
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(true)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(true)));
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(true)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(true)));
|
||||||
|
|
||||||
// Visible on one, then update it to hidden & add to a second as hidden simultaneously
|
// Visible on one, then update it to hidden & add to a second as hidden simultaneously
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAliasAction(AliasActions.remove().index(index1).alias(alias))
|
.addAliasAction(AliasActions.remove().index(index1).alias(alias))
|
||||||
.addAliasAction(AliasActions.remove().index(index2).alias(alias))
|
.addAliasAction(AliasActions.remove().index(index2).alias(alias))
|
||||||
);
|
);
|
||||||
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(false)));
|
assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(false)));
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(true))
|
.addAliasAction(AliasActions.add().index(index1).alias(alias).isHidden(true))
|
||||||
.addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(true))
|
.addAliasAction(AliasActions.add().index(index2).alias(alias).isHidden(true))
|
||||||
);
|
);
|
||||||
|
@ -1328,8 +1314,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
createIndex(writeIndex, nonWriteIndex);
|
createIndex(writeIndex, nonWriteIndex);
|
||||||
|
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAliasAction(AliasActions.add().index(writeIndex).alias(alias).isHidden(true).writeIndex(true))
|
.addAliasAction(AliasActions.add().index(writeIndex).alias(alias).isHidden(true).writeIndex(true))
|
||||||
.addAliasAction(AliasActions.add().index(nonWriteIndex).alias(alias).isHidden(true))
|
.addAliasAction(AliasActions.add().index(nonWriteIndex).alias(alias).isHidden(true))
|
||||||
);
|
);
|
||||||
|
@ -1384,7 +1369,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAliases() {
|
private void checkAliases() {
|
||||||
GetAliasesResponse getAliasesResponse = admin().indices().prepareGetAliases("alias1").get();
|
GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases("alias1").get();
|
||||||
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
|
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
|
||||||
AliasMetadata aliasMetadata = getAliasesResponse.getAliases().get("test").get(0);
|
AliasMetadata aliasMetadata = getAliasesResponse.getAliases().get("test").get(0);
|
||||||
assertThat(aliasMetadata.alias(), equalTo("alias1"));
|
assertThat(aliasMetadata.alias(), equalTo("alias1"));
|
||||||
|
@ -1393,7 +1378,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(aliasMetadata.searchRouting(), nullValue());
|
assertThat(aliasMetadata.searchRouting(), nullValue());
|
||||||
assertThat(aliasMetadata.isHidden(), nullValue());
|
assertThat(aliasMetadata.isHidden(), nullValue());
|
||||||
|
|
||||||
getAliasesResponse = admin().indices().prepareGetAliases("alias2").get();
|
getAliasesResponse = indicesAdmin().prepareGetAliases("alias2").get();
|
||||||
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
|
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
|
||||||
aliasMetadata = getAliasesResponse.getAliases().get("test").get(0);
|
aliasMetadata = getAliasesResponse.getAliases().get("test").get(0);
|
||||||
assertThat(aliasMetadata.alias(), equalTo("alias2"));
|
assertThat(aliasMetadata.alias(), equalTo("alias2"));
|
||||||
|
@ -1402,7 +1387,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(aliasMetadata.searchRouting(), nullValue());
|
assertThat(aliasMetadata.searchRouting(), nullValue());
|
||||||
assertThat(aliasMetadata.isHidden(), nullValue());
|
assertThat(aliasMetadata.isHidden(), nullValue());
|
||||||
|
|
||||||
getAliasesResponse = admin().indices().prepareGetAliases("alias3").get();
|
getAliasesResponse = indicesAdmin().prepareGetAliases("alias3").get();
|
||||||
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
|
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
|
||||||
aliasMetadata = getAliasesResponse.getAliases().get("test").get(0);
|
aliasMetadata = getAliasesResponse.getAliases().get("test").get(0);
|
||||||
assertThat(aliasMetadata.alias(), equalTo("alias3"));
|
assertThat(aliasMetadata.alias(), equalTo("alias3"));
|
||||||
|
@ -1411,7 +1396,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(aliasMetadata.searchRouting(), equalTo("search"));
|
assertThat(aliasMetadata.searchRouting(), equalTo("search"));
|
||||||
assertThat(aliasMetadata.isHidden(), nullValue());
|
assertThat(aliasMetadata.isHidden(), nullValue());
|
||||||
|
|
||||||
getAliasesResponse = admin().indices().prepareGetAliases("alias4").get();
|
getAliasesResponse = indicesAdmin().prepareGetAliases("alias4").get();
|
||||||
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
|
assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1));
|
||||||
aliasMetadata = getAliasesResponse.getAliases().get("test").get(0);
|
aliasMetadata = getAliasesResponse.getAliases().get("test").get(0);
|
||||||
assertThat(aliasMetadata.alias(), equalTo("alias4"));
|
assertThat(aliasMetadata.alias(), equalTo("alias4"));
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class NetNewSystemIndexAliasIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
GetAliasesRequest getAliasesRequest = new GetAliasesRequest();
|
GetAliasesRequest getAliasesRequest = new GetAliasesRequest();
|
||||||
GetAliasesResponse aliasResponse = client().admin().indices().getAliases(getAliasesRequest).get();
|
GetAliasesResponse aliasResponse = indicesAdmin().getAliases(getAliasesRequest).get();
|
||||||
assertThat(aliasResponse.getAliases().size(), is(0));
|
assertThat(aliasResponse.getAliases().size(), is(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class SystemIndexAliasIT extends ESIntegTestCase {
|
||||||
public void testCreateAliasForSystemIndex() throws Exception {
|
public void testCreateAliasForSystemIndex() throws Exception {
|
||||||
createIndex(PRIMARY_INDEX_NAME);
|
createIndex(PRIMARY_INDEX_NAME);
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
assertAcked(admin().indices().prepareAliases().addAlias(PRIMARY_INDEX_NAME, INDEX_NAME + "-system-alias"));
|
assertAcked(indicesAdmin().prepareAliases().addAlias(PRIMARY_INDEX_NAME, INDEX_NAME + "-system-alias"));
|
||||||
|
|
||||||
final GetAliasesResponse getAliasesResponse = indicesAdmin().getAliases(
|
final GetAliasesResponse getAliasesResponse = indicesAdmin().getAliases(
|
||||||
new GetAliasesRequest().indicesOptions(IndicesOptions.strictExpandHidden())
|
new GetAliasesRequest().indicesOptions(IndicesOptions.strictExpandHidden())
|
||||||
|
@ -51,6 +51,6 @@ public class SystemIndexAliasIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
getAliasesResponse.getAliases().get(PRIMARY_INDEX_NAME).forEach(alias -> assertThat(alias.isHidden(), is(true)));
|
getAliasesResponse.getAliases().get(PRIMARY_INDEX_NAME).forEach(alias -> assertThat(alias.isHidden(), is(true)));
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareDeleteTemplate("*").get());
|
assertAcked(indicesAdmin().prepareDeleteTemplate("*").get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class ClusterHealthIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
createIndex("index-2");
|
createIndex("index-2");
|
||||||
assertAcked(client().admin().indices().prepareClose("index-2"));
|
assertAcked(indicesAdmin().prepareClose("index-2"));
|
||||||
|
|
||||||
{
|
{
|
||||||
ClusterHealthResponse response = clusterAdmin().prepareHealth().setWaitForGreenStatus().get();
|
ClusterHealthResponse response = clusterAdmin().prepareHealth().setWaitForGreenStatus().get();
|
||||||
|
@ -152,7 +152,7 @@ public class ClusterHealthIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
createIndex("index-3", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 50).build());
|
createIndex("index-3", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 50).build());
|
||||||
assertAcked(client().admin().indices().prepareClose("index-3"));
|
assertAcked(indicesAdmin().prepareClose("index-3"));
|
||||||
|
|
||||||
{
|
{
|
||||||
ClusterHealthResponse response = clusterAdmin().prepareHealth()
|
ClusterHealthResponse response = clusterAdmin().prepareHealth()
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
assertAcked(client().admin().indices().prepareClose(indexName));
|
assertAcked(indicesAdmin().prepareClose(indexName));
|
||||||
}
|
}
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
InternalTestCluster internalTestCluster = internalCluster();
|
InternalTestCluster internalTestCluster = internalCluster();
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class DesiredNodesSnapshotsIT extends AbstractSnapshotIntegTestCase {
|
||||||
final var snapshotName = "snapshot";
|
final var snapshotName = "snapshot";
|
||||||
createFullSnapshot(repositoryName, snapshotName);
|
createFullSnapshot(repositoryName, snapshotName);
|
||||||
|
|
||||||
client().admin().indices().prepareDelete(indexName).get();
|
indicesAdmin().prepareDelete(indexName).get();
|
||||||
|
|
||||||
final var updateDesiredNodesWithNewHistoryRequest = randomUpdateDesiredNodesRequest();
|
final var updateDesiredNodesWithNewHistoryRequest = randomUpdateDesiredNodesRequest();
|
||||||
final var updateDesiredNodesResponse = updateDesiredNodes(updateDesiredNodesWithNewHistoryRequest);
|
final var updateDesiredNodesResponse = updateDesiredNodes(updateDesiredNodesWithNewHistoryRequest);
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||||
equalTo(false)
|
equalTo(false)
|
||||||
);
|
);
|
||||||
// flush for simpler debugging
|
// flush for simpler debugging
|
||||||
client().admin().indices().prepareFlush().execute().actionGet();
|
indicesAdmin().prepareFlush().execute().actionGet();
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
logger.info("--> verify we get the data back");
|
logger.info("--> verify we get the data back");
|
||||||
|
|
|
@ -183,7 +183,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
|
||||||
ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().get();
|
ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().get();
|
||||||
assertThat(clusterStateResponseUnfiltered.getState().metadata().templates().size(), is(greaterThanOrEqualTo(2)));
|
assertThat(clusterStateResponseUnfiltered.getState().metadata().templates().size(), is(greaterThanOrEqualTo(2)));
|
||||||
|
|
||||||
GetIndexTemplatesResponse getIndexTemplatesResponse = client().admin().indices().prepareGetTemplates("foo_template").get();
|
GetIndexTemplatesResponse getIndexTemplatesResponse = indicesAdmin().prepareGetTemplates("foo_template").get();
|
||||||
assertIndexTemplateExists(getIndexTemplatesResponse, "foo_template");
|
assertIndexTemplateExists(getIndexTemplatesResponse, "foo_template");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
|
||||||
.get()
|
.get()
|
||||||
);
|
);
|
||||||
ensureGreen(); // wait for green state, so its both green, and there are no more pending events
|
ensureGreen(); // wait for green state, so its both green, and there are no more pending events
|
||||||
MappingMetadata masterMappingMetadata = client().admin().indices().prepareGetMappings("test").get().getMappings().get("test");
|
MappingMetadata masterMappingMetadata = indicesAdmin().prepareGetMappings("test").get().getMappings().get("test");
|
||||||
for (Client client : clients()) {
|
for (Client client : clients()) {
|
||||||
MappingMetadata mappingMetadata = client.admin()
|
MappingMetadata mappingMetadata = client.admin()
|
||||||
.indices()
|
.indices()
|
||||||
|
@ -278,7 +278,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
|
||||||
ensureGreen("fuu");
|
ensureGreen("fuu");
|
||||||
|
|
||||||
// close one index
|
// close one index
|
||||||
assertAcked(client().admin().indices().close(new CloseIndexRequest("fuu")).get());
|
assertAcked(indicesAdmin().close(new CloseIndexRequest("fuu")).get());
|
||||||
clusterStateResponse = client().admin().cluster().prepareState().clear().setMetadata(true).setIndices("f*").get();
|
clusterStateResponse = client().admin().cluster().prepareState().clear().setMetadata(true).setIndices("f*").get();
|
||||||
assertThat(clusterStateResponse.getState().metadata().indices().size(), is(1));
|
assertThat(clusterStateResponse.getState().metadata().indices().size(), is(1));
|
||||||
assertThat(clusterStateResponse.getState().metadata().index("foo").getState(), equalTo(IndexMetadata.State.OPEN));
|
assertThat(clusterStateResponse.getState().metadata().index("foo").getState(), equalTo(IndexMetadata.State.OPEN));
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class SimpleDataNodesIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testIndexingBeforeAndAfterDataNodesStart() {
|
public void testIndexingBeforeAndAfterDataNodesStart() {
|
||||||
internalCluster().startNode(nonDataNode());
|
internalCluster().startNode(nonDataNode());
|
||||||
client().admin().indices().create(new CreateIndexRequest("test").waitForActiveShards(ActiveShardCount.NONE)).actionGet();
|
indicesAdmin().create(new CreateIndexRequest("test").waitForActiveShards(ActiveShardCount.NONE)).actionGet();
|
||||||
try {
|
try {
|
||||||
client().index(new IndexRequest("test").id("1").source(SOURCE, XContentType.JSON).timeout(timeValueSeconds(1))).actionGet();
|
client().index(new IndexRequest("test").id("1").source(SOURCE, XContentType.JSON).timeout(timeValueSeconds(1))).actionGet();
|
||||||
fail("no allocation should happen");
|
fail("no allocation should happen");
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
||||||
ensureGreen(index);
|
ensureGreen(index);
|
||||||
|
|
||||||
// close to have some unassigned started shards shards..
|
// close to have some unassigned started shards shards..
|
||||||
client().admin().indices().prepareClose(index).get();
|
indicesAdmin().prepareClose(index).get();
|
||||||
|
|
||||||
final String masterName = internalCluster().getMasterName();
|
final String masterName = internalCluster().getMasterName();
|
||||||
final ClusterService clusterService = internalCluster().clusterService(masterName);
|
final ClusterService clusterService = internalCluster().clusterService(masterName);
|
||||||
|
@ -192,7 +192,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
||||||
refresh();
|
refresh();
|
||||||
disruption.startDisrupting();
|
disruption.startDisrupting();
|
||||||
logger.info("--> delete index");
|
logger.info("--> delete index");
|
||||||
executeAndCancelCommittedPublication(client().admin().indices().prepareDelete("test").setTimeout("0s")).get(10, TimeUnit.SECONDS);
|
executeAndCancelCommittedPublication(indicesAdmin().prepareDelete("test").setTimeout("0s")).get(10, TimeUnit.SECONDS);
|
||||||
logger.info("--> and recreate it");
|
logger.info("--> and recreate it");
|
||||||
executeAndCancelCommittedPublication(
|
executeAndCancelCommittedPublication(
|
||||||
prepareCreate("test").setSettings(
|
prepareCreate("test").setSettings(
|
||||||
|
@ -262,12 +262,12 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// Add a new mapping...
|
// Add a new mapping...
|
||||||
ActionFuture<AcknowledgedResponse> putMappingResponse = executeAndCancelCommittedPublication(
|
ActionFuture<AcknowledgedResponse> putMappingResponse = executeAndCancelCommittedPublication(
|
||||||
client().admin().indices().preparePutMapping("index").setSource("field", "type=long")
|
indicesAdmin().preparePutMapping("index").setSource("field", "type=long")
|
||||||
);
|
);
|
||||||
|
|
||||||
// ...and wait for mappings to be available on master
|
// ...and wait for mappings to be available on master
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
MappingMetadata typeMappings = client().admin().indices().prepareGetMappings("index").get().getMappings().get("index");
|
MappingMetadata typeMappings = indicesAdmin().prepareGetMappings("index").get().getMappings().get("index");
|
||||||
assertNotNull(typeMappings);
|
assertNotNull(typeMappings);
|
||||||
Object properties;
|
Object properties;
|
||||||
try {
|
try {
|
||||||
|
@ -344,7 +344,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
||||||
internalCluster().setDisruptionScheme(disruption);
|
internalCluster().setDisruptionScheme(disruption);
|
||||||
disruption.startDisrupting();
|
disruption.startDisrupting();
|
||||||
final ActionFuture<AcknowledgedResponse> putMappingResponse = executeAndCancelCommittedPublication(
|
final ActionFuture<AcknowledgedResponse> putMappingResponse = executeAndCancelCommittedPublication(
|
||||||
client().admin().indices().preparePutMapping("index").setSource("field", "type=long")
|
indicesAdmin().preparePutMapping("index").setSource("field", "type=long")
|
||||||
);
|
);
|
||||||
|
|
||||||
final Index index = resolveIndex("index");
|
final Index index = resolveIndex("index");
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class RemoveCustomsCommandIT extends ESIntegTestCase {
|
||||||
internalCluster().setBootstrapMasterNodeIndex(0);
|
internalCluster().setBootstrapMasterNodeIndex(0);
|
||||||
String node = internalCluster().startNode();
|
String node = internalCluster().startNode();
|
||||||
createIndex("test");
|
createIndex("test");
|
||||||
client().admin().indices().prepareDelete("test").get();
|
indicesAdmin().prepareDelete("test").get();
|
||||||
assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
|
assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
|
||||||
Settings dataPathSettings = internalCluster().dataPathSettings(node);
|
Settings dataPathSettings = internalCluster().dataPathSettings(node);
|
||||||
ensureStableCluster(1);
|
ensureStableCluster(1);
|
||||||
|
@ -71,7 +71,7 @@ public class RemoveCustomsCommandIT extends ESIntegTestCase {
|
||||||
internalCluster().setBootstrapMasterNodeIndex(0);
|
internalCluster().setBootstrapMasterNodeIndex(0);
|
||||||
String node = internalCluster().startNode();
|
String node = internalCluster().startNode();
|
||||||
createIndex("test");
|
createIndex("test");
|
||||||
client().admin().indices().prepareDelete("test").get();
|
indicesAdmin().prepareDelete("test").get();
|
||||||
assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
|
assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
|
||||||
Settings dataPathSettings = internalCluster().dataPathSettings(node);
|
Settings dataPathSettings = internalCluster().dataPathSettings(node);
|
||||||
ensureStableCluster(1);
|
ensureStableCluster(1);
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
|
||||||
|
|
||||||
createIndex("test");
|
createIndex("test");
|
||||||
ensureSearchable("test");
|
ensureSearchable("test");
|
||||||
RecoveryResponse r = client().admin().indices().prepareRecoveries("test").get();
|
RecoveryResponse r = indicesAdmin().prepareRecoveries("test").get();
|
||||||
int numRecoveriesBeforeNewMaster = r.shardRecoveryStates().get("test").size();
|
int numRecoveriesBeforeNewMaster = r.shardRecoveryStates().get("test").size();
|
||||||
|
|
||||||
final String oldMaster = internalCluster().getMasterName();
|
final String oldMaster = internalCluster().getMasterName();
|
||||||
|
@ -56,7 +56,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
|
||||||
});
|
});
|
||||||
ensureSearchable("test");
|
ensureSearchable("test");
|
||||||
|
|
||||||
r = client().admin().indices().prepareRecoveries("test").get();
|
r = indicesAdmin().prepareRecoveries("test").get();
|
||||||
int numRecoveriesAfterNewMaster = r.shardRecoveryStates().get("test").size();
|
int numRecoveriesAfterNewMaster = r.shardRecoveryStates().get("test").size();
|
||||||
assertThat(numRecoveriesAfterNewMaster, equalTo(numRecoveriesBeforeNewMaster));
|
assertThat(numRecoveriesAfterNewMaster, equalTo(numRecoveriesBeforeNewMaster));
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class TemplateUpgradeServiceIT extends ESIntegTestCase {
|
||||||
// the updates only happen on cluster state updates, so we need to make sure that the cluster state updates are happening
|
// the updates only happen on cluster state updates, so we need to make sure that the cluster state updates are happening
|
||||||
// so we need to simulate updates to make sure the template upgrade kicks in
|
// so we need to simulate updates to make sure the template upgrade kicks in
|
||||||
updateClusterSettings(Settings.builder().put(TestPlugin.UPDATE_TEMPLATE_DUMMY_SETTING.getKey(), updateCount.incrementAndGet()));
|
updateClusterSettings(Settings.builder().put(TestPlugin.UPDATE_TEMPLATE_DUMMY_SETTING.getKey(), updateCount.incrementAndGet()));
|
||||||
List<IndexTemplateMetadata> templates = client().admin().indices().prepareGetTemplates("test_*").get().getIndexTemplates();
|
List<IndexTemplateMetadata> templates = indicesAdmin().prepareGetTemplates("test_*").get().getIndexTemplates();
|
||||||
assertThat(templates, hasSize(3));
|
assertThat(templates, hasSize(3));
|
||||||
boolean addedFound = false;
|
boolean addedFound = false;
|
||||||
boolean changedFound = false;
|
boolean changedFound = false;
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class DiskThresholdMonitorIT extends DiskUsageIntegTestCase {
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
// ensure we have a system index on the data node too.
|
// ensure we have a system index on the data node too.
|
||||||
assertAcked(client().admin().indices().prepareCreate(TaskResultsService.TASK_INDEX));
|
assertAcked(indicesAdmin().prepareCreate(TaskResultsService.TASK_INDEX));
|
||||||
|
|
||||||
getTestFileStore(dataNodeName).setTotalSpace(1L);
|
getTestFileStore(dataNodeName).setTotalSpace(1L);
|
||||||
refreshClusterInfo();
|
refreshClusterInfo();
|
||||||
|
@ -110,7 +110,7 @@ public class DiskThresholdMonitorIT extends DiskUsageIntegTestCase {
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
// ensure we have a system index on the data node too.
|
// ensure we have a system index on the data node too.
|
||||||
assertAcked(client().admin().indices().prepareCreate(TaskResultsService.TASK_INDEX));
|
assertAcked(indicesAdmin().prepareCreate(TaskResultsService.TASK_INDEX));
|
||||||
|
|
||||||
getTestFileStore(dataNodeName).setTotalSpace(1L);
|
getTestFileStore(dataNodeName).setTotalSpace(1L);
|
||||||
refreshClusterInfo();
|
refreshClusterInfo();
|
||||||
|
@ -143,7 +143,7 @@ public class DiskThresholdMonitorIT extends DiskUsageIntegTestCase {
|
||||||
|
|
||||||
// Retrieves the value of the given block on an index.
|
// Retrieves the value of the given block on an index.
|
||||||
private static String getIndexBlock(String indexName, String blockName) {
|
private static String getIndexBlock(String indexName, String blockName) {
|
||||||
return client().admin().indices().prepareGetSettings(indexName).setNames(blockName).get().getSetting(indexName, blockName);
|
return indicesAdmin().prepareGetSettings(indexName).setNames(blockName).get().getSetting(indexName, blockName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,7 +443,7 @@ public class MockDiskUsagesIT extends ESIntegTestCase {
|
||||||
assertThat("node2 has 2 shards", shardCountByNodeId.get(nodeIds.get(2)), equalTo(2));
|
assertThat("node2 has 2 shards", shardCountByNodeId.get(nodeIds.get(2)), equalTo(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
final long shardsOnGoodPath = Arrays.stream(client().admin().indices().prepareStats("test").get().getShards())
|
final long shardsOnGoodPath = Arrays.stream(indicesAdmin().prepareStats("test").get().getShards())
|
||||||
.filter(
|
.filter(
|
||||||
shardStats -> shardStats.getShardRouting().currentNodeId().equals(nodeWithTwoPaths)
|
shardStats -> shardStats.getShardRouting().currentNodeId().equals(nodeWithTwoPaths)
|
||||||
&& shardStats.getDataPath().startsWith(pathOverWatermark.toString()) == false
|
&& shardStats.getDataPath().startsWith(pathOverWatermark.toString()) == false
|
||||||
|
@ -468,20 +468,20 @@ public class MockDiskUsagesIT extends ESIntegTestCase {
|
||||||
logger.info("--> waiting for shards to relocate off path [{}]", pathOverWatermark);
|
logger.info("--> waiting for shards to relocate off path [{}]", pathOverWatermark);
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
for (final ShardStats shardStats : client().admin().indices().prepareStats("test").get().getShards()) {
|
for (final ShardStats shardStats : indicesAdmin().prepareStats("test").get().getShards()) {
|
||||||
assertThat(shardStats.getDataPath(), not(startsWith(pathOverWatermark.toString())));
|
assertThat(shardStats.getDataPath(), not(startsWith(pathOverWatermark.toString())));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ensureGreen("test");
|
ensureGreen("test");
|
||||||
|
|
||||||
for (final ShardStats shardStats : client().admin().indices().prepareStats("test").get().getShards()) {
|
for (final ShardStats shardStats : indicesAdmin().prepareStats("test").get().getShards()) {
|
||||||
assertThat(shardStats.getDataPath(), not(startsWith(pathOverWatermark.toString())));
|
assertThat(shardStats.getDataPath(), not(startsWith(pathOverWatermark.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
"should not have moved any shards off of the path that wasn't too full",
|
"should not have moved any shards off of the path that wasn't too full",
|
||||||
Arrays.stream(client().admin().indices().prepareStats("test").get().getShards())
|
Arrays.stream(indicesAdmin().prepareStats("test").get().getShards())
|
||||||
.filter(
|
.filter(
|
||||||
shardStats -> shardStats.getShardRouting().currentNodeId().equals(nodeWithTwoPaths)
|
shardStats -> shardStats.getShardRouting().currentNodeId().equals(nodeWithTwoPaths)
|
||||||
&& shardStats.getDataPath().startsWith(pathOverWatermark.toString()) == false
|
&& shardStats.getDataPath().startsWith(pathOverWatermark.toString()) == false
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class ClusterShardLimitIT extends ESIntegTestCase {
|
||||||
|
|
||||||
final IllegalArgumentException e = expectThrows(
|
final IllegalArgumentException e = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> client().admin().indices().prepareCreate("should-fail").get()
|
() -> indicesAdmin().prepareCreate("should-fail").get()
|
||||||
);
|
);
|
||||||
verifyException(dataNodes, counts, e);
|
verifyException(dataNodes, counts, e);
|
||||||
ClusterState clusterState = clusterAdmin().prepareState().get().getState();
|
ClusterState clusterState = clusterAdmin().prepareState().get().getState();
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class DiskDisruptionIT extends AbstractDisruptionTestCase {
|
||||||
final Thread globalCheckpointSampler = new Thread(() -> {
|
final Thread globalCheckpointSampler = new Thread(() -> {
|
||||||
while (stopGlobalCheckpointFetcher.get() == false) {
|
while (stopGlobalCheckpointFetcher.get() == false) {
|
||||||
try {
|
try {
|
||||||
for (ShardStats shardStats : client().admin().indices().prepareStats("test").clear().get().getShards()) {
|
for (ShardStats shardStats : indicesAdmin().prepareStats("test").clear().get().getShards()) {
|
||||||
final int shardId = shardStats.getShardRouting().id();
|
final int shardId = shardStats.getShardRouting().id();
|
||||||
final long globalCheckpoint = shardStats.getSeqNoStats().getGlobalCheckpoint();
|
final long globalCheckpoint = shardStats.getSeqNoStats().getGlobalCheckpoint();
|
||||||
shardToGcp.compute(shardId, (i, v) -> Math.max(v, globalCheckpoint));
|
shardToGcp.compute(shardId, (i, v) -> Math.max(v, globalCheckpoint));
|
||||||
|
@ -166,7 +166,7 @@ public class DiskDisruptionIT extends AbstractDisruptionTestCase {
|
||||||
logger.info("waiting for green");
|
logger.info("waiting for green");
|
||||||
ensureGreen("test");
|
ensureGreen("test");
|
||||||
|
|
||||||
for (ShardStats shardStats : client().admin().indices().prepareStats("test").clear().get().getShards()) {
|
for (ShardStats shardStats : indicesAdmin().prepareStats("test").clear().get().getShards()) {
|
||||||
final int shardId = shardStats.getShardRouting().id();
|
final int shardId = shardStats.getShardRouting().id();
|
||||||
final long maxSeqNo = shardStats.getSeqNoStats().getMaxSeqNo();
|
final long maxSeqNo = shardStats.getSeqNoStats().getMaxSeqNo();
|
||||||
if (shardStats.getShardRouting().active()) {
|
if (shardStats.getShardRouting().active()) {
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class MasterDisruptionIT extends AbstractDisruptionTestCase {
|
||||||
disruption.stopDisrupting();
|
disruption.stopDisrupting();
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
IndicesStatsResponse stats = client().admin().indices().prepareStats("test").clear().get();
|
IndicesStatsResponse stats = indicesAdmin().prepareStats("test").clear().get();
|
||||||
for (ShardStats shardStats : stats.getShards()) {
|
for (ShardStats shardStats : stats.getShards()) {
|
||||||
assertThat(
|
assertThat(
|
||||||
shardStats.getShardRouting().toString(),
|
shardStats.getShardRouting().toString(),
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class SnapshotDisruptionIT extends AbstractSnapshotIntegTestCase {
|
||||||
logger.info("--> done");
|
logger.info("--> done");
|
||||||
|
|
||||||
logger.info("--> recreate the index with potentially different shard counts");
|
logger.info("--> recreate the index with potentially different shard counts");
|
||||||
client().admin().indices().prepareDelete(idxName).get();
|
indicesAdmin().prepareDelete(idxName).get();
|
||||||
createIndex(idxName);
|
createIndex(idxName);
|
||||||
index(idxName, JsonXContent.contentBuilder().startObject().field("foo", "bar").endObject());
|
index(idxName, JsonXContent.contentBuilder().startObject().field("foo", "bar").endObject());
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class AliasedIndexDocumentActionsIT extends DocumentActionsIT {
|
||||||
protected void createIndex() {
|
protected void createIndex() {
|
||||||
logger.info("Creating index [test1] with alias [test]");
|
logger.info("Creating index [test1] with alias [test]");
|
||||||
try {
|
try {
|
||||||
client().admin().indices().prepareDelete("test1").execute().actionGet();
|
indicesAdmin().prepareDelete("test1").execute().actionGet();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class DocumentActionsIT extends ESIntegTestCase {
|
||||||
assertThat(deleteResponse.getIndex(), equalTo(getConcreteIndexName()));
|
assertThat(deleteResponse.getIndex(), equalTo(getConcreteIndexName()));
|
||||||
assertThat(deleteResponse.getId(), equalTo("1"));
|
assertThat(deleteResponse.getId(), equalTo("1"));
|
||||||
logger.info("Refreshing");
|
logger.info("Refreshing");
|
||||||
client().admin().indices().refresh(new RefreshRequest("test")).actionGet();
|
indicesAdmin().refresh(new RefreshRequest("test")).actionGet();
|
||||||
|
|
||||||
logger.info("Get [type1/1] (should be empty)");
|
logger.info("Get [type1/1] (should be empty)");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
@ -132,11 +132,11 @@ public class DocumentActionsIT extends ESIntegTestCase {
|
||||||
client().index(new IndexRequest("test").id("2").source(source("2", "test2"))).actionGet();
|
client().index(new IndexRequest("test").id("2").source(source("2", "test2"))).actionGet();
|
||||||
|
|
||||||
logger.info("Flushing");
|
logger.info("Flushing");
|
||||||
FlushResponse flushResult = client().admin().indices().prepareFlush("test").execute().actionGet();
|
FlushResponse flushResult = indicesAdmin().prepareFlush("test").execute().actionGet();
|
||||||
assertThat(flushResult.getSuccessfulShards(), equalTo(numShards.totalNumShards));
|
assertThat(flushResult.getSuccessfulShards(), equalTo(numShards.totalNumShards));
|
||||||
assertThat(flushResult.getFailedShards(), equalTo(0));
|
assertThat(flushResult.getFailedShards(), equalTo(0));
|
||||||
logger.info("Refreshing");
|
logger.info("Refreshing");
|
||||||
client().admin().indices().refresh(new RefreshRequest("test")).actionGet();
|
indicesAdmin().refresh(new RefreshRequest("test")).actionGet();
|
||||||
|
|
||||||
logger.info("Get [type1/1] and [type1/2]");
|
logger.info("Get [type1/1] and [type1/2]");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
@ -222,7 +222,7 @@ public class DocumentActionsIT extends ESIntegTestCase {
|
||||||
assertThat(bulkResponse.getItems()[5].getIndex(), equalTo(getConcreteIndexName()));
|
assertThat(bulkResponse.getItems()[5].getIndex(), equalTo(getConcreteIndexName()));
|
||||||
|
|
||||||
waitForRelocation(ClusterHealthStatus.GREEN);
|
waitForRelocation(ClusterHealthStatus.GREEN);
|
||||||
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().actionGet();
|
RefreshResponse refreshResponse = indicesAdmin().prepareRefresh("test").execute().actionGet();
|
||||||
assertNoFailures(refreshResponse);
|
assertNoFailures(refreshResponse);
|
||||||
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
|
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class ShardInfoIT extends ESIntegTestCase {
|
||||||
ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth("idx").setWaitForNoRelocatingShards(true).get();
|
ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth("idx").setWaitForNoRelocatingShards(true).get();
|
||||||
assertThat(healthResponse.isTimedOut(), equalTo(false));
|
assertThat(healthResponse.isTimedOut(), equalTo(false));
|
||||||
|
|
||||||
RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("idx").setActiveOnly(true).get();
|
RecoveryResponse recoveryResponse = indicesAdmin().prepareRecoveries("idx").setActiveOnly(true).get();
|
||||||
assertThat(recoveryResponse.shardRecoveryStates().get("idx").size(), equalTo(0));
|
assertThat(recoveryResponse.shardRecoveryStates().get("idx").size(), equalTo(0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
|
||||||
assertIndexInMetaState(masterNode, index);
|
assertIndexInMetaState(masterNode, index);
|
||||||
assertIndexDirectoryDeleted(masterNode, resolveIndex);
|
assertIndexDirectoryDeleted(masterNode, resolveIndex);
|
||||||
|
|
||||||
client().admin().indices().prepareDelete(index).get();
|
indicesAdmin().prepareDelete(index).get();
|
||||||
assertIndexDirectoryDeleted(node1, resolveIndex);
|
assertIndexDirectoryDeleted(node1, resolveIndex);
|
||||||
assertIndexDirectoryDeleted(node2, resolveIndex);
|
assertIndexDirectoryDeleted(node2, resolveIndex);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
|
||||||
assertIndexInMetaState(masterNode, index);
|
assertIndexInMetaState(masterNode, index);
|
||||||
|
|
||||||
logger.info("--> close index");
|
logger.info("--> close index");
|
||||||
client().admin().indices().prepareClose(index).get();
|
indicesAdmin().prepareClose(index).get();
|
||||||
// close the index
|
// close the index
|
||||||
ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get();
|
ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get();
|
||||||
assertThat(clusterStateResponse.getState().getMetadata().index(index).getState().name(), equalTo(IndexMetadata.State.CLOSE.name()));
|
assertThat(clusterStateResponse.getState().getMetadata().index(index).getState().name(), equalTo(IndexMetadata.State.CLOSE.name()));
|
||||||
|
@ -114,7 +114,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings(index).get();
|
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
|
||||||
assertNotNull(
|
assertNotNull(
|
||||||
((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("integer_field")
|
((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("integer_field")
|
||||||
);
|
);
|
||||||
|
@ -145,7 +145,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
getMappingsResponse = client().admin().indices().prepareGetMappings(index).get();
|
getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
|
||||||
assertNotNull(
|
assertNotNull(
|
||||||
((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("float_field")
|
((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("float_field")
|
||||||
);
|
);
|
||||||
|
@ -156,7 +156,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
|
||||||
assertThat(indicesMetadata.get(index).getState(), equalTo(IndexMetadata.State.CLOSE));
|
assertThat(indicesMetadata.get(index).getState(), equalTo(IndexMetadata.State.CLOSE));
|
||||||
|
|
||||||
// finally check that meta data is also written of index opened again
|
// finally check that meta data is also written of index opened again
|
||||||
assertAcked(client().admin().indices().prepareOpen(index).get());
|
assertAcked(indicesAdmin().prepareOpen(index).get());
|
||||||
// make sure index is fully initialized and nothing is changed anymore
|
// make sure index is fully initialized and nothing is changed anymore
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
indicesMetadata = getIndicesMetadataOnNode(dataNode);
|
indicesMetadata = getIndicesMetadataOnNode(dataNode);
|
||||||
|
|
|
@ -174,14 +174,14 @@ public class ReplicaShardAllocatorSyncIdIT extends ESIntegTestCase {
|
||||||
IntStream.range(0, between(100, 500)).mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v")).toList()
|
IntStream.range(0, between(100, 500)).mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v")).toList()
|
||||||
);
|
);
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
client().admin().indices().prepareFlush(indexName).get();
|
indicesAdmin().prepareFlush(indexName).get();
|
||||||
}
|
}
|
||||||
ensureGlobalCheckpointAdvancedAndSynced(indexName);
|
ensureGlobalCheckpointAdvancedAndSynced(indexName);
|
||||||
syncFlush(indexName);
|
syncFlush(indexName);
|
||||||
internalCluster().stopNode(nodeWithReplica);
|
internalCluster().stopNode(nodeWithReplica);
|
||||||
// Wait until the peer recovery retention leases of the offline node are expired
|
// Wait until the peer recovery retention leases of the offline node are expired
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
for (ShardStats shardStats : client().admin().indices().prepareStats(indexName).get().getShards()) {
|
for (ShardStats shardStats : indicesAdmin().prepareStats(indexName).get().getShards()) {
|
||||||
assertThat(shardStats.getRetentionLeaseStats().retentionLeases().leases(), hasSize(1));
|
assertThat(shardStats.getRetentionLeaseStats().retentionLeases().leases(), hasSize(1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -207,7 +207,7 @@ public class ReplicaShardAllocatorSyncIdIT extends ESIntegTestCase {
|
||||||
recoveryStarted.await();
|
recoveryStarted.await();
|
||||||
nodeWithReplica = internalCluster().startDataOnlyNode(nodeWithReplicaSettings);
|
nodeWithReplica = internalCluster().startDataOnlyNode(nodeWithReplicaSettings);
|
||||||
// AllocationService only calls GatewayAllocator if there are unassigned shards
|
// AllocationService only calls GatewayAllocator if there are unassigned shards
|
||||||
assertAcked(client().admin().indices().prepareCreate("dummy-index").setWaitForActiveShards(0));
|
assertAcked(indicesAdmin().prepareCreate("dummy-index").setWaitForActiveShards(0));
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
assertThat(internalCluster().nodesInclude(indexName), containsInAnyOrder(nodeWithPrimary, nodeWithReplica));
|
assertThat(internalCluster().nodesInclude(indexName), containsInAnyOrder(nodeWithPrimary, nodeWithReplica));
|
||||||
assertNoOpRecoveries(indexName);
|
assertNoOpRecoveries(indexName);
|
||||||
|
@ -239,7 +239,7 @@ public class ReplicaShardAllocatorSyncIdIT extends ESIntegTestCase {
|
||||||
IntStream.range(0, between(200, 500)).mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v")).toList()
|
IntStream.range(0, between(200, 500)).mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v")).toList()
|
||||||
);
|
);
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
client().admin().indices().prepareFlush(indexName).get();
|
indicesAdmin().prepareFlush(indexName).get();
|
||||||
}
|
}
|
||||||
ensureGlobalCheckpointAdvancedAndSynced(indexName);
|
ensureGlobalCheckpointAdvancedAndSynced(indexName);
|
||||||
syncFlush(indexName);
|
syncFlush(indexName);
|
||||||
|
@ -248,7 +248,7 @@ public class ReplicaShardAllocatorSyncIdIT extends ESIntegTestCase {
|
||||||
ensureYellow(indexName);
|
ensureYellow(indexName);
|
||||||
// Wait until the peer recovery retention leases of the offline node are expired
|
// Wait until the peer recovery retention leases of the offline node are expired
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
for (ShardStats shardStats : client().admin().indices().prepareStats(indexName).get().getShards()) {
|
for (ShardStats shardStats : indicesAdmin().prepareStats(indexName).get().getShards()) {
|
||||||
assertThat(shardStats.getRetentionLeaseStats().retentionLeases().leases(), hasSize(1));
|
assertThat(shardStats.getRetentionLeaseStats().retentionLeases().leases(), hasSize(1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -278,7 +278,7 @@ public class ReplicaShardAllocatorSyncIdIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
client().admin().indices().prepareFlush(indexName).get();
|
indicesAdmin().prepareFlush(indexName).get();
|
||||||
}
|
}
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
syncFlush(indexName);
|
syncFlush(indexName);
|
||||||
|
@ -311,7 +311,7 @@ public class ReplicaShardAllocatorSyncIdIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertNoOpRecoveries(String indexName) {
|
private void assertNoOpRecoveries(String indexName) {
|
||||||
for (RecoveryState recovery : client().admin().indices().prepareRecoveries(indexName).get().shardRecoveryStates().get(indexName)) {
|
for (RecoveryState recovery : indicesAdmin().prepareRecoveries(indexName).get().shardRecoveryStates().get(indexName)) {
|
||||||
if (recovery.getPrimary() == false) {
|
if (recovery.getPrimary() == false) {
|
||||||
assertThat(recovery.getIndex().fileDetails(), empty());
|
assertThat(recovery.getIndex().fileDetails(), empty());
|
||||||
assertThat(recovery.getTranslog().totalLocal(), equalTo(recovery.getTranslog().totalOperations()));
|
assertThat(recovery.getTranslog().totalLocal(), equalTo(recovery.getTranslog().totalOperations()));
|
||||||
|
|
|
@ -195,13 +195,13 @@ public class GetActionIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetWithAliasPointingToMultipleIndices() {
|
public void testGetWithAliasPointingToMultipleIndices() {
|
||||||
client().admin().indices().prepareCreate("index1").addAlias(new Alias("alias1").indexRouting("0")).get();
|
indicesAdmin().prepareCreate("index1").addAlias(new Alias("alias1").indexRouting("0")).get();
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
indicesAdmin().prepareCreate("index2")
|
indicesAdmin().prepareCreate("index2")
|
||||||
.addAlias(new Alias("alias1").indexRouting("0").writeIndex(randomFrom(false, null)))
|
.addAlias(new Alias("alias1").indexRouting("0").writeIndex(randomFrom(false, null)))
|
||||||
.get();
|
.get();
|
||||||
} else {
|
} else {
|
||||||
client().admin().indices().prepareCreate("index3").addAlias(new Alias("alias1").indexRouting("1").writeIndex(true)).get();
|
indicesAdmin().prepareCreate("index3").addAlias(new Alias("alias1").indexRouting("1").writeIndex(true)).get();
|
||||||
}
|
}
|
||||||
IndexResponse indexResponse = client().prepareIndex("index1").setId("id").setSource(Collections.singletonMap("foo", "bar")).get();
|
IndexResponse indexResponse = client().prepareIndex("index1").setId("id").setSource(Collections.singletonMap("foo", "bar")).get();
|
||||||
assertThat(indexResponse.status().getStatus(), equalTo(RestStatus.CREATED.getStatus()));
|
assertThat(indexResponse.status().getStatus(), equalTo(RestStatus.CREATED.getStatus()));
|
||||||
|
@ -646,7 +646,7 @@ public class GetActionIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
logger.info("flushing");
|
logger.info("flushing");
|
||||||
FlushResponse flushResponse = client().admin().indices().prepareFlush("my-index").setForce(true).get();
|
FlushResponse flushResponse = indicesAdmin().prepareFlush("my-index").setForce(true).get();
|
||||||
if (flushResponse.getSuccessfulShards() == 0) {
|
if (flushResponse.getSuccessfulShards() == 0) {
|
||||||
StringBuilder sb = new StringBuilder("failed to flush at least one shard. total shards [").append(
|
StringBuilder sb = new StringBuilder("failed to flush at least one shard. total shards [").append(
|
||||||
flushResponse.getTotalShards()
|
flushResponse.getTotalShards()
|
||||||
|
|
|
@ -335,15 +335,13 @@ public class FinalPipelineIT extends ESIntegTestCase {
|
||||||
final Settings defaultPipelineSettings = Settings.builder()
|
final Settings defaultPipelineSettings = Settings.builder()
|
||||||
.put(IndexSettings.DEFAULT_PIPELINE.getKey(), "default_pipeline")
|
.put(IndexSettings.DEFAULT_PIPELINE.getKey(), "default_pipeline")
|
||||||
.build();
|
.build();
|
||||||
admin().indices()
|
indicesAdmin().preparePutTemplate("default")
|
||||||
.preparePutTemplate("default")
|
|
||||||
.setPatterns(List.of("index*"))
|
.setPatterns(List.of("index*"))
|
||||||
.setOrder(defaultPipelineOrder)
|
.setOrder(defaultPipelineOrder)
|
||||||
.setSettings(defaultPipelineSettings)
|
.setSettings(defaultPipelineSettings)
|
||||||
.get();
|
.get();
|
||||||
final Settings finalPipelineSettings = Settings.builder().put(IndexSettings.FINAL_PIPELINE.getKey(), "final_pipeline").build();
|
final Settings finalPipelineSettings = Settings.builder().put(IndexSettings.FINAL_PIPELINE.getKey(), "final_pipeline").build();
|
||||||
admin().indices()
|
indicesAdmin().preparePutTemplate("final")
|
||||||
.preparePutTemplate("final")
|
|
||||||
.setPatterns(List.of("index*"))
|
.setPatterns(List.of("index*"))
|
||||||
.setOrder(finalPipelineOrder)
|
.setOrder(finalPipelineOrder)
|
||||||
.setSettings(finalPipelineSettings)
|
.setSettings(finalPipelineSettings)
|
||||||
|
@ -369,8 +367,7 @@ public class FinalPipelineIT extends ESIntegTestCase {
|
||||||
final Settings lowOrderFinalPipelineSettings = Settings.builder()
|
final Settings lowOrderFinalPipelineSettings = Settings.builder()
|
||||||
.put(IndexSettings.FINAL_PIPELINE.getKey(), "low_order_final_pipeline")
|
.put(IndexSettings.FINAL_PIPELINE.getKey(), "low_order_final_pipeline")
|
||||||
.build();
|
.build();
|
||||||
admin().indices()
|
indicesAdmin().preparePutTemplate("low_order")
|
||||||
.preparePutTemplate("low_order")
|
|
||||||
.setPatterns(List.of("index*"))
|
.setPatterns(List.of("index*"))
|
||||||
.setOrder(lowOrder)
|
.setOrder(lowOrder)
|
||||||
.setSettings(lowOrderFinalPipelineSettings)
|
.setSettings(lowOrderFinalPipelineSettings)
|
||||||
|
@ -378,8 +375,7 @@ public class FinalPipelineIT extends ESIntegTestCase {
|
||||||
final Settings highOrderFinalPipelineSettings = Settings.builder()
|
final Settings highOrderFinalPipelineSettings = Settings.builder()
|
||||||
.put(IndexSettings.FINAL_PIPELINE.getKey(), "high_order_final_pipeline")
|
.put(IndexSettings.FINAL_PIPELINE.getKey(), "high_order_final_pipeline")
|
||||||
.build();
|
.build();
|
||||||
admin().indices()
|
indicesAdmin().preparePutTemplate("high_order")
|
||||||
.preparePutTemplate("high_order")
|
|
||||||
.setPatterns(List.of("index*"))
|
.setPatterns(List.of("index*"))
|
||||||
.setOrder(highOrder)
|
.setOrder(highOrder)
|
||||||
.setSettings(highOrderFinalPipelineSettings)
|
.setSettings(highOrderFinalPipelineSettings)
|
||||||
|
|
|
@ -146,9 +146,7 @@ public class HiddenIndexIT extends ESIntegTestCase {
|
||||||
assertAcked(indicesAdmin().prepareCreate(hiddenIndex).setSettings(Settings.builder().put("index.hidden", true).build()).get());
|
assertAcked(indicesAdmin().prepareCreate(hiddenIndex).setSettings(Settings.builder().put("index.hidden", true).build()).get());
|
||||||
|
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases().addAliasAction(IndicesAliasesRequest.AliasActions.add().index(hiddenIndex).alias(visibleAlias))
|
||||||
.prepareAliases()
|
|
||||||
.addAliasAction(IndicesAliasesRequest.AliasActions.add().index(hiddenIndex).alias(visibleAlias))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// The index should be returned here when queried by name or by wildcard because the alias is visible
|
// The index should be returned here when queried by name or by wildcard because the alias is visible
|
||||||
|
@ -165,8 +163,7 @@ public class HiddenIndexIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// Now try with a hidden alias
|
// Now try with a hidden alias
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAliasAction(IndicesAliasesRequest.AliasActions.remove().index(hiddenIndex).alias(visibleAlias))
|
.addAliasAction(IndicesAliasesRequest.AliasActions.remove().index(hiddenIndex).alias(visibleAlias))
|
||||||
.addAliasAction(IndicesAliasesRequest.AliasActions.add().index(hiddenIndex).alias(hiddenAlias).isHidden(true))
|
.addAliasAction(IndicesAliasesRequest.AliasActions.add().index(hiddenIndex).alias(hiddenAlias).isHidden(true))
|
||||||
);
|
);
|
||||||
|
@ -189,8 +186,7 @@ public class HiddenIndexIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// Now try with a hidden alias that starts with a dot
|
// Now try with a hidden alias that starts with a dot
|
||||||
assertAcked(
|
assertAcked(
|
||||||
admin().indices()
|
indicesAdmin().prepareAliases()
|
||||||
.prepareAliases()
|
|
||||||
.addAliasAction(IndicesAliasesRequest.AliasActions.remove().index(hiddenIndex).alias(hiddenAlias))
|
.addAliasAction(IndicesAliasesRequest.AliasActions.remove().index(hiddenIndex).alias(hiddenAlias))
|
||||||
.addAliasAction(IndicesAliasesRequest.AliasActions.add().index(hiddenIndex).alias(dotHiddenAlias).isHidden(true))
|
.addAliasAction(IndicesAliasesRequest.AliasActions.add().index(hiddenIndex).alias(dotHiddenAlias).isHidden(true))
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class IndexSettingsIT extends ESIntegTestCase {
|
||||||
try {
|
try {
|
||||||
internalCluster().fullRestart();
|
internalCluster().fullRestart();
|
||||||
|
|
||||||
final var indicesClient = client().admin().indices();
|
final var indicesClient = indicesAdmin();
|
||||||
assertThat(indicesClient.prepareGetSettings("test").get().getSetting("test", "archived.index.test_setting"), equalTo("true"));
|
assertThat(indicesClient.prepareGetSettings("test").get().getSetting("test", "archived.index.test_setting"), equalTo("true"));
|
||||||
updateIndexSettings(Settings.builder().putNull("archived.*"), "test");
|
updateIndexSettings(Settings.builder().putNull("archived.*"), "test");
|
||||||
assertNull(indicesClient.prepareGetSettings("test").get().getSetting("test", "archived.index.test_setting"));
|
assertNull(indicesClient.prepareGetSettings("test").get().getSetting("test", "archived.index.test_setting"));
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class WaitUntilRefreshIT extends ESIntegTestCase {
|
||||||
.setRefreshPolicy(RefreshPolicy.WAIT_UNTIL)
|
.setRefreshPolicy(RefreshPolicy.WAIT_UNTIL)
|
||||||
.execute();
|
.execute();
|
||||||
while (false == index.isDone()) {
|
while (false == index.isDone()) {
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
}
|
}
|
||||||
assertEquals(RestStatus.CREATED, index.get().status());
|
assertEquals(RestStatus.CREATED, index.get().status());
|
||||||
assertFalse("request shouldn't have forced a refresh", index.get().forcedRefresh());
|
assertFalse("request shouldn't have forced a refresh", index.get().forcedRefresh());
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class InternalEngineMergeIT extends ESIntegTestCase {
|
||||||
BulkResponse response = request.execute().actionGet();
|
BulkResponse response = request.execute().actionGet();
|
||||||
refresh();
|
refresh();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
IndicesStatsResponse stats = client().admin().indices().prepareStats("test").setSegments(true).setMerge(true).get();
|
IndicesStatsResponse stats = indicesAdmin().prepareStats("test").setSegments(true).setMerge(true).get();
|
||||||
logger.info(
|
logger.info(
|
||||||
"index round [{}] - segments {}, total merges {}, current merge {}",
|
"index round [{}] - segments {}, total merges {}, current merge {}",
|
||||||
i,
|
i,
|
||||||
|
@ -56,7 +56,7 @@ public class InternalEngineMergeIT extends ESIntegTestCase {
|
||||||
final long upperNumberSegments = 2 * numOfShards * 10;
|
final long upperNumberSegments = 2 * numOfShards * 10;
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).setMerge(true).get();
|
IndicesStatsResponse stats = indicesAdmin().prepareStats().setSegments(true).setMerge(true).get();
|
||||||
logger.info(
|
logger.info(
|
||||||
"numshards {}, segments {}, total merges {}, current merge {}",
|
"numshards {}, segments {}, total merges {}, current merge {}",
|
||||||
numOfShards,
|
numOfShards,
|
||||||
|
@ -70,7 +70,7 @@ public class InternalEngineMergeIT extends ESIntegTestCase {
|
||||||
assertThat(current, equalTo(0L));
|
assertThat(current, equalTo(0L));
|
||||||
});
|
});
|
||||||
|
|
||||||
IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).setMerge(true).get();
|
IndicesStatsResponse stats = indicesAdmin().prepareStats().setSegments(true).setMerge(true).get();
|
||||||
logger.info(
|
logger.info(
|
||||||
"numshards {}, segments {}, total merges {}, current merge {}",
|
"numshards {}, segments {}, total merges {}, current merge {}",
|
||||||
numOfShards,
|
numOfShards,
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class MaxDocsLimitIT extends ESIntegTestCase {
|
||||||
() -> client().prepareDelete("test", "any-id").get()
|
() -> client().prepareDelete("test", "any-id").get()
|
||||||
);
|
);
|
||||||
assertThat(deleteError.getMessage(), containsString("Number of documents in the index can't exceed [" + maxDocs.get() + "]"));
|
assertThat(deleteError.getMessage(), containsString("Number of documents in the index can't exceed [" + maxDocs.get() + "]"));
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
SearchResponse searchResponse = client().prepareSearch("test")
|
SearchResponse searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(new MatchAllQueryBuilder())
|
.setQuery(new MatchAllQueryBuilder())
|
||||||
.setTrackTotalHitsUpTo(Integer.MAX_VALUE)
|
.setTrackTotalHitsUpTo(Integer.MAX_VALUE)
|
||||||
|
@ -116,7 +116,7 @@ public class MaxDocsLimitIT extends ESIntegTestCase {
|
||||||
ElasticsearchAssertions.assertNoFailures(searchResponse);
|
ElasticsearchAssertions.assertNoFailures(searchResponse);
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo((long) maxDocs.get()));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo((long) maxDocs.get()));
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
client().admin().indices().prepareFlush("test").get();
|
indicesAdmin().prepareFlush("test").get();
|
||||||
}
|
}
|
||||||
internalCluster().fullRestart();
|
internalCluster().fullRestart();
|
||||||
internalCluster().ensureAtLeastNumDataNodes(2);
|
internalCluster().ensureAtLeastNumDataNodes(2);
|
||||||
|
@ -132,13 +132,11 @@ public class MaxDocsLimitIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testMaxDocsLimitConcurrently() throws Exception {
|
public void testMaxDocsLimitConcurrently() throws Exception {
|
||||||
internalCluster().ensureAtLeastNumDataNodes(1);
|
internalCluster().ensureAtLeastNumDataNodes(1);
|
||||||
assertAcked(
|
assertAcked(indicesAdmin().prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)));
|
||||||
client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1))
|
|
||||||
);
|
|
||||||
IndexingResult indexingResult = indexDocs(between(maxDocs.get() + 1, maxDocs.get() * 2), between(2, 8));
|
IndexingResult indexingResult = indexDocs(between(maxDocs.get() + 1, maxDocs.get() * 2), between(2, 8));
|
||||||
assertThat(indexingResult.numFailures, greaterThan(0));
|
assertThat(indexingResult.numFailures, greaterThan(0));
|
||||||
assertThat(indexingResult.numSuccess, both(greaterThan(0)).and(lessThanOrEqualTo(maxDocs.get())));
|
assertThat(indexingResult.numSuccess, both(greaterThan(0)).and(lessThanOrEqualTo(maxDocs.get())));
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
SearchResponse searchResponse = client().prepareSearch("test")
|
SearchResponse searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(new MatchAllQueryBuilder())
|
.setQuery(new MatchAllQueryBuilder())
|
||||||
.setTrackTotalHitsUpTo(Integer.MAX_VALUE)
|
.setTrackTotalHitsUpTo(Integer.MAX_VALUE)
|
||||||
|
@ -156,7 +154,7 @@ public class MaxDocsLimitIT extends ESIntegTestCase {
|
||||||
indexingResult = indexDocs(between(1, 10), between(1, 8));
|
indexingResult = indexDocs(between(1, 10), between(1, 8));
|
||||||
assertThat(indexingResult.numSuccess, equalTo(0));
|
assertThat(indexingResult.numSuccess, equalTo(0));
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(new MatchAllQueryBuilder())
|
.setQuery(new MatchAllQueryBuilder())
|
||||||
.setTrackTotalHitsUpTo(Integer.MAX_VALUE)
|
.setTrackTotalHitsUpTo(Integer.MAX_VALUE)
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class FieldDataLoadingIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
client().prepareIndex("test").setId("1").setSource("name", "name").get();
|
client().prepareIndex("test").setId("1").setSource("name", "name").get();
|
||||||
client().admin().indices().prepareRefresh("test").get();
|
indicesAdmin().prepareRefresh("test").get();
|
||||||
|
|
||||||
ClusterStatsResponse response = clusterAdmin().prepareClusterStats().get();
|
ClusterStatsResponse response = clusterAdmin().prepareClusterStats().get();
|
||||||
assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L));
|
assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L));
|
||||||
|
|
|
@ -26,14 +26,14 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class CopyToMapperIntegrationIT extends ESIntegTestCase {
|
public class CopyToMapperIntegrationIT extends ESIntegTestCase {
|
||||||
public void testDynamicTemplateCopyTo() throws Exception {
|
public void testDynamicTemplateCopyTo() throws Exception {
|
||||||
assertAcked(client().admin().indices().prepareCreate("test-idx").setMapping(createDynamicTemplateMapping()));
|
assertAcked(indicesAdmin().prepareCreate("test-idx").setMapping(createDynamicTemplateMapping()));
|
||||||
|
|
||||||
int recordCount = between(1, 200);
|
int recordCount = between(1, 200);
|
||||||
|
|
||||||
for (int i = 0; i < recordCount * 2; i++) {
|
for (int i = 0; i < recordCount * 2; i++) {
|
||||||
client().prepareIndex("test-idx").setId(Integer.toString(i)).setSource("test_field", "test " + i, "even", i % 2 == 0).get();
|
client().prepareIndex("test-idx").setId(Integer.toString(i)).setSource("test_field", "test " + i, "even", i % 2 == 0).get();
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareRefresh("test-idx").execute().actionGet();
|
indicesAdmin().prepareRefresh("test-idx").execute().actionGet();
|
||||||
|
|
||||||
SubAggCollectionMode aggCollectionMode = randomFrom(SubAggCollectionMode.values());
|
SubAggCollectionMode aggCollectionMode = randomFrom(SubAggCollectionMode.values());
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ public class CopyToMapperIntegrationIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
);
|
);
|
||||||
assertAcked(client().admin().indices().prepareCreate("test-idx").setMapping(mapping));
|
assertAcked(indicesAdmin().prepareCreate("test-idx").setMapping(mapping));
|
||||||
client().prepareIndex("test-idx").setId("1").setSource("foo", "bar").get();
|
client().prepareIndex("test-idx").setId("1").setSource("foo", "bar").get();
|
||||||
client().admin().indices().prepareRefresh("test-idx").execute().actionGet();
|
indicesAdmin().prepareRefresh("test-idx").execute().actionGet();
|
||||||
SearchResponse response = client().prepareSearch("test-idx").setQuery(QueryBuilders.termQuery("root.top.child", "bar")).get();
|
SearchResponse response = client().prepareSearch("test-idx").setQuery(QueryBuilders.termQuery("root.top.child", "bar")).get();
|
||||||
assertThat(response.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(response.getHits().getTotalHits().value, equalTo(1L));
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,9 @@ import static org.hamcrest.Matchers.nullValue;
|
||||||
public class MultiFieldsIntegrationIT extends ESIntegTestCase {
|
public class MultiFieldsIntegrationIT extends ESIntegTestCase {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testMultiFields() throws Exception {
|
public void testMultiFields() throws Exception {
|
||||||
assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createTypeSource()));
|
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createTypeSource()));
|
||||||
|
|
||||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
|
||||||
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||||
assertThat(mappingMetadata, not(nullValue()));
|
assertThat(mappingMetadata, not(nullValue()));
|
||||||
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
|
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
|
||||||
|
@ -52,9 +52,9 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
|
||||||
searchResponse = client().prepareSearch("my-index").setQuery(matchQuery("title.not_analyzed", "Multi fields")).get();
|
searchResponse = client().prepareSearch("my-index").setQuery(matchQuery("title.not_analyzed", "Multi fields")).get();
|
||||||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||||
|
|
||||||
assertAcked(client().admin().indices().preparePutMapping("my-index").setSource(createPutMappingSource()));
|
assertAcked(indicesAdmin().preparePutMapping("my-index").setSource(createPutMappingSource()));
|
||||||
|
|
||||||
getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
|
||||||
mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||||
assertThat(mappingMetadata, not(nullValue()));
|
assertThat(mappingMetadata, not(nullValue()));
|
||||||
mappingSource = mappingMetadata.sourceAsMap();
|
mappingSource = mappingMetadata.sourceAsMap();
|
||||||
|
@ -74,9 +74,9 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testGeoPointMultiField() throws Exception {
|
public void testGeoPointMultiField() throws Exception {
|
||||||
assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("geo_point")));
|
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("geo_point")));
|
||||||
|
|
||||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
|
||||||
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||||
assertThat(mappingMetadata, not(nullValue()));
|
assertThat(mappingMetadata, not(nullValue()));
|
||||||
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
|
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
|
||||||
|
@ -103,9 +103,9 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testCompletionMultiField() throws Exception {
|
public void testCompletionMultiField() throws Exception {
|
||||||
assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("completion")));
|
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("completion")));
|
||||||
|
|
||||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
|
||||||
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||||
assertThat(mappingMetadata, not(nullValue()));
|
assertThat(mappingMetadata, not(nullValue()));
|
||||||
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
|
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
|
||||||
|
@ -125,9 +125,9 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testIpMultiField() throws Exception {
|
public void testIpMultiField() throws Exception {
|
||||||
assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("ip")));
|
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("ip")));
|
||||||
|
|
||||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
|
||||||
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||||
assertThat(mappingMetadata, not(nullValue()));
|
assertThat(mappingMetadata, not(nullValue()));
|
||||||
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
|
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class GlobalCheckpointSyncIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
SeqNoStats seqNoStats = client().admin().indices().prepareStats("test").get().getIndex("test").getShards()[0].getSeqNoStats();
|
SeqNoStats seqNoStats = indicesAdmin().prepareStats("test").get().getIndex("test").getShards()[0].getSeqNoStats();
|
||||||
assertThat(seqNoStats.getGlobalCheckpoint(), equalTo(seqNoStats.getMaxSeqNo()));
|
assertThat(seqNoStats.getGlobalCheckpoint(), equalTo(seqNoStats.getMaxSeqNo()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class PeerRecoveryRetentionLeaseCreationIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RetentionLeases getRetentionLeases() {
|
public RetentionLeases getRetentionLeases() {
|
||||||
return client().admin().indices().prepareStats(INDEX_NAME).get().getShards()[0].getRetentionLeaseStats().retentionLeases();
|
return indicesAdmin().prepareStats(INDEX_NAME).get().getShards()[0].getRetentionLeaseStats().retentionLeases();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,25 +200,17 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDurability(IndexShard shard, Translog.Durability durability) {
|
private void setDurability(IndexShard shard, Translog.Durability durability) {
|
||||||
client().admin()
|
indicesAdmin().prepareUpdateSettings(shard.shardId().getIndexName())
|
||||||
.indices()
|
|
||||||
.prepareUpdateSettings(shard.shardId().getIndexName())
|
|
||||||
.setSettings(Settings.builder().put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), durability.name()).build())
|
.setSettings(Settings.builder().put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), durability.name()).build())
|
||||||
.get();
|
.get();
|
||||||
assertEquals(durability, shard.getTranslogDurability());
|
assertEquals(durability, shard.getTranslogDurability());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdatePriority() {
|
public void testUpdatePriority() {
|
||||||
assertAcked(
|
assertAcked(indicesAdmin().prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_PRIORITY, 200)));
|
||||||
client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_PRIORITY, 200))
|
|
||||||
);
|
|
||||||
IndexService indexService = getInstanceFromNode(IndicesService.class).indexService(resolveIndex("test"));
|
IndexService indexService = getInstanceFromNode(IndicesService.class).indexService(resolveIndex("test"));
|
||||||
assertEquals(200, indexService.getIndexSettings().getSettings().getAsInt(IndexMetadata.SETTING_PRIORITY, 0).intValue());
|
assertEquals(200, indexService.getIndexSettings().getSettings().getAsInt(IndexMetadata.SETTING_PRIORITY, 0).intValue());
|
||||||
client().admin()
|
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_PRIORITY, 400).build()).get();
|
||||||
.indices()
|
|
||||||
.prepareUpdateSettings("test")
|
|
||||||
.setSettings(Settings.builder().put(IndexMetadata.SETTING_PRIORITY, 400).build())
|
|
||||||
.get();
|
|
||||||
assertEquals(400, indexService.getIndexSettings().getSettings().getAsInt(IndexMetadata.SETTING_PRIORITY, 0).intValue());
|
assertEquals(400, indexService.getIndexSettings().getSettings().getAsInt(IndexMetadata.SETTING_PRIORITY, 0).intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,13 +224,13 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get();
|
client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get();
|
||||||
SearchResponse response = client().prepareSearch("test").get();
|
SearchResponse response = client().prepareSearch("test").get();
|
||||||
assertHitCount(response, 1L);
|
assertHitCount(response, 1L);
|
||||||
client().admin().indices().prepareDelete("test").get();
|
indicesAdmin().prepareDelete("test").get();
|
||||||
assertAllIndicesRemovedAndDeletionCompleted(Collections.singleton(getInstanceFromNode(IndicesService.class)));
|
assertAllIndicesRemovedAndDeletionCompleted(Collections.singleton(getInstanceFromNode(IndicesService.class)));
|
||||||
assertPathHasBeenCleared(idxPath);
|
assertPathHasBeenCleared(idxPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExpectedShardSizeIsPresent() throws InterruptedException {
|
public void testExpectedShardSizeIsPresent() throws InterruptedException {
|
||||||
assertAcked(client().admin().indices().prepareCreate("test").setSettings(indexSettings(1, 0)));
|
assertAcked(indicesAdmin().prepareCreate("test").setSettings(indexSettings(1, 0)));
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
client().prepareIndex("test").setSource("{}", XContentType.JSON).get();
|
client().prepareIndex("test").setSource("{}", XContentType.JSON).get();
|
||||||
}
|
}
|
||||||
|
@ -269,9 +261,9 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
assertHitCount(client().prepareSearch(index).setSize(0).get(), 1L);
|
assertHitCount(client().prepareSearch(index).setSize(0).get(), 1L);
|
||||||
|
|
||||||
logger.info("--> closing the index [{}]", index);
|
logger.info("--> closing the index [{}]", index);
|
||||||
assertAcked(client().admin().indices().prepareClose(index));
|
assertAcked(indicesAdmin().prepareClose(index));
|
||||||
logger.info("--> index closed, re-opening...");
|
logger.info("--> index closed, re-opening...");
|
||||||
assertAcked(client().admin().indices().prepareOpen(index));
|
assertAcked(indicesAdmin().prepareOpen(index));
|
||||||
logger.info("--> index re-opened");
|
logger.info("--> index re-opened");
|
||||||
ensureGreen(index);
|
ensureGreen(index);
|
||||||
|
|
||||||
|
@ -279,7 +271,7 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
// Now, try closing and changing the settings
|
// Now, try closing and changing the settings
|
||||||
logger.info("--> closing the index [{}] before updating data_path", index);
|
logger.info("--> closing the index [{}] before updating data_path", index);
|
||||||
assertAcked(client().admin().indices().prepareClose(index));
|
assertAcked(indicesAdmin().prepareClose(index));
|
||||||
|
|
||||||
final Path newIndexDataPath = sharedDataPath.resolve("end-" + randomAlphaOfLength(10));
|
final Path newIndexDataPath = sharedDataPath.resolve("end-" + randomAlphaOfLength(10));
|
||||||
IOUtils.rm(newIndexDataPath);
|
IOUtils.rm(newIndexDataPath);
|
||||||
|
@ -301,21 +293,19 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
logger.info("--> updating data_path to [{}] for index [{}]", newIndexDataPath, index);
|
logger.info("--> updating data_path to [{}] for index [{}]", newIndexDataPath, index);
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client().admin()
|
indicesAdmin().prepareUpdateSettings(index)
|
||||||
.indices()
|
|
||||||
.prepareUpdateSettings(index)
|
|
||||||
.setSettings(Settings.builder().put(IndexMetadata.SETTING_DATA_PATH, newIndexDataPath.toAbsolutePath().toString()).build())
|
.setSettings(Settings.builder().put(IndexMetadata.SETTING_DATA_PATH, newIndexDataPath.toAbsolutePath().toString()).build())
|
||||||
.setIndicesOptions(IndicesOptions.fromOptions(true, false, true, true))
|
.setIndicesOptions(IndicesOptions.fromOptions(true, false, true, true))
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.info("--> settings updated and files moved, re-opening index");
|
logger.info("--> settings updated and files moved, re-opening index");
|
||||||
assertAcked(client().admin().indices().prepareOpen(index));
|
assertAcked(indicesAdmin().prepareOpen(index));
|
||||||
logger.info("--> index re-opened");
|
logger.info("--> index re-opened");
|
||||||
ensureGreen(index);
|
ensureGreen(index);
|
||||||
|
|
||||||
assertHitCount(client().prepareSearch(index).setSize(0).get(), 1L);
|
assertHitCount(client().prepareSearch(index).setSize(0).get(), 1L);
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareDelete(index));
|
assertAcked(indicesAdmin().prepareDelete(index));
|
||||||
assertAllIndicesRemovedAndDeletionCompleted(Collections.singleton(getInstanceFromNode(IndicesService.class)));
|
assertAllIndicesRemovedAndDeletionCompleted(Collections.singleton(getInstanceFromNode(IndicesService.class)));
|
||||||
assertPathHasBeenCleared(newIndexDataPath.toAbsolutePath());
|
assertPathHasBeenCleared(newIndexDataPath.toAbsolutePath());
|
||||||
}
|
}
|
||||||
|
@ -330,9 +320,7 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
IndexService test = indicesService.indexService(resolveIndex("test"));
|
IndexService test = indicesService.indexService(resolveIndex("test"));
|
||||||
IndexShard shard = test.getShardOrNull(0);
|
IndexShard shard = test.getShardOrNull(0);
|
||||||
assertFalse(shard.shouldPeriodicallyFlush());
|
assertFalse(shard.shouldPeriodicallyFlush());
|
||||||
client().admin()
|
indicesAdmin().prepareUpdateSettings("test")
|
||||||
.indices()
|
|
||||||
.prepareUpdateSettings("test")
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
Settings.builder()
|
Settings.builder()
|
||||||
.put(
|
.put(
|
||||||
|
@ -382,9 +370,7 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
translog.stats().getUncommittedOperations(),
|
translog.stats().getUncommittedOperations(),
|
||||||
translog.getGeneration()
|
translog.getGeneration()
|
||||||
);
|
);
|
||||||
client().admin()
|
indicesAdmin().prepareUpdateSettings("test")
|
||||||
.indices()
|
|
||||||
.prepareUpdateSettings("test")
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
Settings.builder()
|
Settings.builder()
|
||||||
.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(size, ByteSizeUnit.BYTES))
|
.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(size, ByteSizeUnit.BYTES))
|
||||||
|
@ -469,7 +455,7 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
// size of the operation plus header and footer
|
// size of the operation plus header and footer
|
||||||
settings = Settings.builder().put("index.translog.generation_threshold_size", "117b").build();
|
settings = Settings.builder().put("index.translog.generation_threshold_size", "117b").build();
|
||||||
}
|
}
|
||||||
client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
|
indicesAdmin().prepareUpdateSettings("test").setSettings(settings).get();
|
||||||
client().prepareIndex("test")
|
client().prepareIndex("test")
|
||||||
.setId("0")
|
.setId("0")
|
||||||
.setSource("{}", XContentType.JSON)
|
.setSource("{}", XContentType.JSON)
|
||||||
|
@ -540,23 +526,23 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
final IndexService indexService = createIndex("test");
|
final IndexService indexService = createIndex("test");
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
Settings settings = Settings.builder().put("index.translog.flush_threshold_size", "" + between(200, 300) + "b").build();
|
Settings settings = Settings.builder().put("index.translog.flush_threshold_size", "" + between(200, 300) + "b").build();
|
||||||
client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
|
indicesAdmin().prepareUpdateSettings("test").setSettings(settings).get();
|
||||||
final int numDocs = between(10, 100);
|
final int numDocs = between(10, 100);
|
||||||
for (int i = 0; i < numDocs; i++) {
|
for (int i = 0; i < numDocs; i++) {
|
||||||
client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get();
|
client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get();
|
||||||
}
|
}
|
||||||
// A flush stats may include the new total count but the old period count - assert eventually.
|
// A flush stats may include the new total count but the old period count - assert eventually.
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
final FlushStats flushStats = client().admin().indices().prepareStats("test").clear().setFlush(true).get().getTotal().flush;
|
final FlushStats flushStats = indicesAdmin().prepareStats("test").clear().setFlush(true).get().getTotal().flush;
|
||||||
assertThat(flushStats.getPeriodic(), allOf(equalTo(flushStats.getTotal()), greaterThan(0L)));
|
assertThat(flushStats.getPeriodic(), allOf(equalTo(flushStats.getTotal()), greaterThan(0L)));
|
||||||
});
|
});
|
||||||
assertBusy(() -> assertThat(indexService.getShard(0).shouldPeriodicallyFlush(), equalTo(false)));
|
assertBusy(() -> assertThat(indexService.getShard(0).shouldPeriodicallyFlush(), equalTo(false)));
|
||||||
settings = Settings.builder().put("index.translog.flush_threshold_size", (String) null).build();
|
settings = Settings.builder().put("index.translog.flush_threshold_size", (String) null).build();
|
||||||
client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
|
indicesAdmin().prepareUpdateSettings("test").setSettings(settings).get();
|
||||||
|
|
||||||
client().prepareIndex("test").setId(UUIDs.randomBase64UUID()).setSource("{}", XContentType.JSON).get();
|
client().prepareIndex("test").setId(UUIDs.randomBase64UUID()).setSource("{}", XContentType.JSON).get();
|
||||||
client().admin().indices().prepareFlush("test").setForce(randomBoolean()).setWaitIfOngoing(true).get();
|
indicesAdmin().prepareFlush("test").setForce(randomBoolean()).setWaitIfOngoing(true).get();
|
||||||
final FlushStats flushStats = client().admin().indices().prepareStats("test").clear().setFlush(true).get().getTotal().flush;
|
final FlushStats flushStats = indicesAdmin().prepareStats("test").clear().setFlush(true).get().getTotal().flush;
|
||||||
assertThat(flushStats.getTotal(), greaterThan(flushStats.getPeriodic()));
|
assertThat(flushStats.getTotal(), greaterThan(flushStats.getPeriodic()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,7 +743,7 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
||||||
createIndex(indexName, indexSettings(1, 0).build());
|
createIndex(indexName, indexSettings(1, 0).build());
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareClose(indexName));
|
assertAcked(indicesAdmin().prepareClose(indexName));
|
||||||
|
|
||||||
final ClusterService clusterService = getInstanceFromNode(ClusterService.class);
|
final ClusterService clusterService = getInstanceFromNode(ClusterService.class);
|
||||||
final ClusterState clusterState = clusterService.state();
|
final ClusterState clusterState = clusterService.state();
|
||||||
|
|
|
@ -433,7 +433,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {
|
||||||
SearchRequestBuilder q = client().prepareSearch(indexName).setPreference("_only_nodes:" + node).setQuery(matchAllQuery());
|
SearchRequestBuilder q = client().prepareSearch(indexName).setPreference("_only_nodes:" + node).setQuery(matchAllQuery());
|
||||||
assertHitCount(q.get(), numDocsToKeep);
|
assertHitCount(q.get(), numDocsToKeep);
|
||||||
}
|
}
|
||||||
final RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries(indexName).setActiveOnly(false).get();
|
final RecoveryResponse recoveryResponse = indicesAdmin().prepareRecoveries(indexName).setActiveOnly(false).get();
|
||||||
final RecoveryState replicaRecoveryState = recoveryResponse.shardRecoveryStates()
|
final RecoveryState replicaRecoveryState = recoveryResponse.shardRecoveryStates()
|
||||||
.get(indexName)
|
.get(indexName)
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -540,7 +540,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries(indexName).setActiveOnly(false).get();
|
final RecoveryResponse recoveryResponse = indicesAdmin().prepareRecoveries(indexName).setActiveOnly(false).get();
|
||||||
final RecoveryState replicaRecoveryState = recoveryResponse.shardRecoveryStates()
|
final RecoveryState replicaRecoveryState = recoveryResponse.shardRecoveryStates()
|
||||||
.get(indexName)
|
.get(indexName)
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -651,7 +651,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SeqNoStats getSeqNoStats(String index, int shardId) {
|
private SeqNoStats getSeqNoStats(String index, int shardId) {
|
||||||
final ShardStats[] shardStats = client().admin().indices().prepareStats(index).get().getIndices().get(index).getShards();
|
final ShardStats[] shardStats = indicesAdmin().prepareStats(index).get().getIndices().get(index).getShards();
|
||||||
return shardStats[shardId].getSeqNoStats();
|
return shardStats[shardId].getSeqNoStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
indexingDone.await();
|
indexingDone.await();
|
||||||
t.join();
|
t.join();
|
||||||
final IndicesStatsResponse statsResponse = client().admin().indices().stats(new IndicesStatsRequest()).actionGet();
|
final IndicesStatsResponse statsResponse = indicesAdmin().stats(new IndicesStatsRequest()).actionGet();
|
||||||
for (ShardStats shardStats : statsResponse.getShards()) {
|
for (ShardStats shardStats : statsResponse.getShards()) {
|
||||||
if (randomTimeValue != null && shardStats.isSearchIdle()) {
|
if (randomTimeValue != null && shardStats.isSearchIdle()) {
|
||||||
assertTrue(shardStats.getSearchIdleTime() >= randomTimeValue.millis());
|
assertTrue(shardStats.getSearchIdleTime() >= randomTimeValue.millis());
|
||||||
|
@ -163,7 +163,7 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
assertTrue(shard.isSearchIdle());
|
assertTrue(shard.isSearchIdle());
|
||||||
CountDownLatch refreshLatch = new CountDownLatch(1);
|
CountDownLatch refreshLatch = new CountDownLatch(1);
|
||||||
// async on purpose to make sure it happens concurrently
|
// async on purpose to make sure it happens concurrently
|
||||||
client().admin().indices().prepareRefresh().execute(ActionListener.running(refreshLatch::countDown));
|
indicesAdmin().prepareRefresh().execute(ActionListener.running(refreshLatch::countDown));
|
||||||
assertHitCount(client().prepareSearch().get(), 1);
|
assertHitCount(client().prepareSearch().get(), 1);
|
||||||
client().prepareIndex("test").setId("1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
|
client().prepareIndex("test").setId("1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
|
||||||
scheduleRefresh(shard, false);
|
scheduleRefresh(shard, false);
|
||||||
|
@ -171,9 +171,7 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
// now disable background refresh and make sure the refresh happens
|
// now disable background refresh and make sure the refresh happens
|
||||||
CountDownLatch updateSettingsLatch = new CountDownLatch(1);
|
CountDownLatch updateSettingsLatch = new CountDownLatch(1);
|
||||||
client().admin()
|
indicesAdmin().prepareUpdateSettings("test")
|
||||||
.indices()
|
|
||||||
.prepareUpdateSettings("test")
|
|
||||||
.setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), -1).build())
|
.setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), -1).build())
|
||||||
.execute(ActionListener.running(updateSettingsLatch::countDown));
|
.execute(ActionListener.running(updateSettingsLatch::countDown));
|
||||||
assertHitCount(client().prepareSearch().get(), 2);
|
assertHitCount(client().prepareSearch().get(), 2);
|
||||||
|
@ -189,7 +187,7 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
assertFalse(shard.hasRefreshPending());
|
assertFalse(shard.hasRefreshPending());
|
||||||
assertTrue(shard.isSearchIdle());
|
assertTrue(shard.isSearchIdle());
|
||||||
assertHitCount(client().prepareSearch().get(), 3);
|
assertHitCount(client().prepareSearch().get(), 3);
|
||||||
final IndicesStatsResponse statsResponse = client().admin().indices().stats(new IndicesStatsRequest()).actionGet();
|
final IndicesStatsResponse statsResponse = indicesAdmin().stats(new IndicesStatsRequest()).actionGet();
|
||||||
for (ShardStats shardStats : statsResponse.getShards()) {
|
for (ShardStats shardStats : statsResponse.getShards()) {
|
||||||
if (shardStats.isSearchIdle()) {
|
if (shardStats.isSearchIdle()) {
|
||||||
assertTrue(shardStats.getSearchIdleTime() >= TimeValue.ZERO.millis());
|
assertTrue(shardStats.getSearchIdleTime() >= TimeValue.ZERO.millis());
|
||||||
|
@ -219,9 +217,7 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
public void testSearchIdleStats() throws InterruptedException {
|
public void testSearchIdleStats() throws InterruptedException {
|
||||||
int searchIdleAfter = randomIntBetween(2, 5);
|
int searchIdleAfter = randomIntBetween(2, 5);
|
||||||
final String indexName = randomAlphaOfLength(5).toLowerCase(Locale.ROOT);
|
final String indexName = randomAlphaOfLength(5).toLowerCase(Locale.ROOT);
|
||||||
client().admin()
|
indicesAdmin().prepareCreate(indexName)
|
||||||
.indices()
|
|
||||||
.prepareCreate(indexName)
|
|
||||||
.setSettings(
|
.setSettings(
|
||||||
Settings.builder()
|
Settings.builder()
|
||||||
.put(IndexSettings.INDEX_SEARCH_IDLE_AFTER.getKey(), searchIdleAfter + "s")
|
.put(IndexSettings.INDEX_SEARCH_IDLE_AFTER.getKey(), searchIdleAfter + "s")
|
||||||
|
@ -229,12 +225,12 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
waitUntil(
|
waitUntil(
|
||||||
() -> Arrays.stream(client().admin().indices().prepareStats(indexName).get().getShards()).allMatch(ShardStats::isSearchIdle),
|
() -> Arrays.stream(indicesAdmin().prepareStats(indexName).get().getShards()).allMatch(ShardStats::isSearchIdle),
|
||||||
searchIdleAfter,
|
searchIdleAfter,
|
||||||
TimeUnit.SECONDS
|
TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
|
|
||||||
final IndicesStatsResponse statsResponse = client().admin().indices().prepareStats(indexName).get();
|
final IndicesStatsResponse statsResponse = indicesAdmin().prepareStats(indexName).get();
|
||||||
assertTrue(Arrays.stream(statsResponse.getShards()).allMatch(ShardStats::isSearchIdle));
|
assertTrue(Arrays.stream(statsResponse.getShards()).allMatch(ShardStats::isSearchIdle));
|
||||||
assertTrue(Arrays.stream(statsResponse.getShards()).allMatch(x -> x.getSearchIdleTime() >= searchIdleAfter));
|
assertTrue(Arrays.stream(statsResponse.getShards()).allMatch(x -> x.getSearchIdleTime() >= searchIdleAfter));
|
||||||
}
|
}
|
||||||
|
@ -298,19 +294,18 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
.get()
|
.get()
|
||||||
.status()
|
.status()
|
||||||
);
|
);
|
||||||
assertEquals(RestStatus.OK, client().admin().indices().prepareRefresh(idleIndex, activeIndex).get().getStatus());
|
assertEquals(RestStatus.OK, indicesAdmin().prepareRefresh(idleIndex, activeIndex).get().getStatus());
|
||||||
|
|
||||||
waitUntil(
|
waitUntil(
|
||||||
() -> Arrays.stream(client().admin().indices().prepareStats(idleIndex, activeIndex).get().getShards())
|
() -> Arrays.stream(indicesAdmin().prepareStats(idleIndex, activeIndex).get().getShards()).allMatch(ShardStats::isSearchIdle),
|
||||||
.allMatch(ShardStats::isSearchIdle),
|
|
||||||
2,
|
2,
|
||||||
TimeUnit.SECONDS
|
TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
|
|
||||||
final IndicesStatsResponse idleIndexStatsBefore = client().admin().indices().prepareStats("test1").get();
|
final IndicesStatsResponse idleIndexStatsBefore = indicesAdmin().prepareStats("test1").get();
|
||||||
assertIdleShard(idleIndexStatsBefore);
|
assertIdleShard(idleIndexStatsBefore);
|
||||||
|
|
||||||
final IndicesStatsResponse activeIndexStatsBefore = client().admin().indices().prepareStats("test2").get();
|
final IndicesStatsResponse activeIndexStatsBefore = indicesAdmin().prepareStats("test2").get();
|
||||||
assertIdleShard(activeIndexStatsBefore);
|
assertIdleShard(activeIndexStatsBefore);
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
|
@ -326,7 +321,7 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
Arrays.stream(searchResponse.getHits().getHits()).forEach(searchHit -> assertEquals("test2", searchHit.getIndex()));
|
Arrays.stream(searchResponse.getHits().getHits()).forEach(searchHit -> assertEquals("test2", searchHit.getIndex()));
|
||||||
// NOTE: we need an empty result from at least one shard
|
// NOTE: we need an empty result from at least one shard
|
||||||
assertEquals(1, searchResponse.getHits().getHits().length);
|
assertEquals(1, searchResponse.getHits().getHits().length);
|
||||||
final IndicesStatsResponse idleIndexStatsAfter = client().admin().indices().prepareStats(idleIndex).get();
|
final IndicesStatsResponse idleIndexStatsAfter = indicesAdmin().prepareStats(idleIndex).get();
|
||||||
assertIdleShardsRefreshStats(idleIndexStatsBefore, idleIndexStatsAfter);
|
assertIdleShardsRefreshStats(idleIndexStatsBefore, idleIndexStatsAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,19 +359,18 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
RestStatus.CREATED,
|
RestStatus.CREATED,
|
||||||
client().prepareIndex(activeIndex).setSource("keyword", "active", "unmapped", "bbb").get().status()
|
client().prepareIndex(activeIndex).setSource("keyword", "active", "unmapped", "bbb").get().status()
|
||||||
);
|
);
|
||||||
assertEquals(RestStatus.OK, client().admin().indices().prepareRefresh(idleIndex, activeIndex).get().getStatus());
|
assertEquals(RestStatus.OK, indicesAdmin().prepareRefresh(idleIndex, activeIndex).get().getStatus());
|
||||||
|
|
||||||
waitUntil(
|
waitUntil(
|
||||||
() -> Arrays.stream(client().admin().indices().prepareStats(idleIndex, activeIndex).get().getShards())
|
() -> Arrays.stream(indicesAdmin().prepareStats(idleIndex, activeIndex).get().getShards()).allMatch(ShardStats::isSearchIdle),
|
||||||
.allMatch(ShardStats::isSearchIdle),
|
|
||||||
2,
|
2,
|
||||||
TimeUnit.SECONDS
|
TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
|
|
||||||
final IndicesStatsResponse idleIndexStatsBefore = client().admin().indices().prepareStats("test1").get();
|
final IndicesStatsResponse idleIndexStatsBefore = indicesAdmin().prepareStats("test1").get();
|
||||||
assertIdleShard(idleIndexStatsBefore);
|
assertIdleShard(idleIndexStatsBefore);
|
||||||
|
|
||||||
final IndicesStatsResponse activeIndexStatsBefore = client().admin().indices().prepareStats("test2").get();
|
final IndicesStatsResponse activeIndexStatsBefore = indicesAdmin().prepareStats("test2").get();
|
||||||
assertIdleShard(activeIndexStatsBefore);
|
assertIdleShard(activeIndexStatsBefore);
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
|
@ -392,7 +386,7 @@ public class SearchIdleIT extends ESSingleNodeTestCase {
|
||||||
Arrays.stream(searchResponse.getHits().getHits()).forEach(searchHit -> assertEquals("test2", searchHit.getIndex()));
|
Arrays.stream(searchResponse.getHits().getHits()).forEach(searchHit -> assertEquals("test2", searchHit.getIndex()));
|
||||||
// NOTE: we need an empty result from at least one shard
|
// NOTE: we need an empty result from at least one shard
|
||||||
assertEquals(1, searchResponse.getHits().getHits().length);
|
assertEquals(1, searchResponse.getHits().getHits().length);
|
||||||
final IndicesStatsResponse idleIndexStatsAfter = client().admin().indices().prepareStats(idleIndex).get();
|
final IndicesStatsResponse idleIndexStatsAfter = indicesAdmin().prepareStats(idleIndex).get();
|
||||||
assertIdleShardsRefreshStats(idleIndexStatsBefore, idleIndexStatsAfter);
|
assertIdleShardsRefreshStats(idleIndexStatsBefore, idleIndexStatsAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,8 +163,8 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
indexRandom(true, builders);
|
indexRandom(true, builders);
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
// double flush to create safe commit in case of async durability
|
// double flush to create safe commit in case of async durability
|
||||||
assertAllSuccessful(client().admin().indices().prepareFlush().setForce(true).get());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
||||||
assertAllSuccessful(client().admin().indices().prepareFlush().setForce(true).get());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
eventListener.setNewDelegate(listener);
|
eventListener.setNewDelegate(listener);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
client().admin().indices().prepareDelete("test").get();
|
indicesAdmin().prepareDelete("test").get();
|
||||||
latch.await();
|
latch.await();
|
||||||
assertThat(exception, empty());
|
assertThat(exception, empty());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -274,8 +274,8 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
indexRandom(true, builders);
|
indexRandom(true, builders);
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
// double flush to create safe commit in case of async durability
|
// double flush to create safe commit in case of async durability
|
||||||
assertAllSuccessful(client().admin().indices().prepareFlush().setForce(true).get());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
||||||
assertAllSuccessful(client().admin().indices().prepareFlush().setForce(true).get());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).get());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
indexRandom(true, builders);
|
indexRandom(true, builders);
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
assertAllSuccessful(client().admin().indices().prepareFlush().setForce(true).execute().actionGet());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
indexRandom(true, builders);
|
indexRandom(true, builders);
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
assertAllSuccessful(client().admin().indices().prepareFlush().setForce(true).execute().actionGet());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
indexRandom(true, builders);
|
indexRandom(true, builders);
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
assertAllSuccessful(client().admin().indices().prepareFlush().setForce(true).execute().actionGet());
|
assertAllSuccessful(indicesAdmin().prepareFlush().setForce(true).execute().actionGet());
|
||||||
// we have to flush at least once here since we don't corrupt the translog
|
// we have to flush at least once here since we don't corrupt the translog
|
||||||
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
assertHitCount(client().prepareSearch().setSize(0).get(), numDocs);
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
||||||
|
|
||||||
final Index index = resolveIndex("test");
|
final Index index = resolveIndex("test");
|
||||||
|
|
||||||
final IndicesShardStoresResponse stores = client().admin().indices().prepareShardStores(index.getName()).get();
|
final IndicesShardStoresResponse stores = indicesAdmin().prepareShardStores(index.getName()).get();
|
||||||
|
|
||||||
for (Map.Entry<Integer, List<IndicesShardStoresResponse.StoreStatus>> shards : stores.getStoreStatuses()
|
for (Map.Entry<Integer, List<IndicesShardStoresResponse.StoreStatus>> shards : stores.getStoreStatuses()
|
||||||
.get(index.getName())
|
.get(index.getName())
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ExceptionRetryIT extends ESIntegTestCase {
|
||||||
Client client = internalCluster().coordOnlyNodeClient();
|
Client client = internalCluster().coordOnlyNodeClient();
|
||||||
NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().get();
|
NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().get();
|
||||||
NodeStats unluckyNode = randomFrom(nodeStats.getNodes().stream().filter((s) -> s.getNode().canContainData()).toList());
|
NodeStats unluckyNode = randomFrom(nodeStats.getNodes().stream().filter((s) -> s.getNode().canContainData()).toList());
|
||||||
assertAcked(client().admin().indices().prepareCreate("index").setSettings(indexSettings(5, 1)));
|
assertAcked(indicesAdmin().prepareCreate("index").setSettings(indexSettings(5, 1)));
|
||||||
ensureGreen("index");
|
ensureGreen("index");
|
||||||
logger.info("unlucky node: {}", unluckyNode.getNode());
|
logger.info("unlucky node: {}", unluckyNode.getNode());
|
||||||
// create a transport service that throws a ConnectTransportException for one bulk request and therefore triggers a retry.
|
// create a transport service that throws a ConnectTransportException for one bulk request and therefore triggers a retry.
|
||||||
|
@ -133,7 +133,7 @@ public class ExceptionRetryIT extends ESIntegTestCase {
|
||||||
assertSearchResponse(searchResponse);
|
assertSearchResponse(searchResponse);
|
||||||
assertThat(dupCounter, equalTo(0L));
|
assertThat(dupCounter, equalTo(0L));
|
||||||
assertHitCount(searchResponse, numDocs);
|
assertHitCount(searchResponse, numDocs);
|
||||||
IndicesStatsResponse index = client().admin().indices().prepareStats("index").clear().setSegments(true).get();
|
IndicesStatsResponse index = indicesAdmin().prepareStats("index").clear().setSegments(true).get();
|
||||||
IndexStats indexStats = index.getIndex("index");
|
IndexStats indexStats = index.getIndex("index");
|
||||||
long maxUnsafeAutoIdTimestamp = Long.MIN_VALUE;
|
long maxUnsafeAutoIdTimestamp = Long.MIN_VALUE;
|
||||||
for (IndexShardStats indexShardStats : indexStats) {
|
for (IndexShardStats indexShardStats : indexStats) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class SuggestStatsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testSimpleStats() throws Exception {
|
public void testSimpleStats() throws Exception {
|
||||||
// clear all stats first
|
// clear all stats first
|
||||||
client().admin().indices().prepareStats().clear().execute().actionGet();
|
indicesAdmin().prepareStats().clear().execute().actionGet();
|
||||||
final int numNodes = cluster().numDataNodes();
|
final int numNodes = cluster().numDataNodes();
|
||||||
assertThat(numNodes, greaterThanOrEqualTo(2));
|
assertThat(numNodes, greaterThanOrEqualTo(2));
|
||||||
final int shardsIdx1 = randomIntBetween(1, 10); // we make sure each node gets at least a single shard...
|
final int shardsIdx1 = randomIntBetween(1, 10); // we make sure each node gets at least a single shard...
|
||||||
|
@ -79,7 +79,7 @@ public class SuggestStatsIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
|
|
||||||
IndicesStatsResponse indicesStats = client().admin().indices().prepareStats().execute().actionGet();
|
IndicesStatsResponse indicesStats = indicesAdmin().prepareStats().execute().actionGet();
|
||||||
final SearchStats.Stats suggest = indicesStats.getTotal().getSearch().getTotal();
|
final SearchStats.Stats suggest = indicesStats.getTotal().getSearch().getTotal();
|
||||||
|
|
||||||
// check current
|
// check current
|
||||||
|
|
|
@ -203,7 +203,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase {
|
||||||
|
|
||||||
logger.info("Deleting index [test]");
|
logger.info("Deleting index [test]");
|
||||||
// last, lets delete the index
|
// last, lets delete the index
|
||||||
AcknowledgedResponse deleteIndexResponse = client().admin().indices().prepareDelete("test").execute().actionGet();
|
AcknowledgedResponse deleteIndexResponse = indicesAdmin().prepareDelete("test").execute().actionGet();
|
||||||
assertThat(deleteIndexResponse.isAcknowledged(), equalTo(true));
|
assertThat(deleteIndexResponse.isAcknowledged(), equalTo(true));
|
||||||
|
|
||||||
clusterState = client().admin().cluster().prepareState().get().getState();
|
clusterState = client().admin().cluster().prepareState().get().getState();
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class DateMathIndexExpressionsIntegrationIT extends ESIntegTestCase {
|
||||||
String index3 = ".marvel-" + DateTimeFormatter.ofPattern("yyyy.MM.dd", Locale.ROOT).format(now.minusDays(2));
|
String index3 = ".marvel-" + DateTimeFormatter.ofPattern("yyyy.MM.dd", Locale.ROOT).format(now.minusDays(2));
|
||||||
createIndex(index1, index2, index3);
|
createIndex(index1, index2, index3);
|
||||||
|
|
||||||
GetSettingsResponse getSettingsResponse = dateSensitiveGet(client().admin().indices().prepareGetSettings(index1, index2, index3));
|
GetSettingsResponse getSettingsResponse = dateSensitiveGet(indicesAdmin().prepareGetSettings(index1, index2, index3));
|
||||||
assertEquals(index1, getSettingsResponse.getSetting(index1, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
assertEquals(index1, getSettingsResponse.getSetting(index1, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
||||||
assertEquals(index2, getSettingsResponse.getSetting(index2, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
assertEquals(index2, getSettingsResponse.getSetting(index2, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
||||||
assertEquals(index3, getSettingsResponse.getSetting(index3, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
assertEquals(index3, getSettingsResponse.getSetting(index3, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
||||||
|
@ -113,9 +113,7 @@ public class DateMathIndexExpressionsIntegrationIT extends ESIntegTestCase {
|
||||||
assertThat(mgetResponse.getResponses()[2].getResponse().isExists(), is(true));
|
assertThat(mgetResponse.getResponses()[2].getResponse().isExists(), is(true));
|
||||||
assertThat(mgetResponse.getResponses()[2].getResponse().getId(), equalTo("3"));
|
assertThat(mgetResponse.getResponses()[2].getResponse().getId(), equalTo("3"));
|
||||||
|
|
||||||
IndicesStatsResponse indicesStatsResponse = dateSensitiveGet(
|
IndicesStatsResponse indicesStatsResponse = dateSensitiveGet(indicesAdmin().prepareStats(dateMathExp1, dateMathExp2, dateMathExp3));
|
||||||
client().admin().indices().prepareStats(dateMathExp1, dateMathExp2, dateMathExp3)
|
|
||||||
);
|
|
||||||
assertThat(indicesStatsResponse.getIndex(index1), notNullValue());
|
assertThat(indicesStatsResponse.getIndex(index1), notNullValue());
|
||||||
assertThat(indicesStatsResponse.getIndex(index2), notNullValue());
|
assertThat(indicesStatsResponse.getIndex(index2), notNullValue());
|
||||||
assertThat(indicesStatsResponse.getIndex(index3), notNullValue());
|
assertThat(indicesStatsResponse.getIndex(index3), notNullValue());
|
||||||
|
@ -150,9 +148,7 @@ public class DateMathIndexExpressionsIntegrationIT extends ESIntegTestCase {
|
||||||
assertHitCount(searchResponse, 3);
|
assertHitCount(searchResponse, 3);
|
||||||
assertSearchHits(searchResponse, "1", "2", "3");
|
assertSearchHits(searchResponse, "1", "2", "3");
|
||||||
|
|
||||||
IndicesStatsResponse indicesStatsResponse = dateSensitiveGet(
|
IndicesStatsResponse indicesStatsResponse = dateSensitiveGet(indicesAdmin().prepareStats(dateMathExp1, dateMathExp2, dateMathExp3));
|
||||||
client().admin().indices().prepareStats(dateMathExp1, dateMathExp2, dateMathExp3)
|
|
||||||
);
|
|
||||||
assertThat(indicesStatsResponse.getIndex(index1), notNullValue());
|
assertThat(indicesStatsResponse.getIndex(index1), notNullValue());
|
||||||
assertThat(indicesStatsResponse.getIndex(index2), notNullValue());
|
assertThat(indicesStatsResponse.getIndex(index2), notNullValue());
|
||||||
assertThat(indicesStatsResponse.getIndex(index3), notNullValue());
|
assertThat(indicesStatsResponse.getIndex(index3), notNullValue());
|
||||||
|
@ -168,7 +164,7 @@ public class DateMathIndexExpressionsIntegrationIT extends ESIntegTestCase {
|
||||||
String dateMathExp3 = "<.marvel-{now/d-2d}>";
|
String dateMathExp3 = "<.marvel-{now/d-2d}>";
|
||||||
createIndex(dateMathExp1, dateMathExp2, dateMathExp3);
|
createIndex(dateMathExp1, dateMathExp2, dateMathExp3);
|
||||||
|
|
||||||
GetSettingsResponse getSettingsResponse = dateSensitiveGet(client().admin().indices().prepareGetSettings(index1, index2, index3));
|
GetSettingsResponse getSettingsResponse = dateSensitiveGet(indicesAdmin().prepareGetSettings(index1, index2, index3));
|
||||||
assertEquals(dateMathExp1, getSettingsResponse.getSetting(index1, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
assertEquals(dateMathExp1, getSettingsResponse.getSetting(index1, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
||||||
assertEquals(dateMathExp2, getSettingsResponse.getSetting(index2, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
assertEquals(dateMathExp2, getSettingsResponse.getSetting(index2, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
||||||
assertEquals(dateMathExp3, getSettingsResponse.getSetting(index3, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
assertEquals(dateMathExp3, getSettingsResponse.getSetting(index3, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase {
|
||||||
assertThat("beforeIndexCreated called on each data node", allCreatedCount.get(), greaterThanOrEqualTo(3));
|
assertThat("beforeIndexCreated called on each data node", allCreatedCount.get(), greaterThanOrEqualTo(3));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client().admin().indices().prepareCreate("failed").setSettings(Settings.builder().put("index.fail", true)).get();
|
indicesAdmin().prepareCreate("failed").setSettings(Settings.builder().put("index.fail", true)).get();
|
||||||
fail("should have thrown an exception during creation");
|
fail("should have thrown an exception during creation");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assertTrue(e.getMessage().contains("failing on purpose"));
|
assertTrue(e.getMessage().contains("failing on purpose"));
|
||||||
|
@ -200,7 +200,7 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase {
|
||||||
assertShardStatesMatch(stateChangeListenerNode2, 3, CREATED, RECOVERING, POST_RECOVERY, STARTED);
|
assertShardStatesMatch(stateChangeListenerNode2, 3, CREATED, RECOVERING, POST_RECOVERY, STARTED);
|
||||||
|
|
||||||
// close the index
|
// close the index
|
||||||
assertAcked(client().admin().indices().prepareClose("test"));
|
assertAcked(indicesAdmin().prepareClose("test"));
|
||||||
|
|
||||||
assertThat(stateChangeListenerNode1.afterCloseSettings.getAsInt(SETTING_NUMBER_OF_SHARDS, -1), equalTo(6));
|
assertThat(stateChangeListenerNode1.afterCloseSettings.getAsInt(SETTING_NUMBER_OF_SHARDS, -1), equalTo(6));
|
||||||
assertThat(stateChangeListenerNode1.afterCloseSettings.getAsInt(SETTING_NUMBER_OF_REPLICAS, -1), equalTo(1));
|
assertThat(stateChangeListenerNode1.afterCloseSettings.getAsInt(SETTING_NUMBER_OF_REPLICAS, -1), equalTo(1));
|
||||||
|
|
|
@ -45,9 +45,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
public void testCacheAggs() throws Exception {
|
public void testCacheAggs() throws Exception {
|
||||||
Client client = client();
|
Client client = client();
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client.admin()
|
indicesAdmin().prepareCreate("index")
|
||||||
.indices()
|
|
||||||
.prepareCreate("index")
|
|
||||||
.setMapping("f", "type=date")
|
.setMapping("f", "type=date")
|
||||||
.setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
|
.setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
|
||||||
.get()
|
.get()
|
||||||
|
@ -73,7 +71,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// The cached is actually used
|
// The cached is actually used
|
||||||
assertThat(
|
assertThat(
|
||||||
client.admin().indices().prepareStats("index").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(),
|
indicesAdmin().prepareStats("index").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(),
|
||||||
greaterThan(0L)
|
greaterThan(0L)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -106,9 +104,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
public void testQueryRewrite() throws Exception {
|
public void testQueryRewrite() throws Exception {
|
||||||
Client client = client();
|
Client client = client();
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client.admin()
|
indicesAdmin().prepareCreate("index")
|
||||||
.indices()
|
|
||||||
.prepareCreate("index")
|
|
||||||
.setMapping("s", "type=date")
|
.setMapping("s", "type=date")
|
||||||
.setSettings(
|
.setSettings(
|
||||||
indexSettings(5, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
|
indexSettings(5, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
|
||||||
|
@ -132,7 +128,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
assertCacheState(client, "index", 0, 0);
|
assertCacheState(client, "index", 0, 0);
|
||||||
|
|
||||||
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
||||||
ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get();
|
ForceMergeResponse forceMergeResponse = indicesAdmin().prepareForceMerge("index").setFlush(true).get();
|
||||||
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
||||||
refresh();
|
refresh();
|
||||||
ensureSearchable("index");
|
ensureSearchable("index");
|
||||||
|
@ -174,9 +170,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
public void testQueryRewriteMissingValues() throws Exception {
|
public void testQueryRewriteMissingValues() throws Exception {
|
||||||
Client client = client();
|
Client client = client();
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client.admin()
|
indicesAdmin().prepareCreate("index")
|
||||||
.indices()
|
|
||||||
.prepareCreate("index")
|
|
||||||
.setMapping("s", "type=date")
|
.setMapping("s", "type=date")
|
||||||
.setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
|
.setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
|
||||||
.get()
|
.get()
|
||||||
|
@ -197,7 +191,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
assertCacheState(client, "index", 0, 0);
|
assertCacheState(client, "index", 0, 0);
|
||||||
|
|
||||||
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
||||||
ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get();
|
ForceMergeResponse forceMergeResponse = indicesAdmin().prepareForceMerge("index").setFlush(true).get();
|
||||||
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
||||||
refresh();
|
refresh();
|
||||||
ensureSearchable("index");
|
ensureSearchable("index");
|
||||||
|
@ -235,9 +229,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
public void testQueryRewriteDates() throws Exception {
|
public void testQueryRewriteDates() throws Exception {
|
||||||
Client client = client();
|
Client client = client();
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client.admin()
|
indicesAdmin().prepareCreate("index")
|
||||||
.indices()
|
|
||||||
.prepareCreate("index")
|
|
||||||
.setMapping("d", "type=date")
|
.setMapping("d", "type=date")
|
||||||
.setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
|
.setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
|
||||||
.get()
|
.get()
|
||||||
|
@ -258,7 +250,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
assertCacheState(client, "index", 0, 0);
|
assertCacheState(client, "index", 0, 0);
|
||||||
|
|
||||||
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
||||||
ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get();
|
ForceMergeResponse forceMergeResponse = indicesAdmin().prepareForceMerge("index").setFlush(true).get();
|
||||||
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
||||||
refresh();
|
refresh();
|
||||||
ensureSearchable("index");
|
ensureSearchable("index");
|
||||||
|
@ -300,9 +292,9 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
public void testQueryRewriteDatesWithNow() throws Exception {
|
public void testQueryRewriteDatesWithNow() throws Exception {
|
||||||
Client client = client();
|
Client client = client();
|
||||||
Settings settings = indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true).build();
|
Settings settings = indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true).build();
|
||||||
assertAcked(client.admin().indices().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings).get());
|
assertAcked(indicesAdmin().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings).get());
|
||||||
assertAcked(client.admin().indices().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings).get());
|
assertAcked(indicesAdmin().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings).get());
|
||||||
assertAcked(client.admin().indices().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings).get());
|
assertAcked(indicesAdmin().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings).get());
|
||||||
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
|
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
|
||||||
DateFormatter formatter = DateFormatter.forPattern("strict_date_optional_time");
|
DateFormatter formatter = DateFormatter.forPattern("strict_date_optional_time");
|
||||||
indexRandom(
|
indexRandom(
|
||||||
|
@ -378,7 +370,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
Settings settings = indexSettings(2, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
|
Settings settings = indexSettings(2, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
|
||||||
.put("index.number_of_routing_shards", 2)
|
.put("index.number_of_routing_shards", 2)
|
||||||
.build();
|
.build();
|
||||||
assertAcked(client.admin().indices().prepareCreate("index").setMapping("s", "type=date").setSettings(settings).get());
|
assertAcked(indicesAdmin().prepareCreate("index").setMapping("s", "type=date").setSettings(settings).get());
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
client.prepareIndex("index").setId("1").setRouting("1").setSource("s", "2016-03-19"),
|
client.prepareIndex("index").setId("1").setRouting("1").setSource("s", "2016-03-19"),
|
||||||
|
@ -395,7 +387,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
assertCacheState(client, "index", 0, 0);
|
assertCacheState(client, "index", 0, 0);
|
||||||
|
|
||||||
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
||||||
ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get();
|
ForceMergeResponse forceMergeResponse = indicesAdmin().prepareForceMerge("index").setFlush(true).get();
|
||||||
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
||||||
refresh();
|
refresh();
|
||||||
ensureSearchable("index");
|
ensureSearchable("index");
|
||||||
|
@ -474,9 +466,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
Client client = client();
|
Client client = client();
|
||||||
Settings settings = indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true).build();
|
Settings settings = indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true).build();
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client.admin()
|
indicesAdmin().prepareCreate("index")
|
||||||
.indices()
|
|
||||||
.prepareCreate("index")
|
|
||||||
.setMapping("created_at", "type=date")
|
.setMapping("created_at", "type=date")
|
||||||
.setSettings(settings)
|
.setSettings(settings)
|
||||||
.addAlias(new Alias("last_week").filter(QueryBuilders.rangeQuery("created_at").gte("now-7d/d")))
|
.addAlias(new Alias("last_week").filter(QueryBuilders.rangeQuery("created_at").gte("now-7d/d")))
|
||||||
|
@ -485,7 +475,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
|
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
|
||||||
client.prepareIndex("index").setId("1").setRouting("1").setSource("created_at", DateTimeFormatter.ISO_LOCAL_DATE.format(now)).get();
|
client.prepareIndex("index").setId("1").setRouting("1").setSource("created_at", DateTimeFormatter.ISO_LOCAL_DATE.format(now)).get();
|
||||||
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
|
||||||
ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get();
|
ForceMergeResponse forceMergeResponse = indicesAdmin().prepareForceMerge("index").setFlush(true).get();
|
||||||
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
ElasticsearchAssertions.assertAllSuccessful(forceMergeResponse);
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
@ -523,9 +513,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
|
||||||
public void testProfileDisableCache() throws Exception {
|
public void testProfileDisableCache() throws Exception {
|
||||||
Client client = client();
|
Client client = client();
|
||||||
assertAcked(
|
assertAcked(
|
||||||
client.admin()
|
indicesAdmin().prepareCreate("index")
|
||||||
.indices()
|
|
||||||
.prepareCreate("index")
|
|
||||||
.setMapping("k", "type=keyword")
|
.setMapping("k", "type=keyword")
|
||||||
.setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
|
.setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
|
||||||
.get()
|
.get()
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class SystemIndexMappingUpdateServiceIT extends ESIntegTestCase {
|
||||||
*/
|
*/
|
||||||
private void triggerClusterStateUpdates() {
|
private void triggerClusterStateUpdates() {
|
||||||
final String name = randomAlphaOfLength(5).toLowerCase(Locale.ROOT);
|
final String name = randomAlphaOfLength(5).toLowerCase(Locale.ROOT);
|
||||||
client().admin().indices().putTemplate(new PutIndexTemplateRequest(name).patterns(List.of(name))).actionGet();
|
indicesAdmin().putTemplate(new PutIndexTemplateRequest(name).patterns(List.of(name))).actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class PreBuiltAnalyzerIntegrationIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
client().admin().indices().prepareCreate(indexName).setMapping(mapping).setSettings(settings(randomVersion)).get();
|
indicesAdmin().prepareCreate(indexName).setMapping(mapping).setSettings(settings(randomVersion)).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
@ -86,7 +86,7 @@ public class PreBuiltAnalyzerIntegrationIT extends ESIntegTestCase {
|
||||||
int amountOfIndicesToClose = randomInt(numIndices - 1);
|
int amountOfIndicesToClose = randomInt(numIndices - 1);
|
||||||
for (int i = 0; i < amountOfIndicesToClose; i++) {
|
for (int i = 0; i < amountOfIndicesToClose; i++) {
|
||||||
String indexName = indexNames.get(i);
|
String indexName = indexNames.get(i);
|
||||||
client().admin().indices().prepareClose(indexName).execute().actionGet();
|
indicesAdmin().prepareClose(indexName).execute().actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class FlushIT extends ESIntegTestCase {
|
||||||
final CountDownLatch latch = new CountDownLatch(10);
|
final CountDownLatch latch = new CountDownLatch(10);
|
||||||
final CopyOnWriteArrayList<Throwable> errors = new CopyOnWriteArrayList<>();
|
final CopyOnWriteArrayList<Throwable> errors = new CopyOnWriteArrayList<>();
|
||||||
for (int j = 0; j < 10; j++) {
|
for (int j = 0; j < 10; j++) {
|
||||||
client().admin().indices().prepareFlush("test").execute(new ActionListener<FlushResponse>() {
|
indicesAdmin().prepareFlush("test").execute(new ActionListener<FlushResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(FlushResponse flushResponse) {
|
public void onResponse(FlushResponse flushResponse) {
|
||||||
try {
|
try {
|
||||||
|
@ -93,16 +93,13 @@ public class FlushIT extends ESIntegTestCase {
|
||||||
assertThat(
|
assertThat(
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ValidationException.class,
|
ValidationException.class,
|
||||||
() -> client().admin().indices().flush(new FlushRequest().force(true).waitIfOngoing(false)).actionGet()
|
() -> indicesAdmin().flush(new FlushRequest().force(true).waitIfOngoing(false)).actionGet()
|
||||||
).getMessage(),
|
).getMessage(),
|
||||||
containsString("wait_if_ongoing must be true for a force flush")
|
containsString("wait_if_ongoing must be true for a force flush")
|
||||||
);
|
);
|
||||||
|
assertThat(indicesAdmin().flush(new FlushRequest().force(true).waitIfOngoing(true)).actionGet().getShardFailures(), emptyArray());
|
||||||
assertThat(
|
assertThat(
|
||||||
client().admin().indices().flush(new FlushRequest().force(true).waitIfOngoing(true)).actionGet().getShardFailures(),
|
indicesAdmin().flush(new FlushRequest().force(false).waitIfOngoing(randomBoolean())).actionGet().getShardFailures(),
|
||||||
emptyArray()
|
|
||||||
);
|
|
||||||
assertThat(
|
|
||||||
client().admin().indices().flush(new FlushRequest().force(false).waitIfOngoing(randomBoolean())).actionGet().getShardFailures(),
|
|
||||||
emptyArray()
|
emptyArray()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +132,7 @@ public class FlushIT extends ESIntegTestCase {
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
}
|
}
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
for (ShardStats shardStats : client().admin().indices().prepareStats(indexName).get().getShards()) {
|
for (ShardStats shardStats : indicesAdmin().prepareStats(indexName).get().getShards()) {
|
||||||
assertThat(shardStats.getStats().getTranslog().getUncommittedOperations(), equalTo(0));
|
assertThat(shardStats.getStats().getTranslog().getUncommittedOperations(), equalTo(0));
|
||||||
}
|
}
|
||||||
}, 30, TimeUnit.SECONDS);
|
}, 30, TimeUnit.SECONDS);
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class MalformedDynamicTemplateIT extends ESIntegTestCase {
|
||||||
).setMapping(mapping).get()
|
).setMapping(mapping).get()
|
||||||
);
|
);
|
||||||
client().prepareIndex(indexName).setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
|
client().prepareIndex(indexName).setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
|
||||||
assertNoFailures((client().admin().indices().prepareRefresh(indexName)).get());
|
assertNoFailures((indicesAdmin().prepareRefresh(indexName)).get());
|
||||||
assertHitCount(client().prepareSearch(indexName).get(), 1);
|
assertHitCount(client().prepareSearch(indexName).get(), 1);
|
||||||
|
|
||||||
MapperParsingException ex = expectThrows(
|
MapperParsingException ex = expectThrows(
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
|
||||||
private void reset() {
|
private void reset() {
|
||||||
logger.info("--> resetting breaker settings");
|
logger.info("--> resetting breaker settings");
|
||||||
// clear all caches, we could be very close (or even above) the limit and then we will not be able to reset the breaker settings
|
// clear all caches, we could be very close (or even above) the limit and then we will not be able to reset the breaker settings
|
||||||
client().admin().indices().prepareClearCache().setFieldDataCache(true).setQueryCache(true).setRequestCache(true).get();
|
indicesAdmin().prepareClearCache().setFieldDataCache(true).setQueryCache(true).setRequestCache(true).get();
|
||||||
|
|
||||||
Settings.Builder resetSettings = Settings.builder();
|
Settings.Builder resetSettings = Settings.builder();
|
||||||
Stream.of(
|
Stream.of(
|
||||||
|
@ -293,7 +293,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
|
||||||
|
|
||||||
/** Issues a cache clear and waits 30 seconds for the field data breaker to be cleared */
|
/** Issues a cache clear and waits 30 seconds for the field data breaker to be cleared */
|
||||||
public void clearFieldData() throws Exception {
|
public void clearFieldData() throws Exception {
|
||||||
client().admin().indices().prepareClearCache().setFieldDataCache(true).execute().actionGet();
|
indicesAdmin().prepareClearCache().setFieldDataCache(true).execute().actionGet();
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
NodesStatsResponse resp = clusterAdmin().prepareNodesStats().clear().setBreaker(true).get(new TimeValue(15, TimeUnit.SECONDS));
|
NodesStatsResponse resp = clusterAdmin().prepareNodesStats().clear().setBreaker(true).get(new TimeValue(15, TimeUnit.SECONDS));
|
||||||
for (NodeStats nStats : resp.getNodes()) {
|
for (NodeStats nStats : resp.getNodes()) {
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
logger.info("Start Refresh");
|
logger.info("Start Refresh");
|
||||||
// don't assert on failures here
|
// don't assert on failures here
|
||||||
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().get();
|
RefreshResponse refreshResponse = indicesAdmin().prepareRefresh("test").execute().get();
|
||||||
final boolean refreshFailed = refreshResponse.getShardFailures().length != 0 || refreshResponse.getFailedShards() != 0;
|
final boolean refreshFailed = refreshResponse.getShardFailures().length != 0 || refreshResponse.getFailedShards() != 0;
|
||||||
logger.info(
|
logger.info(
|
||||||
"Refresh failed: [{}] numShardsFailed: [{}], shardFailuresLength: [{}], successfulShards: [{}], totalShards: [{}] ",
|
"Refresh failed: [{}] numShardsFailed: [{}], shardFailuresLength: [{}], successfulShards: [{}], totalShards: [{}] ",
|
||||||
|
@ -172,7 +172,7 @@ public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase {
|
||||||
// breaker adjustment code, it should show up here by the breaker
|
// breaker adjustment code, it should show up here by the breaker
|
||||||
// estimate being either positive or negative.
|
// estimate being either positive or negative.
|
||||||
ensureGreen("test"); // make sure all shards are there - there could be shards that are still starting up.
|
ensureGreen("test"); // make sure all shards are there - there could be shards that are still starting up.
|
||||||
assertAllSuccessful(client().admin().indices().prepareClearCache("test").setFieldDataCache(true).execute().actionGet());
|
assertAllSuccessful(indicesAdmin().prepareClearCache("test").setFieldDataCache(true).execute().actionGet());
|
||||||
|
|
||||||
// Since .cleanUp() is no longer called on cache clear, we need to call it on each node manually
|
// Since .cleanUp() is no longer called on cache clear, we need to call it on each node manually
|
||||||
for (String node : internalCluster().getNodeNames()) {
|
for (String node : internalCluster().getNodeNames()) {
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class DanglingIndicesIT extends ESIntegTestCase {
|
||||||
// not cause the deleted dangling index to be considered "live" again, just because its
|
// not cause the deleted dangling index to be considered "live" again, just because its
|
||||||
// tombstone has been pushed out of the graveyard.
|
// tombstone has been pushed out of the graveyard.
|
||||||
createIndex("additional");
|
createIndex("additional");
|
||||||
assertAcked(client().admin().indices().prepareDelete("additional"));
|
assertAcked(indicesAdmin().prepareDelete("additional"));
|
||||||
assertThat(listDanglingIndices(), is(empty()));
|
assertThat(listDanglingIndices(), is(empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,8 +215,8 @@ public class DanglingIndicesIT extends ESIntegTestCase {
|
||||||
@Override
|
@Override
|
||||||
public Settings onNodeStopped(String nodeName) throws Exception {
|
public Settings onNodeStopped(String nodeName) throws Exception {
|
||||||
internalCluster().validateClusterFormed();
|
internalCluster().validateClusterFormed();
|
||||||
assertAcked(client().admin().indices().prepareDelete(INDEX_NAME));
|
assertAcked(indicesAdmin().prepareDelete(INDEX_NAME));
|
||||||
assertAcked(client().admin().indices().prepareDelete(OTHER_INDEX_NAME));
|
assertAcked(indicesAdmin().prepareDelete(OTHER_INDEX_NAME));
|
||||||
return super.onNodeStopped(nodeName);
|
return super.onNodeStopped(nodeName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -244,7 +244,7 @@ public class DanglingIndicesIT extends ESIntegTestCase {
|
||||||
// not cause the deleted dangling index to be considered "live" again, just because its
|
// not cause the deleted dangling index to be considered "live" again, just because its
|
||||||
// tombstone has been pushed out of the graveyard.
|
// tombstone has been pushed out of the graveyard.
|
||||||
createIndex("additional");
|
createIndex("additional");
|
||||||
assertAcked(client().admin().indices().prepareDelete("additional"));
|
assertAcked(indicesAdmin().prepareDelete("additional"));
|
||||||
assertBusy(() -> assertThat(listDanglingIndices(), empty()));
|
assertBusy(() -> assertThat(listDanglingIndices(), empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ public class DanglingIndicesIT extends ESIntegTestCase {
|
||||||
final long endTimeMillis = System.currentTimeMillis() + timeout.millis();
|
final long endTimeMillis = System.currentTimeMillis() + timeout.millis();
|
||||||
while (isImporting.get() && System.currentTimeMillis() < endTimeMillis) {
|
while (isImporting.get() && System.currentTimeMillis() < endTimeMillis) {
|
||||||
try {
|
try {
|
||||||
client().admin().indices().prepareDelete(INDEX_NAME).get(timeout);
|
indicesAdmin().prepareDelete(INDEX_NAME).get(timeout);
|
||||||
isImporting.set(false);
|
isImporting.set(false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// failures are expected
|
// failures are expected
|
||||||
|
@ -316,7 +316,7 @@ public class DanglingIndicesIT extends ESIntegTestCase {
|
||||||
if (isImporting.get()) {
|
if (isImporting.get()) {
|
||||||
isImporting.set(false);
|
isImporting.set(false);
|
||||||
try {
|
try {
|
||||||
client().admin().indices().prepareDelete(INDEX_NAME).get(timeout);
|
indicesAdmin().prepareDelete(INDEX_NAME).get(timeout);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AssertionError("delete index never succeeded", e);
|
throw new AssertionError("delete index never succeeded", e);
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ public class DanglingIndicesIT extends ESIntegTestCase {
|
||||||
internalCluster().validateClusterFormed();
|
internalCluster().validateClusterFormed();
|
||||||
stoppedNodeName.set(nodeName);
|
stoppedNodeName.set(nodeName);
|
||||||
for (String index : indices) {
|
for (String index : indices) {
|
||||||
assertAcked(client().admin().indices().prepareDelete(index));
|
assertAcked(indicesAdmin().prepareDelete(index));
|
||||||
}
|
}
|
||||||
return super.onNodeStopped(nodeName);
|
return super.onNodeStopped(nodeName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class IndexPrimaryRelocationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testPrimaryRelocationWhileIndexing() throws Exception {
|
public void testPrimaryRelocationWhileIndexing() throws Exception {
|
||||||
internalCluster().ensureAtLeastNumDataNodes(randomIntBetween(2, 3));
|
internalCluster().ensureAtLeastNumDataNodes(randomIntBetween(2, 3));
|
||||||
client().admin().indices().prepareCreate("test").setSettings(indexSettings(1, 0)).setMapping("field", "type=text").get();
|
indicesAdmin().prepareCreate("test").setSettings(indexSettings(1, 0)).setMapping("field", "type=text").get();
|
||||||
ensureGreen("test");
|
ensureGreen("test");
|
||||||
AtomicInteger numAutoGenDocs = new AtomicInteger();
|
AtomicInteger numAutoGenDocs = new AtomicInteger();
|
||||||
final AtomicBoolean finished = new AtomicBoolean(false);
|
final AtomicBoolean finished = new AtomicBoolean(false);
|
||||||
|
@ -106,7 +106,7 @@ public class IndexPrimaryRelocationIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
if (i > 0 && i % 5 == 0) {
|
if (i > 0 && i % 5 == 0) {
|
||||||
logger.info("--> [iteration {}] flushing index", i);
|
logger.info("--> [iteration {}] flushing index", i);
|
||||||
client().admin().indices().prepareFlush("test").get();
|
indicesAdmin().prepareFlush("test").get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finished.set(true);
|
finished.set(true);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue