diff --git a/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java b/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java index 46953a1b419..25f5a326a1a 100644 --- a/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java +++ b/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java @@ -25,7 +25,7 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.elasticsearch.common.lucene.Lucene; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.io.IOException; @@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.equalTo; /** */ -public class UniqueTokenFilterTests extends ElasticsearchTestCase { +public class UniqueTokenFilterTests extends ElasticSearchTestCase { @Test public void simpleTest() throws IOException { diff --git a/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java b/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java index 933bf6139c4..c2dda54a82a 100644 --- a/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java +++ b/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.aliases; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistResponse; @@ -41,6 +40,7 @@ import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.facet.FacetBuilders; import org.elasticsearch.search.facet.terms.TermsFacet; import org.elasticsearch.search.sort.SortOrder; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Set; @@ -57,7 +57,7 @@ import static org.hamcrest.Matchers.*; /** * */ -public class IndexAliasesTests extends AbstractSharedClusterTest { +public class IndexAliasesTests extends AbstractIntegrationTest { @Test public void testAliases() throws Exception { diff --git a/src/test/java/org/elasticsearch/blocks/SimpleBlocksTests.java b/src/test/java/org/elasticsearch/blocks/SimpleBlocksTests.java index 8ee29901b14..ba5e2d52eba 100644 --- a/src/test/java/org/elasticsearch/blocks/SimpleBlocksTests.java +++ b/src/test/java/org/elasticsearch/blocks/SimpleBlocksTests.java @@ -32,14 +32,13 @@ import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.node.Node; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; import java.util.HashMap; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.notNullValue; public class SimpleBlocksTests extends AbstractNodesTests { diff --git a/src/test/java/org/elasticsearch/broadcast/BroadcastActionsTests.java b/src/test/java/org/elasticsearch/broadcast/BroadcastActionsTests.java index 0226d501982..ee36f49da4e 100644 --- a/src/test/java/org/elasticsearch/broadcast/BroadcastActionsTests.java +++ b/src/test/java/org/elasticsearch/broadcast/BroadcastActionsTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.broadcast; import com.google.common.base.Charsets; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; @@ -28,6 +27,7 @@ import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; @@ -40,7 +40,7 @@ import static org.hamcrest.Matchers.equalTo; /** * */ -public class BroadcastActionsTests extends AbstractSharedClusterTest { +public class BroadcastActionsTests extends AbstractIntegrationTest { @Test public void testBroadcastOperations() throws IOException { diff --git a/src/test/java/org/elasticsearch/cluster/AbstractZenNodesTests.java b/src/test/java/org/elasticsearch/cluster/AbstractZenNodesTests.java index c3ea59640b0..27f35145d95 100644 --- a/src/test/java/org/elasticsearch/cluster/AbstractZenNodesTests.java +++ b/src/test/java/org/elasticsearch/cluster/AbstractZenNodesTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.cluster; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; diff --git a/src/test/java/org/elasticsearch/cluster/ClusterHealthTests.java b/src/test/java/org/elasticsearch/cluster/ClusterHealthTests.java index ac9b6c78c8d..9d66f1f76fc 100644 --- a/src/test/java/org/elasticsearch/cluster/ClusterHealthTests.java +++ b/src/test/java/org/elasticsearch/cluster/ClusterHealthTests.java @@ -22,13 +22,12 @@ package org.elasticsearch.cluster; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -public class ClusterHealthTests extends AbstractSharedClusterTest { +public class ClusterHealthTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java b/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java index 71f7bd716b1..518f790eafe 100644 --- a/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java +++ b/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java @@ -19,12 +19,12 @@ package org.elasticsearch.cluster; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import static org.hamcrest.Matchers.equalTo; -public class DiskUsageTests extends ElasticsearchTestCase { +public class DiskUsageTests extends ElasticSearchTestCase { @Test public void diskUsageCalcTest() { diff --git a/src/test/java/org/elasticsearch/cluster/NoMasterNodeTests.java b/src/test/java/org/elasticsearch/cluster/NoMasterNodeTests.java index 18962bfd57a..792aa9c8c8e 100644 --- a/src/test/java/org/elasticsearch/cluster/NoMasterNodeTests.java +++ b/src/test/java/org/elasticsearch/cluster/NoMasterNodeTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.cluster; import com.google.common.base.Predicate; -import org.elasticsearch.AbstractNodesTests; import org.elasticsearch.action.percolate.PercolateSourceBuilder; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.common.settings.Settings; @@ -29,6 +28,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.discovery.Discovery; import org.elasticsearch.node.Node; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/cluster/SimpleDataNodesTests.java b/src/test/java/org/elasticsearch/cluster/SimpleDataNodesTests.java index 62554f20290..af3e0f152b9 100644 --- a/src/test/java/org/elasticsearch/cluster/SimpleDataNodesTests.java +++ b/src/test/java/org/elasticsearch/cluster/SimpleDataNodesTests.java @@ -23,14 +23,13 @@ import org.elasticsearch.action.UnavailableShardsException; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.Requests; import org.elasticsearch.common.Priority; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; import static org.elasticsearch.client.Requests.createIndexRequest; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** diff --git a/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesTests.java b/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesTests.java index 373978e7e74..654a5790290 100644 --- a/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesTests.java +++ b/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesTests.java @@ -24,7 +24,6 @@ import org.junit.After; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; diff --git a/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationTests.java b/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationTests.java index d4ee5e198d0..ad777517c55 100644 --- a/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationTests.java +++ b/src/test/java/org/elasticsearch/cluster/UpdateSettingsValidationTests.java @@ -22,42 +22,38 @@ package org.elasticsearch.cluster; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.common.Priority; -import org.elasticsearch.AbstractNodesTests; -import org.junit.After; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** */ -public class UpdateSettingsValidationTests extends AbstractNodesTests { - - @After - public void closeNodes() { - closeAllNodes(); - } +@ClusterScope(scope=Scope.TEST, numNodes=0) +public class UpdateSettingsValidationTests extends AbstractIntegrationTest { @Test public void testUpdateSettingsValidation() throws Exception { - startNode("master", settingsBuilder().put("node.data", false).build()); - startNode("node1", settingsBuilder().put("node.master", false).build()); - startNode("node2", settingsBuilder().put("node.master", false).build()); + String master = cluster().startNode(settingsBuilder().put("node.data", false).build()); + String node_1 = cluster().startNode(settingsBuilder().put("node.master", false).build()); + String node_2 = cluster().startNode(settingsBuilder().put("node.master", false).build()); - client("master").admin().indices().prepareCreate("test") + client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", 5).put("index.number_of_replicas", 1)).execute().actionGet(); - ClusterHealthResponse healthResponse = client("master").admin().cluster().prepareHealth("test").setWaitForEvents(Priority.LANGUID).setWaitForNodes("3").setWaitForGreenStatus().execute().actionGet(); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth("test").setWaitForEvents(Priority.LANGUID).setWaitForNodes("3").setWaitForGreenStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); assertThat(healthResponse.getIndices().get("test").getActiveShards(), equalTo(10)); - client("master").admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put("index.number_of_replicas", 0)).execute().actionGet(); - healthResponse = client("master").admin().cluster().prepareHealth("test").setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + client().admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put("index.number_of_replicas", 0)).execute().actionGet(); + healthResponse = client().admin().cluster().prepareHealth("test").setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); assertThat(healthResponse.getIndices().get("test").getActiveShards(), equalTo(5)); try { - client("master").admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put("index.refresh_interval", "")).execute().actionGet(); + client().admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put("index.refresh_interval", "")).execute().actionGet(); assert false; } catch (ElasticSearchIllegalArgumentException ex) { logger.info("Error message: [{}]", ex.getMessage()); diff --git a/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationTests.java b/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationTests.java index 467588fd02f..c1c16694f55 100644 --- a/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/allocation/AwarenessAllocationTests.java @@ -31,8 +31,9 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.AbstractNodesTests; -import org.junit.After; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; @@ -41,15 +42,11 @@ import static org.hamcrest.Matchers.equalTo; /** */ -public class AwarenessAllocationTests extends AbstractNodesTests { +@ClusterScope(scope=Scope.TEST, numNodes=0) +public class AwarenessAllocationTests extends AbstractIntegrationTest { private final ESLogger logger = Loggers.getLogger(AwarenessAllocationTests.class); - @After - public void cleanAndCloseNodes() throws Exception { - closeAllNodes(); - } - @Test public void testSimpleAwareness() throws Exception { Settings commonSettings = ImmutableSettings.settingsBuilder() @@ -57,19 +54,19 @@ public class AwarenessAllocationTests extends AbstractNodesTests { .put("cluster.routing.allocation.awareness.attributes", "rack_id") .build(); - + logger.info("--> starting 2 nodes on the same rack"); - startNode("node1", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.rack_id", "rack_1")); - startNode("node2", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.rack_id", "rack_1")); + cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.rack_id", "rack_1").build()); + cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.rack_id", "rack_1").build()); - client("node1").admin().indices().prepareCreate("test1").execute().actionGet(); - client("node1").admin().indices().prepareCreate("test2").execute().actionGet(); + client().admin().indices().prepareCreate("test1").execute().actionGet(); + client().admin().indices().prepareCreate("test2").execute().actionGet(); - ClusterHealthResponse health = client("node1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); assertThat(health.isTimedOut(), equalTo(false)); logger.info("--> starting 1 node on a different rack"); - startNode("node3", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.rack_id", "rack_2")); + String node3 = cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.rack_id", "rack_2").build()); long start = System.currentTimeMillis(); TObjectIntHashMap counts; @@ -77,11 +74,11 @@ public class AwarenessAllocationTests extends AbstractNodesTests { do { Thread.sleep(100); logger.info("--> waiting for no relocation"); - health = client("node1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("3").setWaitForRelocatingShards(0).execute().actionGet(); + health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("3").setWaitForRelocatingShards(0).execute().actionGet(); assertThat(health.isTimedOut(), equalTo(false)); logger.info("--> checking current state"); - ClusterState clusterState = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); //System.out.println(clusterState.routingTable().prettyPrint()); // verify that we have 10 shards on node3 counts = new TObjectIntHashMap(); @@ -92,8 +89,8 @@ public class AwarenessAllocationTests extends AbstractNodesTests { } } } - } while (counts.get("node3") != 10 && (System.currentTimeMillis() - start) < 10000); - assertThat(counts.get("node3"), equalTo(10)); + } while (counts.get(node3) != 10 && (System.currentTimeMillis() - start) < 10000); + assertThat(counts.get(node3), equalTo(10)); } @Test @@ -105,10 +102,10 @@ public class AwarenessAllocationTests extends AbstractNodesTests { .build(); logger.info("--> starting 6 nodes on different zones"); - startNode("A-0", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "a")); - startNode("B-0", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "b")); - startNode("B-1", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "b")); - startNode("A-1", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "a")); + String A_0 = cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "a").build()); + String B_0 = cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "b").build()); + String B_1 = cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "b").build()); + String A_1 = cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "a").build()); client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", 5) .put("index.number_of_replicas", 1)).execute().actionGet(); @@ -124,10 +121,10 @@ public class AwarenessAllocationTests extends AbstractNodesTests { } } } - assertThat(counts.get("A-1"), anyOf(equalTo(2),equalTo(3))); - assertThat(counts.get("B-1"), anyOf(equalTo(2),equalTo(3))); - assertThat(counts.get("A-0"), anyOf(equalTo(2),equalTo(3))); - assertThat(counts.get("B-0"), anyOf(equalTo(2),equalTo(3))); + assertThat(counts.get(A_1), anyOf(equalTo(2),equalTo(3))); + assertThat(counts.get(B_1), anyOf(equalTo(2),equalTo(3))); + assertThat(counts.get(A_0), anyOf(equalTo(2),equalTo(3))); + assertThat(counts.get(B_0), anyOf(equalTo(2),equalTo(3))); } @Test @@ -140,8 +137,8 @@ public class AwarenessAllocationTests extends AbstractNodesTests { logger.info("--> starting 2 nodes on zones 'a' & 'b'"); - startNode("A-0", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "a")); - startNode("B-0", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "b")); + String A_0 = cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "a").build()); + String B_0 = cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "b").build()); client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", 5) .put("index.number_of_replicas", 1)).execute().actionGet(); @@ -157,11 +154,11 @@ public class AwarenessAllocationTests extends AbstractNodesTests { } } } - assertThat(counts.get("A-0"), equalTo(5)); - assertThat(counts.get("B-0"), equalTo(5)); + assertThat(counts.get(A_0), equalTo(5)); + assertThat(counts.get(B_0), equalTo(5)); logger.info("--> starting another node in zone 'b'"); - startNode("B-1", ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "b")); + String B_1 = cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.zone", "b").build()); health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("3").execute().actionGet(); assertThat(health.isTimedOut(), equalTo(false)); client().admin().cluster().prepareReroute().get(); @@ -179,9 +176,8 @@ public class AwarenessAllocationTests extends AbstractNodesTests { } } } - assertThat(counts.get("A-0"), equalTo(5)); - assertThat(counts.get("B-0"), equalTo(3)); - assertThat(counts.get("B-1"), equalTo(2)); - + assertThat(counts.get(A_0), equalTo(5)); + assertThat(counts.get(B_0), equalTo(3)); + assertThat(counts.get(B_1), equalTo(2)); } } diff --git a/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteTests.java b/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteTests.java index 5ce7a44be06..d839b12aadf 100644 --- a/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteTests.java +++ b/src/test/java/org/elasticsearch/cluster/allocation/ClusterRerouteTests.java @@ -32,11 +32,10 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.gateway.Gateway; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; -import org.junit.After; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import java.io.File; @@ -46,21 +45,11 @@ import static org.hamcrest.Matchers.equalTo; /** */ -public class ClusterRerouteTests extends AbstractNodesTests { +@ClusterScope(scope=Scope.TEST, numNodes=0) +public class ClusterRerouteTests extends AbstractIntegrationTest { private final ESLogger logger = Loggers.getLogger(ClusterRerouteTests.class); - - @After - public void cleanAndCloseNodes() throws Exception { - for (int i = 0; i < 10; i++) { - if (node("node" + i) != null) { - node("node" + i).stop(); - // since we store (by default) the index snapshot under the gateway, resetting it will reset the index data as well - ((InternalNode) node("node" + i)).injector().getInstance(Gateway.class).reset(); - } - } - closeAllNodes(); - } + @Test public void rerouteWithCommands() throws Exception { @@ -69,60 +58,60 @@ public class ClusterRerouteTests extends AbstractNodesTests { .put(DisableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_DISABLE_ALLOCATION, true) .build(); - startNode("node1", commonSettings); - startNode("node2", commonSettings); + String node_1 = cluster().startNode(commonSettings); + String node_2 = cluster().startNode(commonSettings); logger.info("--> create an index with 1 shard, 1 replica, nothing should allocate"); - client("node1").admin().indices().prepareCreate("test") + client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", 1)) .execute().actionGet(); - ClusterState state = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(2)); logger.info("--> explicitly allocate shard 1, *under dry_run*"); - state = client("node1").admin().cluster().prepareReroute() - .add(new AllocateAllocationCommand(new ShardId("test", 0), "node1", true)) + state = client().admin().cluster().prepareReroute() + .add(new AllocateAllocationCommand(new ShardId("test", 0), node_1, true)) .setDryRun(true) .execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(1)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node1").id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_1).id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); logger.info("--> get the state, verify nothing changed because of the dry run"); - state = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(2)); logger.info("--> explicitly allocate shard 1, actually allocating, no dry run"); - state = client("node1").admin().cluster().prepareReroute() - .add(new AllocateAllocationCommand(new ShardId("test", 0), "node1", true)) + state = client().admin().cluster().prepareReroute() + .add(new AllocateAllocationCommand(new ShardId("test", 0), node_1, true)) .execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(1)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node1").id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_1).id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); - ClusterHealthResponse healthResponse = client("node1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); logger.info("--> get the state, verify shard 1 primary allocated"); - state = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(1)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node1").id()).shards().get(0).state(), equalTo(ShardRoutingState.STARTED)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_1).id()).shards().get(0).state(), equalTo(ShardRoutingState.STARTED)); logger.info("--> move shard 1 primary from node1 to node2"); - state = client("node1").admin().cluster().prepareReroute() - .add(new MoveAllocationCommand(new ShardId("test", 0), "node1", "node2")) + state = client().admin().cluster().prepareReroute() + .add(new MoveAllocationCommand(new ShardId("test", 0), node_1, node_2)) .execute().actionGet().getState(); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node1").id()).shards().get(0).state(), equalTo(ShardRoutingState.RELOCATING)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node2").id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_1).id()).shards().get(0).state(), equalTo(ShardRoutingState.RELOCATING)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_2).id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); - healthResponse = client("node1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().setWaitForRelocatingShards(0).execute().actionGet(); + healthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().setWaitForRelocatingShards(0).execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); logger.info("--> get the state, verify shard 1 primary moved from node1 to node2"); - state = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(1)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node2").id()).shards().get(0).state(), equalTo(ShardRoutingState.STARTED)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_2).id()).shards().get(0).state(), equalTo(ShardRoutingState.STARTED)); } @Test @@ -133,69 +122,68 @@ public class ClusterRerouteTests extends AbstractNodesTests { .put("gateway.type", "local") .build(); - // clean three nodes - logger.info("--> cleaning nodes"); - buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); - buildNode("node2", settingsBuilder().put("gateway.type", "local").build()); - cleanAndCloseNodes(); - logger.info("--> starting 2 nodes"); - startNode("node1", commonSettings); - startNode("node2", commonSettings); + String node_1 = cluster().startNode(commonSettings); + cluster().startNode(commonSettings); + assertThat(cluster().numNodes(), equalTo(2)); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForNodes("2").execute().actionGet(); + assertThat(healthResponse.isTimedOut(), equalTo(false)); logger.info("--> create an index with 1 shard, 1 replica, nothing should allocate"); - client("node1").admin().indices().prepareCreate("test") + client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", 1)) .execute().actionGet(); - ClusterState state = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(2)); logger.info("--> explicitly allocate shard 1, actually allocating, no dry run"); - state = client("node1").admin().cluster().prepareReroute() - .add(new AllocateAllocationCommand(new ShardId("test", 0), "node1", true)) + state = client().admin().cluster().prepareReroute() + .add(new AllocateAllocationCommand(new ShardId("test", 0), node_1, true)) .execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(1)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node1").id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_1).id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); - ClusterHealthResponse healthResponse = client("node1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); + healthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); logger.info("--> get the state, verify shard 1 primary allocated"); - state = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(1)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node1").id()).shards().get(0).state(), equalTo(ShardRoutingState.STARTED)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_1).id()).shards().get(0).state(), equalTo(ShardRoutingState.STARTED)); - client("node1").prepareIndex("test", "type", "1").setSource("field", "value").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type", "1").setSource("field", "value").setRefresh(true).execute().actionGet(); logger.info("--> closing all nodes"); - File shardLocation = ((InternalNode) node("node1")).injector().getInstance(NodeEnvironment.class).shardLocations(new ShardId("test", 0))[0]; - closeAllNodes(); + File shardLocation = cluster().getInstance(NodeEnvironment.class).shardLocations(new ShardId("test", 0))[0]; + + cluster().resetAllGateways(); + cluster().closeAllNodesAndReset(); - logger.info("--> deleting the shard data"); + logger.info("--> deleting the shard data [{}] ", shardLocation); FileSystemUtils.deleteRecursively(shardLocation); logger.info("--> starting nodes back, will not allocate the shard since it has no data, but the index will be there"); - startNode("node1", commonSettings); - startNode("node2", commonSettings); + node_1 = cluster().startNode(commonSettings); + cluster().startNode(commonSettings); // wait a bit for the cluster to realize that the shard is not there... // TODO can we get around this? the cluster is RED, so what do we wait for? - Thread.sleep(300); - assertThat(client("node1").admin().cluster().prepareHealth().execute().actionGet().getStatus(), equalTo(ClusterHealthStatus.RED)); + client().admin().cluster().prepareReroute().get(); + assertThat(cluster().client().admin().cluster().prepareHealth().setWaitForNodes("2").execute().actionGet().getStatus(), equalTo(ClusterHealthStatus.RED)); logger.info("--> explicitly allocate primary"); - state = client("node1").admin().cluster().prepareReroute() - .add(new AllocateAllocationCommand(new ShardId("test", 0), "node1", true)) + state = client().admin().cluster().prepareReroute() + .add(new AllocateAllocationCommand(new ShardId("test", 0), node_1, true)) .execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(1)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node1").id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_1).id()).shards().get(0).state(), equalTo(ShardRoutingState.INITIALIZING)); - healthResponse = client("node1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); + healthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); logger.info("--> get the state, verify shard 1 primary allocated"); - state = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.routingNodes().unassigned().size(), equalTo(1)); - assertThat(state.routingNodes().node(state.nodes().resolveNode("node1").id()).shards().get(0).state(), equalTo(ShardRoutingState.STARTED)); + assertThat(state.routingNodes().node(state.nodes().resolveNode(node_1).id()).shards().get(0).state(), equalTo(ShardRoutingState.STARTED)); } diff --git a/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationTests.java b/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationTests.java index f8b67e5ba90..4a03798c27d 100644 --- a/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationTests.java @@ -19,104 +19,91 @@ package org.elasticsearch.cluster.allocation; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.IndexShardRoutingTable; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider; -import org.elasticsearch.common.Priority; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractNodesTests; -import org.junit.After; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** */ -public class FilteringAllocationTests extends AbstractNodesTests { +@ClusterScope(scope=Scope.TEST, numNodes=0) +public class FilteringAllocationTests extends AbstractIntegrationTest { private final ESLogger logger = Loggers.getLogger(FilteringAllocationTests.class); - @After - public void cleanAndCloseNodes() throws Exception { - closeAllNodes(); - } - @Test public void testDecommissionNodeNoReplicas() throws Exception { logger.info("--> starting 2 nodes"); - startNode("node1"); - startNode("node2"); - + final String node_0 = cluster().startNode(); + final String node_1 = cluster().startNode(); + assertThat(cluster().numNodes(), equalTo(2)); + logger.info("--> creating an index with no replicas"); - client("node1").admin().indices().prepareCreate("test") + client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_replicas", 0)) .execute().actionGet(); - - ClusterHealthResponse clusterHealthResponse = client("node1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); - assertThat(clusterHealthResponse.isTimedOut(), equalTo(false)); - + ensureGreen(); logger.info("--> index some data"); for (int i = 0; i < 100; i++) { - client("node1").prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet(); + client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet(); } - client("node1").admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client("node1").prepareCount().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getCount(), equalTo(100l)); + client().admin().indices().prepareRefresh().execute().actionGet(); + assertThat(client().prepareCount().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getCount(), equalTo(100l)); logger.info("--> decommission the second node"); - client("node1").admin().cluster().prepareUpdateSettings() - .setTransientSettings(settingsBuilder().put("cluster.routing.allocation.exclude._name", "node2")) + client().admin().cluster().prepareUpdateSettings() + .setTransientSettings(settingsBuilder().put("cluster.routing.allocation.exclude._name", node_1)) .execute().actionGet(); - Thread.sleep(200); - - clusterHealthResponse = client("node1").admin().cluster().prepareHealth() - .setWaitForGreenStatus() - .setWaitForRelocatingShards(0) - .execute().actionGet(); - assertThat(clusterHealthResponse.isTimedOut(), equalTo(false)); + client().admin().cluster().prepareReroute().get(); + ensureGreen(); logger.info("--> verify all are allocated on node1 now"); - ClusterState clusterState = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - assertThat(clusterState.nodes().get(shardRouting.currentNodeId()).name(), equalTo("node1")); + assertThat(clusterState.nodes().get(shardRouting.currentNodeId()).name(), equalTo(node_0)); } } } - client("node1").admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client("node1").prepareCount().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getCount(), equalTo(100l)); + client().admin().indices().prepareRefresh().execute().actionGet(); + assertThat(client().prepareCount().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getCount(), equalTo(100l)); } @Test public void testDisablingAllocationFiltering() throws Exception { logger.info("--> starting 2 nodes"); - startNode("node1"); - startNode("node2"); + final String node_0 = cluster().startNode(); + final String node_1 = cluster().startNode(); + assertThat(cluster().numNodes(), equalTo(2)); logger.info("--> creating an index with no replicas"); - client("node1").admin().indices().prepareCreate("test") + client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_replicas", 0)) .execute().actionGet(); - ClusterHealthResponse clusterHealthResponse = client("node1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); - assertThat(clusterHealthResponse.isTimedOut(), equalTo(false)); + ensureGreen(); logger.info("--> index some data"); for (int i = 0; i < 100; i++) { - client("node1").prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet(); + client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet(); } - client("node1").admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client("node1").prepareCount().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getCount(), equalTo(100l)); - ClusterState clusterState = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + client().admin().indices().prepareRefresh().execute().actionGet(); + assertThat(client().prepareCount().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getCount(), equalTo(100l)); + ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); IndexRoutingTable indexRoutingTable = clusterState.routingTable().index("test"); int numShardsOnNode1 = 0; for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { @@ -128,48 +115,37 @@ public class FilteringAllocationTests extends AbstractNodesTests { } if (numShardsOnNode1 > ThrottlingAllocationDecider.DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES) { - client("node1").admin().cluster().prepareUpdateSettings() + client().admin().cluster().prepareUpdateSettings() .setTransientSettings(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", numShardsOnNode1)).execute().actionGet(); // make sure we can recover all the nodes at once otherwise we might run into a state where one of the shards has not yet started relocating // but we already fired up the request to wait for 0 relocating shards. } logger.info("--> remove index from the first node"); - client("node1").admin().indices().prepareUpdateSettings("test") - .setSettings(settingsBuilder().put("index.routing.allocation.exclude._name", "node1")) + client().admin().indices().prepareUpdateSettings("test") + .setSettings(settingsBuilder().put("index.routing.allocation.exclude._name", node_0)) .execute().actionGet(); + client().admin().cluster().prepareReroute().get(); + ensureGreen(); - Thread.sleep(200); - - clusterHealthResponse = client("node1").admin().cluster().prepareHealth() - .setWaitForGreenStatus() - .setWaitForRelocatingShards(0) - .execute().actionGet(); - assertThat(clusterHealthResponse.isTimedOut(), equalTo(false)); - - logger.info("--> verify all shards are allocated on node2 now"); - clusterState = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + logger.info("--> verify all shards are allocated on node_1 now"); + clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); indexRoutingTable = clusterState.routingTable().index("test"); for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { for (ShardRouting shardRouting : indexShardRoutingTable) { - assertThat(clusterState.nodes().get(shardRouting.currentNodeId()).name(), equalTo("node2")); + assertThat(clusterState.nodes().get(shardRouting.currentNodeId()).name(), equalTo(node_1)); } } logger.info("--> disable allocation filtering "); - client("node1").admin().indices().prepareUpdateSettings("test") + client().admin().indices().prepareUpdateSettings("test") .setSettings(settingsBuilder().put("index.routing.allocation.exclude._name", "")) .execute().actionGet(); - Thread.sleep(200); - - clusterHealthResponse = client("node1").admin().cluster().prepareHealth() - .setWaitForGreenStatus() - .setWaitForRelocatingShards(0) - .execute().actionGet(); - assertThat(clusterHealthResponse.isTimedOut(), equalTo(false)); + client().admin().cluster().prepareReroute().get(); + ensureGreen(); logger.info("--> verify that there are shards allocated on both nodes now"); - clusterState = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(clusterState.routingTable().index("test").numberOfNodesShardsAreAllocatedOn(), equalTo(2)); } } diff --git a/src/test/java/org/elasticsearch/cluster/allocation/ShardsAllocatorModuleTests.java b/src/test/java/org/elasticsearch/cluster/allocation/ShardsAllocatorModuleTests.java index d0bc3801013..ca787c8587b 100644 --- a/src/test/java/org/elasticsearch/cluster/allocation/ShardsAllocatorModuleTests.java +++ b/src/test/java/org/elasticsearch/cluster/allocation/ShardsAllocatorModuleTests.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.node.Node; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; diff --git a/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationTests.java b/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationTests.java index ea3922cece5..3e90ce3f682 100644 --- a/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/allocation/SimpleAllocationTests.java @@ -18,20 +18,19 @@ */ package org.elasticsearch.cluster.allocation; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.routing.RoutingNode; +import org.elasticsearch.common.Priority; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.junit.Test; import java.util.Map; import java.util.Map.Entry; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.routing.RoutingNode; -import org.elasticsearch.common.Priority; -import org.elasticsearch.AbstractSharedClusterTest; -import org.junit.Test; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.Matchers.equalTo; -public class SimpleAllocationTests extends AbstractSharedClusterTest { +public class SimpleAllocationTests extends AbstractIntegrationTest { /** * Test for diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java index 02290365a51..6a55d61aff8 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java @@ -1,16 +1,5 @@ package org.elasticsearch.cluster.routing.allocation; -import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; -import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; -import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; -import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; -import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; -import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; -import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; -import static org.hamcrest.MatcherAssert.assertThat; - import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; @@ -27,6 +16,17 @@ import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.junit.Test; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; +import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; + public class AddIncrementallyTests { private final ESLogger logger = Loggers.getLogger(AddIncrementallyTests.class); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocatePostApiFlagTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocatePostApiFlagTests.java index 132eb460815..60211f2cebb 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocatePostApiFlagTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocatePostApiFlagTests.java @@ -32,8 +32,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java index 3cffbd7aba5..f04832abb4e 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java @@ -46,8 +46,8 @@ import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java index 4c3837b2ad4..f2d20348252 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java @@ -27,7 +27,7 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; @@ -36,13 +36,13 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.Matchers.*; /** */ -public class AwarenessAllocationTests extends ElasticsearchTestCase { +public class AwarenessAllocationTests extends ElasticSearchTestCase { private final ESLogger logger = Loggers.getLogger(AwarenessAllocationTests.class); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java index b8bc3b0b811..de32a3fa515 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java @@ -48,8 +48,8 @@ import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; public class BalanceConfigurationTests { diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java index d07e2af6184..b92c23e4091 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java @@ -34,8 +34,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java index c4230930bcd..3a8d77769f3 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java @@ -33,8 +33,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java index 94097934f70..1401f85a092 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/DeadNodesAllocationTests.java @@ -34,8 +34,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/DisableAllocationTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/DisableAllocationTests.java index a9aa9baddd0..1e0915060d1 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/DisableAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/DisableAllocationTests.java @@ -35,8 +35,8 @@ import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java index 20cab10ee54..419bb8a3678 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java @@ -35,8 +35,8 @@ import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java index d89e555912e..6cd30e559a6 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java @@ -37,8 +37,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java index 8c745db2442..5b19972993f 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java @@ -38,8 +38,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java index 3416c55b072..e88f4780a87 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java @@ -35,10 +35,11 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** * diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java index bc0c3d8cec3..ef8352fa280 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java @@ -24,7 +24,7 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; @@ -33,13 +33,13 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.Matchers.equalTo; /** */ -public class PreferPrimaryAllocationTests extends ElasticsearchTestCase { +public class PreferPrimaryAllocationTests extends ElasticSearchTestCase { private final ESLogger logger = Loggers.getLogger(PreferPrimaryAllocationTests.class); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java index b6bfa6a004f..5710a8ae87e 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java @@ -34,8 +34,8 @@ import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java index 78dfbea73b2..7e372a38dc6 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java @@ -34,8 +34,8 @@ import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java index 6335b86e5ce..2a781eebe33 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java @@ -34,7 +34,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; import org.elasticsearch.cluster.routing.allocation.decider.Decision; import org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationDecider; import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.hamcrest.Matchers; import org.junit.Test; @@ -48,11 +48,11 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.Matchers.equalTo; -public class RandomAllocationDeciderTests extends ElasticsearchTestCase { +public class RandomAllocationDeciderTests extends ElasticSearchTestCase { /* This test will make random allocation decision on a growing and shrinking * cluster leading to a random distribution of the shards. After a certain diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java index 32515e49e16..12b2c2eb986 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java @@ -34,8 +34,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java index 474aa7f16fc..d6ac14f8e3e 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java @@ -33,8 +33,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java index db9b8c290ba..d26041dee6e 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java @@ -1,6 +1,5 @@ package org.elasticsearch.cluster.routing.allocation; -import org.elasticsearch.ElasticsearchTestCase; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.MutableShardRouting; @@ -10,6 +9,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationD import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; @@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.equalTo; /** */ -public class SameShardRoutingTests extends ElasticsearchTestCase { +public class SameShardRoutingTests extends ElasticSearchTestCase { private final ESLogger logger = Loggers.getLogger(SameShardRoutingTests.class); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java index 9f7d5a15e54..d11d078b363 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java @@ -34,8 +34,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java index 23b8dcfa778..614cf1fd5d7 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsLimitAllocationTests.java @@ -38,8 +38,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java index 1cb56c87300..229516d8b73 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java @@ -33,8 +33,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java index 7351febe970..6ae82dc11e3 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java @@ -33,8 +33,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java index 9a70da27cd4..3573f604ff5 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java @@ -14,8 +14,8 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java index e5ff0c8ed0c..b58b0830173 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java @@ -31,7 +31,7 @@ import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocators; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.util.Arrays; @@ -45,11 +45,11 @@ import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.Matchers.equalTo; -public class DiskThresholdDeciderTests extends ElasticsearchTestCase { +public class DiskThresholdDeciderTests extends ElasticSearchTestCase { @Test public void diskThresholdTest() { diff --git a/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsTests.java b/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsTests.java index 3dae0c28c88..082d61606a6 100644 --- a/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsTests.java +++ b/src/test/java/org/elasticsearch/cluster/shards/ClusterSearchShardsTests.java @@ -20,10 +20,12 @@ package org.elasticsearch.cluster.shards; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsGroup; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsResponse; -import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.AliasAction; import org.elasticsearch.common.Priority; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; @@ -31,30 +33,26 @@ import static org.hamcrest.Matchers.equalTo; /** */ -public class ClusterSearchShardsTests extends AbstractNodesTests { - +@ClusterScope(scope=Scope.SUITE, numNodes=2) +public class ClusterSearchShardsTests extends AbstractIntegrationTest { + @Override - protected void beforeClass() throws Exception { - startNode("node1", settingsBuilder().put("node.tag", "A")); - startNode("node2", settingsBuilder().put("node.tag", "B")); - } - - public Client client() { - return client("node1"); + protected Settings nodeSettings(int nodeOrdinal) { + switch(nodeOrdinal) { + case 1: + return settingsBuilder().put("node.tag", "B").build(); + case 0: + return settingsBuilder().put("node.tag", "A").build(); + } + return super.nodeSettings(nodeOrdinal); } @Test public void testSingleShardAllocation() throws Exception { - try { - client().admin().indices().prepareDelete("test").execute().actionGet(); - } catch (Exception e) { - // ignore - } client().admin().indices().prepareCreate("test").setSettings(settingsBuilder() .put("index.number_of_shards", "1").put("index.number_of_replicas", 0).put("index.routing.allocation.include.tag", "A")).execute().actionGet(); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); - - ClusterSearchShardsResponse response = client("node1").admin().cluster().prepareSearchShards("test").execute().actionGet(); + ensureGreen(); + ClusterSearchShardsResponse response = client().admin().cluster().prepareSearchShards("test").execute().actionGet(); assertThat(response.getGroups().length, equalTo(1)); assertThat(response.getGroups()[0].getIndex(), equalTo("test")); assertThat(response.getGroups()[0].getShardId(), equalTo(0)); @@ -62,7 +60,7 @@ public class ClusterSearchShardsTests extends AbstractNodesTests { assertThat(response.getNodes().length, equalTo(1)); assertThat(response.getGroups()[0].getShards()[0].currentNodeId(), equalTo(response.getNodes()[0].getId())); - response = client("node2").admin().cluster().prepareSearchShards("test").setRouting("A").execute().actionGet(); + response = client().admin().cluster().prepareSearchShards("test").setRouting("A").execute().actionGet(); assertThat(response.getGroups().length, equalTo(1)); assertThat(response.getGroups()[0].getIndex(), equalTo("test")); assertThat(response.getGroups()[0].getShardId(), equalTo(0)); @@ -74,41 +72,26 @@ public class ClusterSearchShardsTests extends AbstractNodesTests { @Test public void testMultipleShardsSingleNodeAllocation() throws Exception { - try { - client().admin().indices().prepareDelete("test").execute().actionGet(); - } catch (Exception e) { - // ignore - } client().admin().indices().prepareCreate("test").setSettings(settingsBuilder() .put("index.number_of_shards", "4").put("index.number_of_replicas", 0).put("index.routing.allocation.include.tag", "A")).execute().actionGet(); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + ensureGreen(); - ClusterSearchShardsResponse response = client("node1").admin().cluster().prepareSearchShards("test").execute().actionGet(); + ClusterSearchShardsResponse response = client().admin().cluster().prepareSearchShards("test").execute().actionGet(); assertThat(response.getGroups().length, equalTo(4)); assertThat(response.getGroups()[0].getIndex(), equalTo("test")); assertThat(response.getNodes().length, equalTo(1)); assertThat(response.getGroups()[0].getShards()[0].currentNodeId(), equalTo(response.getNodes()[0].getId())); - response = client("node1").admin().cluster().prepareSearchShards("test").setRouting("ABC").execute().actionGet(); + response = client().admin().cluster().prepareSearchShards("test").setRouting("ABC").execute().actionGet(); assertThat(response.getGroups().length, equalTo(1)); - response = client("node1").admin().cluster().prepareSearchShards("test").setPreference("_shards:2").execute().actionGet(); + response = client().admin().cluster().prepareSearchShards("test").setPreference("_shards:2").execute().actionGet(); assertThat(response.getGroups().length, equalTo(1)); assertThat(response.getGroups()[0].getShardId(), equalTo(2)); } @Test public void testMultipleIndicesAllocation() throws Exception { - try { - client().admin().indices().prepareDelete("test1").execute().actionGet(); - } catch (Exception e) { - // ignore - } - try { - client().admin().indices().prepareDelete("test2").execute().actionGet(); - } catch (Exception e) { - // ignore - } client().admin().indices().prepareCreate("test1").setSettings(settingsBuilder() .put("index.number_of_shards", "4").put("index.number_of_replicas", 1)).execute().actionGet(); client().admin().indices().prepareCreate("test2").setSettings(settingsBuilder() diff --git a/src/test/java/org/elasticsearch/codecs/CodecTests.java b/src/test/java/org/elasticsearch/codecs/CodecTests.java index b3dc679bdf4..8abb06674ca 100644 --- a/src/test/java/org/elasticsearch/codecs/CodecTests.java +++ b/src/test/java/org/elasticsearch/codecs/CodecTests.java @@ -24,17 +24,16 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.index.query.MatchQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.equalTo; /** */ -public class CodecTests extends AbstractSharedClusterTest { +public class CodecTests extends AbstractIntegrationTest { @Test public void testFieldsWithCustomPostingsFormat() throws Exception { diff --git a/src/test/java/org/elasticsearch/common/geo/GeoJSONShapeParserTests.java b/src/test/java/org/elasticsearch/common/geo/GeoJSONShapeParserTests.java index 46cd38b8375..359ac661508 100644 --- a/src/test/java/org/elasticsearch/common/geo/GeoJSONShapeParserTests.java +++ b/src/test/java/org/elasticsearch/common/geo/GeoJSONShapeParserTests.java @@ -43,7 +43,7 @@ import com.vividsolutions.jts.geom.MultiPolygon; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Polygon; -import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertEquals; +import static org.elasticsearch.test.hamcrest.ElasticSearchGeoAssertions.assertEquals; /** * Tests for {@link GeoJSONShapeParser} diff --git a/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java b/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java index 71e08a5065b..f0878eb39e9 100644 --- a/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java +++ b/src/test/java/org/elasticsearch/common/geo/ShapeBuilderTests.java @@ -28,8 +28,8 @@ import com.vividsolutions.jts.geom.Polygon; import org.elasticsearch.common.geo.builders.ShapeBuilder; import org.junit.Test; -import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertMultiLineString; -import static org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertMultiPolygon; +import static org.elasticsearch.test.hamcrest.ElasticSearchGeoAssertions.assertMultiLineString; +import static org.elasticsearch.test.hamcrest.ElasticSearchGeoAssertions.assertMultiPolygon; import static org.junit.Assert.assertEquals; /** * Tests for {@link ShapeBuilder} diff --git a/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java b/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java index 6bf02edf3e2..633d6285729 100644 --- a/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java +++ b/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java @@ -35,7 +35,7 @@ import org.elasticsearch.common.Numbers; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.merge.policy.IndexUpgraderMergePolicy; -import org.elasticsearch.ElasticsearchLuceneTestCase; +import org.elasticsearch.test.ElasticSearchLuceneTestCase; import org.hamcrest.MatcherAssert; import org.junit.Test; @@ -46,7 +46,7 @@ import java.util.Map; import static org.hamcrest.Matchers.*; -public class VersionsTests extends ElasticsearchLuceneTestCase { +public class VersionsTests extends ElasticSearchLuceneTestCase { public static DirectoryReader reopen(DirectoryReader reader) throws IOException { return reopen(reader, true); diff --git a/src/test/java/org/elasticsearch/common/regex/RegexTests.java b/src/test/java/org/elasticsearch/common/regex/RegexTests.java index 41c2f668295..fc2fdb7bd6b 100644 --- a/src/test/java/org/elasticsearch/common/regex/RegexTests.java +++ b/src/test/java/org/elasticsearch/common/regex/RegexTests.java @@ -18,14 +18,14 @@ */ package org.elasticsearch.common.regex; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.util.Random; import java.util.regex.Pattern; import static org.hamcrest.Matchers.equalTo; -public class RegexTests extends ElasticsearchTestCase { +public class RegexTests extends ElasticSearchTestCase { @Test public void testFlags() { diff --git a/src/test/java/org/elasticsearch/common/settings/ImmutableSettingsTests.java b/src/test/java/org/elasticsearch/common/settings/ImmutableSettingsTests.java index 4c0d357782a..9a363e6587b 100644 --- a/src/test/java/org/elasticsearch/common/settings/ImmutableSettingsTests.java +++ b/src/test/java/org/elasticsearch/common/settings/ImmutableSettingsTests.java @@ -19,9 +19,9 @@ package org.elasticsearch.common.settings; -import org.elasticsearch.ElasticsearchTestCase; import org.elasticsearch.common.settings.bar.BarTestClass; import org.elasticsearch.common.settings.foo.FooTestClass; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; @@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.*; /** */ -public class ImmutableSettingsTests extends ElasticsearchTestCase{ +public class ImmutableSettingsTests extends ElasticSearchTestCase{ @Test public void testGetAsClass() { diff --git a/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java b/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java index 25a4e6a7bb1..d923893252e 100644 --- a/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java +++ b/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.common.util.concurrent; import com.google.common.base.Predicate; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.util.concurrent.CountDownLatch; @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.lessThan; /** */ -public class EsExecutorsTests extends ElasticsearchTestCase { +public class EsExecutorsTests extends ElasticSearchTestCase { private TimeUnit randomTimeUnit() { return TimeUnit.values()[between(0, TimeUnit.values().length - 1)]; diff --git a/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelTests.java b/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelTests.java index f70b8e2811a..79cad4747dc 100644 --- a/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelTests.java +++ b/src/test/java/org/elasticsearch/consistencylevel/WriteConsistencyLevelTests.java @@ -25,7 +25,7 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.unit.TimeValue.timeValueMillis; @@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.equalTo; /** * */ -public class WriteConsistencyLevelTests extends AbstractSharedClusterTest { +public class WriteConsistencyLevelTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/count/query/SimpleQueryTests.java b/src/test/java/org/elasticsearch/count/query/SimpleQueryTests.java index d6114e3ec54..7b54dc10bf4 100644 --- a/src/test/java/org/elasticsearch/count/query/SimpleQueryTests.java +++ b/src/test/java/org/elasticsearch/count/query/SimpleQueryTests.java @@ -29,7 +29,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.*; import org.elasticsearch.index.query.CommonTermsQueryBuilder.Operator; import org.elasticsearch.index.query.MatchQueryBuilder.Type; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.ISODateTimeFormat; @@ -40,12 +40,12 @@ import java.io.IOException; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; /** * */ -public class SimpleQueryTests extends AbstractSharedClusterTest { +public class SimpleQueryTests extends AbstractIntegrationTest { @Test public void passQueryAsStringTest() throws Exception { diff --git a/src/test/java/org/elasticsearch/count/simple/SimpleCountTests.java b/src/test/java/org/elasticsearch/count/simple/SimpleCountTests.java index c04585f30d4..e981d008431 100644 --- a/src/test/java/org/elasticsearch/count/simple/SimpleCountTests.java +++ b/src/test/java/org/elasticsearch/count/simple/SimpleCountTests.java @@ -4,7 +4,7 @@ import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.concurrent.ExecutionException; @@ -12,10 +12,10 @@ import java.util.concurrent.ExecutionException; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; -public class SimpleCountTests extends AbstractSharedClusterTest { +public class SimpleCountTests extends AbstractIntegrationTest { @Test public void testCountRandomPreference() throws InterruptedException, ExecutionException { diff --git a/src/test/java/org/elasticsearch/deleteByQuery/DeleteByQueryTests.java b/src/test/java/org/elasticsearch/deleteByQuery/DeleteByQueryTests.java index 3eb8e597c87..58d8737b8c9 100644 --- a/src/test/java/org/elasticsearch/deleteByQuery/DeleteByQueryTests.java +++ b/src/test/java/org/elasticsearch/deleteByQuery/DeleteByQueryTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.deleteByQuery; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder; import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse; import org.elasticsearch.action.search.SearchResponse; @@ -27,13 +26,14 @@ import org.elasticsearch.action.support.IgnoreIndices; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Assert; import org.junit.Test; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; -public class DeleteByQueryTests extends AbstractSharedClusterTest { +public class DeleteByQueryTests extends AbstractIntegrationTest { @Test public void testDeleteAllNoIndices() { diff --git a/src/test/java/org/elasticsearch/discovery/DiscoveryTests.java b/src/test/java/org/elasticsearch/discovery/DiscoveryTests.java index d29a763885c..e2705070424 100644 --- a/src/test/java/org/elasticsearch/discovery/DiscoveryTests.java +++ b/src/test/java/org/elasticsearch/discovery/DiscoveryTests.java @@ -22,28 +22,28 @@ package org.elasticsearch.discovery; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -public class DiscoveryTests extends AbstractNodesTests { +@ClusterScope(scope=Scope.SUITE, numNodes=2) +public class DiscoveryTests extends AbstractIntegrationTest { + @Override + protected Settings nodeSettings(int nodeOrdinal) { + return ImmutableSettings.settingsBuilder().put("discovery.zen.multicast.enabled", false) + .put("discovery.zen.unicast.hosts", "localhost").put(super.nodeSettings(nodeOrdinal)).build(); + } + @Test public void testUnicastDiscovery() { - Settings settings = ImmutableSettings.settingsBuilder() - .put("discovery.zen.multicast.enabled", false) - .put("discovery.zen.unicast.hosts", "localhost") - .build(); - - startNode("node1", settings); - startNode("node2", settings); - - ClusterState state = client("node1").admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.nodes().size(), equalTo(2)); - state = client("node2").admin().cluster().prepareState().execute().actionGet().getState(); + state = client().admin().cluster().prepareState().execute().actionGet().getState(); assertThat(state.nodes().size(), equalTo(2)); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPingTests.java b/src/test/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPingTests.java index 2c2a1a16d8d..4cd2bfcb0f6 100644 --- a/src/test/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPingTests.java +++ b/src/test/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPingTests.java @@ -32,7 +32,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import org.elasticsearch.discovery.zen.ping.ZenPing; import org.elasticsearch.node.service.NodeService; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.local.LocalTransport; @@ -47,7 +47,7 @@ import static org.hamcrest.Matchers.equalTo; /** * */ -public class MulticastZenPingTests extends ElasticsearchTestCase { +public class MulticastZenPingTests extends ElasticSearchTestCase { private Settings buildRandomMulticast(Settings settings) { ImmutableSettings.Builder builder = ImmutableSettings.builder().put(settings); diff --git a/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingTests.java b/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingTests.java index 121a961b127..4f86a2ac7aa 100644 --- a/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingTests.java +++ b/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingTests.java @@ -31,7 +31,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import org.elasticsearch.discovery.zen.ping.ZenPing; import org.elasticsearch.node.service.NodeService; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.netty.NettyTransport; @@ -42,7 +42,7 @@ import static org.hamcrest.Matchers.equalTo; /** * */ -public class UnicastZenPingTests extends ElasticsearchTestCase { +public class UnicastZenPingTests extends ElasticSearchTestCase { @Test public void testSimplePings() { diff --git a/src/test/java/org/elasticsearch/document/BulkTests.java b/src/test/java/org/elasticsearch/document/BulkTests.java index 9e28dc1a7b0..a4e29f1ff91 100644 --- a/src/test/java/org/elasticsearch/document/BulkTests.java +++ b/src/test/java/org/elasticsearch/document/BulkTests.java @@ -12,19 +12,19 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.index.VersionType; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.concurrent.CyclicBarrier; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertSearchHits; import static org.hamcrest.Matchers.*; /** */ -public class BulkTests extends AbstractSharedClusterTest { +public class BulkTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/document/DocumentActionsTests.java b/src/test/java/org/elasticsearch/document/DocumentActionsTests.java index db81a6ae9d7..e8fead8a992 100644 --- a/src/test/java/org/elasticsearch/document/DocumentActionsTests.java +++ b/src/test/java/org/elasticsearch/document/DocumentActionsTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.document; import com.google.common.base.Charsets; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse; @@ -37,6 +36,7 @@ import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading; import org.elasticsearch.action.support.replication.ReplicationType; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; @@ -44,14 +44,14 @@ import java.util.Map; import static org.elasticsearch.client.Requests.*; import static org.elasticsearch.index.query.QueryBuilders.termQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; /** * */ -public class DocumentActionsTests extends AbstractSharedClusterTest { +public class DocumentActionsTests extends AbstractIntegrationTest { protected void createIndex() { wipeIndex(getConcreteIndexName()); diff --git a/src/test/java/org/elasticsearch/explain/ExplainActionTests.java b/src/test/java/org/elasticsearch/explain/ExplainActionTests.java index daa02ef87ad..619b384eaf1 100644 --- a/src/test/java/org/elasticsearch/explain/ExplainActionTests.java +++ b/src/test/java/org/elasticsearch/explain/ExplainActionTests.java @@ -19,11 +19,11 @@ package org.elasticsearch.explain; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.explain.ExplainResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Map; @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.equalTo; /** */ -public class ExplainActionTests extends AbstractSharedClusterTest { +public class ExplainActionTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/flt/FuzzyLikeThisActionTests.java b/src/test/java/org/elasticsearch/flt/FuzzyLikeThisActionTests.java index 577443e7f4d..5902d3a1e77 100644 --- a/src/test/java/org/elasticsearch/flt/FuzzyLikeThisActionTests.java +++ b/src/test/java/org/elasticsearch/flt/FuzzyLikeThisActionTests.java @@ -21,19 +21,19 @@ package org.elasticsearch.flt; import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.fuzzyLikeThisFieldQuery; import static org.elasticsearch.index.query.QueryBuilders.fuzzyLikeThisQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertThrows; import static org.hamcrest.Matchers.equalTo; /** * */ -public class FuzzyLikeThisActionTests extends AbstractSharedClusterTest { +public class FuzzyLikeThisActionTests extends AbstractIntegrationTest { @Test // See issue https://github.com/elasticsearch/elasticsearch/issues/3252 diff --git a/src/test/java/org/elasticsearch/gateway/fs/IndexGatewayTests.java b/src/test/java/org/elasticsearch/gateway/fs/IndexGatewayTests.java index 39457d7a96e..e09acead15b 100644 --- a/src/test/java/org/elasticsearch/gateway/fs/IndexGatewayTests.java +++ b/src/test/java/org/elasticsearch/gateway/fs/IndexGatewayTests.java @@ -21,7 +21,6 @@ package org.elasticsearch.gateway.fs; import com.carrotsearch.randomizedtesting.annotations.Nightly; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractNodesTests; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; @@ -40,6 +39,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.gateway.Gateway; import org.elasticsearch.indices.IndexAlreadyExistsException; import org.elasticsearch.node.internal.InternalNode; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java b/src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java index 6344cebe4d6..92ffacc65a7 100644 --- a/src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java +++ b/src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java @@ -36,7 +36,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.gateway.Gateway; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/gateway/local/QuorumLocalGatewayTests.java b/src/test/java/org/elasticsearch/gateway/local/QuorumLocalGatewayTests.java index d89ce0df378..50ef986e118 100644 --- a/src/test/java/org/elasticsearch/gateway/local/QuorumLocalGatewayTests.java +++ b/src/test/java/org/elasticsearch/gateway/local/QuorumLocalGatewayTests.java @@ -21,13 +21,13 @@ package org.elasticsearch.gateway.local; import com.google.common.base.Predicate; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractNodesTests; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.gateway.Gateway; import org.elasticsearch.node.Node; import org.elasticsearch.node.internal.InternalNode; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; @@ -37,8 +37,8 @@ import static org.elasticsearch.client.Requests.clusterHealthRequest; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.equalTo; /** diff --git a/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java b/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java index fd327d99866..35948dd06e6 100644 --- a/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java +++ b/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java @@ -37,7 +37,7 @@ import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.node.Node; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; @@ -46,7 +46,7 @@ import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilde import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.*; /** diff --git a/src/test/java/org/elasticsearch/gateway/none/RecoverAfterNodesTests.java b/src/test/java/org/elasticsearch/gateway/none/RecoverAfterNodesTests.java index a2b7fe746bd..477c4d23ccd 100644 --- a/src/test/java/org/elasticsearch/gateway/none/RecoverAfterNodesTests.java +++ b/src/test/java/org/elasticsearch/gateway/none/RecoverAfterNodesTests.java @@ -22,7 +22,7 @@ package org.elasticsearch.gateway.none; import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.gateway.GatewayService; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/get/GetActionTests.java b/src/test/java/org/elasticsearch/get/GetActionTests.java index b2dc3a010d3..ce171022543 100644 --- a/src/test/java/org/elasticsearch/get/GetActionTests.java +++ b/src/test/java/org/elasticsearch/get/GetActionTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.get; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.delete.DeleteResponse; @@ -33,6 +32,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.engine.VersionConflictEngineException; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Map; @@ -41,7 +41,7 @@ import static org.elasticsearch.client.Requests.clusterHealthRequest; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.*; -public class GetActionTests extends AbstractSharedClusterTest { +public class GetActionTests extends AbstractIntegrationTest { @Test public void simpleGetTests() { diff --git a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java b/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java index 5881d673bde..d3653e791f6 100644 --- a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.analysis; +import com.google.common.base.Charsets; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; @@ -38,20 +39,14 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNameModule; +import org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; -import org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory; import org.hamcrest.MatcherAssert; import org.junit.Test; -import com.google.common.base.Charsets; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.io.StringReader; +import java.io.*; import java.util.Set; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; diff --git a/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java index 03e4e8b87b0..e9eeade9742 100644 --- a/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/CJKFilterFactoryTests.java @@ -21,7 +21,7 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.standard.StandardTokenizer; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; diff --git a/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java b/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java index dca2f7f2ec5..95c711a84bf 100644 --- a/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java @@ -29,7 +29,7 @@ import org.elasticsearch.index.IndexNameModule; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; diff --git a/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java index e4ef9b2309e..401d16ed7ae 100644 --- a/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java @@ -21,7 +21,7 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.common.inject.ProvisionException; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.io.IOException; @@ -30,7 +30,7 @@ import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilde import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -public class HunspellTokenFilterFactoryTests extends ElasticsearchTestCase { +public class HunspellTokenFilterFactoryTests extends ElasticSearchTestCase { @Test public void testDedup() throws IOException { diff --git a/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java index fa8af28b7ea..f2fad3b36d1 100644 --- a/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java @@ -24,7 +24,7 @@ import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java index 7750530952b..545cff6a526 100644 --- a/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactoryTests.java @@ -23,7 +23,7 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; diff --git a/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java index 8bb5f106c81..15d4f1f5478 100644 --- a/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java @@ -31,7 +31,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings.Builder; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; diff --git a/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java b/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java index 6a7549ae23f..500d0b7eb31 100644 --- a/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java @@ -23,7 +23,7 @@ import org.apache.lucene.analysis.NumericTokenStream; import org.apache.lucene.analysis.NumericTokenStream.NumericTermAttribute; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.io.IOException; @@ -31,7 +31,7 @@ import java.io.IOException; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -public class NumericAnalyzerTests extends ElasticsearchTestCase { +public class NumericAnalyzerTests extends ElasticSearchTestCase { @Test public void testAttributeEqual() throws IOException { diff --git a/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java b/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java index 58050014ae8..2d914635263 100644 --- a/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java @@ -30,7 +30,7 @@ import org.elasticsearch.index.IndexNameModule; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; diff --git a/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java index 80c307af50e..a6193e4d6f6 100644 --- a/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactoryTests.java @@ -23,7 +23,7 @@ import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; diff --git a/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java b/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java index 1036054f263..fa3db0f406a 100644 --- a/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java @@ -30,7 +30,7 @@ import org.elasticsearch.index.IndexNameModule; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; diff --git a/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java index 2a72e3a438f..db64e5aa1cf 100644 --- a/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactoryTests.java @@ -21,7 +21,7 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; diff --git a/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java index fc93f1321b5..830b33d6bd7 100644 --- a/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java @@ -26,9 +26,9 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.analysis.AnalysisService; -import org.elasticsearch.index.analysis.TokenFilterFactory; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; import org.elasticsearch.index.analysis.AnalysisTestsHelper; +import org.elasticsearch.index.analysis.TokenFilterFactory; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/codec/CodecTests.java b/src/test/java/org/elasticsearch/index/codec/CodecTests.java index b956b0b8a81..2f8eae9aea7 100644 --- a/src/test/java/org/elasticsearch/index/codec/CodecTests.java +++ b/src/test/java/org/elasticsearch/index/codec/CodecTests.java @@ -42,14 +42,14 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperServiceModule; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.index.similarity.SimilarityModule; -import org.elasticsearch.ElasticsearchLuceneTestCase; +import org.elasticsearch.test.ElasticSearchLuceneTestCase; import org.junit.Before; import org.junit.Test; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; -public class CodecTests extends ElasticsearchLuceneTestCase { +public class CodecTests extends ElasticSearchLuceneTestCase { @Override @Before diff --git a/src/test/java/org/elasticsearch/index/engine/robin/RobinEngineTests.java b/src/test/java/org/elasticsearch/index/engine/robin/RobinEngineTests.java index 6d6028e7ae0..26f71372a42 100644 --- a/src/test/java/org/elasticsearch/index/engine/robin/RobinEngineTests.java +++ b/src/test/java/org/elasticsearch/index/engine/robin/RobinEngineTests.java @@ -27,7 +27,6 @@ import org.apache.lucene.document.TextField; import org.apache.lucene.index.IndexDeletionPolicy; import org.apache.lucene.index.Term; import org.apache.lucene.search.TermQuery; -import org.elasticsearch.ElasticsearchTestCase; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.lucene.Lucene; @@ -61,6 +60,7 @@ import org.elasticsearch.index.store.ram.RamDirectoryService; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.index.translog.TranslogSizeMatcher; import org.elasticsearch.index.translog.fs.FsTranslog; +import org.elasticsearch.test.ElasticSearchTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.hamcrest.MatcherAssert; import org.junit.After; @@ -83,7 +83,7 @@ import static org.hamcrest.Matchers.*; /** * */ -public class RobinEngineTests extends ElasticsearchTestCase { +public class RobinEngineTests extends ElasticSearchTestCase { protected final ShardId shardId = new ShardId(new Index("index"), 1); diff --git a/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTests.java b/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTests.java index 2dcf2453a69..3c8cf4403bd 100644 --- a/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTests.java +++ b/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTests.java @@ -25,12 +25,12 @@ import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.index.Index; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.After; import org.junit.Before; // we might wanna cut this over to LuceneTestCase -public abstract class AbstractFieldDataTests extends ElasticsearchTestCase { +public abstract class AbstractFieldDataTests extends ElasticSearchTestCase { protected IndexFieldDataService ifdService; protected IndexWriter writer; diff --git a/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationTests.java b/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationTests.java index 0c2d682f041..2f61268f5d4 100644 --- a/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationTests.java +++ b/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.fielddata; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; @@ -27,6 +26,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.search.facet.Facets; import org.elasticsearch.search.facet.terms.TermsFacet; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -35,9 +35,9 @@ import java.io.IOException; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.search.facet.FacetBuilders.termsFacet; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertAcked; -public class FieldDataFilterIntegrationTests extends AbstractSharedClusterTest { +public class FieldDataFilterIntegrationTests extends AbstractIntegrationTest { @Test public void testRegexpFilter() throws IOException { diff --git a/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java b/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java index 03de723183b..e274657021b 100644 --- a/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java +++ b/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.fielddata.ordinals; import org.apache.lucene.util.LongsRef; import org.apache.lucene.util.packed.PackedInts; import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.io.IOException; @@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.equalTo; /** */ -public class MultiOrdinalsTests extends ElasticsearchTestCase { +public class MultiOrdinalsTests extends ElasticSearchTestCase { protected final Ordinals creationMultiOrdinals(OrdinalsBuilder builder) { return this.creationMultiOrdinals(builder, ImmutableSettings.builder()); diff --git a/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java index 3d16f0b06d7..f9fbeeaaa89 100644 --- a/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java @@ -23,8 +23,8 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.compress.CompressorFactory; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.MapperTestUtils; +import org.elasticsearch.index.mapper.ParsedDocument; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java index c53fcdd4251..c4d67794991 100644 --- a/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java @@ -24,12 +24,8 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.compress.CompressorFactory; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.ParsedDocument; -import org.elasticsearch.ElasticsearchTestCase; -import org.elasticsearch.index.mapper.MapperTestUtils; +import org.elasticsearch.index.mapper.*; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.util.Map; @@ -39,7 +35,7 @@ import static org.hamcrest.Matchers.equalTo; /** * */ -public class DefaultSourceMappingTests extends ElasticsearchTestCase { +public class DefaultSourceMappingTests extends ElasticSearchTestCase { @Test public void testNoFormat() throws Exception { diff --git a/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java b/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java index 71e660f7050..77876638a7d 100644 --- a/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java +++ b/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java @@ -32,7 +32,6 @@ import org.apache.lucene.search.spans.*; import org.apache.lucene.spatial.prefix.IntersectsPrefixTreeFilter; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.NumericUtils; -import org.elasticsearch.ElasticsearchTestCase; import org.elasticsearch.cache.recycler.CacheRecyclerModule; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.common.bytes.BytesArray; @@ -64,6 +63,7 @@ import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.index.similarity.SimilarityModule; import org.elasticsearch.indices.query.IndicesQueriesModule; import org.elasticsearch.script.ScriptModule; +import org.elasticsearch.test.ElasticSearchTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPoolModule; import org.hamcrest.Matchers; @@ -82,13 +82,13 @@ import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.RegexpFlag.*; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.factorFunction; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBooleanSubQuery; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertBooleanSubQuery; import static org.hamcrest.Matchers.*; /** * */ -public class SimpleIndexQueryParserTests extends ElasticsearchTestCase { +public class SimpleIndexQueryParserTests extends ElasticSearchTestCase { private static Injector injector; diff --git a/src/test/java/org/elasticsearch/index/store/mock/MockDirectoryHelper.java b/src/test/java/org/elasticsearch/index/store/mock/MockDirectoryHelper.java index e824881723a..1bd729b96ee 100644 --- a/src/test/java/org/elasticsearch/index/store/mock/MockDirectoryHelper.java +++ b/src/test/java/org/elasticsearch/index/store/mock/MockDirectoryHelper.java @@ -23,7 +23,6 @@ import com.carrotsearch.randomizedtesting.SeedUtils; import org.apache.lucene.store.*; import org.apache.lucene.store.MockDirectoryWrapper.Throttling; import org.apache.lucene.util.Constants; -import org.elasticsearch.ElasticsearchTestCase; import org.elasticsearch.cache.memory.ByteBufferCache; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.settings.Settings; @@ -37,6 +36,7 @@ import org.elasticsearch.index.store.fs.NioFsDirectoryService; import org.elasticsearch.index.store.fs.SimpleFsDirectoryService; import org.elasticsearch.index.store.memory.ByteBufferDirectoryService; import org.elasticsearch.index.store.ram.RamDirectoryService; +import org.elasticsearch.test.ElasticSearchTestCase; import java.util.Random; import java.util.Set; @@ -58,7 +58,7 @@ public class MockDirectoryHelper { public MockDirectoryHelper(ShardId shardId, Settings indexSettings, ESLogger logger) { randomIOExceptionRate = indexSettings.getAsDouble(RANDOM_IO_EXCEPTION_RATE, 0.0d); randomIOExceptionRateOnOpen = indexSettings.getAsDouble(RANDOM_IO_EXCEPTION_RATE_ON_OPEN, 0.0d); - final long seed = indexSettings.getAsLong(ElasticsearchTestCase.INDEX_SEED_SETTING, 0l); + final long seed = indexSettings.getAsLong(ElasticSearchTestCase.INDEX_SEED_SETTING, 0l); random = new Random(seed); random.nextInt(shardId.getId() + 1); // some randomness per shard throttle = Throttling.valueOf(indexSettings.get(RANDOM_THROTTLE, random.nextDouble() < 0.1 ? "SOMETIMES" : "NEVER")); diff --git a/src/test/java/org/elasticsearch/indexing/IndexActionTests.java b/src/test/java/org/elasticsearch/indexing/IndexActionTests.java index c7dbad1c20c..4a94c759028 100644 --- a/src/test/java/org/elasticsearch/indexing/IndexActionTests.java +++ b/src/test/java/org/elasticsearch/indexing/IndexActionTests.java @@ -22,7 +22,7 @@ package org.elasticsearch.indexing; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.index.VersionType; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.ArrayList; @@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo; /** * */ -public class IndexActionTests extends AbstractSharedClusterTest { +public class IndexActionTests extends AbstractIntegrationTest { @Test public void testCreatedFlag() throws Exception { diff --git a/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionTests.java b/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionTests.java index aae251463b8..047ceef5a48 100644 --- a/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionTests.java +++ b/src/test/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionTests.java @@ -32,7 +32,7 @@ import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.Discovery; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/indices/IgnoreIndicesTests.java b/src/test/java/org/elasticsearch/indices/IgnoreIndicesTests.java index e700a7b1b98..0e21ecc2a43 100644 --- a/src/test/java/org/elasticsearch/indices/IgnoreIndicesTests.java +++ b/src/test/java/org/elasticsearch/indices/IgnoreIndicesTests.java @@ -19,17 +19,17 @@ package org.elasticsearch.indices; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; import org.elasticsearch.action.search.MultiSearchResponse; import org.elasticsearch.action.support.IgnoreIndices; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.hamcrest.Matchers.*; -public class IgnoreIndicesTests extends AbstractSharedClusterTest { +public class IgnoreIndicesTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionTests.java b/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionTests.java index 9ecdbb7f14e..8d3cbf776ea 100644 --- a/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionTests.java +++ b/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionTests.java @@ -25,18 +25,17 @@ import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequestBuilder; import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse; import org.elasticsearch.common.Priority; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * */ -public class AnalyzeActionTests extends AbstractSharedClusterTest { +public class AnalyzeActionTests extends AbstractIntegrationTest { @Test public void simpleAnalyzerTests() throws Exception { diff --git a/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceTests.java b/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceTests.java index c71580bde5d..7cf302ffd23 100644 --- a/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceTests.java +++ b/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceTests.java @@ -25,10 +25,9 @@ import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.indices.analysis.HunspellService; -import org.elasticsearch.node.Node; -import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; -import org.junit.After; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import static org.hamcrest.Matchers.equalTo; @@ -37,14 +36,9 @@ import static org.hamcrest.Matchers.notNullValue; /** * */ -public class HunspellServiceTests extends AbstractNodesTests { +@ClusterScope(scope=Scope.TEST, numNodes=0) +public class HunspellServiceTests extends AbstractIntegrationTest { - - @After - public void closeNodes() { - closeAllNodes(); - } - @Test public void testLocaleDirectoryWithNodeLevelConfig() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() @@ -53,9 +47,8 @@ public class HunspellServiceTests extends AbstractNodesTests { .put("indices.analysis.hunspell.dictionary.ignore_case", true) .build(); - Node node = startNode("node1", settings); - - HunspellDictionary dictionary = ((InternalNode) node).injector().getInstance(HunspellService.class).getDictionary("en_US"); + cluster().startNode(settings); + HunspellDictionary dictionary = cluster().getInstance(HunspellService.class).getDictionary("en_US"); assertThat(dictionary, notNullValue()); Version expectedVersion = Lucene.parseVersion(settings.get("indices.analysis.hunspell.version"), Lucene.ANALYZER_VERSION, logger); assertThat(dictionary.getVersion(), equalTo(expectedVersion)); @@ -72,9 +65,8 @@ public class HunspellServiceTests extends AbstractNodesTests { .put("indices.analysis.hunspell.dictionary.en_US.ignore_case", false) .build(); - Node node = startNode("node1", settings); - - HunspellDictionary dictionary = ((InternalNode) node).injector().getInstance(HunspellService.class).getDictionary("en_US"); + cluster().startNode(settings); + HunspellDictionary dictionary = cluster().getInstance(HunspellService.class).getDictionary("en_US"); assertThat(dictionary, notNullValue()); Version expectedVersion = Lucene.parseVersion(settings.get("indices.analysis.hunspell.version"), Lucene.ANALYZER_VERSION, logger); assertThat(dictionary.getVersion(), equalTo(expectedVersion)); @@ -82,7 +74,7 @@ public class HunspellServiceTests extends AbstractNodesTests { // testing that dictionary specific settings override node level settings - dictionary = ((InternalNode) node).injector().getInstance(HunspellService.class).getDictionary("en_US_custom"); + dictionary = cluster().getInstance(HunspellService.class).getDictionary("en_US_custom"); assertThat(dictionary, notNullValue()); assertThat(dictionary.getVersion(), equalTo(expectedVersion)); assertThat(dictionary.isIgnoreCase(), equalTo(true)); @@ -94,9 +86,8 @@ public class HunspellServiceTests extends AbstractNodesTests { .put("indices.analysis.hunspell.dictionary.location", getResource("/indices/analyze/conf_dir/hunspell")) .build(); - Node node = startNode("node1", settings); - - HunspellDictionary dictionary = ((InternalNode) node).injector().getInstance(HunspellService.class).getDictionary("en_US"); + cluster().startNode(settings); + HunspellDictionary dictionary = cluster().getInstance(HunspellService.class).getDictionary("en_US"); assertThat(dictionary, notNullValue()); } diff --git a/src/test/java/org/elasticsearch/indices/cache/CacheTests.java b/src/test/java/org/elasticsearch/indices/cache/CacheTests.java index a79a458e4bf..aacbeb21348 100644 --- a/src/test/java/org/elasticsearch/indices/cache/CacheTests.java +++ b/src/test/java/org/elasticsearch/indices/cache/CacheTests.java @@ -23,34 +23,30 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.search.sort.SortOrder; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** */ -public class CacheTests extends AbstractNodesTests { - +@ClusterScope(scope=Scope.SUITE, numNodes=1) +public class CacheTests extends AbstractIntegrationTest { @Override - protected void beforeClass() throws Exception { - // Filter cache is cleaned periodically, default is 60s, so make sure it runs often. Thread.sleep for 60s is bad - startNode("node1", ImmutableSettings.settingsBuilder().put("indices.cache.filter.clean_interval", "1ms")); + protected Settings nodeSettings(int nodeOrdinal) { + //Filter cache is cleaned periodically, default is 60s, so make sure it runs often. Thread.sleep for 60s is bad + return ImmutableSettings.settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put("indices.cache.filter.clean_interval", "1ms").build(); } - @Override - public Client client() { - return client("node1"); - } - @Test public void testClearCacheFilterKeys() { client().admin().indices().prepareDelete().execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java b/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java index 5aa07d4b123..d409b7cea2a 100644 --- a/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java +++ b/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java @@ -24,15 +24,13 @@ import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; import org.elasticsearch.action.support.IgnoreIndices; import org.elasticsearch.client.Client; import org.elasticsearch.indices.IndexMissingException; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.fail; -public class TypesExistsTests extends AbstractSharedClusterTest { +public class TypesExistsTests extends AbstractIntegrationTest { @Test public void testSimple() throws Exception { diff --git a/src/test/java/org/elasticsearch/indices/leaks/IndicesLeaksTests.java b/src/test/java/org/elasticsearch/indices/leaks/IndicesLeaksTests.java index 0fe7ed267d9..898190997cd 100644 --- a/src/test/java/org/elasticsearch/indices/leaks/IndicesLeaksTests.java +++ b/src/test/java/org/elasticsearch/indices/leaks/IndicesLeaksTests.java @@ -29,7 +29,7 @@ import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.Node; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateTests.java b/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateTests.java index 936cc6d0b77..4224aa94edc 100644 --- a/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateTests.java +++ b/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateTests.java @@ -25,7 +25,7 @@ import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.index.query.MatchQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHits; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.HashMap; @@ -37,7 +37,7 @@ import java.util.concurrent.CountDownLatch; import static org.hamcrest.Matchers.emptyIterable; -public class ConcurrentDynamicTemplateTests extends AbstractSharedClusterTest { +public class ConcurrentDynamicTemplateTests extends AbstractIntegrationTest { private final String mappingType = "test-mapping"; diff --git a/src/test/java/org/elasticsearch/indices/mapping/SimpleDeleteMappingTests.java b/src/test/java/org/elasticsearch/indices/mapping/SimpleDeleteMappingTests.java index d734aa3edf9..935d71cbe91 100644 --- a/src/test/java/org/elasticsearch/indices/mapping/SimpleDeleteMappingTests.java +++ b/src/test/java/org/elasticsearch/indices/mapping/SimpleDeleteMappingTests.java @@ -19,10 +19,10 @@ package org.elasticsearch.indices.mapping; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.*; /** * */ -public class SimpleDeleteMappingTests extends AbstractSharedClusterTest { +public class SimpleDeleteMappingTests extends AbstractIntegrationTest { @Test public void simpleDeleteMapping() throws Exception { diff --git a/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsTests.java b/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsTests.java index 777b1c8b117..e6d37e4e446 100644 --- a/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsTests.java +++ b/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsTests.java @@ -23,7 +23,7 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.elasticsearch.common.Priority; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.*; /** * */ -public class SimpleGetMappingsTests extends AbstractSharedClusterTest { +public class SimpleGetMappingsTests extends AbstractIntegrationTest { @Test public void getMappingsWhereThereAreNone() { diff --git a/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingTests.java b/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingTests.java index 10ed7b6aee7..9c4ed489dc2 100644 --- a/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingTests.java +++ b/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingTests.java @@ -1,6 +1,5 @@ package org.elasticsearch.indices.mapping; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; @@ -14,6 +13,7 @@ import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MergeMappingException; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -23,11 +23,11 @@ import java.util.concurrent.CyclicBarrier; import java.util.concurrent.atomic.AtomicBoolean; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertThrows; import static org.hamcrest.Matchers.*; -public class UpdateMappingTests extends AbstractSharedClusterTest { +public class UpdateMappingTests extends AbstractIntegrationTest { @Test public void dynamicUpdates() throws Exception { diff --git a/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasTests.java b/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasTests.java index 76757b35105..fe16488d249 100644 --- a/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasTests.java +++ b/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasTests.java @@ -23,19 +23,19 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.common.Priority; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.equalTo; /** * */ -public class UpdateNumberOfReplicasTests extends AbstractSharedClusterTest { +public class UpdateNumberOfReplicasTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsTests.java b/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsTests.java index b00d9129084..c788f03125a 100644 --- a/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsTests.java +++ b/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsTests.java @@ -25,14 +25,14 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.index.engine.VersionConflictEngineException; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertThrows; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -public class UpdateSettingsTests extends AbstractSharedClusterTest { +public class UpdateSettingsTests extends AbstractIntegrationTest { @Test public void testOpenCloseUpdateSettings() throws Exception { diff --git a/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllTests.java b/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllTests.java index 30aa9f685ad..6d2cf1039b2 100644 --- a/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllTests.java +++ b/src/test/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllTests.java @@ -22,84 +22,74 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; -import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.AbstractNodesTests; -import org.junit.After; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; -public class CloseIndexDisableCloseAllTests extends AbstractNodesTests { +@ClusterScope(scope=Scope.SUITE, numNodes=2) +public class CloseIndexDisableCloseAllTests extends AbstractIntegrationTest { @Override - protected void beforeClass() { - ImmutableSettings.Builder settings = ImmutableSettings.builder().put("action.disable_close_all_indices", true); - startNode("server1", settings); - startNode("server2", settings); + protected Settings nodeSettings(int nodeOrdinal) { + return ImmutableSettings.settingsBuilder().put("action.disable_close_all_indices", true).put(super.nodeSettings(nodeOrdinal)).build(); } - @After - public void wipeAllIndices() { - wipeIndices(client("server1"), "_all"); - } @Test(expected = ElasticSearchIllegalArgumentException.class) public void testCloseAllExplicitly() { - Client client = client("server1"); - createIndices(client, "test1", "test2", "test3"); - ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); + createIndex("test1", "test2", "test3"); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); - client.admin().indices().prepareClose("_all").execute().actionGet(); + client().admin().indices().prepareClose("_all").execute().actionGet(); } @Test(expected = ElasticSearchIllegalArgumentException.class) public void testCloseAllWildcard() { - Client client = client("server2"); - createIndices(client, "test1", "test2", "test3"); - ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); + createIndex("test1", "test2", "test3"); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); - client.admin().indices().prepareClose("*").execute().actionGet(); + client().admin().indices().prepareClose("*").execute().actionGet(); } @Test(expected = ElasticSearchIllegalArgumentException.class) public void testCloseAllWildcard2() { - Client client = client("server2"); - createIndices(client, "test1", "test2", "test3"); - ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); + createIndex("test1", "test2", "test3"); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); - client.admin().indices().prepareClose("test*").execute().actionGet(); + client().admin().indices().prepareClose("test*").execute().actionGet(); } @Test public void testCloseWildcardNonMatchingAll() { - Client client = client("server1"); - createIndices(client, "test1", "test2", "test3"); - ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); + createIndex("test1", "test2", "test3"); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); - CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("*", "-test1").execute().actionGet(); + CloseIndexResponse closeIndexResponse = client().admin().indices().prepareClose("*", "-test1").execute().actionGet(); assertThat(closeIndexResponse.isAcknowledged(), equalTo(true)); assertIndexIsClosed("test2", "test3"); } @Test(expected = ElasticSearchIllegalArgumentException.class) public void testCloseWildcardMatchingAll() { - Client client = client("server2"); - createIndices(client, "test1", "test2", "test3"); - ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); + createIndex("test1", "test2", "test3"); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); - client.admin().indices().prepareClose("*", "-test1", "+test1").execute().actionGet(); + client().admin().indices().prepareClose("*", "-test1", "+test1").execute().actionGet(); } @Test public void testCloseWildcardNonMatchingAll2() { - Client client = client("server1"); - createIndices(client, "test1", "test2", "test3", "a"); - ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); + createIndex( "test1", "test2", "test3", "a"); + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); assertThat(healthResponse.isTimedOut(), equalTo(false)); - CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test*").execute().actionGet(); + CloseIndexResponse closeIndexResponse = client().admin().indices().prepareClose("test*").execute().actionGet(); assertThat(closeIndexResponse.isAcknowledged(), equalTo(true)); assertIndexIsClosed("test1", "test2", "test3"); } @@ -109,7 +99,7 @@ public class CloseIndexDisableCloseAllTests extends AbstractNodesTests { } private void checkIndexState(IndexMetaData.State state, String... indices) { - ClusterStateResponse clusterStateResponse = client("server1").admin().cluster().prepareState().execute().actionGet(); + ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().execute().actionGet(); for (String index : indices) { IndexMetaData indexMetaData = clusterStateResponse.getState().metaData().indices().get(index); assertThat(indexMetaData, notNullValue()); diff --git a/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java b/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java index 5d6198b7720..1ca11bd8aef 100644 --- a/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java +++ b/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java @@ -31,13 +31,13 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.junit.annotations.TestLogging; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; -public class OpenCloseIndexTests extends AbstractSharedClusterTest { +public class OpenCloseIndexTests extends AbstractIntegrationTest { @Test public void testSimpleCloseOpen() { diff --git a/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java b/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java index bd93ee687de..4ffab904360 100644 --- a/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java +++ b/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java @@ -35,12 +35,11 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.SettingsException; import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; diff --git a/src/test/java/org/elasticsearch/indices/stats/SimpleIndexStatsTests.java b/src/test/java/org/elasticsearch/indices/stats/SimpleIndexStatsTests.java index 6647773af2f..23b4f406c85 100644 --- a/src/test/java/org/elasticsearch/indices/stats/SimpleIndexStatsTests.java +++ b/src/test/java/org/elasticsearch/indices/stats/SimpleIndexStatsTests.java @@ -23,12 +23,13 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.indices.stats.*; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.client.Client; import org.elasticsearch.common.Priority; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.BytesStreamInput; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import java.io.IOException; @@ -40,22 +41,11 @@ import static org.hamcrest.Matchers.*; /** * */ -public class SimpleIndexStatsTests extends AbstractNodesTests { - - @Override - protected void beforeClass() { - startNode("node1"); - startNode("node2"); - } - - @Override - public Client client() { - return client("node2"); - } +@ClusterScope(scope=Scope.SUITE, numNodes=2) +public class SimpleIndexStatsTests extends AbstractIntegrationTest { @Test public void simpleStats() throws Exception { - client().admin().indices().prepareDelete().execute().actionGet(); // rely on 1 replica for this tests client().admin().indices().prepareCreate("test1").execute().actionGet(); client().admin().indices().prepareCreate("test2").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java b/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java index b892fe8cd02..677cc528a58 100644 --- a/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java +++ b/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.Test; import java.io.File; diff --git a/src/test/java/org/elasticsearch/indices/store/SimpleDistributorTests.java b/src/test/java/org/elasticsearch/indices/store/SimpleDistributorTests.java index 55386e7d806..b89ef3e5a55 100644 --- a/src/test/java/org/elasticsearch/indices/store/SimpleDistributorTests.java +++ b/src/test/java/org/elasticsearch/indices/store/SimpleDistributorTests.java @@ -25,7 +25,7 @@ import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateTests.java b/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateTests.java index 0ad455f8e10..5ceea9b2a64 100644 --- a/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateTests.java +++ b/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateTests.java @@ -20,13 +20,13 @@ package org.elasticsearch.indices.template; import com.google.common.collect.Lists; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.Priority; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.indices.IndexTemplateAlreadyExistsException; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Arrays; @@ -38,7 +38,7 @@ import static org.hamcrest.Matchers.*; /** * */ -public class SimpleIndexTemplateTests extends AbstractSharedClusterTest { +public class SimpleIndexTemplateTests extends AbstractIntegrationTest { @Test public void simpleIndexTemplateTests() throws Exception { diff --git a/src/test/java/org/elasticsearch/indices/warmer/LocalGatewayIndicesWarmerTests.java b/src/test/java/org/elasticsearch/indices/warmer/LocalGatewayIndicesWarmerTests.java index 4ce27d75381..f98da6fc293 100644 --- a/src/test/java/org/elasticsearch/indices/warmer/LocalGatewayIndicesWarmerTests.java +++ b/src/test/java/org/elasticsearch/indices/warmer/LocalGatewayIndicesWarmerTests.java @@ -30,7 +30,7 @@ import org.elasticsearch.gateway.Gateway; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.search.warmer.IndexWarmersMetaData; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.hamcrest.Matchers; import org.junit.After; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerTests.java b/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerTests.java index 7bbf31809f1..cdf8aaf9d64 100644 --- a/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerTests.java +++ b/src/test/java/org/elasticsearch/indices/warmer/SimpleIndicesWarmerTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.warmer.IndexWarmerMissingException; import org.elasticsearch.search.warmer.IndexWarmersMetaData; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo; /** */ -public class SimpleIndicesWarmerTests extends AbstractSharedClusterTest { +public class SimpleIndicesWarmerTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/junit/listeners/ReproduceInfoPrinter.java b/src/test/java/org/elasticsearch/junit/listeners/ReproduceInfoPrinter.java index ec008349d55..a168b1b2b27 100644 --- a/src/test/java/org/elasticsearch/junit/listeners/ReproduceInfoPrinter.java +++ b/src/test/java/org/elasticsearch/junit/listeners/ReproduceInfoPrinter.java @@ -1,11 +1,12 @@ package org.elasticsearch.junit.listeners; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.ElasticSearchTestCase; + import com.carrotsearch.randomizedtesting.RandomizedContext; import com.carrotsearch.randomizedtesting.ReproduceErrorMessageBuilder; import com.carrotsearch.randomizedtesting.SeedUtils; import com.carrotsearch.randomizedtesting.TraceFormatting; -import org.elasticsearch.AbstractSharedClusterTest; -import org.elasticsearch.ElasticsearchTestCase; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.junit.internal.AssumptionViolatedException; @@ -21,7 +22,7 @@ import java.util.Arrays; */ public class ReproduceInfoPrinter extends RunListener { - protected final ESLogger logger = Loggers.getLogger(ElasticsearchTestCase.class); + protected final ESLogger logger = Loggers.getLogger(ElasticSearchTestCase.class); @Override public void testStarted(Description description) throws Exception { @@ -45,8 +46,8 @@ public class ReproduceInfoPrinter extends RunListener { b.append("FAILURE : ").append(d.getDisplayName()).append("\n"); b.append("REPRODUCE WITH : mvn test"); ReproduceErrorMessageBuilder builder = new MavenMessageBuilder(b).appendAllOpts(failure.getDescription()); - if (AbstractSharedClusterTest.class.isAssignableFrom(failure.getDescription().getTestClass())) { - builder.appendOpt("tests.cluster_seed", SeedUtils.formatSeed(ElasticsearchTestCase.SHARED_CLUSTER_SEED)); + if (AbstractIntegrationTest.class.isAssignableFrom(failure.getDescription().getTestClass())) { + builder.appendOpt("tests.cluster_seed", SeedUtils.formatSeed(ElasticSearchTestCase.SHARED_CLUSTER_SEED)); } b.append("\n"); diff --git a/src/test/java/org/elasticsearch/mget/SimpleMgetTests.java b/src/test/java/org/elasticsearch/mget/SimpleMgetTests.java index d7e16c58a8c..a867f3ce765 100644 --- a/src/test/java/org/elasticsearch/mget/SimpleMgetTests.java +++ b/src/test/java/org/elasticsearch/mget/SimpleMgetTests.java @@ -24,7 +24,7 @@ import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.search.fetch.source.FetchSourceContext; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; @@ -33,7 +33,7 @@ import java.util.Map; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.*; -public class SimpleMgetTests extends AbstractSharedClusterTest { +public class SimpleMgetTests extends AbstractIntegrationTest { @Test public void testThatMgetShouldWorkWithOneIndexMissing() throws IOException { diff --git a/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java b/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java index f90373cd8b8..7b7fe4a82fe 100644 --- a/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java +++ b/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java @@ -19,13 +19,13 @@ package org.elasticsearch.mlt; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.client.Requests.*; @@ -33,14 +33,14 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.termFilter; import static org.elasticsearch.index.query.QueryBuilders.moreLikeThisFieldQuery; import static org.elasticsearch.index.query.QueryBuilders.moreLikeThisQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; /** * */ -public class MoreLikeThisActionTests extends AbstractSharedClusterTest { +public class MoreLikeThisActionTests extends AbstractIntegrationTest { @Test public void testSimpleMoreLikeThis() throws Exception { diff --git a/src/test/java/org/elasticsearch/nested/SimpleNestedTests.java b/src/test/java/org/elasticsearch/nested/SimpleNestedTests.java index a41ba1de24d..ab797850862 100644 --- a/src/test/java/org/elasticsearch/nested/SimpleNestedTests.java +++ b/src/test/java/org/elasticsearch/nested/SimpleNestedTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.nested; import org.apache.lucene.search.Explanation; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; import org.elasticsearch.action.delete.DeleteResponse; @@ -40,7 +39,8 @@ import org.elasticsearch.search.facet.statistical.StatisticalFacet; import org.elasticsearch.search.facet.termsstats.TermsStatsFacet; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.junit.Assert; import org.junit.Test; @@ -48,11 +48,11 @@ import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilde import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; -public class SimpleNestedTests extends AbstractSharedClusterTest { +public class SimpleNestedTests extends AbstractIntegrationTest { @Test public void simpleNested() throws Exception { @@ -70,7 +70,7 @@ public class SimpleNestedTests extends AbstractSharedClusterTest { endObject(). endObject(). endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", builder)); + ElasticSearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", builder)); ensureGreen(); // check on no data, see it works diff --git a/src/test/java/org/elasticsearch/node/InternalNodeTests.java b/src/test/java/org/elasticsearch/node/InternalNodeTests.java index 5fad244b857..77fe6f2578e 100644 --- a/src/test/java/org/elasticsearch/node/InternalNodeTests.java +++ b/src/test/java/org/elasticsearch/node/InternalNodeTests.java @@ -28,14 +28,13 @@ import org.elasticsearch.common.inject.Singleton; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.plugins.AbstractPlugin; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** diff --git a/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoTests.java b/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoTests.java index e301a129995..7b946b32031 100644 --- a/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoTests.java +++ b/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoTests.java @@ -32,9 +32,9 @@ import org.elasticsearch.action.admin.cluster.node.info.PluginsInfo; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; import org.elasticsearch.nodesinfo.plugin.dummy1.TestPlugin; import org.elasticsearch.nodesinfo.plugin.dummy2.TestNoVersionPlugin; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; @@ -44,11 +44,11 @@ import java.net.URL; import java.util.Collections; import java.util.List; -import static com.google.common.base.Predicates.*; +import static com.google.common.base.Predicates.and; +import static com.google.common.base.Predicates.isNull; import static org.elasticsearch.client.Requests.clusterHealthRequest; import static org.elasticsearch.client.Requests.nodesInfoRequest; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** diff --git a/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorTests.java b/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorTests.java index 8c1494a2e01..4f1f4118c5d 100644 --- a/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorTests.java +++ b/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorTests.java @@ -34,7 +34,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.Before; import org.junit.Test; @@ -49,8 +49,8 @@ import java.util.concurrent.atomic.AtomicReference; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; import static org.elasticsearch.percolator.PercolatorTests.convertFromTextArray; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; diff --git a/src/test/java/org/elasticsearch/percolator/DeletePercolatorTypeTests.java b/src/test/java/org/elasticsearch/percolator/DeletePercolatorTypeTests.java index 28f4f362301..408d7b477f9 100644 --- a/src/test/java/org/elasticsearch/percolator/DeletePercolatorTypeTests.java +++ b/src/test/java/org/elasticsearch/percolator/DeletePercolatorTypeTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.Node; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.Test; import java.util.List; @@ -20,7 +20,7 @@ import java.util.concurrent.CountDownLatch; import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.equalTo; /** diff --git a/src/test/java/org/elasticsearch/percolator/MultiPercolatorTests.java b/src/test/java/org/elasticsearch/percolator/MultiPercolatorTests.java index b31acf49697..efd32fe1434 100644 --- a/src/test/java/org/elasticsearch/percolator/MultiPercolatorTests.java +++ b/src/test/java/org/elasticsearch/percolator/MultiPercolatorTests.java @@ -23,19 +23,19 @@ import org.elasticsearch.action.percolate.MultiPercolateRequestBuilder; import org.elasticsearch.action.percolate.MultiPercolateResponse; import org.elasticsearch.client.Requests; import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; import static org.elasticsearch.percolator.PercolatorTests.convertFromTextArray; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; /** */ -public class MultiPercolatorTests extends AbstractSharedClusterTest { +public class MultiPercolatorTests extends AbstractIntegrationTest { @Test public void testBasics() throws Exception { diff --git a/src/test/java/org/elasticsearch/percolator/PercolatorTests.java b/src/test/java/org/elasticsearch/percolator/PercolatorTests.java index 39eead9b6d6..9256ba57f5d 100644 --- a/src/test/java/org/elasticsearch/percolator/PercolatorTests.java +++ b/src/test/java/org/elasticsearch/percolator/PercolatorTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.percolator; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; @@ -43,6 +42,7 @@ import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.functionscore.factor.FactorBuilder; import org.elasticsearch.search.highlight.HighlightBuilder; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.*; @@ -53,13 +53,13 @@ import static org.elasticsearch.common.xcontent.XContentFactory.*; import static org.elasticsearch.index.query.FilterBuilders.termFilter; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; /** * */ -public class PercolatorTests extends AbstractSharedClusterTest { +public class PercolatorTests extends AbstractIntegrationTest { @Test public void testSimple1() throws Exception { diff --git a/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorTests.java b/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorTests.java index 951e7419ccd..5387cbb985c 100644 --- a/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorTests.java +++ b/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.percolator; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractNodesTests; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; @@ -39,6 +38,7 @@ import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.gateway.Gateway; import org.elasticsearch.junit.annotations.TestLogging; import org.elasticsearch.node.internal.InternalNode; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; @@ -53,7 +53,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.percolator.PercolatorTests.convertFromTextArray; import static org.elasticsearch.percolator.TTLPercolatorTests.ensureGreen; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; public class RecoveryPercolatorTests extends AbstractNodesTests { diff --git a/src/test/java/org/elasticsearch/percolator/TTLPercolatorTests.java b/src/test/java/org/elasticsearch/percolator/TTLPercolatorTests.java index a17cd619dcc..715cc9c9e9c 100644 --- a/src/test/java/org/elasticsearch/percolator/TTLPercolatorTests.java +++ b/src/test/java/org/elasticsearch/percolator/TTLPercolatorTests.java @@ -10,14 +10,14 @@ import org.elasticsearch.client.Requests; import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; import static org.elasticsearch.percolator.PercolatorTests.convertFromTextArray; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; /** diff --git a/src/test/java/org/elasticsearch/plugin/PluginManagerTests.java b/src/test/java/org/elasticsearch/plugin/PluginManagerTests.java index cecfe3251ae..cd8e48883b3 100644 --- a/src/test/java/org/elasticsearch/plugin/PluginManagerTests.java +++ b/src/test/java/org/elasticsearch/plugin/PluginManagerTests.java @@ -30,9 +30,9 @@ import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.plugins.PluginManager; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.AbstractNodesTests; import org.elasticsearch.rest.helper.HttpClient; import org.elasticsearch.rest.helper.HttpClientResponse; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/plugin/ResponseHeaderPluginTests.java b/src/test/java/org/elasticsearch/plugin/ResponseHeaderPluginTests.java index 480c0e83876..565426266dd 100644 --- a/src/test/java/org/elasticsearch/plugin/ResponseHeaderPluginTests.java +++ b/src/test/java/org/elasticsearch/plugin/ResponseHeaderPluginTests.java @@ -21,45 +21,35 @@ package org.elasticsearch.plugin; import com.google.common.collect.Maps; import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.http.HttpServerTransport; -import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.AbstractNodesTests; import org.elasticsearch.plugin.responseheader.TestResponseHeaderPlugin; +import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.helper.HttpClient; import org.elasticsearch.rest.helper.HttpClientResponse; -import org.junit.After; -import org.junit.Before; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import java.util.Map; -import static org.elasticsearch.client.Requests.clusterHealthRequest; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * Test a rest action that sets special response headers */ -public class ResponseHeaderPluginTests extends AbstractNodesTests { +@ClusterScope(scope=Scope.SUITE, numNodes=1) +public class ResponseHeaderPluginTests extends AbstractIntegrationTest { - public static final String NODE_ID = "TEST"; - - @Before - public void startNode() throws Exception { - ImmutableSettings.Builder settings = settingsBuilder().put("plugin.types", TestResponseHeaderPlugin.class.getName()); - startNode(NODE_ID, settings); - client(NODE_ID).admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet(); - } - - @After - public void closeNodes() { - closeAllNodes(); + @Override + protected Settings nodeSettings(int nodeOrdinal) { + return ImmutableSettings.settingsBuilder().put("plugin.types", TestResponseHeaderPlugin.class.getName()).put(super.nodeSettings(nodeOrdinal)).build(); } @Test public void testThatSettingHeadersWorks() throws Exception { + ensureGreen(); HttpClientResponse response = httpClient().request("/_protected"); assertThat(response.errorCode(), equalTo(RestStatus.UNAUTHORIZED.getStatus())); assertThat(response.getHeader("Secret"), equalTo("required")); @@ -72,7 +62,7 @@ public class ResponseHeaderPluginTests extends AbstractNodesTests { } private HttpClient httpClient() { - HttpServerTransport httpServerTransport = ((InternalNode) node(NODE_ID)).injector().getInstance(HttpServerTransport.class); + HttpServerTransport httpServerTransport = cluster().getInstance(HttpServerTransport.class); return new HttpClient(httpServerTransport.boundAddress().publishAddress()); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/plugin/SitePluginTests.java b/src/test/java/org/elasticsearch/plugin/SitePluginTests.java index 176f633fa72..0f4b0162c31 100644 --- a/src/test/java/org/elasticsearch/plugin/SitePluginTests.java +++ b/src/test/java/org/elasticsearch/plugin/SitePluginTests.java @@ -19,14 +19,14 @@ package org.elasticsearch.plugin; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.http.HttpServerTransport; -import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.AbstractNodesTests; import org.elasticsearch.rest.helper.HttpClient; import org.elasticsearch.rest.helper.HttpClientResponse; -import org.junit.After; -import org.junit.Before; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import java.io.File; @@ -39,24 +39,25 @@ import static org.hamcrest.Matchers.equalTo; /** * We want to test site plugins */ -public class SitePluginTests extends AbstractNodesTests { +@ClusterScope(scope=Scope.SUITE, numNodes=1) +public class SitePluginTests extends AbstractIntegrationTest { - @Before - public void startNodes() throws URISyntaxException { + @Override + protected Settings nodeSettings(int nodeOrdinal) { + try { File pluginDir = new File(SitePluginTests.class.getResource("/org/elasticsearch/plugin").toURI()); - startNode("test", settingsBuilder() + return settingsBuilder() + .put(super.nodeSettings(nodeOrdinal)) .put("path.plugins", pluginDir.getAbsolutePath()) - .build()); - } - - @After - public void closeNodes() { - closeAllNodes(); + .build(); + } catch (URISyntaxException ex) { + throw new RuntimeException(ex); + } } public HttpClient httpClient(String id) { - HttpServerTransport httpServerTransport = ((InternalNode) node(id)).injector().getInstance(HttpServerTransport.class); + HttpServerTransport httpServerTransport = cluster().getInstance(HttpServerTransport.class); return new HttpClient(httpServerTransport.boundAddress().publishAddress()); } diff --git a/src/test/java/org/elasticsearch/recovery/FullRollingRestartTests.java b/src/test/java/org/elasticsearch/recovery/FullRollingRestartTests.java index 83774d3bf20..c83767285a6 100644 --- a/src/test/java/org/elasticsearch/recovery/FullRollingRestartTests.java +++ b/src/test/java/org/elasticsearch/recovery/FullRollingRestartTests.java @@ -22,7 +22,7 @@ package org.elasticsearch.recovery; import org.apache.lucene.util.LuceneTestCase.Slow; import org.elasticsearch.common.Priority; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadTests.java b/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadTests.java index 39c8a2c3788..d87c4d518b4 100644 --- a/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadTests.java +++ b/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadTests.java @@ -21,7 +21,6 @@ package org.elasticsearch.recovery; import com.google.common.base.Predicate; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.admin.indices.stats.ShardStats; @@ -34,6 +33,7 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.index.shard.DocsStats; import org.elasticsearch.junit.annotations.TestLogging; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Arrays; @@ -43,14 +43,14 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.equalTo; /** * */ -public class RecoveryWhileUnderLoadTests extends AbstractSharedClusterTest { +public class RecoveryWhileUnderLoadTests extends AbstractIntegrationTest { private final ESLogger logger = Loggers.getLogger(RecoveryWhileUnderLoadTests.class); diff --git a/src/test/java/org/elasticsearch/recovery/RelocationTests.java b/src/test/java/org/elasticsearch/recovery/RelocationTests.java index 4f536afe426..ef56ba6d439 100644 --- a/src/test/java/org/elasticsearch/recovery/RelocationTests.java +++ b/src/test/java/org/elasticsearch/recovery/RelocationTests.java @@ -35,7 +35,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.After; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/recovery/SimpleRecoveryTests.java b/src/test/java/org/elasticsearch/recovery/SimpleRecoveryTests.java index b802ab1fd39..250ea2a3afd 100644 --- a/src/test/java/org/elasticsearch/recovery/SimpleRecoveryTests.java +++ b/src/test/java/org/elasticsearch/recovery/SimpleRecoveryTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.recovery; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.indices.flush.FlushResponse; @@ -27,6 +26,7 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.client.Requests.*; @@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.equalTo; /** * */ -public class SimpleRecoveryTests extends AbstractSharedClusterTest { +public class SimpleRecoveryTests extends AbstractIntegrationTest { @Override public Settings getSettings() { diff --git a/src/test/java/org/elasticsearch/routing/AliasResolveRoutingTests.java b/src/test/java/org/elasticsearch/routing/AliasResolveRoutingTests.java index e782172f4fa..3d6e8f35998 100644 --- a/src/test/java/org/elasticsearch/routing/AliasResolveRoutingTests.java +++ b/src/test/java/org/elasticsearch/routing/AliasResolveRoutingTests.java @@ -19,9 +19,9 @@ package org.elasticsearch.routing; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Priority; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Map; @@ -36,7 +36,7 @@ import static org.hamcrest.Matchers.nullValue; /** * */ -public class AliasResolveRoutingTests extends AbstractSharedClusterTest { +public class AliasResolveRoutingTests extends AbstractIntegrationTest { @Test public void testResolveIndexRouting() throws Exception { diff --git a/src/test/java/org/elasticsearch/routing/AliasRoutingTests.java b/src/test/java/org/elasticsearch/routing/AliasRoutingTests.java index 06966bcc628..2f0ca3cfb0f 100644 --- a/src/test/java/org/elasticsearch/routing/AliasRoutingTests.java +++ b/src/test/java/org/elasticsearch/routing/AliasRoutingTests.java @@ -27,7 +27,7 @@ import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Requests; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.cluster.metadata.AliasAction.newAddAliasAction; @@ -38,8 +38,7 @@ import static org.hamcrest.Matchers.instanceOf; /** * */ -public class AliasRoutingTests extends AbstractSharedClusterTest { - +public class AliasRoutingTests extends AbstractIntegrationTest { @Test public void testAliasCrudRouting() throws Exception { diff --git a/src/test/java/org/elasticsearch/routing/SimpleRoutingTests.java b/src/test/java/org/elasticsearch/routing/SimpleRoutingTests.java index bf26f6c5f7e..d2dd0b666f5 100644 --- a/src/test/java/org/elasticsearch/routing/SimpleRoutingTests.java +++ b/src/test/java/org/elasticsearch/routing/SimpleRoutingTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.routing; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.RoutingMissingException; import org.elasticsearch.client.Requests; @@ -27,6 +26,7 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; @@ -36,7 +36,7 @@ import static org.hamcrest.Matchers.instanceOf; /** * */ -public class SimpleRoutingTests extends AbstractSharedClusterTest { +public class SimpleRoutingTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexTests.java b/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexTests.java index b22894cdc38..5ef1098a8ef 100644 --- a/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexTests.java +++ b/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexTests.java @@ -20,16 +20,16 @@ package org.elasticsearch.search.basic; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo; @@ -38,7 +38,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo; * This test basically verifies that search with a single shard active (cause we indexed to it) and other * shards possibly not active at all (cause they haven't allocated) will still work. */ -public class SearchWhileCreatingIndexTests extends AbstractSharedClusterTest { +public class SearchWhileCreatingIndexTests extends AbstractIntegrationTest { @Test @Slow diff --git a/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java b/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java index e969f920aa6..8c7f8a87e56 100644 --- a/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java +++ b/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.basic; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -27,6 +26,7 @@ import org.elasticsearch.action.search.SearchType; import org.elasticsearch.common.lucene.search.function.CombineFunction; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.search.SearchHits; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -42,10 +42,10 @@ import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.gaussDecayFunction; import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.equalTo; -public class SearchWhileRelocatingTests extends AbstractSharedClusterTest { +public class SearchWhileRelocatingTests extends AbstractIntegrationTest { @Test public void testSearchAndRelocateConcurrently() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsTests.java b/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsTests.java index a87e79054db..a5f3d40e138 100644 --- a/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsTests.java +++ b/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.search.basic; import org.apache.lucene.util.English; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; @@ -33,6 +32,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.store.mock.MockDirectoryHelper; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -42,7 +42,7 @@ import java.util.concurrent.ExecutionException; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -public class SearchWithRandomExceptionsTests extends AbstractSharedClusterTest { +public class SearchWithRandomExceptionsTests extends AbstractIntegrationTest { @Test public void testRandomExceptions() throws IOException, InterruptedException, ExecutionException { diff --git a/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresTests.java b/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresTests.java index 447938c9863..a11a657198a 100644 --- a/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresTests.java +++ b/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresTests.java @@ -19,17 +19,7 @@ package org.elasticsearch.search.basic; -import static org.elasticsearch.client.Requests.clusterHealthRequest; -import static org.elasticsearch.client.Requests.refreshRequest; -import static org.elasticsearch.client.Requests.searchRequest; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.instanceOf; - -import java.io.IOException; - +import com.google.common.base.Charsets; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.WriteConsistencyLevel; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; @@ -41,15 +31,21 @@ import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; import org.elasticsearch.common.Priority; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; -import com.google.common.base.Charsets; +import java.io.IOException; + +import static org.elasticsearch.client.Requests.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; /** * */ -public class TransportSearchFailuresTests extends AbstractSharedClusterTest { +public class TransportSearchFailuresTests extends AbstractIntegrationTest { @Test public void testFailedSearchWithWrongQuery() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchTests.java b/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchTests.java index 0947c159af3..a5bd96ce97f 100644 --- a/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchTests.java +++ b/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchTests.java @@ -23,7 +23,6 @@ package org.elasticsearch.search.basic; import com.google.common.base.Charsets; import com.google.common.collect.Sets; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.search.MultiSearchResponse; import org.elasticsearch.action.search.SearchPhaseExecutionException; @@ -39,6 +38,7 @@ import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.facet.FacetBuilders; import org.elasticsearch.search.facet.query.QueryFacet; import org.elasticsearch.search.sort.SortOrder; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; @@ -52,13 +52,13 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; /** * */ -public class TransportTwoNodesSearchTests extends AbstractSharedClusterTest { +public class TransportTwoNodesSearchTests extends AbstractIntegrationTest { private Set prepareData() throws Exception { Set fullExpectedIds = Sets.newHashSet(); diff --git a/src/test/java/org/elasticsearch/search/child/SimpleChildQuerySearchTests.java b/src/test/java/org/elasticsearch/search/child/SimpleChildQuerySearchTests.java index da4551eec3d..af0d6eea4ea 100644 --- a/src/test/java/org/elasticsearch/search/child/SimpleChildQuerySearchTests.java +++ b/src/test/java/org/elasticsearch/search/child/SimpleChildQuerySearchTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.child; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.count.CountResponse; @@ -34,6 +33,7 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.facet.terms.TermsFacet; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -46,14 +46,14 @@ import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction; import static org.elasticsearch.search.facet.FacetBuilders.termsFacet; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; /** * */ -public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest { +public class SimpleChildQuerySearchTests extends AbstractIntegrationTest { @Test public void multiLevelChild() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java b/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java index fc19e46830a..3538afc3b5a 100644 --- a/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java +++ b/src/test/java/org/elasticsearch/search/compress/SearchSourceCompressTests.java @@ -27,18 +27,17 @@ import org.elasticsearch.common.compress.lzf.LZFCompressor; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * */ -public class SearchSourceCompressTests extends AbstractSharedClusterTest { +public class SearchSourceCompressTests extends AbstractIntegrationTest { @Test public void testSourceCompressionLZF() throws IOException { diff --git a/src/test/java/org/elasticsearch/search/customscore/CustomScoreSearchTests.java b/src/test/java/org/elasticsearch/search/customscore/CustomScoreSearchTests.java index 24b5abeb9ef..278884f26b0 100644 --- a/src/test/java/org/elasticsearch/search/customscore/CustomScoreSearchTests.java +++ b/src/test/java/org/elasticsearch/search/customscore/CustomScoreSearchTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.common.Priority; import org.elasticsearch.index.query.FilterBuilders; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; @@ -40,15 +40,15 @@ import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.factorFunction; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction; import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertSearchHits; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.equalTo; /** * */ -public class CustomScoreSearchTests extends AbstractSharedClusterTest { +public class CustomScoreSearchTests extends AbstractIntegrationTest { @Test public void testScoreExplainBug_2283() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/facet/ConcurrentDuel.java b/src/test/java/org/elasticsearch/search/facet/ConcurrentDuel.java index 9fa430508ee..f81713f5e30 100644 --- a/src/test/java/org/elasticsearch/search/facet/ConcurrentDuel.java +++ b/src/test/java/org/elasticsearch/search/facet/ConcurrentDuel.java @@ -20,12 +20,7 @@ package org.elasticsearch.search.facet; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicLong; public class ConcurrentDuel { diff --git a/src/test/java/org/elasticsearch/search/facet/ExtendedFacetsTests.java b/src/test/java/org/elasticsearch/search/facet/ExtendedFacetsTests.java index 7b039bf5a43..2ff798d9437 100644 --- a/src/test/java/org/elasticsearch/search/facet/ExtendedFacetsTests.java +++ b/src/test/java/org/elasticsearch/search/facet/ExtendedFacetsTests.java @@ -1,7 +1,6 @@ package org.elasticsearch.search.facet; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.regex.Regex; @@ -11,6 +10,7 @@ import org.elasticsearch.common.text.Text; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.facet.terms.TermsFacet; import org.elasticsearch.search.facet.terms.TermsFacetBuilder; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.*; @@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.equalTo; /** */ -public class ExtendedFacetsTests extends AbstractSharedClusterTest { +public class ExtendedFacetsTests extends AbstractIntegrationTest { @Override public Settings getSettings() { diff --git a/src/test/java/org/elasticsearch/search/facet/SimpleFacetsTests.java b/src/test/java/org/elasticsearch/search/facet/SimpleFacetsTests.java index f85eab6ef4e..4f180375db1 100644 --- a/src/test/java/org/elasticsearch/search/facet/SimpleFacetsTests.java +++ b/src/test/java/org/elasticsearch/search/facet/SimpleFacetsTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.search.facet; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -43,6 +42,7 @@ import org.elasticsearch.search.facet.terms.TermsFacet.Entry; import org.elasticsearch.search.facet.terms.doubles.InternalDoubleTermsFacet; import org.elasticsearch.search.facet.terms.longs.InternalLongTermsFacet; import org.elasticsearch.search.facet.termsstats.TermsStatsFacet; +import org.elasticsearch.test.AbstractIntegrationTest; import org.joda.time.DateTimeZone; import org.joda.time.format.ISODateTimeFormat; import org.junit.Test; @@ -57,13 +57,13 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.termFilter; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.search.facet.FacetBuilders.*; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.*; /** * */ -public class SimpleFacetsTests extends AbstractSharedClusterTest { +public class SimpleFacetsTests extends AbstractIntegrationTest { @Override diff --git a/src/test/java/org/elasticsearch/search/facet/terms/UnmappedFieldsTermsFacetsTests.java b/src/test/java/org/elasticsearch/search/facet/terms/UnmappedFieldsTermsFacetsTests.java index f169ed0c6a9..011b5e59baf 100644 --- a/src/test/java/org/elasticsearch/search/facet/terms/UnmappedFieldsTermsFacetsTests.java +++ b/src/test/java/org/elasticsearch/search/facet/terms/UnmappedFieldsTermsFacetsTests.java @@ -19,11 +19,11 @@ package org.elasticsearch.search.facet.terms; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; @@ -38,7 +38,7 @@ import static org.hamcrest.Matchers.is; /** * */ -public class UnmappedFieldsTermsFacetsTests extends AbstractSharedClusterTest { +public class UnmappedFieldsTermsFacetsTests extends AbstractIntegrationTest { @Override public Settings getSettings() { diff --git a/src/test/java/org/elasticsearch/search/fields/SearchFieldsTests.java b/src/test/java/org/elasticsearch/search/fields/SearchFieldsTests.java index e0b79a3abb5..bb6131d6984 100644 --- a/src/test/java/org/elasticsearch/search/fields/SearchFieldsTests.java +++ b/src/test/java/org/elasticsearch/search/fields/SearchFieldsTests.java @@ -29,7 +29,7 @@ import org.elasticsearch.common.joda.Joda; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.search.sort.SortOrder; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.junit.Test; @@ -41,13 +41,13 @@ import java.util.Map; import static org.elasticsearch.client.Requests.refreshRequest; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; /** * */ -public class SearchFieldsTests extends AbstractSharedClusterTest { +public class SearchFieldsTests extends AbstractIntegrationTest { @Override public Settings getSettings() { diff --git a/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreTests.java b/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreTests.java index f6755d2fa11..2b8011199e5 100644 --- a/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreTests.java +++ b/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.functionscore; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.index.IndexRequestBuilder; @@ -33,7 +32,8 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.functionscore.DecayFunctionBuilder; import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionBuilder; import org.elasticsearch.search.SearchHits; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.joda.time.DateTime; import org.junit.Test; @@ -47,10 +47,10 @@ import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.*; import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertAcked; import static org.hamcrest.Matchers.*; -public class DecayFunctionScoreTests extends AbstractSharedClusterTest { +public class DecayFunctionScoreTests extends AbstractIntegrationTest { @Test public void testDistanceScoreGeoLinGaussExp() throws Exception { @@ -450,7 +450,7 @@ public class DecayFunctionScoreTests extends AbstractSharedClusterTest { functionScoreQuery(termQuery("test", "value"), gaussDecayFunction("num1", "2013-05-28", "-1d"))))); SearchResponse sr = response.actionGet(); - ElasticsearchAssertions.assertNoFailures(sr); + ElasticSearchAssertions.assertNoFailures(sr); SearchHits sh = sr.getHits(); assertThat(sh.hits().length, equalTo(2)); assertThat(sh.getAt(0).getId(), equalTo("2")); @@ -501,7 +501,7 @@ public class DecayFunctionScoreTests extends AbstractSharedClusterTest { .add(linearDecayFunction("num2", "0.0", "1")).scoreMode("multiply")))); SearchResponse sr = response.actionGet(); - ElasticsearchAssertions.assertNoFailures(sr); + ElasticSearchAssertions.assertNoFailures(sr); SearchHits sh = sr.getHits(); assertThat(sh.hits().length, equalTo(4)); double[] scores = new double[4]; @@ -549,7 +549,7 @@ public class DecayFunctionScoreTests extends AbstractSharedClusterTest { .scoreMode("multiply")))); SearchResponse sr = response.actionGet(); - ElasticsearchAssertions.assertNoFailures(sr); + ElasticSearchAssertions.assertNoFailures(sr); SearchHits sh = sr.getHits(); assertThat(sh.hits().length, equalTo(3)); double[] scores = new double[4]; @@ -602,7 +602,7 @@ public class DecayFunctionScoreTests extends AbstractSharedClusterTest { .scoreMode("multiply").boostMode(CombineFunction.REPLACE.getName())))); SearchResponse sr = response.actionGet(); - ElasticsearchAssertions.assertNoFailures(sr); + ElasticSearchAssertions.assertNoFailures(sr); SearchHits sh = sr.getHits(); assertThat(sh.hits().length, equalTo(numDocs)); double[] scores = new double[numDocs]; diff --git a/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginTests.java b/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginTests.java index 80cb345008e..fcf0f92a462 100644 --- a/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginTests.java +++ b/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginTests.java @@ -33,8 +33,8 @@ import org.elasticsearch.index.query.functionscore.DecayFunctionParser; import org.elasticsearch.index.query.functionscore.FunctionScoreModule; import org.elasticsearch.plugins.AbstractPlugin; import org.elasticsearch.search.SearchHits; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.junit.After; import org.junit.Test; @@ -89,7 +89,7 @@ public class FunctionScorePluginTests extends AbstractNodesTests { searchSource().explain(false).query(functionScoreQuery(termQuery("test", "value")).add(gfb)))); SearchResponse sr = response.actionGet(); - ElasticsearchAssertions.assertNoFailures(sr); + ElasticSearchAssertions.assertNoFailures(sr); SearchHits sh = sr.getHits(); assertThat(sh.hits().length, equalTo(2)); diff --git a/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionTests.java b/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionTests.java index e20600df2ff..f2e8e09c9eb 100644 --- a/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionTests.java +++ b/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionTests.java @@ -19,10 +19,10 @@ package org.elasticsearch.search.functionscore; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.search.SearchHits; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.CoreMatchers; import org.junit.Ignore; import org.junit.Test; @@ -33,11 +33,11 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.randomFunction; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -public class RandomScoreFunctionTests extends AbstractSharedClusterTest { +public class RandomScoreFunctionTests extends AbstractIntegrationTest { @Test public void consistentHitsWithSameSeed() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxTests.java b/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxTests.java index fd093fd6536..b65cbbeb2c0 100644 --- a/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxTests.java +++ b/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxTests.java @@ -19,27 +19,24 @@ package org.elasticsearch.search.geo; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.index.query.FilterBuilders.geoBoundingBoxFilter; -import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; -import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.index.query.QueryBuilders.termQuery; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.anyOf; -import static org.hamcrest.Matchers.equalTo; - import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.Priority; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.search.SearchHit; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.geoBoundingBoxFilter; +import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.equalTo; + /** * */ -public class GeoBoundingBoxTests extends AbstractSharedClusterTest { +public class GeoBoundingBoxTests extends AbstractIntegrationTest { @Test public void simpleBoundingBoxTest() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/geo/GeoDistanceFacetTests.java b/src/test/java/org/elasticsearch/search/geo/GeoDistanceFacetTests.java index ee6a2b1527a..44f8bfaf62a 100644 --- a/src/test/java/org/elasticsearch/search/geo/GeoDistanceFacetTests.java +++ b/src/test/java/org/elasticsearch/search/geo/GeoDistanceFacetTests.java @@ -24,19 +24,19 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.search.facet.geodistance.GeoDistanceFacet; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.search.facet.FacetBuilders.geoDistanceFacet; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; /** * */ -public class GeoDistanceFacetTests extends AbstractSharedClusterTest { +public class GeoDistanceFacetTests extends AbstractIntegrationTest { @Test public void simpleGeoFacetTests() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/geo/GeoDistanceTests.java b/src/test/java/org/elasticsearch/search/geo/GeoDistanceTests.java index 450d4b37f50..12adae988d6 100644 --- a/src/test/java/org/elasticsearch/search/geo/GeoDistanceTests.java +++ b/src/test/java/org/elasticsearch/search/geo/GeoDistanceTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.geo; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.Priority; @@ -35,6 +34,7 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; @@ -44,12 +44,12 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; import static org.hamcrest.Matchers.*; /** */ -public class GeoDistanceTests extends AbstractSharedClusterTest { +public class GeoDistanceTests extends AbstractIntegrationTest { @Test public void simpleDistanceTests() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java b/src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java index 98f2b967073..ef63151cbcb 100644 --- a/src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java +++ b/src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java @@ -46,7 +46,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.BeforeClass; import org.junit.Test; @@ -62,13 +62,13 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.geoBoundingBoxFilter; import static org.elasticsearch.index.query.FilterBuilders.geoDistanceFilter; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; import static org.hamcrest.Matchers.*; /** * */ -public class GeoFilterTests extends AbstractSharedClusterTest { +public class GeoFilterTests extends AbstractIntegrationTest { private static boolean intersectSupport; private static boolean disjointSupport; diff --git a/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationTests.java b/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationTests.java index 22f0e0720e6..deff8f8af5b 100644 --- a/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationTests.java +++ b/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.geo.builders.ShapeBuilder; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.io.IOException; @@ -36,10 +36,10 @@ import java.util.Map; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.geoIntersectionFilter; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.*; -public class GeoShapeIntegrationTests extends AbstractSharedClusterTest { +public class GeoShapeIntegrationTests extends AbstractIntegrationTest { @Test public void testNullShape() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchTests.java b/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchTests.java index 6c53ec95166..b8de598bd51 100644 --- a/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchTests.java +++ b/src/test/java/org/elasticsearch/search/highlight/CustomHighlighterSearchTests.java @@ -25,14 +25,14 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.Test; import java.io.IOException; import java.util.Map; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHighlight; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHighlight; import static org.hamcrest.Matchers.equalTo; /** diff --git a/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchTests.java b/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchTests.java index 964a241418c..2ca5bea2d58 100644 --- a/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchTests.java +++ b/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.search.highlight; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchResponse; @@ -36,7 +35,8 @@ import org.elasticsearch.index.query.MatchQueryBuilder.Type; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.junit.Test; import java.io.IOException; @@ -48,15 +48,15 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.search.builder.SearchSourceBuilder.highlight; import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHighlight; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHighlight; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.startsWith; /** * */ -public class HighlighterSearchTests extends AbstractSharedClusterTest { +public class HighlighterSearchTests extends AbstractIntegrationTest { @Test // see #3486 @@ -177,7 +177,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest { endObject(). endObject(). endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").addMapping("test", builder).setSettings( + ElasticSearchAssertions.assertAcked(prepareCreate("test").addMapping("test", builder).setSettings( ImmutableSettings.settingsBuilder() .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("analysis.filter.wordDelimiter.type", "word_delimiter") diff --git a/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchTests.java b/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchTests.java index c378f92b6f8..2392faefae6 100644 --- a/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchTests.java +++ b/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchTests.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.indicesboost; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.junit.Test; import static org.elasticsearch.client.Requests.*; @@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.equalTo; /** * */ -public class SimpleIndicesBoostSearchTests extends AbstractSharedClusterTest { +public class SimpleIndicesBoostSearchTests extends AbstractIntegrationTest { private static final Settings DEFAULT_SETTINGS = ImmutableSettings.settingsBuilder() .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) @@ -46,7 +46,7 @@ public class SimpleIndicesBoostSearchTests extends AbstractSharedClusterTest { @Test public void testIndicesBoost() throws Exception { - ElasticsearchAssertions.assertHitCount(client().prepareSearch().setQuery(termQuery("test", "value")).get(), 0); + ElasticSearchAssertions.assertHitCount(client().prepareSearch().setQuery(termQuery("test", "value")).get(), 0); try { client().prepareSearch("test").setQuery(termQuery("test", "value")).execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesTests.java b/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesTests.java index 831cb160da0..32274a73995 100644 --- a/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesTests.java +++ b/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesTests.java @@ -19,22 +19,22 @@ package org.elasticsearch.search.matchedqueries; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItemInArray; /** * */ -public class MatchedQueriesTests extends AbstractSharedClusterTest { +public class MatchedQueriesTests extends AbstractIntegrationTest { @Test public void simpleMatchedQueryFromFilteredQuery() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchTests.java b/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchTests.java index 7f0bbd1f4ee..dfb3bf42b07 100644 --- a/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchTests.java +++ b/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchTests.java @@ -2,16 +2,15 @@ package org.elasticsearch.search.msearch; import org.elasticsearch.action.search.MultiSearchResponse; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; import static org.hamcrest.Matchers.equalTo; /** */ -public class SimpleMultiSearchTests extends AbstractSharedClusterTest { +public class SimpleMultiSearchTests extends AbstractIntegrationTest { @Test public void simpleMultiSearch() { diff --git a/src/test/java/org/elasticsearch/search/preference/SearchPreferenceTests.java b/src/test/java/org/elasticsearch/search/preference/SearchPreferenceTests.java index 49aecaf45e0..8eb08a8b84a 100644 --- a/src/test/java/org/elasticsearch/search/preference/SearchPreferenceTests.java +++ b/src/test/java/org/elasticsearch/search/preference/SearchPreferenceTests.java @@ -19,20 +19,20 @@ package org.elasticsearch.search.preference; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; import org.elasticsearch.common.Priority; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.hamcrest.Matchers.*; -public class SearchPreferenceTests extends AbstractSharedClusterTest { +public class SearchPreferenceTests extends AbstractIntegrationTest { @Test // see #2896 public void testStopOneNodePreferenceWithRedState() throws InterruptedException { diff --git a/src/test/java/org/elasticsearch/search/query/SimpleQueryTests.java b/src/test/java/org/elasticsearch/search/query/SimpleQueryTests.java index 98b7f54d159..5a7758ccb40 100644 --- a/src/test/java/org/elasticsearch/search/query/SimpleQueryTests.java +++ b/src/test/java/org/elasticsearch/search/query/SimpleQueryTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.search.query; import org.apache.lucene.util.English; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchPhaseExecutionException; @@ -35,6 +34,7 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.facet.FacetBuilders; +import org.elasticsearch.test.AbstractIntegrationTest; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.ISODateTimeFormat; @@ -47,13 +47,13 @@ import java.util.concurrent.ExecutionException; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; import static org.hamcrest.Matchers.*; /** * */ -public class SimpleQueryTests extends AbstractSharedClusterTest { +public class SimpleQueryTests extends AbstractIntegrationTest { @Test // see https://github.com/elasticsearch/elasticsearch/issues/3177 diff --git a/src/test/java/org/elasticsearch/search/rescore/QueryRescorerTests.java b/src/test/java/org/elasticsearch/search/rescore/QueryRescorerTests.java index cb83b0e1a90..93cf5fa1153 100644 --- a/src/test/java/org/elasticsearch/search/rescore/QueryRescorerTests.java +++ b/src/test/java/org/elasticsearch/search/rescore/QueryRescorerTests.java @@ -35,19 +35,19 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.rescore.RescoreBuilder.QueryRescorer; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; /** * */ -public class QueryRescorerTests extends AbstractSharedClusterTest { +public class QueryRescorerTests extends AbstractIntegrationTest { @Test public void testRescorePhrase() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/scan/SearchScanScrollingTests.java b/src/test/java/org/elasticsearch/search/scan/SearchScanScrollingTests.java index a58f24eb0a8..212968a964b 100644 --- a/src/test/java/org/elasticsearch/search/scan/SearchScanScrollingTests.java +++ b/src/test/java/org/elasticsearch/search/scan/SearchScanScrollingTests.java @@ -26,14 +26,14 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.search.SearchHit; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import java.util.Set; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.hamcrest.Matchers.equalTo; -public class SearchScanScrollingTests extends AbstractSharedClusterTest { +public class SearchScanScrollingTests extends AbstractIntegrationTest { public void testRandomized() throws Exception { testScroll(between(1, 4), atLeast(100), between(1, 300), getRandom().nextBoolean()); diff --git a/src/test/java/org/elasticsearch/search/scan/SearchScanTests.java b/src/test/java/org/elasticsearch/search/scan/SearchScanTests.java index aa2c2119537..c348160761b 100644 --- a/src/test/java/org/elasticsearch/search/scan/SearchScanTests.java +++ b/src/test/java/org/elasticsearch/search/scan/SearchScanTests.java @@ -21,7 +21,6 @@ package org.elasticsearch.search.scan; import com.google.common.collect.Sets; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; @@ -29,6 +28,7 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Set; @@ -37,7 +37,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.hamcrest.Matchers.equalTo; -public class SearchScanTests extends AbstractSharedClusterTest { +public class SearchScanTests extends AbstractIntegrationTest { @Test @Slow diff --git a/src/test/java/org/elasticsearch/search/scriptfilter/ScriptFilterSearchTests.java b/src/test/java/org/elasticsearch/search/scriptfilter/ScriptFilterSearchTests.java index 10bf5c28f67..1cd9099c0ef 100644 --- a/src/test/java/org/elasticsearch/search/scriptfilter/ScriptFilterSearchTests.java +++ b/src/test/java/org/elasticsearch/search/scriptfilter/ScriptFilterSearchTests.java @@ -24,7 +24,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.search.sort.SortOrder; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.concurrent.atomic.AtomicInteger; @@ -33,13 +33,12 @@ import static org.elasticsearch.client.Requests.refreshRequest; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.scriptFilter; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * */ -public class ScriptFilterSearchTests extends AbstractSharedClusterTest { +public class ScriptFilterSearchTests extends AbstractIntegrationTest { private final static Settings DEFAULT_SETTINGS = ImmutableSettings.settingsBuilder() .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) diff --git a/src/test/java/org/elasticsearch/search/scroll/SearchScrollTests.java b/src/test/java/org/elasticsearch/search/scroll/SearchScrollTests.java index 5ebeaebdbc5..42017c0371e 100644 --- a/src/test/java/org/elasticsearch/search/scroll/SearchScrollTests.java +++ b/src/test/java/org/elasticsearch/search/scroll/SearchScrollTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.scroll; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.search.ClearScrollResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; @@ -28,6 +27,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.sort.SortOrder; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Map; @@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.equalTo; /** * */ -public class SearchScrollTests extends AbstractSharedClusterTest { +public class SearchScrollTests extends AbstractIntegrationTest { @Test public void testSimpleScrollQueryThenFetch() throws Exception { diff --git a/src/test/java/org/elasticsearch/search/simple/SimpleSearchTests.java b/src/test/java/org/elasticsearch/search/simple/SimpleSearchTests.java index 5cb3c5e7001..6222ac7b5e9 100644 --- a/src/test/java/org/elasticsearch/search/simple/SimpleSearchTests.java +++ b/src/test/java/org/elasticsearch/search/simple/SimpleSearchTests.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.simple; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.junit.annotations.TestLogging; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.concurrent.ExecutionException; @@ -33,10 +33,10 @@ import java.util.concurrent.ExecutionException; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertHitCount; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; -public class SimpleSearchTests extends AbstractSharedClusterTest { +public class SimpleSearchTests extends AbstractIntegrationTest { @Test public void testSearchNullIndex() { diff --git a/src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java b/src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java index 1ed2ee4f742..7d6d5002043 100644 --- a/src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java +++ b/src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java @@ -22,7 +22,6 @@ package org.elasticsearch.search.sort; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util._TestUtil; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchPhaseExecutionException; @@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -46,14 +46,14 @@ import java.util.concurrent.ExecutionException; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; import static org.hamcrest.Matchers.*; /** * */ -public class SimpleSortTests extends AbstractSharedClusterTest { +public class SimpleSortTests extends AbstractIntegrationTest { @Override public Settings getSettings() { diff --git a/src/test/java/org/elasticsearch/search/source/SourceFetchingTests.java b/src/test/java/org/elasticsearch/search/source/SourceFetchingTests.java index 16d51db226c..83ec66977d0 100644 --- a/src/test/java/org/elasticsearch/search/source/SourceFetchingTests.java +++ b/src/test/java/org/elasticsearch/search/source/SourceFetchingTests.java @@ -20,14 +20,14 @@ package org.elasticsearch.search.source; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.IsEqual.equalTo; -public class SourceFetchingTests extends AbstractSharedClusterTest { +public class SourceFetchingTests extends AbstractIntegrationTest { @Test public void testSourceDefaultBehavior() { diff --git a/src/test/java/org/elasticsearch/search/stats/SearchStatsTests.java b/src/test/java/org/elasticsearch/search/stats/SearchStatsTests.java index 3bb7c125247..9ad0bf2924a 100644 --- a/src/test/java/org/elasticsearch/search/stats/SearchStatsTests.java +++ b/src/test/java/org/elasticsearch/search/stats/SearchStatsTests.java @@ -19,15 +19,6 @@ package org.elasticsearch.search.stats; -import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; - -import java.util.Set; - import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; @@ -37,12 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.search.stats.SearchStats.Stats; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; +import java.util.Set; + +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.Matchers.*; + /** */ -public class SearchStatsTests extends AbstractSharedClusterTest { +public class SearchStatsTests extends AbstractIntegrationTest { @Override public Settings getSettings() { diff --git a/src/test/java/org/elasticsearch/search/suggest/CompletionPostingsFormatTest.java b/src/test/java/org/elasticsearch/search/suggest/CompletionPostingsFormatTest.java index 048db0f0291..9e86a7ce496 100644 --- a/src/test/java/org/elasticsearch/search/suggest/CompletionPostingsFormatTest.java +++ b/src/test/java/org/elasticsearch/search/suggest/CompletionPostingsFormatTest.java @@ -47,7 +47,7 @@ import org.elasticsearch.search.suggest.completion.AnalyzingCompletionLookupProv import org.elasticsearch.search.suggest.completion.Completion090PostingsFormat; import org.elasticsearch.search.suggest.completion.Completion090PostingsFormat.LookupFactory; import org.elasticsearch.search.suggest.completion.CompletionSuggestionContext; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.io.IOException; @@ -58,7 +58,7 @@ import java.util.List; import static org.hamcrest.Matchers.equalTo; -public class CompletionPostingsFormatTest extends ElasticsearchTestCase { +public class CompletionPostingsFormatTest extends ElasticSearchTestCase { @Test public void testCompletionPostingsFormat() throws IOException { diff --git a/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java b/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java index 1fe28ee20fb..508824f9105 100644 --- a/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java +++ b/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.search.suggest; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import com.google.common.collect.Lists; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse; @@ -39,7 +38,8 @@ import org.elasticsearch.search.suggest.completion.CompletionStats; import org.elasticsearch.search.suggest.completion.CompletionSuggestion; import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder; import org.elasticsearch.search.suggest.completion.CompletionSuggestionFuzzyBuilder; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.junit.Test; import java.io.IOException; @@ -53,10 +53,10 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.*; -public class CompletionSuggestSearchTests extends AbstractSharedClusterTest { +public class CompletionSuggestSearchTests extends AbstractIntegrationTest { private final String INDEX = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT); private final String TYPE = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT); @@ -736,7 +736,7 @@ public class CompletionSuggestSearchTests extends AbstractSharedClusterTest { for (int i = 0; i < iters; i++) { int len = between(3, 50); String str = replaceReservedChars(randomRealisticUnicodeOfCodepointLengthBetween(len + 1, atLeast(len + 2)), (char) 0x01); - ElasticsearchAssertions.assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject() + ElasticSearchAssertions.assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject() .startObject(TYPE).startObject("properties") .startObject(FIELD) .field("type", "completion") @@ -766,7 +766,7 @@ public class CompletionSuggestSearchTests extends AbstractSharedClusterTest { // see #3596 public void testVeryLongInput() throws IOException { client().admin().indices().prepareCreate(INDEX).get(); - ElasticsearchAssertions.assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject() + ElasticSearchAssertions.assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject() .startObject(TYPE).startObject("properties") .startObject(FIELD) .field("type", "completion") @@ -789,7 +789,7 @@ public class CompletionSuggestSearchTests extends AbstractSharedClusterTest { @Test(expected = MapperParsingException.class) public void testReservedChars() throws IOException { client().admin().indices().prepareCreate(INDEX).get(); - ElasticsearchAssertions.assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject() + ElasticSearchAssertions.assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject() .startObject(TYPE).startObject("properties") .startObject(FIELD) .field("type", "completion") diff --git a/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTest.java b/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTest.java index ba1dd0c020a..44eedcf05af 100644 --- a/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTest.java +++ b/src/test/java/org/elasticsearch/search/suggest/CompletionTokenStreamTest.java @@ -35,7 +35,7 @@ import org.apache.lucene.util.CharsRef; import org.apache.lucene.util.IntsRef; import org.elasticsearch.search.suggest.completion.CompletionTokenStream; import org.elasticsearch.search.suggest.completion.CompletionTokenStream.ByteTermAttribute; -import org.elasticsearch.ElasticSearchTokenStreamTestCase; +import org.elasticsearch.test.ElasticSearchTokenStreamTestCase; import org.junit.Test; import java.io.IOException; diff --git a/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchTests.java b/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchTests.java index 9f961c834fe..9fbd4e0139f 100644 --- a/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchTests.java +++ b/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchTests.java @@ -21,17 +21,17 @@ package org.elasticsearch.search.suggest; import com.google.common.collect.Lists; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.junit.Test; import java.util.List; import java.util.Locale; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; @@ -39,30 +39,27 @@ import static org.hamcrest.Matchers.is; /** * */ -public class CustomSuggesterSearchTests extends AbstractNodesTests { - - private Client client; +@ClusterScope(scope=Scope.SUITE, numNodes=1) +public class CustomSuggesterSearchTests extends AbstractIntegrationTest { @Override - protected void beforeClass() throws Exception { - ImmutableSettings.Builder settings = settingsBuilder().put("plugin.types", CustomSuggesterPlugin.class.getName()); - startNode("server1", settings); - client = client("server1"); - - client.prepareIndex("test", "test", "1").setSource(jsonBuilder() - .startObject() - .field("name", "arbitrary content") - .endObject()) - .setRefresh(true).execute().actionGet(); - client.admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); + protected Settings nodeSettings(int nodeOrdinal) { + return ImmutableSettings.settingsBuilder().put("plugin.types", CustomSuggesterPlugin.class.getName()).put(super.nodeSettings(nodeOrdinal)).build(); } @Test public void testThatCustomSuggestersCanBeRegisteredAndWork() throws Exception { + client().prepareIndex("test", "test", "1").setSource(jsonBuilder() + .startObject() + .field("name", "arbitrary content") + .endObject()) + .setRefresh(true).execute().actionGet(); + ensureYellow(); + String randomText = randomAsciiOfLength(10); String randomField = randomAsciiOfLength(10); String randomSuffix = randomAsciiOfLength(10); - SearchRequestBuilder searchRequestBuilder = client.prepareSearch("test").setTypes("test").setFrom(0).setSize(1); + SearchRequestBuilder searchRequestBuilder = client().prepareSearch("test").setTypes("test").setFrom(0).setSize(1); XContentBuilder query = jsonBuilder().startObject() .startObject("suggest") .startObject("someName") diff --git a/src/test/java/org/elasticsearch/search/suggest/SuggestSearchTests.java b/src/test/java/org/elasticsearch/search/suggest/SuggestSearchTests.java index 847dc9a4250..2d514e14337 100644 --- a/src/test/java/org/elasticsearch/search/suggest/SuggestSearchTests.java +++ b/src/test/java/org/elasticsearch/search/suggest/SuggestSearchTests.java @@ -22,7 +22,6 @@ package org.elasticsearch.search.suggest; import com.google.common.base.Charsets; import com.google.common.io.Resources; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.search.SearchPhaseExecutionException; @@ -36,7 +35,8 @@ import org.elasticsearch.search.suggest.SuggestBuilder.SuggestionBuilder; import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder; import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder.DirectCandidateGenerator; import org.elasticsearch.search.suggest.term.TermSuggestionBuilder; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.junit.Test; import java.io.IOException; @@ -50,7 +50,7 @@ import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.search.suggest.SuggestBuilder.phraseSuggestion; import static org.elasticsearch.search.suggest.SuggestBuilder.termSuggestion; import static org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder.candidateGenerator; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.*; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; @@ -59,7 +59,7 @@ import static org.hamcrest.Matchers.nullValue; * possible these tests should declare for the first request, make the request, modify the configuration for the next request, make that * request, modify again, request again, etc. This makes it very obvious what changes between requests. */ -public class SuggestSearchTests extends AbstractSharedClusterTest { +public class SuggestSearchTests extends AbstractIntegrationTest { @Test // see #3037 public void testSuggestModes() throws IOException { CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder() @@ -425,7 +425,7 @@ public class SuggestSearchTests extends AbstractSharedClusterTest { .endObject() .endObject() .endObject().endObject(); - ElasticsearchAssertions.assertAcked(builder.addMapping("type1", mapping)); + ElasticSearchAssertions.assertAcked(builder.addMapping("type1", mapping)); ensureGreen(); for (String line: Resources.readLines(SuggestSearchTests.class.getResource("/config/names.txt"), Charsets.UTF_8)) { @@ -683,7 +683,7 @@ public class SuggestSearchTests extends AbstractSharedClusterTest { Suggest suggest = searchSuggest(client(), "foobar", termSuggestion("simple") .size(10).minDocFreq(0).field("field1").suggestMode("always")); - ElasticsearchAssertions.assertSuggestionSize(suggest, 0, 3, "simple"); + ElasticSearchAssertions.assertSuggestionSize(suggest, 0, 3, "simple"); } @Test // see #3469 @@ -736,8 +736,8 @@ public class SuggestSearchTests extends AbstractSharedClusterTest { .setSuggestText("tetsting sugestion") .addSuggestion(phraseSuggestion("did_you_mean").field("name").maxErrors(5.0f)) .get(); - ElasticsearchAssertions.assertNoFailures(searchResponse); - ElasticsearchAssertions.assertSuggestion(searchResponse.getSuggest(), 0, 0, "did_you_mean", "testing suggestions"); + ElasticSearchAssertions.assertNoFailures(searchResponse); + ElasticSearchAssertions.assertSuggestion(searchResponse.getSuggest(), 0, 0, "did_you_mean", "testing suggestions"); } @Test // see #3469 @@ -759,7 +759,7 @@ public class SuggestSearchTests extends AbstractSharedClusterTest { endObject(). endObject(). endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").setSettings(settingsBuilder() + ElasticSearchAssertions.assertAcked(prepareCreate("test").setSettings(settingsBuilder() .put(SETTING_NUMBER_OF_SHARDS, 5) .put(SETTING_NUMBER_OF_REPLICAS, 0) .put("index.analysis.analyzer.suggest.tokenizer", "standard") diff --git a/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java b/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java index 5e95c5b184e..a04b6a17c85 100644 --- a/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java +++ b/src/test/java/org/elasticsearch/search/suggest/phrase/NoisyChannelSpellCheckerTests.java @@ -42,7 +42,7 @@ import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.Version; import org.elasticsearch.search.suggest.phrase.NoisyChannelSpellChecker.Result; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.junit.Test; import java.io.*; @@ -51,7 +51,7 @@ import java.util.Map; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; -public class NoisyChannelSpellCheckerTests extends ElasticsearchTestCase{ +public class NoisyChannelSpellCheckerTests extends ElasticSearchTestCase{ private final BytesRef space = new BytesRef(" "); private final BytesRef preTag = new BytesRef(""); private final BytesRef postTag = new BytesRef(""); diff --git a/src/test/java/org/elasticsearch/search/timeout/SearchTimeoutTests.java b/src/test/java/org/elasticsearch/search/timeout/SearchTimeoutTests.java index fa1ca49811b..22b504a6045 100644 --- a/src/test/java/org/elasticsearch/search/timeout/SearchTimeoutTests.java +++ b/src/test/java/org/elasticsearch/search/timeout/SearchTimeoutTests.java @@ -19,20 +19,19 @@ package org.elasticsearch.search.timeout; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.junit.Test; + import static org.elasticsearch.index.query.FilterBuilders.scriptFilter; import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.AbstractSharedClusterTest; -import org.junit.Test; - /** */ -public class SearchTimeoutTests extends AbstractSharedClusterTest { +public class SearchTimeoutTests extends AbstractIntegrationTest { @Override public Settings getSettings() { diff --git a/src/test/java/org/elasticsearch/similarity/SimilarityTests.java b/src/test/java/org/elasticsearch/similarity/SimilarityTests.java index 993a4c0e458..143dfc79968 100644 --- a/src/test/java/org/elasticsearch/similarity/SimilarityTests.java +++ b/src/test/java/org/elasticsearch/similarity/SimilarityTests.java @@ -21,16 +21,15 @@ package org.elasticsearch.similarity; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; -public class SimilarityTests extends AbstractSharedClusterTest { +public class SimilarityTests extends AbstractIntegrationTest { @Test diff --git a/src/test/java/org/elasticsearch/termvectors/AbstractTermVectorTests.java b/src/test/java/org/elasticsearch/termvectors/AbstractTermVectorTests.java index 46f2b10863c..a37e9012838 100644 --- a/src/test/java/org/elasticsearch/termvectors/AbstractTermVectorTests.java +++ b/src/test/java/org/elasticsearch/termvectors/AbstractTermVectorTests.java @@ -42,7 +42,7 @@ import org.elasticsearch.common.inject.internal.Join; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.indices.IndexMissingException; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import java.io.IOException; import java.io.Reader; @@ -51,7 +51,7 @@ import java.util.*; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.equalTo; -public abstract class AbstractTermVectorTests extends AbstractSharedClusterTest { +public abstract class AbstractTermVectorTests extends AbstractIntegrationTest { protected static class TestFieldSetting { final public String name; diff --git a/src/test/java/org/elasticsearch/termvectors/GetTermVectorCheckDocFreqTests.java b/src/test/java/org/elasticsearch/termvectors/GetTermVectorCheckDocFreqTests.java index cbcfb27cb79..de1af0d7ba7 100644 --- a/src/test/java/org/elasticsearch/termvectors/GetTermVectorCheckDocFreqTests.java +++ b/src/test/java/org/elasticsearch/termvectors/GetTermVectorCheckDocFreqTests.java @@ -31,8 +31,8 @@ import org.elasticsearch.common.io.BytesStream; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.hamcrest.Matchers; import org.junit.Test; @@ -40,7 +40,7 @@ import java.io.IOException; import static org.hamcrest.Matchers.equalTo; -public class GetTermVectorCheckDocFreqTests extends AbstractSharedClusterTest { +public class GetTermVectorCheckDocFreqTests extends AbstractIntegrationTest { @@ -55,7 +55,7 @@ public class GetTermVectorCheckDocFreqTests extends AbstractSharedClusterTest { .endObject() .endObject() .endObject().endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings( + ElasticSearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings( ImmutableSettings.settingsBuilder() .put("index.number_of_shards", 1) .put("index.analysis.analyzer.tv_test.tokenizer", "whitespace") diff --git a/src/test/java/org/elasticsearch/termvectors/GetTermVectorTests.java b/src/test/java/org/elasticsearch/termvectors/GetTermVectorTests.java index 342e3b5769b..a25ea817ad4 100644 --- a/src/test/java/org/elasticsearch/termvectors/GetTermVectorTests.java +++ b/src/test/java/org/elasticsearch/termvectors/GetTermVectorTests.java @@ -34,13 +34,13 @@ import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.mapper.core.TypeParsers; import org.elasticsearch.index.mapper.internal.AllFieldMapper; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.hamcrest.ElasticSearchAssertions; import org.hamcrest.Matchers; import org.junit.Test; import java.io.IOException; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertThrows; import static org.hamcrest.Matchers.equalTo; public class GetTermVectorTests extends AbstractTermVectorTests { @@ -57,7 +57,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests { .endObject() .endObject() .endObject().endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping)); + ElasticSearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping)); ensureYellow(); @@ -83,7 +83,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests { .endObject() .endObject() .endObject().endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping)); + ElasticSearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping)); ensureYellow(); // when indexing a field that simply has a question mark, the term @@ -111,7 +111,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests { .endObject() .endObject() .endObject().endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping)); + ElasticSearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping)); ensureYellow(); // when indexing a field that simply has a question mark, the term // vectors will be null @@ -139,7 +139,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests { .endObject() .endObject() .endObject().endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping) + ElasticSearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping) .setSettings(ImmutableSettings.settingsBuilder() .put("index.analysis.analyzer.tv_test.tokenizer", "whitespace") .putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase"))); @@ -251,7 +251,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests { .endObject() .endObject() .endObject().endObject(); - ElasticsearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping) + ElasticSearchAssertions.assertAcked(prepareCreate("test").addMapping("type1", mapping) .setSettings(ImmutableSettings.settingsBuilder() .put("index.analysis.analyzer.tv_test.tokenizer", "whitespace") .putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase"))); diff --git a/src/test/java/org/elasticsearch/termvectors/TermVectorUnitTests.java b/src/test/java/org/elasticsearch/termvectors/TermVectorUnitTests.java index af29cc60525..15059ea2f86 100644 --- a/src/test/java/org/elasticsearch/termvectors/TermVectorUnitTests.java +++ b/src/test/java/org/elasticsearch/termvectors/TermVectorUnitTests.java @@ -28,7 +28,6 @@ import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.Directory; -import org.elasticsearch.ElasticsearchLuceneTestCase; import org.elasticsearch.action.termvector.TermVectorRequest; import org.elasticsearch.action.termvector.TermVectorRequest.Flag; import org.elasticsearch.action.termvector.TermVectorResponse; @@ -40,6 +39,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.rest.action.termvector.RestTermVectorAction; +import org.elasticsearch.test.ElasticSearchLuceneTestCase; import org.hamcrest.Matchers; import org.junit.Test; @@ -51,7 +51,7 @@ import java.util.Set; import static org.hamcrest.Matchers.equalTo; -public class TermVectorUnitTests extends ElasticsearchLuceneTestCase { +public class TermVectorUnitTests extends ElasticSearchLuceneTestCase { @Test public void streamResponse() throws Exception { diff --git a/src/test/java/org/elasticsearch/AbstractSharedClusterTest.java b/src/test/java/org/elasticsearch/test/AbstractIntegrationTest.java similarity index 77% rename from src/test/java/org/elasticsearch/AbstractSharedClusterTest.java rename to src/test/java/org/elasticsearch/test/AbstractIntegrationTest.java index d6a36d042bd..9a3f6a04a28 100644 --- a/src/test/java/org/elasticsearch/AbstractSharedClusterTest.java +++ b/src/test/java/org/elasticsearch/test/AbstractIntegrationTest.java @@ -16,11 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Iterators; import org.apache.lucene.util.AbstractRandomizedTest.IntegrationTests; +import org.apache.lucene.util.IOUtils; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionResponse; @@ -58,18 +61,21 @@ import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.indices.IndexTemplateMissingException; import org.elasticsearch.rest.RestStatus; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.Ignore; import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.emptyIterable; import static org.hamcrest.Matchers.equalTo; @@ -94,57 +100,102 @@ import static org.hamcrest.Matchers.equalTo; */ @Ignore @IntegrationTests -public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { - - private static final TestCluster cluster = new TestCluster(SHARED_CLUSTER_SEED, TestCluster.clusterName("shared", ElasticsearchTestCase.CHILD_VM_ID, SHARED_CLUSTER_SEED)); +public abstract class AbstractIntegrationTest extends ElasticSearchTestCase { + private static final TestCluster globalCluster = new TestCluster(SHARED_CLUSTER_SEED, TestCluster.clusterName("shared", ElasticSearchTestCase.CHILD_VM_ID, SHARED_CLUSTER_SEED)); + private static TestCluster currentCluster; + private static final Map, TestCluster> clusters = new IdentityHashMap, TestCluster>(); + @Before - public final void before() { - cluster.beforeTest(getRandom()); + public final void before() throws IOException { + final Scope currentClusterScope = getCurrentClusterScope(); + switch (currentClusterScope) { + case GLOBAL: + clearClusters(); + currentCluster = globalCluster; + break; + case SUITE: + currentCluster = buildAndPutCluster(currentClusterScope, false); + break; + case TEST: + currentCluster = buildAndPutCluster(currentClusterScope, true); + break; + default: + assert false : "Unknonw Scope: [" + currentClusterScope + "]"; + + } + currentCluster.beforeTest(getRandom()); wipeIndices(); wipeTemplates(); randomIndexTemplate(); logger.info("[{}#{}]: before test", getTestClass().getSimpleName(), getTestName()); } + public TestCluster buildAndPutCluster(Scope currentClusterScope, boolean createIfExists) throws IOException { + TestCluster testCluster = clusters.get(this.getClass()); + if (createIfExists || testCluster == null) { + testCluster = buildTestCluster(currentClusterScope); + } else { + assert testCluster != null; + clusters.remove(this.getClass()); + } + clearClusters(); + clusters.put(this.getClass(), testCluster); + return testCluster; + } + + private void clearClusters() throws IOException { + if (!clusters.isEmpty()) { + IOUtils.close(clusters.values()); + clusters.clear(); + } + } + @After public void after() throws IOException { - logger.info("[{}#{}]: cleaning up after test", getTestClass().getSimpleName(), getTestName()); - MetaData metaData = client().admin().cluster().prepareState().execute().actionGet().getState().getMetaData(); - assertThat("test leaves persistent cluster metadata behind: " + metaData.persistentSettings().getAsMap(), metaData - .persistentSettings().getAsMap().size(), equalTo(0)); - assertThat("test leaves transient cluster metadata behind: " + metaData.transientSettings().getAsMap(), metaData - .persistentSettings().getAsMap().size(), equalTo(0)); - wipeIndices(); // wipe after to make sure we fail in the test that didn't ack the delete - wipeTemplates(); - ensureAllSearchersClosed(); - ensureAllFilesClosed(); - logger.info("[{}#{}]: cleaned up after test", getTestClass().getSimpleName(), getTestName()); + try { + logger.info("[{}#{}]: cleaning up after test", getTestClass().getSimpleName(), getTestName()); + MetaData metaData = client().admin().cluster().prepareState().execute().actionGet().getState().getMetaData(); + assertThat("test leaves persistent cluster metadata behind: " + metaData.persistentSettings().getAsMap(), metaData + .persistentSettings().getAsMap().size(), equalTo(0)); + assertThat("test leaves transient cluster metadata behind: " + metaData.transientSettings().getAsMap(), metaData + .persistentSettings().getAsMap().size(), equalTo(0)); + wipeIndices(); // wipe after to make sure we fail in the test that + // didn't ack the delete + wipeTemplates(); + Scope currentClusterScope = getCurrentClusterScope(); + if (currentClusterScope == Scope.TEST) { + clearClusters(); + } + ensureAllSearchersClosed(); + ensureAllFilesClosed(); + logger.info("[{}#{}]: cleaned up after test", getTestClass().getSimpleName(), getTestName()); + } finally { + currentCluster = null; + } } public static TestCluster cluster() { - return cluster; + return currentCluster; } - + public ClusterService clusterService() { return cluster().clusterService(); } - @AfterClass - public static void afterClass() { - } - public static Client client() { return cluster().client(); } private static void randomIndexTemplate() { - client().admin().indices().preparePutTemplate("random_index_template") - .setTemplate("*") - .setOrder(0) - .setSettings(ImmutableSettings.builder() - .put(INDEX_SEED_SETTING, getRandom().nextLong())) - .execute().actionGet(); + if (cluster().numNodes() > 0) { + client().admin().indices().preparePutTemplate("random_index_template") + .setTemplate("*") + .setOrder(0) + .setSettings(ImmutableSettings.builder() + .put(INDEX_SEED_SETTING, getRandom().nextLong())) + .execute().actionGet(); + } } public static Iterable clients() { @@ -162,10 +213,12 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { } public static void wipeIndices(String... names) { - try { - assertAcked(client().admin().indices().prepareDelete(names)); - } catch (IndexMissingException e) { - // ignore + if (cluster().numNodes() > 0) { + try { + assertAcked(client().admin().indices().prepareDelete(names)); + } catch (IndexMissingException e) { + // ignore + } } } @@ -177,15 +230,17 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { * Deletes index templates, support wildcard notation. */ public static void wipeTemplates(String... templates) { - // if nothing is provided, delete all - if (templates.length == 0) { - templates = new String[]{"*"}; - } - for (String template : templates) { - try { - client().admin().indices().prepareDeleteTemplate(template).execute().actionGet(); - } catch (IndexTemplateMissingException e) { - // ignore + if (cluster().numNodes() > 0) { + // if nothing is provided, delete all + if (templates.length == 0) { + templates = new String[]{"*"}; + } + for (String template : templates) { + try { + client().admin().indices().prepareDeleteTemplate(template).execute().actionGet(); + } catch (IndexTemplateMissingException e) { + // ignore + } } } } @@ -499,5 +554,42 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { .setScrollIds(Arrays.asList(scrollIds)).get(); assertThat(clearResponse.isSucceeded(), equalTo(true)); } + + public static enum Scope { + GLOBAL, SUITE, TEST; + } + + private Scope getCurrentClusterScope() { + ClusterScope annotation = this.getClass().getAnnotation(ClusterScope.class); + // if we are not annotated assume global! + return annotation == null ? Scope.GLOBAL : annotation.scope(); + } + + private int getNumNodes() { + ClusterScope annotation = this.getClass().getAnnotation(ClusterScope.class); + return annotation == null ? -1 : annotation.numNodes(); + } + + + protected Settings nodeSettings(int nodeOrdinal) { + return ImmutableSettings.EMPTY; + } + + protected TestCluster buildTestCluster(Scope scope) { + long currentClusterSeed = randomLong(); + Builder ordinalMap = ImmutableMap.builder(); + int numNodes = getNumNodes(); + for (int i = 0; i < numNodes; i++) { + ordinalMap.put(i, nodeSettings(i)); + } + return new TestCluster(currentClusterSeed, getNumNodes(), TestCluster.clusterName(scope.name(), ElasticSearchTestCase.CHILD_VM_ID, currentClusterSeed), ordinalMap.build()); + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.TYPE}) + public @interface ClusterScope { + Scope scope() default Scope.GLOBAL; + int numNodes() default -1; + } } diff --git a/src/test/java/org/elasticsearch/AbstractNodesTests.java b/src/test/java/org/elasticsearch/test/AbstractNodesTests.java similarity index 98% rename from src/test/java/org/elasticsearch/AbstractNodesTests.java rename to src/test/java/org/elasticsearch/test/AbstractNodesTests.java index e0beddc8ff4..590bcdfb117 100644 --- a/src/test/java/org/elasticsearch/AbstractNodesTests.java +++ b/src/test/java/org/elasticsearch/test/AbstractNodesTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; import com.google.common.collect.ImmutableSet; import org.apache.lucene.util.AbstractRandomizedTest.IntegrationTests; @@ -46,7 +46,7 @@ import static org.elasticsearch.node.NodeBuilder.nodeBuilder; @Ignore @IntegrationTests -public abstract class AbstractNodesTests extends ElasticsearchTestCase { +public abstract class AbstractNodesTests extends ElasticSearchTestCase { private static Map nodes = newHashMap(); private static Map clients = newHashMap(); diff --git a/src/test/java/org/elasticsearch/ElasticsearchLuceneTestCase.java b/src/test/java/org/elasticsearch/test/ElasticSearchLuceneTestCase.java similarity index 81% rename from src/test/java/org/elasticsearch/ElasticsearchLuceneTestCase.java rename to src/test/java/org/elasticsearch/test/ElasticSearchLuceneTestCase.java index 5c07e89501a..7185657a9d7 100644 --- a/src/test/java/org/elasticsearch/ElasticsearchLuceneTestCase.java +++ b/src/test/java/org/elasticsearch/test/ElasticSearchLuceneTestCase.java @@ -17,13 +17,10 @@ * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; -import com.carrotsearch.randomizedtesting.annotations.Listeners; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import com.carrotsearch.randomizedtesting.annotations.*; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; import org.apache.lucene.codecs.Codec; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; @@ -37,7 +34,7 @@ import org.elasticsearch.junit.listeners.ReproduceInfoPrinter; @ThreadLeakScope(Scope.NONE) @TimeoutSuite(millis = TimeUnits.HOUR) @SuppressCodecs("Lucene3x") -public abstract class ElasticsearchLuceneTestCase extends LuceneTestCase { +public abstract class ElasticSearchLuceneTestCase extends LuceneTestCase { private static final Codec DEFAULT_CODEC = Codec.getDefault(); diff --git a/src/test/java/org/elasticsearch/ElasticsearchTestCase.java b/src/test/java/org/elasticsearch/test/ElasticSearchTestCase.java similarity index 98% rename from src/test/java/org/elasticsearch/ElasticsearchTestCase.java rename to src/test/java/org/elasticsearch/test/ElasticSearchTestCase.java index 8f1f6c40d99..cc59621b2d7 100644 --- a/src/test/java/org/elasticsearch/ElasticsearchTestCase.java +++ b/src/test/java/org/elasticsearch/test/ElasticSearchTestCase.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; import com.carrotsearch.randomizedtesting.SeedUtils; import com.carrotsearch.randomizedtesting.annotations.*; @@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit; @ThreadLeakScope(Scope.NONE) @TimeoutSuite(millis = TimeUnits.HOUR) // timeout the suite after 1h and fail the test. @Listeners(LoggingListener.class) -public abstract class ElasticsearchTestCase extends AbstractRandomizedTest { +public abstract class ElasticSearchTestCase extends AbstractRandomizedTest { protected final ESLogger logger = Loggers.getLogger(getClass()); diff --git a/src/test/java/org/elasticsearch/ElasticSearchThreadFilter.java b/src/test/java/org/elasticsearch/test/ElasticSearchThreadFilter.java similarity index 96% rename from src/test/java/org/elasticsearch/ElasticSearchThreadFilter.java rename to src/test/java/org/elasticsearch/test/ElasticSearchThreadFilter.java index 011ad8f022c..fdc7175c43e 100644 --- a/src/test/java/org/elasticsearch/ElasticSearchThreadFilter.java +++ b/src/test/java/org/elasticsearch/test/ElasticSearchThreadFilter.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; import com.carrotsearch.randomizedtesting.ThreadFilter; diff --git a/src/test/java/org/elasticsearch/ElasticSearchTokenStreamTestCase.java b/src/test/java/org/elasticsearch/test/ElasticSearchTokenStreamTestCase.java similarity index 81% rename from src/test/java/org/elasticsearch/ElasticSearchTokenStreamTestCase.java rename to src/test/java/org/elasticsearch/test/ElasticSearchTokenStreamTestCase.java index 8f2d92b731b..03438b49c3b 100644 --- a/src/test/java/org/elasticsearch/ElasticSearchTokenStreamTestCase.java +++ b/src/test/java/org/elasticsearch/test/ElasticSearchTokenStreamTestCase.java @@ -17,13 +17,10 @@ * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; -import com.carrotsearch.randomizedtesting.annotations.Listeners; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import com.carrotsearch.randomizedtesting.annotations.*; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.util.TimeUnits; import org.elasticsearch.junit.listeners.ReproduceInfoPrinter; diff --git a/src/test/java/org/elasticsearch/TestCluster.java b/src/test/java/org/elasticsearch/test/TestCluster.java similarity index 82% rename from src/test/java/org/elasticsearch/TestCluster.java rename to src/test/java/org/elasticsearch/test/TestCluster.java index 91dbddcedef..574fc494b6f 100644 --- a/src/test/java/org/elasticsearch/TestCluster.java +++ b/src/test/java/org/elasticsearch/test/TestCluster.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test; import com.carrotsearch.randomizedtesting.SeedUtils; import com.google.common.base.Function; @@ -37,14 +37,14 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.network.NetworkUtils; import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.ImmutableSettings.Builder; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.index.engine.IndexEngineModule; +import org.elasticsearch.gateway.Gateway; import org.elasticsearch.index.store.mock.MockFSIndexStoreModule; import org.elasticsearch.node.Node; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.test.engine.MockEngineModule; import org.elasticsearch.transport.TransportService; import java.io.Closeable; @@ -56,7 +56,7 @@ import static com.google.common.collect.Maps.newTreeMap; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.node.NodeBuilder.nodeBuilder; -public class TestCluster { +public class TestCluster implements Closeable { protected final ESLogger logger = Loggers.getLogger(getClass()); @@ -83,14 +83,17 @@ public class TestCluster { * fully shared cluster to be more reproducible */ private final long[] sharedNodesSeeds; + private final Map perNodeSettingsMap; + private static final Map EMPTY = Collections.emptyMap(); public TestCluster(long clusterSeed, String clusterName) { - this(clusterSeed, clusterName, ImmutableSettings.EMPTY); + this(clusterSeed, -1, clusterName, EMPTY); } - private TestCluster(long clusterSeed, String clusterName, Settings defaultSettings) { + public TestCluster(long clusterSeed, int numNodes, String clusterName, Map perNodeSettings) { this.clusterName = clusterName; Random random = new Random(clusterSeed); - numSharedNodes = 2 + random.nextInt(4); // at least 2 nodes + numSharedNodes = numNodes == -1 ? 2 + random.nextInt(4) : numNodes; // at least 2 nodes if randomized + assert numSharedNodes >= 0; /* * TODO * - we might want start some master only nodes? @@ -102,23 +105,30 @@ public class TestCluster { for (int i = 0; i < sharedNodesSeeds.length; i++) { sharedNodesSeeds[i] = random.nextLong(); } - logger.info("Started TestCluster with seed [{}] using [{}] nodes" , SeedUtils.formatSeed(clusterSeed), numSharedNodes); - - if (defaultSettings.get("gateway.type") == null) { - // default to non gateway - defaultSettings = settingsBuilder().put(defaultSettings).put("gateway.type", "none").build(); - } - if (defaultSettings.get("cluster.routing.schedule") != null) { - // decrease the routing schedule so new nodes will be added quickly - some random value between 30 and 80 ms - defaultSettings = settingsBuilder().put(defaultSettings).put("cluster.routing.schedule", (30 + random.nextInt(50)) + "ms").build(); - } + logger.info("Setup TestCluster [{}] with seed [{}] using [{}] nodes" , clusterName, SeedUtils.formatSeed(clusterSeed), numSharedNodes); this.defaultSettings = ImmutableSettings.settingsBuilder() /* use RAM directories in 10% of the runs */ // .put("index.store.type", random.nextInt(10) == 0 ? MockRamIndexStoreModule.class.getName() : MockFSIndexStoreModule.class.getName()) .put("index.store.type", MockFSIndexStoreModule.class.getName()) // no RAM dir for now! - .put(IndexEngineModule.EngineSettings.ENGINE_TYPE, MockEngineModule.class.getName()) - .put(defaultSettings) - .put("cluster.name", clusterName).build(); + .put("cluster.name", clusterName) + // decrease the routing schedule so new nodes will be added quickly - some random value between 30 and 80 ms + .put("cluster.routing.schedule", (30 + random.nextInt(50)) + "ms") + // default to non gateway + .put("gateway.type", "none") + .build(); + this.perNodeSettingsMap = perNodeSettings; + } + + private Settings getSettings(int nodeOrdinal, Settings others) { + Builder builder = ImmutableSettings.settingsBuilder().put(defaultSettings); + Settings settings = perNodeSettingsMap.get(nodeOrdinal); + if (settings != null) { + builder.put(settings); + } + if (others != null) { + builder.put(others); + } + return builder.build(); } public static String clusterName(String prefix, String childVMId, long clusterSeed) { @@ -183,17 +193,23 @@ public class TestCluster { next.close(); } } + private NodeAndClient buildNode(Settings settings) { + int ord = nextNodeId.getAndIncrement(); + return buildNode(ord, random.nextLong(), settings); + } private NodeAndClient buildNode() { - return buildNode(nextNodeId.getAndIncrement(), random.nextLong()); + int ord = nextNodeId.getAndIncrement(); + return buildNode(ord, random.nextLong(), null); } - private NodeAndClient buildNode(int nodeId, long seed) { + private NodeAndClient buildNode(int nodeId, long seed, Settings settings) { ensureOpen(); + settings = getSettings(nodeId, settings); String name = buildNodeName(nodeId); assert !nodes.containsKey(name); Settings finalSettings = settingsBuilder() - .put(defaultSettings) + .put(settings) .put("name", name) .put("discovery.id.seed", seed) .build(); @@ -210,6 +226,17 @@ public class TestCluster { /* Randomly return a client to one of the nodes in the cluster */ return getOrBuildRandomNode().client(); } + + private synchronized Client masterClient() { // should we expose this? + Collection values = nodes.values(); + for (NodeAndClient nodeAndClient : values) { + ClusterService instance = getInstance(ClusterService.class, (InternalNode)nodeAndClient.node()); + if (instance.state().getNodes().getMasterNode().id().equals(instance.localNode().id())) { + return nodeAndClient.client(random); + } + } + return null; + } public void close() { ensureOpen(); @@ -336,9 +363,7 @@ public class TestCluster { } logger.debug("Cluster is NOT consistent - restarting shared nodes - nodes: [{}] nextNodeId: [{}] numSharedNodes: [{}]", nodes.keySet(), nextNodeId.get(), sharedNodesSeeds.length); - if (nodes.size() > 0) { - client().admin().cluster().prepareHealth().setWaitForNodes(""+nodes.size()).get(); - } + Set sharedNodes = new HashSet(); boolean changed = false; for (int i = 0; i < sharedNodesSeeds.length; i++) { @@ -346,7 +371,7 @@ public class TestCluster { NodeAndClient nodeAndClient = nodes.get(buildNodeName); if (nodeAndClient == null) { changed = true; - nodeAndClient = buildNode(i, sharedNodesSeeds[i]); + nodeAndClient = buildNode(i, sharedNodesSeeds[i], defaultSettings); nodeAndClient.node.start(); logger.info("Start Shared Node [{}] not shared", nodeAndClient.name); } @@ -354,6 +379,9 @@ public class TestCluster { } if (!changed && sharedNodes.size() == nodes.size()) { logger.debug("Cluster is consistent - moving out - nodes: [{}] nextNodeId: [{}] numSharedNodes: [{}]", nodes.keySet(), nextNodeId.get(), sharedNodesSeeds.length); + if (numNodes() > 0) { + client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(sharedNodesSeeds.length)).get(); + } return; // we are consistent - return } for (NodeAndClient nodeAndClient : sharedNodes) { @@ -372,7 +400,9 @@ public class TestCluster { } nextNodeId.set(sharedNodesSeeds.length); assert numNodes() == sharedNodesSeeds.length; - client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(sharedNodesSeeds.length)).get(); + if (numNodes() > 0) { + client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(sharedNodesSeeds.length)).get(); + } logger.debug("Cluster is consistent again - nodes: [{}] nextNodeId: [{}] numSharedNodes: [{}]", nodes.keySet(), nextNodeId.get(), sharedNodesSeeds.length); } @@ -384,7 +414,14 @@ public class TestCluster { } public synchronized ClusterService clusterService() { - return ((InternalNode) getOrBuildRandomNode()).injector().getInstance(ClusterService.class); + return getInstance(ClusterService.class); + } + public synchronized T getInstance(Class clazz) { + return getInstance(clazz, ((InternalNode) getOrBuildRandomNode())); + } + + private synchronized T getInstance(Class clazz, InternalNode node) { + return node.injector().getInstance(clazz); } public synchronized int numNodes() { @@ -487,4 +524,26 @@ public class TestCluster { } })); } + + public String startNode() { + return startNode(ImmutableSettings.EMPTY); + } + + public String startNode(Settings settings) { + NodeAndClient buildNode = buildNode(settings); + nodes.put(buildNode.name, buildNode); + buildNode.node().start(); + return buildNode.name; + } + + public void resetAllGateways() throws Exception { + Collection values = this.nodes.values(); + for (NodeAndClient nodeAndClient : values) { + getInstance(Gateway.class, ((InternalNode) nodeAndClient.node)).reset(); + } + } + + public void closeAllNodesAndReset() { + beforeTest(random); + } } diff --git a/src/test/java/org/elasticsearch/test/engine/MockRobinEngine.java b/src/test/java/org/elasticsearch/test/engine/MockRobinEngine.java index 3ac975d6b3b..e4d6090da7e 100644 --- a/src/test/java/org/elasticsearch/test/engine/MockRobinEngine.java +++ b/src/test/java/org/elasticsearch/test/engine/MockRobinEngine.java @@ -24,7 +24,6 @@ import org.apache.lucene.search.AssertingIndexSearcher; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.SearcherManager; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.ElasticsearchTestCase; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -44,6 +43,7 @@ import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.indices.warmer.IndicesWarmer; +import org.elasticsearch.test.ElasticSearchTestCase; import org.elasticsearch.threadpool.ThreadPool; import java.util.Map.Entry; @@ -62,7 +62,7 @@ public final class MockRobinEngine extends RobinEngine implements Engine { CodecService codecService) throws EngineException { super(shardId, indexSettings, threadPool, indexSettingsService, indexingService, warmer, store, deletionPolicy, translog, mergePolicyProvider, mergeScheduler, analysisService, similarityService, codecService); - final long seed = indexSettings.getAsLong(ElasticsearchTestCase.INDEX_SEED_SETTING, 0l); + final long seed = indexSettings.getAsLong(ElasticSearchTestCase.INDEX_SEED_SETTING, 0l); if (logger.isTraceEnabled()){ logger.trace("Using [{}] for shard [{}] seed: [{}]", this.getClass().getName(), shardId, seed); } diff --git a/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java b/src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchAssertions.java similarity index 98% rename from src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java rename to src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchAssertions.java index 1b49c4bbc0f..54bbc368694 100644 --- a/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java +++ b/src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchAssertions.java @@ -49,7 +49,7 @@ import static org.junit.Assert.fail; /** * */ -public class ElasticsearchAssertions { +public class ElasticSearchAssertions { public static void assertAcked(PutMappingRequestBuilder builder) { @@ -209,15 +209,15 @@ public class ElasticsearchAssertions { * matchers */ public static Matcher hasId(final String id) { - return new ElasticsearchMatchers.SearchHitHasIdMatcher(id); + return new ElasticSearchMatchers.SearchHitHasIdMatcher(id); } public static Matcher hasType(final String type) { - return new ElasticsearchMatchers.SearchHitHasTypeMatcher(type); + return new ElasticSearchMatchers.SearchHitHasTypeMatcher(type); } public static Matcher hasIndex(final String index) { - return new ElasticsearchMatchers.SearchHitHasIndexMatcher(index); + return new ElasticSearchMatchers.SearchHitHasIndexMatcher(index); } public static T assertBooleanSubQuery(Query query, Class subqueryType, int i) { diff --git a/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchGeoAssertions.java b/src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchGeoAssertions.java similarity index 99% rename from src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchGeoAssertions.java rename to src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchGeoAssertions.java index 967eba4b14e..de7ab6ffcba 100644 --- a/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchGeoAssertions.java +++ b/src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchGeoAssertions.java @@ -34,7 +34,7 @@ import com.vividsolutions.jts.geom.MultiPoint; import com.vividsolutions.jts.geom.MultiPolygon; import com.vividsolutions.jts.geom.Polygon; -public class ElasticsearchGeoAssertions { +public class ElasticSearchGeoAssertions { private static int top(Coordinate...points) { int top = 0; diff --git a/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java b/src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchMatchers.java similarity index 98% rename from src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java rename to src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchMatchers.java index d3cfbe4d19c..aa05eed1812 100644 --- a/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java +++ b/src/test/java/org/elasticsearch/test/hamcrest/ElasticSearchMatchers.java @@ -22,7 +22,7 @@ import org.elasticsearch.search.SearchHit; import org.hamcrest.Description; import org.hamcrest.TypeSafeMatcher; -public class ElasticsearchMatchers { +public class ElasticSearchMatchers { public static class SearchHitHasIdMatcher extends TypeSafeMatcher { private String id; diff --git a/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolTests.java b/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolTests.java index 6ee43b74d15..0b8f1e89301 100644 --- a/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolTests.java +++ b/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolTests.java @@ -2,15 +2,16 @@ package org.elasticsearch.threadpool; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; -import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.json.JsonXContent; -import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractIntegrationTest; +import org.elasticsearch.test.AbstractIntegrationTest.ClusterScope; +import org.elasticsearch.test.AbstractIntegrationTest.Scope; import org.elasticsearch.threadpool.ThreadPool.Names; import org.junit.Test; @@ -23,28 +24,20 @@ import static org.hamcrest.Matchers.*; /** */ -public class SimpleThreadPoolTests extends AbstractNodesTests { - - private Client client1; - - private Client client2; - - private ThreadPool threadPool; +@ClusterScope(scope=Scope.SUITE, numNodes=2) +public class SimpleThreadPoolTests extends AbstractIntegrationTest { @Override - protected void beforeClass() { - startNode("node1", ImmutableSettings.settingsBuilder().put("threadpool.search.type", "cached").build()); - startNode("node2", ImmutableSettings.settingsBuilder().put("threadpool.search.type", "cached").build()); - client1 = client("node1"); - client2 = client("node2"); - threadPool = ((InternalNode) node("node1")).injector().getInstance(ThreadPool.class); + protected Settings nodeSettings(int nodeOrdinal) { + return ImmutableSettings.settingsBuilder().put("threadpool.search.type", "cached").put(super.nodeSettings(nodeOrdinal)).build(); } @Test(timeout = 20000) public void testUpdatingThreadPoolSettings() throws Exception { + ThreadPool threadPool = cluster().getInstance(ThreadPool.class); // Check that settings are changed assertThat(((ThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(5L)); - client1.admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder().put("threadpool.search.keep_alive", "10m").build()).execute().actionGet(); + client().admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder().put("threadpool.search.keep_alive", "10m").build()).execute().actionGet(); assertThat(((ThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L)); // Make sure that threads continue executing when executor is replaced @@ -62,7 +55,7 @@ public class SimpleThreadPoolTests extends AbstractNodesTests { } } }); - client1.admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder().put("threadpool.search.type", "fixed").build()).execute().actionGet(); + client().admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder().put("threadpool.search.type", "fixed").build()).execute().actionGet(); assertThat(threadPool.executor(Names.SEARCH), not(sameInstance(oldExecutor))); assertThat(((ThreadPoolExecutor) oldExecutor).isShutdown(), equalTo(true)); assertThat(((ThreadPoolExecutor) oldExecutor).isTerminating(), equalTo(true)); @@ -82,12 +75,12 @@ public class SimpleThreadPoolTests extends AbstractNodesTests { } } }); - client1.admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder().put("threadpool.search.type", "fixed").build()).execute().actionGet(); + client().admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder().put("threadpool.search.type", "fixed").build()).execute().actionGet(); barrier.await(); Thread.sleep(200); // Check that node info is correct - NodesInfoResponse nodesInfoResponse = client2.admin().cluster().prepareNodesInfo().all().execute().actionGet(); + NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().all().execute().actionGet(); for (int i = 0; i < 2; i++) { NodeInfo nodeInfo = nodesInfoResponse.getNodes()[i]; boolean found = false; diff --git a/src/test/java/org/elasticsearch/timestamp/SimpleTimestampTests.java b/src/test/java/org/elasticsearch/timestamp/SimpleTimestampTests.java index fd56b7713ff..c65c1348f6e 100644 --- a/src/test/java/org/elasticsearch/timestamp/SimpleTimestampTests.java +++ b/src/test/java/org/elasticsearch/timestamp/SimpleTimestampTests.java @@ -22,15 +22,14 @@ package org.elasticsearch.timestamp; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.common.Priority; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** */ -public class SimpleTimestampTests extends AbstractSharedClusterTest { +public class SimpleTimestampTests extends AbstractIntegrationTest { @Test public void testSimpleTimestamp() throws Exception { diff --git a/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java b/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java index 965e448e38e..ef61291395e 100644 --- a/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java +++ b/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.junit.annotations.TestLogging; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; import org.junit.Before; @@ -44,7 +44,7 @@ import static org.hamcrest.Matchers.*; /** * */ -public abstract class AbstractSimpleTransportTests extends ElasticsearchTestCase { +public abstract class AbstractSimpleTransportTests extends ElasticSearchTestCase { protected ThreadPool threadPool; diff --git a/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java b/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java index 1b18e834f04..890061c29ff 100644 --- a/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java +++ b/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java @@ -21,7 +21,7 @@ package org.elasticsearch.transport.netty; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.common.util.concurrent.KeyedLock; -import org.elasticsearch.ElasticsearchTestCase; +import org.elasticsearch.test.ElasticSearchTestCase; import org.hamcrest.Matchers; import org.junit.Test; @@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; -public class KeyedLockTests extends ElasticsearchTestCase { +public class KeyedLockTests extends ElasticSearchTestCase { @Test public void checkIfMapEmptyAfterLotsOfAcquireAndReleases() throws InterruptedException { diff --git a/src/test/java/org/elasticsearch/ttl/SimpleTTLTests.java b/src/test/java/org/elasticsearch/ttl/SimpleTTLTests.java index e36e8cb673e..e46f10eb30d 100644 --- a/src/test/java/org/elasticsearch/ttl/SimpleTTLTests.java +++ b/src/test/java/org/elasticsearch/ttl/SimpleTTLTests.java @@ -24,7 +24,7 @@ import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.common.Priority; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.AbstractNodesTests; +import org.elasticsearch.test.AbstractNodesTests; import org.junit.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; diff --git a/src/test/java/org/elasticsearch/update/UpdateTests.java b/src/test/java/org/elasticsearch/update/UpdateTests.java index bc16921162f..58f6c62977a 100644 --- a/src/test/java/org/elasticsearch/update/UpdateTests.java +++ b/src/test/java/org/elasticsearch/update/UpdateTests.java @@ -30,7 +30,7 @@ import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.index.VersionType; import org.elasticsearch.index.engine.DocumentMissingException; import org.elasticsearch.index.engine.VersionConflictEngineException; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.HashMap; @@ -40,10 +40,10 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertThrows; import static org.hamcrest.Matchers.*; -public class UpdateTests extends AbstractSharedClusterTest { +public class UpdateTests extends AbstractIntegrationTest { protected void createIndex() throws Exception { diff --git a/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java b/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java index b2f2464a26c..1236a457f67 100644 --- a/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java +++ b/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.validate; import com.google.common.base.Charsets; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; import org.elasticsearch.client.Client; import org.elasticsearch.common.Priority; @@ -31,6 +30,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.test.AbstractIntegrationTest; import org.hamcrest.Matcher; import org.junit.Test; @@ -41,7 +41,7 @@ import static org.hamcrest.Matchers.*; /** * */ -public class SimpleValidateQueryTests extends AbstractSharedClusterTest { +public class SimpleValidateQueryTests extends AbstractIntegrationTest { @Test public void simpleValidateQuery() throws Exception { diff --git a/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationTests.java b/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationTests.java index 754ba2491e1..27252e4dcde 100644 --- a/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationTests.java +++ b/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationTests.java @@ -1,8 +1,8 @@ package org.elasticsearch.versioning; -import org.elasticsearch.AbstractSharedClusterTest; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.Map; @@ -16,7 +16,7 @@ import static org.hamcrest.Matchers.nullValue; /** * */ -public class ConcurrentDocumentOperationTests extends AbstractSharedClusterTest { +public class ConcurrentDocumentOperationTests extends AbstractIntegrationTest { @Test public void concurrentOperationOnSameDocTest() throws Exception { diff --git a/src/test/java/org/elasticsearch/versioning/SimpleVersioningTests.java b/src/test/java/org/elasticsearch/versioning/SimpleVersioningTests.java index efccc3a27c7..50602bcb53c 100644 --- a/src/test/java/org/elasticsearch/versioning/SimpleVersioningTests.java +++ b/src/test/java/org/elasticsearch/versioning/SimpleVersioningTests.java @@ -27,20 +27,19 @@ import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.index.VersionType; import org.elasticsearch.index.engine.DocumentAlreadyExistsException; import org.elasticsearch.index.engine.VersionConflictEngineException; -import org.elasticsearch.AbstractSharedClusterTest; +import org.elasticsearch.test.AbstractIntegrationTest; import org.junit.Test; import java.util.HashMap; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.elasticsearch.test.hamcrest.ElasticSearchAssertions.assertThrows; import static org.hamcrest.Matchers.equalTo; /** * */ -public class SimpleVersioningTests extends AbstractSharedClusterTest { +public class SimpleVersioningTests extends AbstractIntegrationTest { @Test public void testExternalVersioningInitialDelete() throws Exception {