[TEST] make sure that IndicesRequestTests is repeateable using the same seed

Remove the creation of a node client if not there before each test through setup method. `numClientNodes` makes sure that the client node gets created during suite cluster initialization.
This commit is contained in:
javanna 2014-09-29 15:51:01 +02:00 committed by Luca Cavanna
parent b118558962
commit c06b772df0
1 changed files with 42 additions and 46 deletions

View File

@ -92,7 +92,6 @@ import org.elasticsearch.action.termvector.TermVectorRequest;
import org.elasticsearch.action.update.UpdateAction; import org.elasticsearch.action.update.UpdateAction;
import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -118,11 +117,10 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ClusterScope(scope = Scope.SUITE) @ClusterScope(scope = Scope.SUITE, numClientNodes = 1)
public class IndicesRequestTests extends ElasticsearchIntegrationTest { public class IndicesRequestTests extends ElasticsearchIntegrationTest {
private final List<String> indices = new ArrayList<>(); private final List<String> indices = new ArrayList<>();
private Client nodeClient;
@Override @Override
protected int minimumNumberOfShards() { protected int minimumNumberOfShards() {
@ -147,8 +145,6 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
@Before @Before
public void setup() { public void setup() {
//make sure there is a node client around before each test starts
nodeClient = internalCluster().clientNodeClient();
int numIndices = iterations(1, 5); int numIndices = iterations(1, 5);
for (int i = 0; i < numIndices; i++) { for (int i = 0; i < numIndices; i++) {
indices.add("test" + i); indices.add("test" + i);
@ -172,7 +168,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
GetFieldMappingsRequest getFieldMappingsRequest = new GetFieldMappingsRequest(); GetFieldMappingsRequest getFieldMappingsRequest = new GetFieldMappingsRequest();
getFieldMappingsRequest.indices(randomIndicesOrAliases()); getFieldMappingsRequest.indices(randomIndicesOrAliases());
nodeClient.admin().indices().getFieldMappings(getFieldMappingsRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().getFieldMappings(getFieldMappingsRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(getFieldMappingsRequest, getFieldMappingsShardAction); assertSameIndices(getFieldMappingsRequest, getFieldMappingsShardAction);
@ -184,7 +180,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(analyzeShardAction); interceptTransportActions(analyzeShardAction);
AnalyzeRequest analyzeRequest = new AnalyzeRequest(randomIndexOrAlias(), "text"); AnalyzeRequest analyzeRequest = new AnalyzeRequest(randomIndexOrAlias(), "text");
nodeClient.admin().indices().analyze(analyzeRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().analyze(analyzeRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(analyzeRequest, analyzeShardAction); assertSameIndices(analyzeRequest, analyzeShardAction);
@ -196,7 +192,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(indexShardActions); interceptTransportActions(indexShardActions);
IndexRequest indexRequest = new IndexRequest(randomIndexOrAlias(), "type", "id").source("field", "value"); IndexRequest indexRequest = new IndexRequest(randomIndexOrAlias(), "type", "id").source("field", "value");
nodeClient.index(indexRequest).actionGet(); internalCluster().clientNodeClient().index(indexRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(indexRequest, indexShardActions); assertSameIndices(indexRequest, indexShardActions);
@ -208,7 +204,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(deleteShardActions); interceptTransportActions(deleteShardActions);
DeleteRequest deleteRequest = new DeleteRequest(randomIndexOrAlias(), "type", "id"); DeleteRequest deleteRequest = new DeleteRequest(randomIndexOrAlias(), "type", "id");
nodeClient.delete(deleteRequest).actionGet(); internalCluster().clientNodeClient().delete(deleteRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(deleteRequest, deleteShardActions); assertSameIndices(deleteRequest, deleteShardActions);
@ -223,7 +219,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
String indexOrAlias = randomIndexOrAlias(); String indexOrAlias = randomIndexOrAlias();
client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get(); client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get();
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").doc("field1", "value1"); UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").doc("field1", "value1");
UpdateResponse updateResponse = nodeClient.update(updateRequest).actionGet(); UpdateResponse updateResponse = internalCluster().clientNodeClient().update(updateRequest).actionGet();
assertThat(updateResponse.isCreated(), equalTo(false)); assertThat(updateResponse.isCreated(), equalTo(false));
clearInterceptedActions(); clearInterceptedActions();
@ -238,7 +234,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
String indexOrAlias = randomIndexOrAlias(); String indexOrAlias = randomIndexOrAlias();
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").upsert("field", "value").doc("field1", "value1"); UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").upsert("field", "value").doc("field1", "value1");
UpdateResponse updateResponse = nodeClient.update(updateRequest).actionGet(); UpdateResponse updateResponse = internalCluster().clientNodeClient().update(updateRequest).actionGet();
assertThat(updateResponse.isCreated(), equalTo(true)); assertThat(updateResponse.isCreated(), equalTo(true));
clearInterceptedActions(); clearInterceptedActions();
@ -254,7 +250,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
String indexOrAlias = randomIndexOrAlias(); String indexOrAlias = randomIndexOrAlias();
client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get(); client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get();
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").script("ctx.op='delete'"); UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").script("ctx.op='delete'");
UpdateResponse updateResponse = nodeClient.update(updateRequest).actionGet(); UpdateResponse updateResponse = internalCluster().clientNodeClient().update(updateRequest).actionGet();
assertThat(updateResponse.isCreated(), equalTo(false)); assertThat(updateResponse.isCreated(), equalTo(false));
clearInterceptedActions(); clearInterceptedActions();
@ -267,7 +263,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(deleteByQueryShardActions); interceptTransportActions(deleteByQueryShardActions);
DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(randomIndicesOrAliases()).source(new QuerySourceBuilder().setQuery(QueryBuilders.matchAllQuery())); DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(randomIndicesOrAliases()).source(new QuerySourceBuilder().setQuery(QueryBuilders.matchAllQuery()));
nodeClient.deleteByQuery(deleteByQueryRequest).actionGet(); internalCluster().clientNodeClient().deleteByQuery(deleteByQueryRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(deleteByQueryRequest, deleteByQueryShardActions); assertSameIndices(deleteByQueryRequest, deleteByQueryShardActions);
@ -299,7 +295,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
indices.add(indexOrAlias); indices.add(indexOrAlias);
} }
nodeClient.bulk(bulkRequest).actionGet(); internalCluster().clientNodeClient().bulk(bulkRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertIndicesSubset(indices, bulkShardActions); assertIndicesSubset(indices, bulkShardActions);
@ -311,7 +307,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(getShardAction); interceptTransportActions(getShardAction);
GetRequest getRequest = new GetRequest(randomIndexOrAlias(), "type", "id"); GetRequest getRequest = new GetRequest(randomIndexOrAlias(), "type", "id");
nodeClient.get(getRequest).actionGet(); internalCluster().clientNodeClient().get(getRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(getRequest, getShardAction); assertSameIndices(getRequest, getShardAction);
@ -323,7 +319,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(explainShardAction); interceptTransportActions(explainShardAction);
ExplainRequest explainRequest = new ExplainRequest(randomIndexOrAlias(), "type", "id").source(new QuerySourceBuilder().setQuery(QueryBuilders.matchAllQuery())); ExplainRequest explainRequest = new ExplainRequest(randomIndexOrAlias(), "type", "id").source(new QuerySourceBuilder().setQuery(QueryBuilders.matchAllQuery()));
nodeClient.explain(explainRequest).actionGet(); internalCluster().clientNodeClient().explain(explainRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(explainRequest, explainShardAction); assertSameIndices(explainRequest, explainShardAction);
@ -335,7 +331,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(termVectorShardAction); interceptTransportActions(termVectorShardAction);
TermVectorRequest termVectorRequest = new TermVectorRequest(randomIndexOrAlias(), "type", "id"); TermVectorRequest termVectorRequest = new TermVectorRequest(randomIndexOrAlias(), "type", "id");
nodeClient.termVector(termVectorRequest).actionGet(); internalCluster().clientNodeClient().termVector(termVectorRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(termVectorRequest, termVectorShardAction); assertSameIndices(termVectorRequest, termVectorShardAction);
@ -354,7 +350,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
multiTermVectorsRequest.add(indexOrAlias, "type", Integer.toString(i)); multiTermVectorsRequest.add(indexOrAlias, "type", Integer.toString(i));
indices.add(indexOrAlias); indices.add(indexOrAlias);
} }
nodeClient.multiTermVectors(multiTermVectorsRequest).actionGet(); internalCluster().clientNodeClient().multiTermVectors(multiTermVectorsRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertIndicesSubset(indices, multiTermVectorsShardAction); assertIndicesSubset(indices, multiTermVectorsShardAction);
@ -373,7 +369,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
multiGetRequest.add(indexOrAlias, "type", Integer.toString(i)); multiGetRequest.add(indexOrAlias, "type", Integer.toString(i));
indices.add(indexOrAlias); indices.add(indexOrAlias);
} }
nodeClient.multiGet(multiGetRequest).actionGet(); internalCluster().clientNodeClient().multiGet(multiGetRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertIndicesSubset(indices, multiGetShardAction); assertIndicesSubset(indices, multiGetShardAction);
@ -385,7 +381,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(countShardAction); interceptTransportActions(countShardAction);
CountRequest countRequest = new CountRequest(randomIndicesOrAliases()); CountRequest countRequest = new CountRequest(randomIndicesOrAliases());
nodeClient.count(countRequest).actionGet(); internalCluster().clientNodeClient().count(countRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(countRequest, countShardAction); assertSameIndices(countRequest, countShardAction);
@ -397,7 +393,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(existsShardAction); interceptTransportActions(existsShardAction);
ExistsRequest existsRequest = new ExistsRequest(randomIndicesOrAliases()); ExistsRequest existsRequest = new ExistsRequest(randomIndicesOrAliases());
nodeClient.exists(existsRequest).actionGet(); internalCluster().clientNodeClient().exists(existsRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(existsRequest, existsShardAction); assertSameIndices(existsRequest, existsShardAction);
@ -409,7 +405,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(flushShardAction); interceptTransportActions(flushShardAction);
FlushRequest flushRequest = new FlushRequest(randomIndicesOrAliases()); FlushRequest flushRequest = new FlushRequest(randomIndicesOrAliases());
nodeClient.admin().indices().flush(flushRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().flush(flushRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(flushRequest, flushShardAction); assertSameIndices(flushRequest, flushShardAction);
@ -421,7 +417,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(optimizeShardAction); interceptTransportActions(optimizeShardAction);
OptimizeRequest optimizeRequest = new OptimizeRequest(randomIndicesOrAliases()); OptimizeRequest optimizeRequest = new OptimizeRequest(randomIndicesOrAliases());
nodeClient.admin().indices().optimize(optimizeRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().optimize(optimizeRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(optimizeRequest, optimizeShardAction); assertSameIndices(optimizeRequest, optimizeShardAction);
@ -433,7 +429,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(refreshShardAction); interceptTransportActions(refreshShardAction);
RefreshRequest refreshRequest = new RefreshRequest(randomIndicesOrAliases()); RefreshRequest refreshRequest = new RefreshRequest(randomIndicesOrAliases());
nodeClient.admin().indices().refresh(refreshRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().refresh(refreshRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(refreshRequest, refreshShardAction); assertSameIndices(refreshRequest, refreshShardAction);
@ -445,7 +441,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(clearCacheAction); interceptTransportActions(clearCacheAction);
ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(randomIndicesOrAliases()); ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(randomIndicesOrAliases());
nodeClient.admin().indices().clearCache(clearIndicesCacheRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().clearCache(clearIndicesCacheRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(clearIndicesCacheRequest, clearCacheAction); assertSameIndices(clearIndicesCacheRequest, clearCacheAction);
@ -457,7 +453,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(recoveryAction); interceptTransportActions(recoveryAction);
RecoveryRequest recoveryRequest = new RecoveryRequest(randomIndicesOrAliases()); RecoveryRequest recoveryRequest = new RecoveryRequest(randomIndicesOrAliases());
nodeClient.admin().indices().recoveries(recoveryRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().recoveries(recoveryRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(recoveryRequest, recoveryAction); assertSameIndices(recoveryRequest, recoveryAction);
@ -469,7 +465,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(segmentsAction); interceptTransportActions(segmentsAction);
IndicesSegmentsRequest segmentsRequest = new IndicesSegmentsRequest(randomIndicesOrAliases()); IndicesSegmentsRequest segmentsRequest = new IndicesSegmentsRequest(randomIndicesOrAliases());
nodeClient.admin().indices().segments(segmentsRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().segments(segmentsRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(segmentsRequest, segmentsAction); assertSameIndices(segmentsRequest, segmentsAction);
@ -481,7 +477,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(indicesStats); interceptTransportActions(indicesStats);
IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest().indices(randomIndicesOrAliases()); IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest().indices(randomIndicesOrAliases());
nodeClient.admin().indices().stats(indicesStatsRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().stats(indicesStatsRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(indicesStatsRequest, indicesStats); assertSameIndices(indicesStatsRequest, indicesStats);
@ -493,7 +489,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(suggestAction); interceptTransportActions(suggestAction);
SuggestRequest suggestRequest = new SuggestRequest(randomIndicesOrAliases()); SuggestRequest suggestRequest = new SuggestRequest(randomIndicesOrAliases());
nodeClient.suggest(suggestRequest).actionGet(); internalCluster().clientNodeClient().suggest(suggestRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(suggestRequest, suggestAction); assertSameIndices(suggestRequest, suggestAction);
@ -505,7 +501,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(validateQueryShardAction); interceptTransportActions(validateQueryShardAction);
ValidateQueryRequest validateQueryRequest = new ValidateQueryRequest(randomIndicesOrAliases()); ValidateQueryRequest validateQueryRequest = new ValidateQueryRequest(randomIndicesOrAliases());
nodeClient.admin().indices().validateQuery(validateQueryRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().validateQuery(validateQueryRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(validateQueryRequest, validateQueryShardAction); assertSameIndices(validateQueryRequest, validateQueryShardAction);
@ -524,7 +520,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
} else { } else {
percolateRequest.source("\"field\":\"value\""); percolateRequest.source("\"field\":\"value\"");
} }
nodeClient.percolate(percolateRequest).actionGet(); internalCluster().clientNodeClient().percolate(percolateRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(percolateRequest, percolateShardAction); assertSameIndices(percolateRequest, percolateShardAction);
@ -552,7 +548,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
multiPercolateRequest.add(percolateRequest); multiPercolateRequest.add(percolateRequest);
} }
nodeClient.multiPercolate(multiPercolateRequest).actionGet(); internalCluster().clientNodeClient().multiPercolate(multiPercolateRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertIndicesSubset(indices, multiPercolateShardAction); assertIndicesSubset(indices, multiPercolateShardAction);
@ -563,7 +559,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(OpenIndexAction.NAME); interceptTransportActions(OpenIndexAction.NAME);
OpenIndexRequest openIndexRequest = new OpenIndexRequest(randomUniqueIndicesOrAliases()); OpenIndexRequest openIndexRequest = new OpenIndexRequest(randomUniqueIndicesOrAliases());
nodeClient.admin().indices().open(openIndexRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().open(openIndexRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(openIndexRequest, OpenIndexAction.NAME); assertSameIndices(openIndexRequest, OpenIndexAction.NAME);
@ -574,7 +570,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(CloseIndexAction.NAME); interceptTransportActions(CloseIndexAction.NAME);
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(randomUniqueIndicesOrAliases()); CloseIndexRequest closeIndexRequest = new CloseIndexRequest(randomUniqueIndicesOrAliases());
nodeClient.admin().indices().close(closeIndexRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().close(closeIndexRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(closeIndexRequest, CloseIndexAction.NAME); assertSameIndices(closeIndexRequest, CloseIndexAction.NAME);
@ -586,7 +582,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
String[] randomIndicesOrAliases = randomUniqueIndicesOrAliases(); String[] randomIndicesOrAliases = randomUniqueIndicesOrAliases();
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(randomIndicesOrAliases); DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(randomIndicesOrAliases);
assertAcked(nodeClient.admin().indices().delete(deleteIndexRequest).actionGet()); assertAcked(internalCluster().clientNodeClient().admin().indices().delete(deleteIndexRequest).actionGet());
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(deleteIndexRequest, DeleteIndexAction.NAME); assertSameIndices(deleteIndexRequest, DeleteIndexAction.NAME);
@ -597,7 +593,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(GetMappingsAction.NAME); interceptTransportActions(GetMappingsAction.NAME);
GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(randomIndicesOrAliases()); GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(randomIndicesOrAliases());
nodeClient.admin().indices().getMappings(getMappingsRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().getMappings(getMappingsRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(getMappingsRequest, GetMappingsAction.NAME); assertSameIndices(getMappingsRequest, GetMappingsAction.NAME);
@ -608,7 +604,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(PutMappingAction.NAME); interceptTransportActions(PutMappingAction.NAME);
PutMappingRequest putMappingRequest = new PutMappingRequest(randomUniqueIndicesOrAliases()).type("type").source("field", "type=string"); PutMappingRequest putMappingRequest = new PutMappingRequest(randomUniqueIndicesOrAliases()).type("type").source("field", "type=string");
nodeClient.admin().indices().putMapping(putMappingRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().putMapping(putMappingRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(putMappingRequest, PutMappingAction.NAME); assertSameIndices(putMappingRequest, PutMappingAction.NAME);
@ -621,7 +617,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
String[] indices = randomUniqueIndicesOrAliases(); String[] indices = randomUniqueIndicesOrAliases();
client().admin().indices().putMapping(new PutMappingRequest(indices).type("type").source("field", "type=string")).actionGet(); client().admin().indices().putMapping(new PutMappingRequest(indices).type("type").source("field", "type=string")).actionGet();
DeleteMappingRequest deleteMappingRequest = new DeleteMappingRequest(indices).types("type"); DeleteMappingRequest deleteMappingRequest = new DeleteMappingRequest(indices).types("type");
nodeClient.admin().indices().deleteMapping(deleteMappingRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().deleteMapping(deleteMappingRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(deleteMappingRequest, DeleteMappingAction.NAME); assertSameIndices(deleteMappingRequest, DeleteMappingAction.NAME);
@ -632,7 +628,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(GetSettingsAction.NAME); interceptTransportActions(GetSettingsAction.NAME);
GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(randomIndicesOrAliases()); GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(randomIndicesOrAliases());
nodeClient.admin().indices().getSettings(getSettingsRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().getSettings(getSettingsRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(getSettingsRequest, GetSettingsAction.NAME); assertSameIndices(getSettingsRequest, GetSettingsAction.NAME);
@ -643,7 +639,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
interceptTransportActions(UpdateSettingsAction.NAME); interceptTransportActions(UpdateSettingsAction.NAME);
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(randomIndicesOrAliases()).settings(ImmutableSettings.builder().put("refresh_interval", -1)); UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(randomIndicesOrAliases()).settings(ImmutableSettings.builder().put("refresh_interval", -1));
nodeClient.admin().indices().updateSettings(updateSettingsRequest).actionGet(); internalCluster().clientNodeClient().admin().indices().updateSettings(updateSettingsRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
assertSameIndices(updateSettingsRequest, UpdateSettingsAction.NAME); assertSameIndices(updateSettingsRequest, UpdateSettingsAction.NAME);
@ -661,7 +657,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
refresh(); refresh();
SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.QUERY_THEN_FETCH); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.QUERY_THEN_FETCH);
SearchResponse searchResponse = nodeClient.search(searchRequest).actionGet(); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet();
assertNoFailures(searchResponse); assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); assertThat(searchResponse.getHits().totalHits(), greaterThan(0l));
@ -683,7 +679,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
refresh(); refresh();
SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.DFS_QUERY_THEN_FETCH); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.DFS_QUERY_THEN_FETCH);
SearchResponse searchResponse = nodeClient.search(searchRequest).actionGet(); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet();
assertNoFailures(searchResponse); assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); assertThat(searchResponse.getHits().totalHits(), greaterThan(0l));
@ -706,7 +702,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
refresh(); refresh();
SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.QUERY_AND_FETCH); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.QUERY_AND_FETCH);
SearchResponse searchResponse = nodeClient.search(searchRequest).actionGet(); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet();
assertNoFailures(searchResponse); assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); assertThat(searchResponse.getHits().totalHits(), greaterThan(0l));
@ -728,7 +724,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
refresh(); refresh();
SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.DFS_QUERY_AND_FETCH); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.DFS_QUERY_AND_FETCH);
SearchResponse searchResponse = nodeClient.search(searchRequest).actionGet(); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet();
assertNoFailures(searchResponse); assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); assertThat(searchResponse.getHits().totalHits(), greaterThan(0l));
@ -749,7 +745,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
refresh(); refresh();
SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.SCAN).scroll(new TimeValue(500)); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.SCAN).scroll(new TimeValue(500));
SearchResponse searchResponse = nodeClient.search(searchRequest).actionGet(); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet();
assertNoFailures(searchResponse); assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); assertThat(searchResponse.getHits().totalHits(), greaterThan(0l));
@ -776,7 +772,7 @@ public class IndicesRequestTests extends ElasticsearchIntegrationTest {
MoreLikeThisRequest moreLikeThisRequest = new MoreLikeThisRequest(indexGet).type("type").id("1") MoreLikeThisRequest moreLikeThisRequest = new MoreLikeThisRequest(indexGet).type("type").id("1")
.searchIndices(randomIndicesOrAliases()); .searchIndices(randomIndicesOrAliases());
nodeClient.moreLikeThis(moreLikeThisRequest).actionGet(); internalCluster().clientNodeClient().moreLikeThis(moreLikeThisRequest).actionGet();
clearInterceptedActions(); clearInterceptedActions();
//get might end up being executed locally, only optionally over the transport //get might end up being executed locally, only optionally over the transport