From d7cf5cd6afcd18bb3acfa34a1a15d01c5060a6ad Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 3 Aug 2015 21:34:53 -0400 Subject: [PATCH] NamingConventionTests should test subclasses of ESIntegTestCase end with IT These are integration tests. --- .../org/elasticsearch/NamingConventionTests.java | 12 +++++++++++- ...pleNodesInfoTests.java => SimpleNodesInfoIT.java} | 2 +- ...bStoreFormatTests.java => BlobStoreFormatIT.java} | 2 +- .../{RepositoriesTests.java => RepositoriesIT.java} | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) rename core/src/test/java/org/elasticsearch/nodesinfo/{SimpleNodesInfoTests.java => SimpleNodesInfoIT.java} (98%) rename core/src/test/java/org/elasticsearch/snapshots/{BlobStoreFormatTests.java => BlobStoreFormatIT.java} (99%) rename core/src/test/java/org/elasticsearch/snapshots/{RepositoriesTests.java => RepositoriesIT.java} (99%) diff --git a/core/src/test/java/org/elasticsearch/NamingConventionTests.java b/core/src/test/java/org/elasticsearch/NamingConventionTests.java index 1187a1e2635..071cd256e44 100644 --- a/core/src/test/java/org/elasticsearch/NamingConventionTests.java +++ b/core/src/test/java/org/elasticsearch/NamingConventionTests.java @@ -26,6 +26,7 @@ import junit.framework.TestCase; import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.io.PathUtils; +import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTokenStreamTestCase; import org.junit.Ignore; @@ -51,6 +52,7 @@ public class NamingConventionTests extends ESTestCase { final Set notImplementing = new HashSet<>(); final Set pureUnitTest = new HashSet<>(); final Set missingSuffix = new HashSet<>(); + final Set integTestsInDisguise = new HashSet<>(); String[] packages = {"org.elasticsearch", "org.apache.lucene"}; for (final String packageName : packages) { final String path = "/" + packageName.replace('.', '/'); @@ -76,12 +78,19 @@ public class NamingConventionTests extends ESTestCase { Class clazz = loadClass(filename); if (Modifier.isAbstract(clazz.getModifiers()) == false && Modifier.isInterface(clazz.getModifiers()) == false) { if (clazz.getName().endsWith("Tests") || - clazz.getName().endsWith("IT") || clazz.getName().endsWith("Test")) { // don't worry about the ones that match the pattern + if (ESIntegTestCase.class.isAssignableFrom(clazz)) { + integTestsInDisguise.add(clazz); + } if (isTestCase(clazz) == false) { notImplementing.add(clazz); } + } else if (clazz.getName().endsWith("IT")) { + if (isTestCase(clazz) == false) { + notImplementing.add(clazz); + } + // otherwise fine } else if (isTestCase(clazz)) { missingSuffix.add(clazz); } else if (junit.framework.Test.class.isAssignableFrom(clazz) || hasTestAnnotation(clazz)) { @@ -151,6 +160,7 @@ public class NamingConventionTests extends ESTestCase { pureUnitTest.isEmpty()); assertTrue("Classes ending with Test|Tests] must subclass [" + classesToSubclass +"] " + notImplementing.toString(), notImplementing.isEmpty()); + assertTrue("Subclasses of ESIntegTestCase should end with IT as they are integration tests: " + integTestsInDisguise, integTestsInDisguise.isEmpty()); } /* diff --git a/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoTests.java b/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java similarity index 98% rename from core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoTests.java rename to core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java index 21d292e4d63..86b1a6a4cc3 100644 --- a/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoTests.java +++ b/core/src/test/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java @@ -36,7 +36,7 @@ import static org.hamcrest.Matchers.*; * */ @ClusterScope(scope= Scope.TEST, numDataNodes =0) -public class SimpleNodesInfoTests extends PluginTestCase { +public class SimpleNodesInfoIT extends PluginTestCase { static final class Fields { static final String SITE_PLUGIN = "dummy"; diff --git a/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatTests.java b/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java similarity index 99% rename from core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatTests.java rename to core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java index 4a16d2ff17c..a805aa34bd3 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatTests.java +++ b/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java @@ -49,7 +49,7 @@ import java.util.concurrent.*; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.greaterThan; -public class BlobStoreFormatTests extends AbstractSnapshotIntegTestCase { +public class BlobStoreFormatIT extends AbstractSnapshotIntegTestCase { private static final ParseFieldMatcher parseFieldMatcher = new ParseFieldMatcher(Settings.EMPTY); diff --git a/core/src/test/java/org/elasticsearch/snapshots/RepositoriesTests.java b/core/src/test/java/org/elasticsearch/snapshots/RepositoriesIT.java similarity index 99% rename from core/src/test/java/org/elasticsearch/snapshots/RepositoriesTests.java rename to core/src/test/java/org/elasticsearch/snapshots/RepositoriesIT.java index ff67973a619..1ea8c68f778 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/RepositoriesTests.java +++ b/core/src/test/java/org/elasticsearch/snapshots/RepositoriesIT.java @@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.notNullValue; /** */ @ESIntegTestCase.ClusterScope(minNumDataNodes = 2) -public class RepositoriesTests extends AbstractSnapshotIntegTestCase { +public class RepositoriesIT extends AbstractSnapshotIntegTestCase { @Test public void testRepositoryCreation() throws Exception {