From da1992248960e75f27cfc1af5386e905e3ea8fcc Mon Sep 17 00:00:00 2001 From: javanna Date: Fri, 4 Mar 2016 19:51:56 +0100 Subject: [PATCH] [TEST] adapt test infra to node.client setting removal No changes were really needed in our test infra as it didn't use `node.client`. Yet it didn't take into account ingest nodes, what we used to call client nodes in InternalTestCluster were actually ingest only nodes, which now become coordinating only nodes. Also renamed some method to get rid of the node client terminology as much as possible in favour or coordinating only node. --- .../cluster/ClusterServiceIT.java | 6 +- .../index/suggest/stats/SuggestStatsIT.java | 6 +- .../search/morelikethis/MoreLikeThisIT.java | 2 +- .../messy/tests/IndicesRequestTests.java | 70 +++++++++---------- .../messy/tests/SearchStatsTests.java | 2 +- .../test/CompositeTestCluster.java | 3 +- .../test/InternalTestCluster.java | 42 +++++------ 7 files changed, 65 insertions(+), 66 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java index f5c99fd5f7e..017a46a5462 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java @@ -510,7 +510,7 @@ public class ClusterServiceIT extends ESIntegTestCase { .put("discovery.type", "local") .build(); String node_0 = internalCluster().startNode(settings); - internalCluster().startNodeClient(settings); + internalCluster().startCoordinatingOnlyNode(settings); final ClusterService clusterService = internalCluster().getInstance(ClusterService.class, node_0); final CountDownLatch block1 = new CountDownLatch(1); @@ -568,7 +568,7 @@ public class ClusterServiceIT extends ESIntegTestCase { assertTrue(controlSources.isEmpty()); controlSources = new HashSet<>(Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")); - PendingClusterTasksResponse response = internalCluster().clientNodeClient().admin().cluster().preparePendingClusterTasks().execute().actionGet(); + PendingClusterTasksResponse response = internalCluster().coordOnlyNodeClient().admin().cluster().preparePendingClusterTasks().execute().actionGet(); assertThat(response.pendingTasks().size(), greaterThanOrEqualTo(10)); assertThat(response.pendingTasks().get(0).getSource().string(), equalTo("1")); assertThat(response.pendingTasks().get(0).isExecuting(), equalTo(true)); @@ -628,7 +628,7 @@ public class ClusterServiceIT extends ESIntegTestCase { } assertTrue(controlSources.isEmpty()); - response = internalCluster().clientNodeClient().admin().cluster().preparePendingClusterTasks().get(); + response = internalCluster().coordOnlyNodeClient().admin().cluster().preparePendingClusterTasks().get(); assertThat(response.pendingTasks().size(), greaterThanOrEqualTo(5)); controlSources = new HashSet<>(Arrays.asList("1", "2", "3", "4", "5")); for (PendingClusterTask task : response) { diff --git a/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java b/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java index 23c9e223972..2b8ed9c3171 100644 --- a/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java +++ b/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java @@ -86,15 +86,15 @@ public class SuggestStatsIT extends ESIntegTestCase { long startTime = System.currentTimeMillis(); for (int i = 0; i < suggestAllIdx; i++) { - SuggestResponse suggestResponse = addSuggestions(internalCluster().clientNodeClient().prepareSuggest(), i).get(); + SuggestResponse suggestResponse = addSuggestions(internalCluster().coordOnlyNodeClient().prepareSuggest(), i).get(); assertAllSuccessful(suggestResponse); } for (int i = 0; i < suggestIdx1; i++) { - SuggestResponse suggestResponse = addSuggestions(internalCluster().clientNodeClient().prepareSuggest("test1"), i).get(); + SuggestResponse suggestResponse = addSuggestions(internalCluster().coordOnlyNodeClient().prepareSuggest("test1"), i).get(); assertAllSuccessful(suggestResponse); } for (int i = 0; i < suggestIdx2; i++) { - SuggestResponse suggestResponse = addSuggestions(internalCluster().clientNodeClient().prepareSuggest("test2"), i).get(); + SuggestResponse suggestResponse = addSuggestions(internalCluster().coordOnlyNodeClient().prepareSuggest("test2"), i).get(); assertAllSuccessful(suggestResponse); } long endTime = System.currentTimeMillis(); diff --git a/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java b/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java index 8f0ef3c0fbe..38d8287239e 100644 --- a/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java +++ b/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java @@ -139,7 +139,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).id(), equalTo("2")); logger.info("Running moreLikeThis on alias with node client"); - response = internalCluster().clientNodeClient().prepareSearch("beta").setQuery( + response = internalCluster().coordOnlyNodeClient().prepareSearch("beta").setQuery( new MoreLikeThisQueryBuilder(null, new Item[] {new Item("test", "type1", "1")}).minTermFreq(1).minDocFreq(1)).get(); assertHitCount(response, 1L); assertThat(response.getHits().getAt(0).id(), equalTo("3")); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java index 60b9460bb12..748345fd447 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java @@ -178,7 +178,7 @@ public class IndicesRequestTests extends ESIntegTestCase { GetFieldMappingsRequest getFieldMappingsRequest = new GetFieldMappingsRequest(); getFieldMappingsRequest.indices(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().getFieldMappings(getFieldMappingsRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().getFieldMappings(getFieldMappingsRequest).actionGet(); clearInterceptedActions(); assertSameIndices(getFieldMappingsRequest, getFieldMappingsShardAction); @@ -190,7 +190,7 @@ public class IndicesRequestTests extends ESIntegTestCase { AnalyzeRequest analyzeRequest = new AnalyzeRequest(randomIndexOrAlias()); analyzeRequest.text("text"); - internalCluster().clientNodeClient().admin().indices().analyze(analyzeRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().analyze(analyzeRequest).actionGet(); clearInterceptedActions(); assertSameIndices(analyzeRequest, analyzeShardAction); @@ -201,7 +201,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(indexShardActions); IndexRequest indexRequest = new IndexRequest(randomIndexOrAlias(), "type", "id").source("field", "value"); - internalCluster().clientNodeClient().index(indexRequest).actionGet(); + internalCluster().coordOnlyNodeClient().index(indexRequest).actionGet(); clearInterceptedActions(); assertSameIndices(indexRequest, indexShardActions); @@ -212,7 +212,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(deleteShardActions); DeleteRequest deleteRequest = new DeleteRequest(randomIndexOrAlias(), "type", "id"); - internalCluster().clientNodeClient().delete(deleteRequest).actionGet(); + internalCluster().coordOnlyNodeClient().delete(deleteRequest).actionGet(); clearInterceptedActions(); assertSameIndices(deleteRequest, deleteShardActions); @@ -226,7 +226,7 @@ public class IndicesRequestTests extends ESIntegTestCase { String indexOrAlias = randomIndexOrAlias(); client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get(); UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").doc("field1", "value1"); - UpdateResponse updateResponse = internalCluster().clientNodeClient().update(updateRequest).actionGet(); + UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet(); assertThat(updateResponse.isCreated(), equalTo(false)); clearInterceptedActions(); @@ -240,7 +240,7 @@ public class IndicesRequestTests extends ESIntegTestCase { String indexOrAlias = randomIndexOrAlias(); UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").upsert("field", "value").doc("field1", "value1"); - UpdateResponse updateResponse = internalCluster().clientNodeClient().update(updateRequest).actionGet(); + UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet(); assertThat(updateResponse.isCreated(), equalTo(true)); clearInterceptedActions(); @@ -255,7 +255,7 @@ public class IndicesRequestTests extends ESIntegTestCase { String indexOrAlias = randomIndexOrAlias(); client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get(); UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").script(new Script("ctx.op='delete'")); - UpdateResponse updateResponse = internalCluster().clientNodeClient().update(updateRequest).actionGet(); + UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet(); assertThat(updateResponse.isCreated(), equalTo(false)); clearInterceptedActions(); @@ -287,7 +287,7 @@ public class IndicesRequestTests extends ESIntegTestCase { indices.add(indexOrAlias); } - internalCluster().clientNodeClient().bulk(bulkRequest).actionGet(); + internalCluster().coordOnlyNodeClient().bulk(bulkRequest).actionGet(); clearInterceptedActions(); assertIndicesSubset(indices, bulkShardActions); @@ -298,7 +298,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(getShardAction); GetRequest getRequest = new GetRequest(randomIndexOrAlias(), "type", "id"); - internalCluster().clientNodeClient().get(getRequest).actionGet(); + internalCluster().coordOnlyNodeClient().get(getRequest).actionGet(); clearInterceptedActions(); assertSameIndices(getRequest, getShardAction); @@ -309,7 +309,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(explainShardAction); ExplainRequest explainRequest = new ExplainRequest(randomIndexOrAlias(), "type", "id").query(QueryBuilders.matchAllQuery()); - internalCluster().clientNodeClient().explain(explainRequest).actionGet(); + internalCluster().coordOnlyNodeClient().explain(explainRequest).actionGet(); clearInterceptedActions(); assertSameIndices(explainRequest, explainShardAction); @@ -320,7 +320,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(termVectorShardAction); TermVectorsRequest termVectorsRequest = new TermVectorsRequest(randomIndexOrAlias(), "type", "id"); - internalCluster().clientNodeClient().termVectors(termVectorsRequest).actionGet(); + internalCluster().coordOnlyNodeClient().termVectors(termVectorsRequest).actionGet(); clearInterceptedActions(); assertSameIndices(termVectorsRequest, termVectorShardAction); @@ -338,7 +338,7 @@ public class IndicesRequestTests extends ESIntegTestCase { multiTermVectorsRequest.add(indexOrAlias, "type", Integer.toString(i)); indices.add(indexOrAlias); } - internalCluster().clientNodeClient().multiTermVectors(multiTermVectorsRequest).actionGet(); + internalCluster().coordOnlyNodeClient().multiTermVectors(multiTermVectorsRequest).actionGet(); clearInterceptedActions(); assertIndicesSubset(indices, multiTermVectorsShardAction); @@ -356,7 +356,7 @@ public class IndicesRequestTests extends ESIntegTestCase { multiGetRequest.add(indexOrAlias, "type", Integer.toString(i)); indices.add(indexOrAlias); } - internalCluster().clientNodeClient().multiGet(multiGetRequest).actionGet(); + internalCluster().coordOnlyNodeClient().multiGet(multiGetRequest).actionGet(); clearInterceptedActions(); assertIndicesSubset(indices, multiGetShardAction); @@ -367,7 +367,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(indexShardActions); FlushRequest flushRequest = new FlushRequest(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().flush(flushRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().flush(flushRequest).actionGet(); clearInterceptedActions(); String[] indices = new IndexNameExpressionResolver(Settings.EMPTY).concreteIndices(client().admin().cluster().prepareState().get().getState(), flushRequest); @@ -379,7 +379,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(mergeShardAction); ForceMergeRequest mergeRequest = new ForceMergeRequest(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().forceMerge(mergeRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().forceMerge(mergeRequest).actionGet(); clearInterceptedActions(); assertSameIndices(mergeRequest, mergeShardAction); @@ -390,7 +390,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(indexShardActions); RefreshRequest refreshRequest = new RefreshRequest(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().refresh(refreshRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().refresh(refreshRequest).actionGet(); clearInterceptedActions(); String[] indices = new IndexNameExpressionResolver(Settings.EMPTY).concreteIndices(client().admin().cluster().prepareState().get().getState(), refreshRequest); @@ -402,7 +402,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(clearCacheAction); ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().clearCache(clearIndicesCacheRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().clearCache(clearIndicesCacheRequest).actionGet(); clearInterceptedActions(); assertSameIndices(clearIndicesCacheRequest, clearCacheAction); @@ -413,7 +413,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(recoveryAction); RecoveryRequest recoveryRequest = new RecoveryRequest(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().recoveries(recoveryRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().recoveries(recoveryRequest).actionGet(); clearInterceptedActions(); assertSameIndices(recoveryRequest, recoveryAction); @@ -424,7 +424,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(segmentsAction); IndicesSegmentsRequest segmentsRequest = new IndicesSegmentsRequest(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().segments(segmentsRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().segments(segmentsRequest).actionGet(); clearInterceptedActions(); assertSameIndices(segmentsRequest, segmentsAction); @@ -435,7 +435,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(indicesStats); IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest().indices(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().stats(indicesStatsRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().stats(indicesStatsRequest).actionGet(); clearInterceptedActions(); assertSameIndices(indicesStatsRequest, indicesStats); @@ -446,7 +446,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(suggestAction); SuggestRequest suggestRequest = new SuggestRequest(randomIndicesOrAliases()); - internalCluster().clientNodeClient().suggest(suggestRequest).actionGet(); + internalCluster().coordOnlyNodeClient().suggest(suggestRequest).actionGet(); clearInterceptedActions(); assertSameIndices(suggestRequest, suggestAction); @@ -457,7 +457,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(validateQueryShardAction); ValidateQueryRequest validateQueryRequest = new ValidateQueryRequest(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().validateQuery(validateQueryRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().validateQuery(validateQueryRequest).actionGet(); clearInterceptedActions(); assertSameIndices(validateQueryRequest, validateQueryShardAction); @@ -475,7 +475,7 @@ public class IndicesRequestTests extends ESIntegTestCase { } else { percolateRequest.source("\"field\":\"value\""); } - internalCluster().clientNodeClient().percolate(percolateRequest).actionGet(); + internalCluster().coordOnlyNodeClient().percolate(percolateRequest).actionGet(); clearInterceptedActions(); assertSameIndices(percolateRequest, percolateShardAction); @@ -502,7 +502,7 @@ public class IndicesRequestTests extends ESIntegTestCase { multiPercolateRequest.add(percolateRequest); } - internalCluster().clientNodeClient().multiPercolate(multiPercolateRequest).actionGet(); + internalCluster().coordOnlyNodeClient().multiPercolate(multiPercolateRequest).actionGet(); clearInterceptedActions(); assertIndicesSubset(indices, multiPercolateShardAction); @@ -512,7 +512,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(OpenIndexAction.NAME); OpenIndexRequest openIndexRequest = new OpenIndexRequest(randomUniqueIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().open(openIndexRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().open(openIndexRequest).actionGet(); clearInterceptedActions(); assertSameIndices(openIndexRequest, OpenIndexAction.NAME); @@ -522,7 +522,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(CloseIndexAction.NAME); CloseIndexRequest closeIndexRequest = new CloseIndexRequest(randomUniqueIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().close(closeIndexRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().close(closeIndexRequest).actionGet(); clearInterceptedActions(); assertSameIndices(closeIndexRequest, CloseIndexAction.NAME); @@ -533,7 +533,7 @@ public class IndicesRequestTests extends ESIntegTestCase { String[] randomIndicesOrAliases = randomUniqueIndicesOrAliases(); DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(randomIndicesOrAliases); - assertAcked(internalCluster().clientNodeClient().admin().indices().delete(deleteIndexRequest).actionGet()); + assertAcked(internalCluster().coordOnlyNodeClient().admin().indices().delete(deleteIndexRequest).actionGet()); clearInterceptedActions(); assertSameIndices(deleteIndexRequest, DeleteIndexAction.NAME); @@ -543,7 +543,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(GetMappingsAction.NAME); GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().getMappings(getMappingsRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().getMappings(getMappingsRequest).actionGet(); clearInterceptedActions(); assertSameIndices(getMappingsRequest, GetMappingsAction.NAME); @@ -553,7 +553,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(PutMappingAction.NAME); PutMappingRequest putMappingRequest = new PutMappingRequest(randomUniqueIndicesOrAliases()).type("type").source("field", "type=text"); - internalCluster().clientNodeClient().admin().indices().putMapping(putMappingRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().putMapping(putMappingRequest).actionGet(); clearInterceptedActions(); assertSameIndices(putMappingRequest, PutMappingAction.NAME); @@ -563,7 +563,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(GetSettingsAction.NAME); GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(randomIndicesOrAliases()); - internalCluster().clientNodeClient().admin().indices().getSettings(getSettingsRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().getSettings(getSettingsRequest).actionGet(); clearInterceptedActions(); assertSameIndices(getSettingsRequest, GetSettingsAction.NAME); @@ -573,7 +573,7 @@ public class IndicesRequestTests extends ESIntegTestCase { interceptTransportActions(UpdateSettingsAction.NAME); UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(randomIndicesOrAliases()).settings(Settings.builder().put("refresh_interval", -1)); - internalCluster().clientNodeClient().admin().indices().updateSettings(updateSettingsRequest).actionGet(); + internalCluster().coordOnlyNodeClient().admin().indices().updateSettings(updateSettingsRequest).actionGet(); clearInterceptedActions(); assertSameIndices(updateSettingsRequest, UpdateSettingsAction.NAME); @@ -590,7 +590,7 @@ public class IndicesRequestTests extends ESIntegTestCase { refresh(); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.QUERY_THEN_FETCH); - SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet(); + SearchResponse searchResponse = internalCluster().coordOnlyNodeClient().search(searchRequest).actionGet(); assertNoFailures(searchResponse); assertThat(searchResponse.getHits().totalHits(), greaterThan(0L)); @@ -611,7 +611,7 @@ public class IndicesRequestTests extends ESIntegTestCase { refresh(); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.DFS_QUERY_THEN_FETCH); - SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet(); + SearchResponse searchResponse = internalCluster().coordOnlyNodeClient().search(searchRequest).actionGet(); assertNoFailures(searchResponse); assertThat(searchResponse.getHits().totalHits(), greaterThan(0L)); @@ -633,7 +633,7 @@ public class IndicesRequestTests extends ESIntegTestCase { refresh(); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.QUERY_AND_FETCH); - SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet(); + SearchResponse searchResponse = internalCluster().coordOnlyNodeClient().search(searchRequest).actionGet(); assertNoFailures(searchResponse); assertThat(searchResponse.getHits().totalHits(), greaterThan(0L)); @@ -654,7 +654,7 @@ public class IndicesRequestTests extends ESIntegTestCase { refresh(); SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.DFS_QUERY_AND_FETCH); - SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet(); + SearchResponse searchResponse = internalCluster().coordOnlyNodeClient().search(searchRequest).actionGet(); assertNoFailures(searchResponse); assertThat(searchResponse.getHits().totalHits(), greaterThan(0L)); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java index 72abe487d89..d2dbd997402 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java @@ -105,7 +105,7 @@ public class SearchStatsTests extends ESIntegTestCase { refresh(); int iters = scaledRandomIntBetween(100, 150); for (int i = 0; i < iters; i++) { - SearchResponse searchResponse = internalCluster().clientNodeClient().prepareSearch() + SearchResponse searchResponse = internalCluster().coordOnlyNodeClient().prepareSearch() .setQuery(QueryBuilders.termQuery("field", "value")).setStats("group1", "group2") .highlighter(new HighlightBuilder().field("field")) .addScriptField("scrip1", new Script("_source.field")) diff --git a/test/framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java index f9f57feb916..c6470123090 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.Random; import java.util.stream.Collectors; @@ -72,7 +71,7 @@ public class CompositeTestCluster extends TestCluster { super.beforeTest(random, transportClientRatio); cluster.beforeTest(random, transportClientRatio); Settings defaultSettings = cluster.getDefaultSettings(); - final Client client = cluster.size() > 0 ? cluster.client() : cluster.clientNodeClient(); + final Client client = cluster.size() > 0 ? cluster.client() : cluster.coordOnlyNodeClient(); for (int i = 0; i < externalNodes.length; i++) { if (!externalNodes[i].running()) { externalNodes[i] = externalNodes[i].start(client, defaultSettings, NODE_PREFIX + i, cluster.getClusterName(), i); diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index 51fab2d2f4f..d90ff1b8d17 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -200,9 +200,9 @@ public final class InternalTestCluster extends TestCluster { * fully shared cluster to be more reproducible */ private final long[] sharedNodesSeeds; - private final int numSharedDataNodes; + private final int numSharedAllRolesNodes; - private final int numSharedClientNodes; + private final int numShareCoordOnlyNodes; private final NodeConfigurationSource nodeConfigurationSource; @@ -241,20 +241,20 @@ public final class InternalTestCluster extends TestCluster { Random random = new Random(clusterSeed); - this.numSharedDataNodes = RandomInts.randomIntBetween(random, minNumDataNodes, maxNumDataNodes); - assert this.numSharedDataNodes >= 0; + this.numSharedAllRolesNodes = RandomInts.randomIntBetween(random, minNumDataNodes, maxNumDataNodes); + assert this.numSharedAllRolesNodes >= 0; //for now all shared data nodes are also master eligible - if (numSharedDataNodes == 0) { - this.numSharedClientNodes = 0; + if (numSharedAllRolesNodes == 0) { + this.numShareCoordOnlyNodes = 0; } else { if (numClientNodes < 0) { - this.numSharedClientNodes = RandomInts.randomIntBetween(random, DEFAULT_MIN_NUM_CLIENT_NODES, DEFAULT_MAX_NUM_CLIENT_NODES); + this.numShareCoordOnlyNodes = RandomInts.randomIntBetween(random, DEFAULT_MIN_NUM_CLIENT_NODES, DEFAULT_MAX_NUM_CLIENT_NODES); } else { - this.numSharedClientNodes = numClientNodes; + this.numShareCoordOnlyNodes = numClientNodes; } } - assert this.numSharedClientNodes >= 0; + assert this.numShareCoordOnlyNodes >= 0; this.nodePrefix = nodePrefix; @@ -268,12 +268,12 @@ public final class InternalTestCluster extends TestCluster { * - we could add a flag that never returns a client to the master * - along those lines use a dedicated node that is master eligible and let all other nodes be only data nodes */ - sharedNodesSeeds = new long[numSharedDataNodes + numSharedClientNodes]; + sharedNodesSeeds = new long[numSharedAllRolesNodes + numShareCoordOnlyNodes]; for (int i = 0; i < sharedNodesSeeds.length; i++) { sharedNodesSeeds[i] = random.nextLong(); } - logger.info("Setup InternalTestCluster [{}] with seed [{}] using [{}] data nodes and [{}] client nodes", clusterName, SeedUtils.formatSeed(clusterSeed), numSharedDataNodes, numSharedClientNodes); + logger.info("Setup InternalTestCluster [{}] with seed [{}] using [{}] data nodes and [{}] client nodes", clusterName, SeedUtils.formatSeed(clusterSeed), numSharedAllRolesNodes, numShareCoordOnlyNodes); this.nodeConfigurationSource = nodeConfigurationSource; Builder builder = Settings.settingsBuilder(); if (random.nextInt(5) == 0) { // sometimes set this @@ -552,7 +552,7 @@ public final class InternalTestCluster extends TestCluster { n == 0 ? nodes.values().stream() : nodes.values().stream().filter(new DataNodePredicate().and(new MasterNodePredicate(getMasterName()).negate())); final Iterator values = collection.iterator(); - logger.info("changing cluster size from {} to {}, {} data nodes", size(), n + numSharedClientNodes, n); + logger.info("changing cluster size from {} to {}, {} data nodes", size(), n + numShareCoordOnlyNodes, n); Set nodesToRemove = new HashSet<>(); int numNodesAndClients = 0; while (values.hasNext() && numNodesAndClients++ < size-n) { @@ -652,9 +652,9 @@ public final class InternalTestCluster extends TestCluster { } /** - * Returns a client to a node started with "node.client: true" + * Returns a client to a coordinating only node */ - public synchronized Client clientNodeClient() { + public synchronized Client coordOnlyNodeClient() { ensureOpen(); NodeAndClient randomNodeAndClient = getRandomNodeAndClient(new NoDataNoMasterNodePredicate()); if (randomNodeAndClient != null) { @@ -662,14 +662,14 @@ public final class InternalTestCluster extends TestCluster { } int nodeId = nextNodeId.getAndIncrement(); Settings settings = getSettings(nodeId, random.nextLong(), Settings.EMPTY); - startNodeClient(settings); + startCoordinatingOnlyNode(settings); return getRandomNodeAndClient(new NoDataNoMasterNodePredicate()).client(random); } - public synchronized Client startNodeClient(Settings settings) { + public synchronized Client startCoordinatingOnlyNode(Settings settings) { ensureOpen(); // currently unused Builder builder = settingsBuilder().put(settings).put(Node.NODE_MASTER_SETTING.getKey(), false) - .put(Node.NODE_DATA_SETTING.getKey(), false); + .put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_INGEST_SETTING.getKey(), false); if (size() == 0) { // if we are the first node - don't wait for a state builder.put(DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), 0); @@ -935,9 +935,9 @@ public final class InternalTestCluster extends TestCluster { Set sharedNodes = new HashSet<>(); - assert sharedNodesSeeds.length == numSharedDataNodes + numSharedClientNodes; + assert sharedNodesSeeds.length == numSharedAllRolesNodes + numShareCoordOnlyNodes; boolean changed = false; - for (int i = 0; i < numSharedDataNodes; i++) { + for (int i = 0; i < numSharedAllRolesNodes; i++) { String buildNodeName = buildNodeName(i); NodeAndClient nodeAndClient = nodes.get(buildNodeName); if (nodeAndClient == null) { @@ -948,13 +948,13 @@ public final class InternalTestCluster extends TestCluster { } sharedNodes.add(nodeAndClient); } - for (int i = numSharedDataNodes; i < numSharedDataNodes + numSharedClientNodes; i++) { + for (int i = numSharedAllRolesNodes; i < numSharedAllRolesNodes + numShareCoordOnlyNodes; i++) { String buildNodeName = buildNodeName(i); NodeAndClient nodeAndClient = nodes.get(buildNodeName); if (nodeAndClient == null) { changed = true; Builder clientSettingsBuilder = Settings.builder().put(Node.NODE_MASTER_SETTING.getKey(), false) - .put(Node.NODE_DATA_SETTING.getKey(), false); + .put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_INGEST_SETTING.getKey(), false); nodeAndClient = buildNode(i, sharedNodesSeeds[i], clientSettingsBuilder.build(), Version.CURRENT); nodeAndClient.node.start(); logger.info("Start Shared Node [{}] not shared", nodeAndClient.name);