From b4ad3d0d88259588d0e6d08a075654d1f12a4ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Fri, 27 Mar 2020 09:46:31 -0700 Subject: [PATCH] fix nullhandling exceptions related to test ordering (#9570) * fix nullhandling exceptions related to test ordering Tests might get executed in different order depending on the maven version and the test environment. This may lead to "NullHandling module not initialized" errors for some tests where we do not initialize null-handling explicitly. * use InitializedNullHandlingTest --- extensions-core/hdfs-storage/pom.xml | 7 +++++++ .../apache/druid/inputsource/hdfs/HdfsInputSourceTest.java | 3 ++- .../seekablestream/RecordSupplierInputSourceTest.java | 4 +++- .../org/apache/druid/segment/SchemalessTestFullTest.java | 3 ++- .../org/apache/druid/segment/SchemalessTestSimpleTest.java | 4 +++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/extensions-core/hdfs-storage/pom.xml b/extensions-core/hdfs-storage/pom.xml index 03ece8a044e..8c609fb20ec 100644 --- a/extensions-core/hdfs-storage/pom.xml +++ b/extensions-core/hdfs-storage/pom.xml @@ -422,6 +422,13 @@ ${project.parent.version} test + + org.apache.druid + druid-core + ${project.parent.version} + tests + test + diff --git a/extensions-core/hdfs-storage/src/test/java/org/apache/druid/inputsource/hdfs/HdfsInputSourceTest.java b/extensions-core/hdfs-storage/src/test/java/org/apache/druid/inputsource/hdfs/HdfsInputSourceTest.java index 92b4ad8ed40..d2c7820d5c1 100644 --- a/extensions-core/hdfs-storage/src/test/java/org/apache/druid/inputsource/hdfs/HdfsInputSourceTest.java +++ b/extensions-core/hdfs-storage/src/test/java/org/apache/druid/inputsource/hdfs/HdfsInputSourceTest.java @@ -34,6 +34,7 @@ import org.apache.druid.data.input.impl.DimensionsSpec; import org.apache.druid.data.input.impl.TimestampSpec; import org.apache.druid.java.util.common.parsers.CloseableIterator; import org.apache.druid.storage.hdfs.HdfsStorageDruidModule; +import org.apache.druid.testing.InitializedNullHandlingTest; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.MiniDFSCluster; @@ -64,7 +65,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; @RunWith(Enclosed.class) -public class HdfsInputSourceTest +public class HdfsInputSourceTest extends InitializedNullHandlingTest { private static final String PATH = "/foo/bar"; private static final Configuration CONFIGURATION = new Configuration(); diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/RecordSupplierInputSourceTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/RecordSupplierInputSourceTest.java index b03de85fe32..10d6bf857a4 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/RecordSupplierInputSourceTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/RecordSupplierInputSourceTest.java @@ -35,6 +35,7 @@ import org.apache.druid.indexing.seekablestream.common.StreamPartition; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.parsers.CloseableIterator; +import org.apache.druid.testing.InitializedNullHandlingTest; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -54,8 +55,9 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; import java.util.stream.IntStream; -public class RecordSupplierInputSourceTest +public class RecordSupplierInputSourceTest extends InitializedNullHandlingTest { + private static final int NUM_COLS = 16; private static final int NUM_ROWS = 128; private static final String TIMESTAMP_STRING = "2019-01-01"; diff --git a/processing/src/test/java/org/apache/druid/segment/SchemalessTestFullTest.java b/processing/src/test/java/org/apache/druid/segment/SchemalessTestFullTest.java index eb266304a88..dcd4eee5d27 100644 --- a/processing/src/test/java/org/apache/druid/segment/SchemalessTestFullTest.java +++ b/processing/src/test/java/org/apache/druid/segment/SchemalessTestFullTest.java @@ -60,6 +60,7 @@ import org.apache.druid.query.topn.TopNResultValue; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMediumFactory; +import org.apache.druid.testing.InitializedNullHandlingTest; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -73,7 +74,7 @@ import java.util.Map; /** */ @RunWith(Parameterized.class) -public class SchemalessTestFullTest +public class SchemalessTestFullTest extends InitializedNullHandlingTest { @Parameterized.Parameters public static Collection constructorFeeder() diff --git a/processing/src/test/java/org/apache/druid/segment/SchemalessTestSimpleTest.java b/processing/src/test/java/org/apache/druid/segment/SchemalessTestSimpleTest.java index 590ba5b5995..2d662597ad7 100644 --- a/processing/src/test/java/org/apache/druid/segment/SchemalessTestSimpleTest.java +++ b/processing/src/test/java/org/apache/druid/segment/SchemalessTestSimpleTest.java @@ -57,6 +57,7 @@ import org.apache.druid.query.topn.TopNQueryBuilder; import org.apache.druid.query.topn.TopNResultValue; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; +import org.apache.druid.testing.InitializedNullHandlingTest; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -72,8 +73,9 @@ import java.util.List; /** */ @RunWith(Parameterized.class) -public class SchemalessTestSimpleTest +public class SchemalessTestSimpleTest extends InitializedNullHandlingTest { + @Parameterized.Parameters public static Collection constructorFeeder() {