From eb9c0d077b08e92673edc60ed3a6db4378f5c1df Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Wed, 14 Aug 2013 00:02:29 +0200 Subject: [PATCH] no need doc action test to check count in before class - also, since we randomize client transports, no need for specific classes to test for it, we test different clients across all our tests --- .../DiscoveryTransportClientTests.java | 60 ------------------- .../TransportClientDocumentActionsTests.java | 37 ------------ ...nsportClientSniffDocumentActionsTests.java | 38 ------------ .../document/DocumentActionsTests.java | 29 +++------ 4 files changed, 9 insertions(+), 155 deletions(-) delete mode 100644 src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java delete mode 100644 src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java delete mode 100644 src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java diff --git a/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java b/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java deleted file mode 100644 index 62bde7ae712..00000000000 --- a/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to ElasticSearch and Shay Banon under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. ElasticSearch licenses this - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.test.integration.client.transport; - -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.common.network.NetworkUtils; -import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.test.integration.AbstractNodesTests; -import org.junit.After; -import org.junit.Ignore; - -import static org.elasticsearch.client.Requests.createIndexRequest; - -/** - * - */ -public class DiscoveryTransportClientTests extends AbstractNodesTests { - - private TransportClient client; - - @After - public void closeServers() { - if (client != null) { - client.close(); - } - closeAllNodes(); - } - - /*@Test*/ - @Ignore("fails for some reason?") - public void testWithDiscovery() throws Exception { - startNode("server1"); - client = new TransportClient(ImmutableSettings.settingsBuilder() - .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName()) - .put("discovery.enabled", true) - .build()); - // wait a bit so nodes will be discovered - Thread.sleep(1000); - client.admin().indices().create(createIndexRequest("test")).actionGet(); - Thread.sleep(500); - } - -} diff --git a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java b/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java deleted file mode 100644 index a0878195351..00000000000 --- a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to Elastic Search and Shay Banon under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. Elastic Search licenses this - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.test.integration.client.transport; - -import org.elasticsearch.test.integration.TestCluster; -import org.elasticsearch.test.integration.document.DocumentActionsTests; -import org.junit.BeforeClass; - -/** - * - */ -public class TransportClientDocumentActionsTests extends DocumentActionsTests { - - - @BeforeClass - public static void beforeTransportClientDocumentActionsTests() throws Exception { - cluster().setClientFactory(TestCluster.TransportClientFactory.NO_SNIFF_CLIENT_FACTORY); - DocumentActionsTests.beforeDocumentActionsTests(); - } -} diff --git a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java b/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java deleted file mode 100644 index 97a64e39e32..00000000000 --- a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to ElasticSearch and Shay Banon under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. ElasticSearch licenses this - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.test.integration.client.transport; - -import org.elasticsearch.test.integration.TestCluster; -import org.elasticsearch.test.integration.document.DocumentActionsTests; -import org.junit.BeforeClass; - -/** - * - */ -public class TransportClientSniffDocumentActionsTests extends DocumentActionsTests { - - @BeforeClass - public static void beforTransportClientSniffDocumentActionsTests() throws Exception { - DocumentActionsTests.beforeDocumentActionsTests(); - cluster().setClientFactory(TestCluster.TransportClientFactory.SNIFF_CLIENT_FACTORY); - DocumentActionsTests.beforeDocumentActionsTests(); - - } -} diff --git a/src/test/java/org/elasticsearch/test/integration/document/DocumentActionsTests.java b/src/test/java/org/elasticsearch/test/integration/document/DocumentActionsTests.java index 2805d9bf9fb..a6758bad3ca 100644 --- a/src/test/java/org/elasticsearch/test/integration/document/DocumentActionsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/document/DocumentActionsTests.java @@ -37,7 +37,6 @@ import org.elasticsearch.action.support.replication.ReplicationType; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.test.integration.AbstractSharedClusterTest; -import org.junit.BeforeClass; import org.junit.Test; import java.io.IOException; @@ -53,25 +52,15 @@ import static org.hamcrest.Matchers.nullValue; * */ public class DocumentActionsTests extends AbstractSharedClusterTest { - - @BeforeClass - public static void beforeDocumentActionsTests() throws Exception { - AbstractSharedClusterTest.beforeClass(); - wipeIndices(); - // no indices, check that simple operations fail - try { - client().prepareCount("test").setQuery(termQuery("_type", "type1")).setOperationThreading(BroadcastOperationThreading.NO_THREADS).execute().actionGet(); - assert false : "should fail"; - } catch (Exception e) { - // all is well - } - client().prepareCount().setQuery(termQuery("_type", "type1")).setOperationThreading(BroadcastOperationThreading.NO_THREADS).execute().actionGet(); - cluster().ensureAtLeastNumNodes(2); + + @Override + protected int numberOfNodes() { + return 2; } protected void createIndex() { - wipeIndex(getConcreteIndexName()); - createIndex(getConcreteIndexName()); + wipeIndex(getConcreteIndexName()); + createIndex(getConcreteIndexName()); } @@ -92,7 +81,7 @@ public class DocumentActionsTests extends AbstractSharedClusterTest { logger.info("Refreshing"); RefreshResponse refreshResponse = refresh(); assertThat(refreshResponse.getSuccessfulShards(), equalTo(10)); - + logger.info("--> index exists?"); assertThat(indexExists(getConcreteIndexName()), equalTo(true)); logger.info("--> index exists?, fake index"); @@ -102,7 +91,7 @@ public class DocumentActionsTests extends AbstractSharedClusterTest { ClearIndicesCacheResponse clearIndicesCacheResponse = client().admin().indices().clearCache(clearIndicesCacheRequest("test").recycler(true).fieldDataCache(true).filterCache(true).idCache(true)).actionGet(); assertNoFailures(clearIndicesCacheResponse); assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(10)); - + logger.info("Optimizing"); waitForRelocation(ClusterHealthStatus.GREEN); OptimizeResponse optimizeResponse = optimize(); @@ -203,7 +192,7 @@ public class DocumentActionsTests extends AbstractSharedClusterTest { // count with no query is a match all one countResponse = client().prepareCount("test").execute().actionGet(); - assertThat("Failures " + countResponse.getShardFailures(), countResponse.getShardFailures()==null?0:countResponse.getShardFailures().length, equalTo(0)); + assertThat("Failures " + countResponse.getShardFailures(), countResponse.getShardFailures() == null ? 0 : countResponse.getShardFailures().length, equalTo(0)); assertThat(countResponse.getCount(), equalTo(2l)); assertThat(countResponse.getSuccessfulShards(), equalTo(5)); assertThat(countResponse.getFailedShards(), equalTo(0));