From 95dc08fa3bf7193bfa117deed1aca7fef3a58a76 Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 24 Jan 2011 16:06:28 +0200 Subject: [PATCH] refactor search tests into separate packages --- ...> ClientTransportTwoNodesSearchTests.java} | 4 ++-- .../ClientTransportTwoServersSearchTests.yml | 9 --------- .../SingleInstanceEmbeddedSearchTests.yml | 6 ------ .../search/TransportSearchFailuresTests.yml | 9 --------- .../search/TransportTwoServersSearchTests.yml | 9 --------- .../search/TwoInstanceEmbeddedSearchTests.yml | 9 --------- ...nceUnbalancedShardsEmbeddedSearchTests.yml | 8 -------- .../TransportSearchFailuresTests.java | 9 +++++++-- .../TransportTwoNodesSearchTests.java} | 11 ++++++++--- .../SingleInstanceEmbeddedSearchTests.java | 8 ++++++-- .../TwoInstanceEmbeddedSearchTests.java | 11 +++++------ ...ceUnbalancedShardsEmbeddedSearchTests.java | 19 +++++++++++-------- 12 files changed, 39 insertions(+), 73 deletions(-) rename modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/{ClientTransportTwoServersSearchTests.java => ClientTransportTwoNodesSearchTests.java} (89%) delete mode 100644 modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoServersSearchTests.yml delete mode 100644 modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/SingleInstanceEmbeddedSearchTests.yml delete mode 100644 modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportSearchFailuresTests.yml delete mode 100644 modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportTwoServersSearchTests.yml delete mode 100644 modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceEmbeddedSearchTests.yml delete mode 100644 modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceUnbalancedShardsEmbeddedSearchTests.yml rename modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/{ => basic}/TransportSearchFailuresTests.java (93%) rename modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/{TransportTwoServersSearchTests.java => basic/TransportTwoNodesSearchTests.java} (97%) rename modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/{ => embedded}/SingleInstanceEmbeddedSearchTests.java (95%) rename modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/{ => embedded}/TwoInstanceEmbeddedSearchTests.java (98%) rename modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/{ => embedded}/TwoInstanceUnbalancedShardsEmbeddedSearchTests.java (96%) diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoServersSearchTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java similarity index 89% rename from modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoServersSearchTests.java rename to modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java index afffa03af62..a2948fb2d25 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoServersSearchTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java @@ -23,13 +23,13 @@ import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.test.integration.search.TransportTwoServersSearchTests; +import org.elasticsearch.test.integration.search.basic.TransportTwoNodesSearchTests; import org.elasticsearch.transport.TransportService; /** * @author kimchy (shay.banon) */ -public class ClientTransportTwoServersSearchTests extends TransportTwoServersSearchTests { +public class ClientTransportTwoNodesSearchTests extends TransportTwoNodesSearchTests { @Override protected Client getClient() { TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress(); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoServersSearchTests.yml b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoServersSearchTests.yml deleted file mode 100644 index e98b4011121..00000000000 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoServersSearchTests.yml +++ /dev/null @@ -1,9 +0,0 @@ -cluster: - routing: - schedule: 100ms -index: - number_of_shards: 3 - number_of_replicas: 0 - routing : - # Use simple hashing since we want even distribution and our ids are simple incremented number based - hash.type : simple diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/SingleInstanceEmbeddedSearchTests.yml b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/SingleInstanceEmbeddedSearchTests.yml deleted file mode 100644 index e700f1f35fa..00000000000 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/SingleInstanceEmbeddedSearchTests.yml +++ /dev/null @@ -1,6 +0,0 @@ -cluster: - routing: - schedule: 100ms -index: - number_of_shards: 1 - number_of_replicas: 0 diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportSearchFailuresTests.yml b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportSearchFailuresTests.yml deleted file mode 100644 index e2222b13819..00000000000 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportSearchFailuresTests.yml +++ /dev/null @@ -1,9 +0,0 @@ -cluster: - routing: - schedule: 100ms -index: - number_of_shards: 3 - number_of_replicas: 2 - routing : - # Use simple hashing since we want even distribution and our ids are simple incremented number based - hash.type : simple diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportTwoServersSearchTests.yml b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportTwoServersSearchTests.yml deleted file mode 100644 index e98b4011121..00000000000 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportTwoServersSearchTests.yml +++ /dev/null @@ -1,9 +0,0 @@ -cluster: - routing: - schedule: 100ms -index: - number_of_shards: 3 - number_of_replicas: 0 - routing : - # Use simple hashing since we want even distribution and our ids are simple incremented number based - hash.type : simple diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceEmbeddedSearchTests.yml b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceEmbeddedSearchTests.yml deleted file mode 100644 index e98b4011121..00000000000 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceEmbeddedSearchTests.yml +++ /dev/null @@ -1,9 +0,0 @@ -cluster: - routing: - schedule: 100ms -index: - number_of_shards: 3 - number_of_replicas: 0 - routing : - # Use simple hashing since we want even distribution and our ids are simple incremented number based - hash.type : simple diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceUnbalancedShardsEmbeddedSearchTests.yml b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceUnbalancedShardsEmbeddedSearchTests.yml deleted file mode 100644 index c052d039521..00000000000 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceUnbalancedShardsEmbeddedSearchTests.yml +++ /dev/null @@ -1,8 +0,0 @@ -cluster: - routing: - schedule: 100ms - operation: - type: org.elasticsearch.test.integration.search.TwoInstanceUnbalancedShardsEmbeddedSearchTests$UnevenOperationRoutingModule -index: - number_of_shards: 3 - number_of_replicas: 0 diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportSearchFailuresTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/basic/TransportSearchFailuresTests.java similarity index 93% rename from modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportSearchFailuresTests.java rename to modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/basic/TransportSearchFailuresTests.java index b84a8ff67d5..0b27fe03a2d 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportSearchFailuresTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/basic/TransportSearchFailuresTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.test.integration.search; +package org.elasticsearch.test.integration.search.basic; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.WriteConsistencyLevel; @@ -37,6 +37,7 @@ import org.testng.annotations.Test; import java.io.IOException; import static org.elasticsearch.client.Requests.*; +import static org.elasticsearch.common.settings.ImmutableSettings.*; import static org.elasticsearch.common.xcontent.XContentFactory.*; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; @@ -53,7 +54,11 @@ public class TransportSearchFailuresTests extends AbstractNodesTests { @Test public void testFailedSearchWithWrongQuery() throws Exception { logger.info("Start Testing failed search with wrong query"); startNode("server1"); - client("server1").admin().indices().create(createIndexRequest("test")).actionGet(); + client("server1").admin().indices().create(createIndexRequest("test") + .settings(settingsBuilder().put("number_of_shards", 3).put("number_of_replicas", 2).put("routing.hash.type", "simple"))) + .actionGet(); + + client("server1").admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(); for (int i = 0; i < 100; i++) { index(client("server1"), Integer.toString(i), "test", i); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportTwoServersSearchTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/basic/TransportTwoNodesSearchTests.java similarity index 97% rename from modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportTwoServersSearchTests.java rename to modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/basic/TransportTwoNodesSearchTests.java index 3aff05dc603..2f42bd46e19 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TransportTwoServersSearchTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/basic/TransportTwoNodesSearchTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.test.integration.search; +package org.elasticsearch.test.integration.search.basic; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.search.SearchPhaseExecutionException; @@ -44,6 +44,7 @@ import java.util.Set; import static org.elasticsearch.action.search.SearchType.*; import static org.elasticsearch.client.Requests.*; +import static org.elasticsearch.common.settings.ImmutableSettings.*; import static org.elasticsearch.common.unit.TimeValue.*; import static org.elasticsearch.common.xcontent.XContentFactory.*; import static org.elasticsearch.index.query.xcontent.QueryBuilders.*; @@ -54,7 +55,7 @@ import static org.hamcrest.Matchers.*; /** * @author kimchy (shay.banon) */ -public class TransportTwoServersSearchTests extends AbstractNodesTests { +public class TransportTwoNodesSearchTests extends AbstractNodesTests { private Client client; @@ -63,7 +64,11 @@ public class TransportTwoServersSearchTests extends AbstractNodesTests { startNode("server2"); client = getClient(); - client.admin().indices().create(createIndexRequest("test")).actionGet(); + client.admin().indices().create(createIndexRequest("test") + .settings(settingsBuilder().put("number_of_shards", 3).put("number_of_replicas", 0).put("routing.hash.type", "simple"))) + .actionGet(); + + client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); for (int i = 0; i < 100; i++) { index(client("server1"), Integer.toString(i), "test", i); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/SingleInstanceEmbeddedSearchTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleInstanceEmbeddedSearchTests.java similarity index 95% rename from modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/SingleInstanceEmbeddedSearchTests.java rename to modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleInstanceEmbeddedSearchTests.java index 118485fe6d1..151336ef88b 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/SingleInstanceEmbeddedSearchTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleInstanceEmbeddedSearchTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.test.integration.search; +package org.elasticsearch.test.integration.search.embedded; import org.elasticsearch.client.Client; import org.elasticsearch.common.trove.ExtTIntArrayList; @@ -49,6 +49,7 @@ import java.util.Map; import static org.elasticsearch.client.Requests.*; import static org.elasticsearch.common.collect.Lists.*; +import static org.elasticsearch.common.settings.ImmutableSettings.*; import static org.elasticsearch.index.query.xcontent.QueryBuilders.*; import static org.elasticsearch.search.builder.SearchSourceBuilder.*; import static org.hamcrest.MatcherAssert.*; @@ -66,7 +67,10 @@ public class SingleInstanceEmbeddedSearchTests extends AbstractNodesTests { @BeforeClass public void createNodeAndInitWithData() throws Exception { startNode("server1"); - client("server1").admin().indices().create(createIndexRequest("test")).actionGet(); + client("server1").admin().indices().prepareCreate("test") + .setSettings(settingsBuilder().put("number_of_shards", 1).put("number_of_replicas", 0)) + .execute().actionGet(); + client("server1").admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); index(client("server1"), "1", "test1", 1); index(client("server1"), "2", "test2", 2); index(client("server1"), "3", "test3", 2); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceEmbeddedSearchTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/TwoInstanceEmbeddedSearchTests.java similarity index 98% rename from modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceEmbeddedSearchTests.java rename to modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/TwoInstanceEmbeddedSearchTests.java index 16d7a503209..38705a17a3a 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceEmbeddedSearchTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/TwoInstanceEmbeddedSearchTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.test.integration.search; +package org.elasticsearch.test.integration.search.embedded; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; @@ -28,7 +28,6 @@ import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.search.*; import org.elasticsearch.search.builder.SearchSourceBuilder; @@ -61,6 +60,7 @@ import java.util.concurrent.TimeUnit; import static org.elasticsearch.client.Requests.*; import static org.elasticsearch.common.collect.Lists.*; import static org.elasticsearch.common.collect.Maps.*; +import static org.elasticsearch.common.settings.ImmutableSettings.*; import static org.elasticsearch.common.unit.TimeValue.*; import static org.elasticsearch.index.query.xcontent.QueryBuilders.*; import static org.elasticsearch.search.builder.SearchSourceBuilder.*; @@ -72,8 +72,6 @@ import static org.hamcrest.Matchers.*; */ public class TwoInstanceEmbeddedSearchTests extends AbstractNodesTests { - private IndicesService indicesService; - private ClusterService clusterService; private Map nodeToSearchService; @@ -85,8 +83,9 @@ public class TwoInstanceEmbeddedSearchTests extends AbstractNodesTests { startNode("server2"); clusterService = ((InternalNode) node("server1")).injector().getInstance(ClusterService.class); - indicesService = ((InternalNode) node("server1")).injector().getInstance(IndicesService.class); - client("server1").admin().indices().create(Requests.createIndexRequest("test")).actionGet(); + client("server1").admin().indices().create(Requests.createIndexRequest("test") + .settings(settingsBuilder().put("number_of_shards", 3).put("number_of_replicas", 0))) + .actionGet(); for (int i = 0; i < 100; i++) { index(client("server1"), Integer.toString(i), "test", i); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceUnbalancedShardsEmbeddedSearchTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/TwoInstanceUnbalancedShardsEmbeddedSearchTests.java similarity index 96% rename from modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceUnbalancedShardsEmbeddedSearchTests.java rename to modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/TwoInstanceUnbalancedShardsEmbeddedSearchTests.java index 40b017b46a3..df250357b55 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/TwoInstanceUnbalancedShardsEmbeddedSearchTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/embedded/TwoInstanceUnbalancedShardsEmbeddedSearchTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.test.integration.search; +package org.elasticsearch.test.integration.search.embedded; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; @@ -29,10 +29,10 @@ import org.elasticsearch.cluster.routing.operation.plain.PlainOperationRouting; import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.search.*; import org.elasticsearch.search.builder.SearchSourceBuilder; @@ -63,6 +63,7 @@ import java.util.concurrent.TimeUnit; import static org.elasticsearch.client.Requests.*; import static org.elasticsearch.common.collect.Lists.*; import static org.elasticsearch.common.collect.Maps.*; +import static org.elasticsearch.common.settings.ImmutableSettings.*; import static org.elasticsearch.common.unit.TimeValue.*; import static org.elasticsearch.index.query.xcontent.QueryBuilders.*; import static org.elasticsearch.search.builder.SearchSourceBuilder.*; @@ -75,8 +76,6 @@ import static org.hamcrest.Matchers.*; */ public class TwoInstanceUnbalancedShardsEmbeddedSearchTests extends AbstractNodesTests { - private IndicesService indicesService; - private ClusterService clusterService; private Map nodeToSearchService; @@ -84,13 +83,17 @@ public class TwoInstanceUnbalancedShardsEmbeddedSearchTests extends AbstractNode private SearchPhaseController searchPhaseController; @BeforeClass public void createNodeAndInitWithData() throws Exception { - startNode("server1"); - startNode("server2"); + ImmutableSettings.Builder nodeSettings = ImmutableSettings.settingsBuilder() + .put("cluster.routing.operation.type", "org.elasticsearch.test.integration.search.embedded.TwoInstanceUnbalancedShardsEmbeddedSearchTests$UnevenOperationRoutingModule"); + startNode("server1", nodeSettings); + startNode("server2", nodeSettings); clusterService = ((InternalNode) node("server1")).injector().getInstance(ClusterService.class); - indicesService = ((InternalNode) node("server1")).injector().getInstance(IndicesService.class); - client("server1").admin().indices().create(Requests.createIndexRequest("test")).actionGet(); + client("server1").admin().indices().create(Requests.createIndexRequest("test") + .settings(settingsBuilder().put("number_of_shards", 3).put("number_of_replicas", 0))) + .actionGet(); + client("server1").admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); for (int i = 0; i < 100; i++) { index(client("server1"), Integer.toString(i), "test", i);