You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by pr...@apache.org on 2017/11/15 01:47:08 UTC
[22/22] drill git commit: DRILL-5783, DRILL-5841,
DRILL-5894: Rationalize test temp directories
DRILL-5783, DRILL-5841, DRILL-5894: Rationalize test temp directories
This change includes:
DRILL-5783:
- A unit test is created for the priority queue in the TopN operator.
- The code generation classes passed around a completely unused function registry reference in some places so it is removed.
- The priority queue had unused parameters for some of its methods so it is removed.
DRILL-5841:
- Created standardized temp directory classes DirTestWatcher, SubDirTestWatcher, and BaseDirTestWatcher. And updated all unit tests to use them.
DRILL-5894:
- Removed the dfs_test storage plugin for tests and replaced it with the already existing dfs storage plugin.
Misc:
- General code cleanup.
- Removed unnecessary use of String.format in the tests.
This closes #984
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/acc5ed92
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/acc5ed92
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/acc5ed92
Branch: refs/heads/master
Commit: acc5ed927e1fa4011ac1c3724d15197484b9f45b
Parents: c56de2f
Author: Timothy Farkas <ti...@apache.org>
Authored: Thu Nov 9 14:25:53 2017 -0800
Committer: Paul Rogers <pr...@maprtech.com>
Committed: Tue Nov 14 17:26:41 2017 -0800
----------------------------------------------------------------------
.../drill/common/util/DrillFileUtils.java | 46 +
.../org/apache/drill/common/util/FileUtils.java | 47 --
.../org/apache/drill/common/util/TestTools.java | 75 --
.../org/apache/drill/test/DirTestWatcher.java | 167 ++++
.../java/org/apache/drill/test/DrillTest.java | 19 +-
.../apache/drill/test/SubDirTestWatcher.java | 193 +++++
.../java/org/apache/drill/test/TestTools.java | 104 +++
.../apache/drill/testutils/DirTestWatcher.java | 61 --
.../drill/maprdb/tests/json/BaseJsonTest.java | 2 +-
.../expr/fn/impl/gis/TestGeometryFunctions.java | 10 +-
.../org/apache/drill/hbase/BaseHBaseTest.java | 6 +-
.../drill/hbase/HBaseRecordReaderTest.java | 2 +-
.../hbase/TestOrderedBytesConvertFunctions.java | 2 +-
.../apache/drill/exec/fn/hive/TestHiveUDFs.java | 2 +-
.../drill/exec/fn/hive/TestInbuiltHiveUDFs.java | 4 +-
.../apache/drill/exec/hive/HiveTestBase.java | 4 +-
.../apache/drill/exec/hive/TestHiveStorage.java | 1 -
.../exec/hive/TestInfoSchemaOnHiveStorage.java | 5 +-
.../hive/BaseTestHiveImpersonation.java | 14 +-
.../sql/hive/TestViewSupportOnHiveTables.java | 16 +-
.../exec/store/hive/HiveTestDataGenerator.java | 46 +-
.../apache/drill/store/kudu/TestKuduPlugin.java | 2 +-
.../store/mongo/TestMongoProjectPushDown.java | 4 +-
.../drill/exec/compile/ClassTransformer.java | 11 +-
.../apache/drill/exec/compile/CodeCompiler.java | 6 +-
.../apache/drill/exec/expr/CodeGenerator.java | 38 +-
.../drill/exec/expr/EvaluationVisitor.java | 9 +-
.../exec/expr/fn/FunctionGenerationHelper.java | 18 +-
.../drill/exec/expr/fn/FunctionInitializer.java | 5 +-
.../exec/physical/impl/TopN/PriorityQueue.java | 60 +-
.../impl/TopN/PriorityQueueTemplate.java | 18 +-
.../exec/physical/impl/TopN/TopNBatch.java | 78 +-
.../physical/impl/aggregate/HashAggBatch.java | 3 +-
.../impl/aggregate/StreamingAggBatch.java | 5 +-
.../physical/impl/common/ChainedHashTable.java | 2 +-
.../physical/impl/filter/FilterRecordBatch.java | 4 +-
.../impl/flatten/FlattenRecordBatch.java | 4 +-
.../exec/physical/impl/join/HashJoinBatch.java | 5 +-
.../exec/physical/impl/join/MergeJoinBatch.java | 4 +-
.../physical/impl/join/NestedLoopJoinBatch.java | 5 +-
.../impl/mergereceiver/MergingRecordBatch.java | 6 +-
.../OrderedPartitionRecordBatch.java | 9 +-
.../PartitionSenderRootExec.java | 4 +-
.../impl/project/ProjectRecordBatch.java | 13 +-
.../exec/physical/impl/sort/SortBatch.java | 6 +-
.../impl/svremover/RemovingRecordBatch.java | 19 +-
.../impl/union/UnionAllRecordBatch.java | 2 +-
.../impl/window/WindowFrameRecordBatch.java | 3 +-
.../physical/impl/xsort/ExternalSortBatch.java | 6 +-
.../impl/xsort/managed/MergeSortWrapper.java | 4 +-
.../managed/PriorityQueueCopierWrapper.java | 4 +-
.../impl/xsort/managed/SorterWrapper.java | 3 +-
.../apache/drill/exec/record/BatchSchema.java | 4 +-
.../exec/record/selection/SelectionVector4.java | 8 +
.../drill/exec/store/dfs/FileSystemPlugin.java | 1 +
.../exec/store/easy/json/JSONFormatPlugin.java | 2 +-
.../drill/exec/util/StoragePluginTestUtils.java | 125 +++
.../apache/drill/exec/util/TestUtilities.java | 148 ----
.../src/main/resources/drill-module.conf | 1 +
.../java/org/apache/drill/BaseTestQuery.java | 713 ----------------
.../java/org/apache/drill/DrillTestWrapper.java | 808 ------------------
.../java/org/apache/drill/PlanTestBase.java | 2 +
.../java/org/apache/drill/PlanningBase.java | 2 +-
.../java/org/apache/drill/QueryTestUtil.java | 221 -----
.../java/org/apache/drill/TestAggNullable.java | 23 +-
.../org/apache/drill/TestAltSortQueries.java | 22 +-
.../java/org/apache/drill/TestBugFixes.java | 27 +-
.../test/java/org/apache/drill/TestBuilder.java | 689 ---------------
.../java/org/apache/drill/TestCTASJson.java | 16 +-
.../apache/drill/TestCTASPartitionFilter.java | 45 +-
.../org/apache/drill/TestCaseSensitivity.java | 1 +
.../apache/drill/TestDisabledFunctionality.java | 56 +-
.../java/org/apache/drill/TestDropTable.java | 62 +-
.../org/apache/drill/TestDynamicUDFSupport.java | 196 +++--
.../org/apache/drill/TestExampleQueries.java | 195 ++---
.../org/apache/drill/TestFrameworkTest.java | 14 +-
.../org/apache/drill/TestFunctionsQuery.java | 1 +
.../drill/TestFunctionsWithTypeExpoQueries.java | 172 ++--
.../test/java/org/apache/drill/TestInList.java | 3 +-
.../java/org/apache/drill/TestJoinNullable.java | 157 ++--
.../org/apache/drill/TestMergeFilterPlan.java | 64 +-
.../apache/drill/TestOutOfMemoryOutcome.java | 3 +-
.../org/apache/drill/TestPartitionFilter.java | 258 +++---
.../org/apache/drill/TestProjectPushDown.java | 20 +-
.../java/org/apache/drill/TestSchemaChange.java | 15 +-
.../org/apache/drill/TestSelectWithOption.java | 13 +-
.../java/org/apache/drill/TestSelectivity.java | 1 +
.../java/org/apache/drill/TestStarQueries.java | 30 +-
.../java/org/apache/drill/TestTextJoin.java | 25 +-
.../org/apache/drill/TestTpchDistributed.java | 1 +
.../drill/TestTpchDistributedConcurrent.java | 4 +-
.../drill/TestTpchDistributedStreaming.java | 3 +-
.../java/org/apache/drill/TestTpchExplain.java | 3 +-
.../java/org/apache/drill/TestTpchLimit0.java | 3 +-
.../java/org/apache/drill/TestTpchPlanning.java | 2 +-
.../org/apache/drill/TestTpchSingleMode.java | 3 +-
.../java/org/apache/drill/TestUnionAll.java | 343 ++++----
.../org/apache/drill/TestUnionDistinct.java | 338 +++-----
.../drill/TestUtf8SupportInQueryString.java | 1 +
.../drill/exec/DrillSeparatePlanningTest.java | 44 +-
.../java/org/apache/drill/exec/ExecTest.java | 20 -
.../apache/drill/exec/TestEmptyInputSql.java | 52 +-
.../drill/exec/TestQueriesOnLargeFile.java | 32 +-
.../apache/drill/exec/TestRepeatedReaders.java | 41 +-
.../apache/drill/exec/TestWindowFunctions.java | 47 +-
.../drill/exec/cache/TestWriteToDisk.java | 2 +-
.../apache/drill/exec/client/DumpCatTest.java | 4 +-
.../exec/compile/TestClassTransformation.java | 4 +-
.../exec/compile/TestEvaluationVisitor.java | 11 +-
.../exec/compile/TestLargeFileCompilation.java | 17 +-
.../apache/drill/exec/expr/ExpressionTest.java | 8 +-
.../drill/exec/expr/TestLogicalExprSerDe.java | 2 +-
.../expr/TestSchemaPathMaterialization.java | 14 +-
.../exec/expr/fn/FunctionInitializerTest.java | 10 +-
.../exec/expr/fn/impl/TestStringFunctions.java | 21 +-
.../exec/fn/impl/TestAggregateFunction.java | 4 +-
.../exec/fn/impl/TestAggregateFunctions.java | 70 +-
.../exec/fn/impl/TestCastEmptyStrings.java | 143 ++--
.../drill/exec/fn/impl/TestCastFunctions.java | 76 +-
.../exec/fn/impl/TestContextFunctions.java | 10 +-
.../drill/exec/fn/impl/TestCryptoFunctions.java | 2 +-
.../exec/fn/impl/TestDateAddFunctions.java | 2 +-
.../drill/exec/fn/impl/TestDateFunctions.java | 7 +-
.../exec/fn/impl/TestDateTruncFunctions.java | 2 +-
.../drill/exec/fn/impl/TestMathFunctions.java | 4 +-
.../drill/exec/fn/impl/TestMultiInputAdd.java | 4 +-
.../exec/fn/impl/TestNetworkFunctions.java | 2 +-
.../exec/fn/impl/TestNewAggregateFunctions.java | 4 +-
.../exec/fn/impl/TestNewDateFunctions.java | 2 +-
.../fn/impl/TestNewSimpleRepeatedFunctions.java | 2 +-
.../exec/fn/impl/TestRepeatedFunction.java | 4 +-
.../drill/exec/fn/impl/TestTrigFunctions.java | 2 +-
.../fn/impl/testing/TestDateConversions.java | 117 +--
.../exec/fn/interp/TestConstantFolding.java | 38 +-
.../impersonation/BaseTestImpersonation.java | 11 +-
.../TestImpersonationDisabledWithMiniDFS.java | 16 +-
.../TestImpersonationMetadata.java | 16 +-
.../impersonation/TestImpersonationQueries.java | 24 +-
.../impersonation/TestInboundImpersonation.java | 8 +-
.../TestInboundImpersonationPrivileges.java | 4 +-
.../drill/exec/memory/TestAllocators.java | 4 +-
.../exec/nested/TestFastComplexSchema.java | 2 +-
.../exec/nested/TestNestedComplexSchema.java | 2 +-
.../drill/exec/opt/BasicOptimizerTest.java | 4 +-
.../physical/config/TestParsePhysicalPlan.java | 4 +-
.../physical/impl/TestBroadcastExchange.java | 10 +-
.../exec/physical/impl/TestCastFunctions.java | 24 +-
.../physical/impl/TestCastVarCharToBigInt.java | 4 +-
.../physical/impl/TestConvertFunctions.java | 58 +-
.../drill/exec/physical/impl/TestDecimal.java | 14 +-
.../impl/TestDistributedFragmentRun.java | 10 +-
.../physical/impl/TestExtractFunctions.java | 4 +-
.../physical/impl/TestHashToRandomExchange.java | 4 +-
.../exec/physical/impl/TestLocalExchange.java | 47 +-
.../exec/physical/impl/TestOptiqPlans.java | 6 +-
.../physical/impl/TestReverseImplicitCast.java | 4 +-
.../physical/impl/TestSimpleFragmentRun.java | 8 +-
.../exec/physical/impl/TestSimpleFunctions.java | 8 +-
.../exec/physical/impl/TestStringFunctions.java | 1 -
.../exec/physical/impl/TestUnionExchange.java | 4 +-
.../exec/physical/impl/TopN/TestSimpleTopN.java | 102 ---
.../impl/TopN/TestTopNSchemaChanges.java | 77 +-
.../exec/physical/impl/TopN/TopNBatchTest.java | 173 ++++
.../drill/exec/physical/impl/agg/TestAgg.java | 4 +-
.../exec/physical/impl/agg/TestHashAggr.java | 2 +-
.../physical/impl/agg/TestHashAggrSpill.java | 153 ++--
.../impl/broadcastsender/TestBroadcast.java | 25 +-
.../physical/impl/filter/TestLargeInClause.java | 2 +-
.../physical/impl/filter/TestSimpleFilter.java | 6 +-
.../exec/physical/impl/flatten/TestFlatten.java | 221 +++--
.../impl/flatten/TestFlattenPlanning.java | 6 +-
.../exec/physical/impl/join/TestHashJoin.java | 24 +-
.../impl/join/TestHashJoinAdvanced.java | 45 +-
.../exec/physical/impl/join/TestMergeJoin.java | 32 +-
.../impl/join/TestMergeJoinAdvanced.java | 42 +-
.../impl/join/TestMergeJoinMulCondition.java | 10 +-
.../join/TestMergeJoinWithSchemaChanges.java | 123 +--
.../physical/impl/join/TestNestedLoopJoin.java | 17 +-
.../impl/limit/TestEarlyLimit0Optimization.java | 36 +-
.../impl/limit/TestLimitWithExchanges.java | 45 +-
.../physical/impl/limit/TestSimpleLimit.java | 6 +-
.../impl/mergereceiver/TestMergingReceiver.java | 12 +-
.../TestOrderedPartitionExchange.java | 4 +-
.../partitionsender/TestPartitionSender.java | 31 +-
.../impl/project/TestSimpleProjection.java | 4 +-
.../exec/physical/impl/sort/TestSimpleSort.java | 6 +-
.../drill/exec/physical/impl/sort/TestSort.java | 2 +-
.../physical/impl/svremover/TestSVRemover.java | 2 +-
.../impl/trace/TestTraceMultiRecordBatch.java | 4 +-
.../impl/trace/TestTraceOutputDump.java | 4 +-
.../physical/impl/union/TestSimpleUnion.java | 4 +-
.../impl/validate/TestValidationOptions.java | 21 +-
.../physical/impl/window/GenerateTestData.java | 24 +-
.../physical/impl/window/TestWindowFrame.java | 85 +-
.../TestCorruptParquetDateCorrection.java | 85 +-
.../physical/impl/writer/TestParquetWriter.java | 146 ++--
.../writer/TestParquetWriterEmptyFiles.java | 50 +-
.../exec/physical/impl/writer/TestWriter.java | 110 ++-
.../physical/impl/xsort/TestExternalSort.java | 171 ++--
.../impl/xsort/TestSimpleExternalSort.java | 29 +-
.../impl/xsort/TestSortSpillWithException.java | 17 +-
.../physical/unit/BasicPhysicalOpUnitTest.java | 2 +-
.../physical/unit/MiniPlanUnitTestBase.java | 8 +-
.../physical/unit/PhysicalOpUnitTestBase.java | 61 +-
.../drill/exec/physical/unit/TestMiniPlan.java | 4 +-
.../physical/unit/TestNullInputMiniPlan.java | 6 +-
.../exec/planner/TestDirectoryExplorerUDFs.java | 93 +--
.../planner/logical/TestCaseNullableTypes.java | 2 +-
.../logical/TestConvertCountToDirectScan.java | 12 +-
.../exec/planner/sql/TestDrillSQLWorker.java | 2 +-
.../apache/drill/exec/pop/PopUnitTestBase.java | 6 +-
.../drill/exec/pop/TestInjectionValue.java | 4 +-
.../drill/exec/record/TestRecordIterator.java | 6 +-
.../drill/exec/record/vector/TestDateTypes.java | 14 +-
.../exec/rpc/control/TestCustomTunnel.java | 2 +-
.../drill/exec/rpc/data/TestBitBitKerberos.java | 4 +-
.../drill/exec/rpc/security/KerberosHelper.java | 6 +-
.../user/TemporaryTablesAutomaticDropTest.java | 67 +-
.../security/TestCustomUserAuthenticator.java | 2 +-
.../rpc/user/security/TestUserBitKerberos.java | 4 +-
.../security/TestUserBitKerberosEncryption.java | 4 +-
.../exec/rpc/user/security/TestUserBitSSL.java | 5 +-
.../rpc/user/security/TestUserBitSSLServer.java | 20 +-
.../security/TestUserBitSaslCompatibility.java | 3 +-
.../exec/server/TestDrillbitResilience.java | 4 +-
.../apache/drill/exec/server/TestOptions.java | 2 +-
.../exec/server/TestOptionsAuthEnabled.java | 8 +-
.../drill/exec/server/TestTpcdsSf1Leaks.java | 4 +-
.../options/PersistedOptionValueTest.java | 11 +-
.../exec/server/options/TestConfigLinkage.java | 332 ++++++++
.../exec/server/rest/StatusResourcesTest.java | 14 +-
.../drill/exec/sql/TestBaseViewSupport.java | 16 +-
.../org/apache/drill/exec/sql/TestCTAS.java | 207 ++---
.../org/apache/drill/exec/sql/TestCTTAS.java | 82 +-
.../apache/drill/exec/sql/TestInfoSchema.java | 66 +-
.../drill/exec/sql/TestSimpleCastFunctions.java | 2 +-
.../apache/drill/exec/sql/TestViewSupport.java | 173 ++--
.../apache/drill/exec/sql/TestWithClause.java | 2 +-
.../exec/store/TestImplicitFileColumns.java | 94 +--
.../drill/exec/store/TestTimedRunnable.java | 2 +-
.../drill/exec/store/avro/AvroFormatTest.java | 257 +++---
.../drill/exec/store/avro/AvroTestUtil.java | 82 +-
.../exec/store/bson/TestBsonRecordReader.java | 2 +-
.../drill/exec/store/dfs/TestFileSelection.java | 11 +-
.../apache/drill/exec/store/dfs/TestGlob.java | 92 +-
.../store/dfs/TestSchemaNotFoundException.java | 12 +-
.../exec/store/easy/text/compliant/TestCsv.java | 18 +-
.../Drill2283InfoSchemaVarchar1BugTest.java | 2 +-
.../exec/store/json/TestJsonRecordReader.java | 24 +-
.../store/parquet/ParquetInternalsTest.java | 37 +-
.../store/parquet/ParquetRecordReaderTest.java | 100 ++-
.../exec/store/parquet/TestFixedlenDecimal.java | 15 +-
.../exec/store/parquet/TestParquetComplex.java | 2 +-
.../parquet/TestParquetFilterPushDown.java | 227 ++---
.../store/parquet/TestParquetGroupScan.java | 44 +-
.../store/parquet/TestParquetMetadataCache.java | 393 +++++----
.../exec/store/parquet/TestParquetScan.java | 40 +-
.../columnreaders/TestColumnReaderFactory.java | 2 +-
.../parquet/columnreaders/TestDateReader.java | 2 +-
.../store/parquet2/TestDrillParquetReader.java | 6 +-
.../drill/exec/store/pcap/TestPcapDecoder.java | 3 +-
.../exec/store/pcap/TestPcapRecordReader.java | 22 +-
.../sequencefile/TestSequenceFileReader.java | 9 +-
.../drill/exec/store/sys/PStoreTestUtil.java | 30 +-
.../exec/store/sys/TestPStoreProviders.java | 27 +-
.../drill/exec/store/sys/TestSystemTable.java | 2 +-
.../drill/exec/store/text/TestCsvHeader.java | 68 +-
.../exec/store/text/TestNewTextReader.java | 31 +-
.../drill/exec/store/text/TestTextColumn.java | 11 +-
.../exec/store/text/TextRecordReaderTest.java | 6 +-
.../testing/TestCountDownLatchInjection.java | 2 +-
.../exec/testing/TestExceptionInjection.java | 2 +-
.../drill/exec/testing/TestPauseInjection.java | 2 +-
.../drill/exec/testing/TestResourceLeak.java | 2 +-
.../vector/complex/TestEmptyPopulation.java | 6 +-
.../fn/TestJsonReaderWithSparseFiles.java | 2 +-
.../complex/writer/TestComplexToJson.java | 8 +-
.../complex/writer/TestComplexTypeReader.java | 59 +-
.../complex/writer/TestComplexTypeWriter.java | 2 +-
.../complex/writer/TestExtendedTypes.java | 46 +-
.../vector/complex/writer/TestJsonReader.java | 241 +++---
.../exec/work/batch/TestSpoolingBuffer.java | 6 +-
.../fragment/TestFragmentExecutorCancel.java | 2 +-
.../work/metadata/TestMetadataProvider.java | 19 +-
.../work/metadata/TestServerMetaProvider.java | 2 +-
.../work/prepare/PreparedStatementTestBase.java | 2 +-
.../apache/drill/test/BaseDirTestWatcher.java | 278 +++++++
.../org/apache/drill/test/BaseTestQuery.java | 613 ++++++++++++++
.../org/apache/drill/test/ClientFixture.java | 4 +-
.../org/apache/drill/test/ClusterFixture.java | 215 ++---
.../drill/test/ClusterFixtureBuilder.java | 61 +-
.../java/org/apache/drill/test/ClusterTest.java | 2 -
.../org/apache/drill/test/DrillTestWrapper.java | 832 +++++++++++++++++++
.../java/org/apache/drill/test/ExampleTest.java | 98 ++-
.../java/org/apache/drill/test/HadoopUtils.java | 44 +
.../org/apache/drill/test/QueryBuilder.java | 1 -
.../org/apache/drill/test/QueryTestUtil.java | 220 +++++
.../java/org/apache/drill/test/TestBuilder.java | 695 ++++++++++++++++
.../apache/drill/test/TestConfigLinkage.java | 319 -------
.../org/apache/drill/test/package-info.java | 117 ++-
.../org/apache/drill/test/rowSet/RowSet.java | 16 +-
.../apache/drill/test/rowSet/RowSetBuilder.java | 2 +-
.../drill/test/rowSet/RowSetComparison.java | 37 +
.../drill/test/rowSet/file/JsonFileBuilder.java | 159 ++++
.../resources/bootstrap-storage-plugins.json | 75 --
.../resources/parquet/parquet_nullable.json | 6 +-
.../parquet/parquet_nullable_varlen.json | 6 +-
.../resources/parquet/parquet_scan_screen.json | 6 +-
.../src/test/resources/queries/tpch/15.sql | 2 +-
.../src/test/resources/store/text/test.json | 2 +-
.../src/test/resources/topN/one_key_sort.json | 4 +-
.../src/test/resources/tpcds-sf1/q73.sql | 10 +-
.../src/test/resources/window/3604.sql | 2 +-
.../src/test/resources/window/3605.sql | 2 +-
.../src/test/resources/window/3606.sql | 2 +-
.../src/test/resources/window/3648.sql | 2 +-
.../src/test/resources/window/3668.sql | 2 +-
.../src/test/resources/window/fval.alltypes.sql | 2 +-
.../src/test/resources/window/fval.pby.sql | 2 +-
.../src/test/resources/window/lag.oby.sql | 2 +-
.../src/test/resources/window/lag.pby.oby.sql | 2 +-
.../src/test/resources/window/lead.oby.sql | 2 +-
.../src/test/resources/window/lead.pby.oby.sql | 2 +-
.../src/test/resources/window/lval.alltypes.sql | 2 +-
.../src/test/resources/window/lval.pby.oby.sql | 2 +-
.../src/test/resources/window/ntile.sql | 2 +-
exec/java-exec/src/test/resources/window/q1.sql | 2 +-
exec/java-exec/src/test/resources/window/q2.sql | 2 +-
exec/java-exec/src/test/resources/window/q3.sql | 2 +-
.../src/test/resources/window/q3218.sql | 2 +-
.../src/test/resources/window/q3220.sql | 2 +-
exec/java-exec/src/test/resources/window/q4.sql | 2 +-
.../resources/writer/simple_csv_writer.json | 6 +-
.../org/apache/drill/jdbc/ITTestShadedJar.java | 134 +--
.../drill/jdbc/impl/DrillConnectionImpl.java | 42 +-
.../jdbc/DatabaseMetaDataGetColumnsTest.java | 79 +-
.../apache/drill/jdbc/DrillResultSetTest.java | 13 +-
.../org/apache/drill/jdbc/JdbcTestBase.java | 334 +++++++-
.../LegacyDatabaseMetaDataGetColumnsTest.java | 6 +-
.../drill/jdbc/ResultSetMetaDataTest.java | 11 +-
.../jdbc/test/Bug1735ConnectionCloseTest.java | 8 +-
...ug1735ResultSetCloseReleasesBuffersTest.java | 5 +-
...etColumnsDataTypeNotTypeCodeIntBugsTest.java | 2 +-
...ill2288GetColumnsMetadataWhenNoRowsTest.java | 8 +-
...39GetBooleanFailsSayingWrongTypeBugTest.java | 2 +-
...rill2461IntervalsBreakInfoSchemaBugTest.java | 4 +-
...2463GetNullsFailedWithAssertionsBugTest.java | 2 +-
...l2489CallsAfterCloseThrowExceptionsTest.java | 8 +-
...69UnsupportedReportsUseSqlExceptionTest.java | 7 +-
.../org/apache/drill/jdbc/test/JdbcAssert.java | 361 --------
.../test/JdbcConnectTriesTestEmbeddedBits.java | 20 +-
.../apache/drill/jdbc/test/JdbcDataTest.java | 133 +--
.../test/JdbcNullOrderingAndGroupingTest.java | 266 ++----
.../drill/jdbc/test/JdbcTestActionBase.java | 62 +-
.../drill/jdbc/test/JdbcTestQueryBase.java | 8 +-
.../jdbc/test/TestAggregateFunctionsQuery.java | 34 +-
.../jdbc/test/TestInformationSchemaColumns.java | 76 +-
.../drill/jdbc/test/TestJdbcDistQuery.java | 111 ++-
.../drill/jdbc/test/TestJdbcMetadata.java | 7 +-
.../apache/drill/jdbc/test/TestJdbcQuery.java | 84 +-
.../drill/jdbc/test/TestLegacyJdbcMetadata.java | 2 +-
.../drill/exec/memory/ChildAllocator.java | 11 +-
.../drill/exec/vector/BaseValueVector.java | 2 -
.../apache/drill/exec/vector/ValueVector.java | 1 +
.../exec/vector/complex/RepeatedMapVector.java | 4 -
.../drill/storage/CheckStorageConfig.java | 4 +-
366 files changed, 9004 insertions(+), 9170 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java b/common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java
new file mode 100644
index 0000000..f20fef7
--- /dev/null
+++ b/common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.drill.common.util;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+
+public class DrillFileUtils {
+ // These two seperators are intentionally used instead of Path.SEPERATPR or File.seperator
+ // for loading classes since both alternatives return '\' on Windows. However, in the context
+ // of classpath scanning and loading only '/' is valid.
+ public static final char SEPARATOR_CHAR = '/';
+ public static final String SEPARATOR = "/";
+
+ public static File getResourceAsFile(String fileName) throws IOException {
+ URL u = DrillFileUtils.class.getResource(fileName);
+ if (u == null) {
+ throw new FileNotFoundException(String.format("Unable to find file on path %s", fileName));
+ }
+ return new File(u.getPath());
+ }
+
+ public static String getResourceAsString(String fileName) throws IOException {
+ return Files.toString(getResourceAsFile(fileName), Charsets.UTF_8);
+ }
+}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/common/src/main/java/org/apache/drill/common/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/util/FileUtils.java b/common/src/main/java/org/apache/drill/common/util/FileUtils.java
deleted file mode 100644
index cd846f8..0000000
--- a/common/src/main/java/org/apache/drill/common/util/FileUtils.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.drill.common.util;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URL;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-
-public class FileUtils {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(FileUtils.class);
-
- public static final char separatorChar = '/';
-
- public static final String separator = "" + separatorChar;
-
- public static File getResourceAsFile(String fileName) throws IOException {
- URL u = FileUtils.class.getResource(fileName);
- if (u == null) {
- throw new FileNotFoundException(String.format("Unable to find file on path %s", fileName));
- }
- return new File(u.getPath());
- }
-
- public static String getResourceAsString(String fileName) throws IOException {
- return Files.toString(getResourceAsFile(fileName), Charsets.UTF_8);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/common/src/main/java/org/apache/drill/common/util/TestTools.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/util/TestTools.java b/common/src/main/java/org/apache/drill/common/util/TestTools.java
deleted file mode 100644
index 30d073e..0000000
--- a/common/src/main/java/org/apache/drill/common/util/TestTools.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.drill.common.util;
-
-import java.nio.file.Paths;
-
-import org.junit.rules.TestName;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-
-public class TestTools {
- // private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestTools.class);
-
- static final boolean IS_DEBUG = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()
- .toString().indexOf("-agentlib:jdwp") > 0;
- static final String WORKING_PATH = Paths.get("").toAbsolutePath().toString();
-
- public static TestRule getTimeoutRule() {
- return getTimeoutRule(10000);
- }
-
- public static TestRule getTimeoutRule(int timeout) {
- return IS_DEBUG ? new TestName() : new Timeout(timeout);
- }
-
- /**
- * If not enforced, the repeat rule applies only if the test is run in non-debug mode.
- */
- public static TestRule getRepeatRule(final boolean enforce) {
- return enforce || !IS_DEBUG ? new RepeatTestRule() : new TestName();
- }
-
- public static String getWorkingPath() {
- return WORKING_PATH;
- }
-
- private static final String PATH_SEPARATOR = System.getProperty("file.separator");
- private static final String[] STRUCTURE = {"drill", "exec", "java-exec", "src", "test", "resources"};
-
- /**
- * Returns fully qualified path where test resources reside if current working directory is at any level in the
- * following root->exec->java-exec->src->test->resources, throws an {@link IllegalStateException} otherwise.
- */
- public static String getTestResourcesPath() {
- final StringBuilder builder = new StringBuilder(WORKING_PATH);
- for (int i=0; i< STRUCTURE.length; i++) {
- if (WORKING_PATH.endsWith(STRUCTURE[i])) {
- for (int j=i+1; j< STRUCTURE.length; j++) {
- builder.append(PATH_SEPARATOR).append(STRUCTURE[j]);
- }
- return builder.toString();
- }
- }
- final String msg = String.format("Unable to recognize working directory[%s]. The workspace must be root or exec " +
- "module.", WORKING_PATH);
- throw new IllegalStateException(msg);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/common/src/test/java/org/apache/drill/test/DirTestWatcher.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/drill/test/DirTestWatcher.java b/common/src/test/java/org/apache/drill/test/DirTestWatcher.java
new file mode 100644
index 0000000..c741b80
--- /dev/null
+++ b/common/src/test/java/org/apache/drill/test/DirTestWatcher.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.drill.test;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * <p>
+ * This class is used to create consistently named and safe temp directories for unit tests.
+ * </p>
+ *
+ * <p>
+ * A {@link DirTestWatcher} is added to a test by declaring it as a JUnit {@link org.junit.Rule}. A {@link org.junit.Rule} is
+ * a piece of code that is run before and after every JUnit test marked with the {@link org.junit.Test} annotation. When the
+ * {@link DirTestWatcher} is added to a test class the {@link DirTestWatcher} will create a temp directory before each of your
+ * {@link org.junit.Test}s and optionally delete the temp directory after each of your {@link org.junit.Test}s. The temp directory
+ * created by the {@link DirTestWatcher} is in the <b>target</b> folder of the maven project and has the form
+ * <b>(my test class fully qualified name)/(my test method name)</b>. So in the context of the code example below, the temp directory created for
+ * each test in <b>target</b> will be <b>my.proj.MyTestClass/myTestMethod1</b> and <b>my.proj.MyTestClass/myTestMethod2</b> respectively.
+ * </p>
+ *
+ * <p>
+ * The temp directory created by the {@link DirTestWatcher} can be used within a test by simply calling the {@link DirTestWatcher#getDir()}
+ * method on the {@link DirTestWatcher} within your unit test.
+ * </p>
+ *
+ * <p>
+ * By default, the {@link DirTestWatcher} deletes the temp directory it creates at the end of each {@link org.junit.Test}. However, you can create a {@link DirTestWatcher}
+ * by doing {@code new DirTestWatcher(false)} to disable the deletion of temp directories after a test. This is useful if you want to examine files after a test runs.
+ * </p>
+ *
+ * <pre>
+ * package my.proj;
+ *
+ * public class MyTestClass {
+ * @org.junit.Rule
+ * public final DirTestWatcher dirTestWatcher = new DirTestWatcher();
+ *
+ * @org.junit.Test
+ * public void myTestMethod1() {
+ * File dir = dirTestWatcher.getDir();
+ * // Do stuff in the temp directory
+ * }
+ *
+ * @org.junit.Test
+ * public void myTestMethod2() {
+ * File dir = dirTestWatcher.getDir();
+ * // Do stuff in the temp directory
+ * }
+ * }
+ * </pre>
+ *
+ * <p>
+ * <b>Note:</b> In the code sample above, the directories returned by {@link DirTestWatcher#getDir()} in myTestMethod1 and myTestMethod2 are
+ * <b>my.proj.MyTestClass/myTestMethod1</b> and <b>my.proj.MyTestClass/myTestMethod2</b> respectively.
+ * </p>
+ */
+public class DirTestWatcher extends TestWatcher {
+ private static final int TEMP_DIR_ATTEMPTS = 10000;
+
+ private String dirPath;
+ private File dir;
+ private boolean deleteDirAtEnd = true;
+
+ /**
+ * Creates a {@link DirTestWatcher} that deletes temp directories after the {@link TestWatcher} completes.
+ */
+ public DirTestWatcher() {
+ }
+
+ /**
+ * Creates a {@link DirTestWatcher} which can delete or keep the temp directory after the {@link TestWatcher} completes.
+ * @param deleteDirAtEnd When true the temp directory created by the {@link DirTestWatcher} is deleted. When false the
+ * temp directory created by the {@link DirTestWatcher} is not deleted.
+ */
+ public DirTestWatcher(boolean deleteDirAtEnd) {
+ this.deleteDirAtEnd = deleteDirAtEnd;
+ }
+
+ @Override
+ protected void starting(Description description) {
+ if (description.getMethodName() != null) {
+ dirPath = Paths.get(".","target", description.getClassName(), description.getMethodName()).toString();
+ } else {
+ dirPath = Paths.get(".","target", description.getClassName()).toString();
+ }
+
+ dir = new File(dirPath);
+ FileUtils.deleteQuietly(dir);
+ dir.mkdirs();
+ }
+
+ @Override
+ protected void finished(Description description) {
+ deleteDir();
+ }
+
+ @Override
+ protected void failed(Throwable e, Description description) {
+ deleteDir();
+ }
+
+ /**
+ * Creates a sub directory with the given relative path in current temp directory
+ * @param relativeDirPath The relative path of the sub directory to create in the current temp directory.
+ * @return The {@link java.io.File} object of the newly created sub directory.
+ */
+ public File makeSubDir(Path relativeDirPath) {
+ File subDir = dir
+ .toPath()
+ .resolve(relativeDirPath)
+ .toFile();
+ subDir.mkdirs();
+ return subDir;
+ }
+
+ private void deleteDir() {
+ if (deleteDirAtEnd) {
+ FileUtils.deleteQuietly(dir);
+ }
+ }
+
+ /**
+ * Gets the {@link java.io.File} object of the current temp directory.
+ * @return The {@link java.io.File} object of the current temp directory.
+ */
+ public File getDir() {
+ return dir;
+ }
+
+ public static File createTempDir(File baseDir) {
+ String baseName = System.currentTimeMillis() + "-";
+
+ for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) {
+ File tempDir = new File(baseDir, baseName + counter);
+ if (tempDir.mkdirs()) {
+ return tempDir;
+ }
+ }
+
+ String message = String.format("Failed to create directory within %s attempts (tried %s0 to %s)",
+ TEMP_DIR_ATTEMPTS, baseName, baseName + (TEMP_DIR_ATTEMPTS - 1));
+ throw new IllegalStateException(message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/common/src/test/java/org/apache/drill/test/DrillTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/drill/test/DrillTest.java b/common/src/test/java/org/apache/drill/test/DrillTest.java
index 64df178..de26470 100644
--- a/common/src/test/java/org/apache/drill/test/DrillTest.java
+++ b/common/src/test/java/org/apache/drill/test/DrillTest.java
@@ -25,7 +25,6 @@ import java.util.List;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.drill.common.util.DrillStringUtils;
-import org.apache.drill.common.util.TestTools;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -41,8 +40,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class DrillTest {
-// private static final Logger logger = org.slf4j.LoggerFactory.getLogger(DrillTest.class);
-
protected static final ObjectMapper objectMapper;
static {
System.setProperty("line.separator", "\n");
@@ -104,7 +101,8 @@ public class DrillTest {
@AfterClass
public static void finiDrillTest() throws InterruptedException{
testReporter.info(String.format("Test Class done (%s): %s.", memWatcher.getMemString(true), className));
- LOG_OUTCOME.sleepIfFailure();
+ // Clear interrupts for next test
+ Thread.interrupted();
}
protected static class MemWatcher {
@@ -138,9 +136,7 @@ public class DrillTest {
}
private static class TestLogReporter extends TestWatcher {
-
private MemWatcher memWatcher;
- private int failureCount = 0;
@Override
protected void starting(Description description) {
@@ -152,23 +148,12 @@ public class DrillTest {
@Override
protected void failed(Throwable e, Description description) {
testReporter.error(String.format("Test Failed (%s): %s", memWatcher.getMemString(), description.getDisplayName()), e);
- failureCount++;
}
@Override
public void succeeded(Description description) {
testReporter.info(String.format("Test Succeeded (%s): %s", memWatcher.getMemString(), description.getDisplayName()));
}
-
- public void sleepIfFailure() throws InterruptedException {
- if(failureCount > 0){
- Thread.sleep(2000);
- failureCount = 0;
- } else {
- // pause to get logger to catch up.
- Thread.sleep(250);
- }
- }
}
public static String escapeJsonString(String original) {
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/common/src/test/java/org/apache/drill/test/SubDirTestWatcher.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/drill/test/SubDirTestWatcher.java b/common/src/test/java/org/apache/drill/test/SubDirTestWatcher.java
new file mode 100644
index 0000000..bffb605
--- /dev/null
+++ b/common/src/test/java/org/apache/drill/test/SubDirTestWatcher.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.drill.test;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.commons.io.FileUtils;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.util.List;
+
+/**
+ * This is a {@link org.junit.rules.TestWatcher} which is used to create and delete sub directories before and after unit tests respectively.
+ * Ideally a {@link SubDirTestWatcher} would be used in conjunction with a {@link DirTestWatcher} or a sub class of {@link DirTestWatcher}. The
+ * {@link DirTestWatcher} would be used to create the base directory used by the {@link SubDirTestWatcher} to create all its sub directories. Here
+ * is an example of using the {@link SubDirTestWatcher} in this way.
+ *
+ * <pre>
+ * package my.proj;
+ *
+ * public class MyTestClass {
+ * public static final String TEST_SUB_DIR = "testSubDir";
+ * private static File testSubDir;
+ *
+ * @org.junit.ClassRule
+ * public static final DirTestWatcher dirTestWatcher = new DirTestWatcher();
+ *
+ * @org.junit.BeforeClass
+ * public static void setupFiles() {
+ * testSubDir = new File(dirTestWatcher.getDir(), TEST_SUB_DIR);
+ * }
+ *
+ * @org.junit.Rule
+ * public final SubDirTestWatcher subDirTestWatcher =
+ * new SubDirTestWatcher.Builder(dirTestWatcher.getDir())
+ * .addSubDir(TEST_SUB_DIR)
+ * .build();
+ *
+ * @org.junit.Test
+ * public void myTestMethod1() {
+ * // The testSubDir should be created for us by the SubDirTestWatcher
+ * org.junit.Assert.assertTrue(testSubDir.exists());
+ *
+ * // Lets make another sub directory in our sub directory
+ * File newSubDirectory = new File(testSubDir, "a");
+ * newSubDirectory.mkdirs();
+ * org.junit.Assert.assertTrue(newSubDirectory.exists());
+ * }
+ *
+ * @org.junit.Test
+ * public void myTestMethod2() {
+ * // The testSubDir should be created for us by the SubDirTestWatcher
+ * org.junit.Assert.assertTrue(testSubDir.exists());
+ *
+ * // The directory we created in the previous test should be gone
+ * org.junit.Assert.assertFalse(new File(testSubDir, "a").exists());
+ * }
+ * }
+ * </pre>
+ */
+public class SubDirTestWatcher extends TestWatcher {
+ private File baseDir;
+ private boolean createAtBeginning;
+ private boolean deleteAtEnd;
+ private List<Path> subDirs;
+
+ protected SubDirTestWatcher(File baseDir, boolean createAtBeginning, boolean deleteAtEnd, List<Path> subDirs) {
+ this.baseDir = Preconditions.checkNotNull(baseDir);
+ this.createAtBeginning = createAtBeginning;
+ this.deleteAtEnd = deleteAtEnd;
+ this.subDirs = Preconditions.checkNotNull(subDirs);
+
+ Preconditions.checkArgument(!subDirs.isEmpty(), "The list of subDirs is empty.");
+ }
+
+ @Override
+ protected void starting(Description description) {
+ deleteDirs(true);
+
+ if (!createAtBeginning) {
+ return;
+ }
+
+ for (Path subDir: subDirs) {
+ baseDir.toPath()
+ .resolve(subDir)
+ .toFile()
+ .mkdirs();
+ }
+ }
+
+ @Override
+ protected void finished(Description description) {
+ deleteDirs(deleteAtEnd);
+ }
+
+ @Override
+ protected void failed(Throwable e, Description description) {
+ deleteDirs(deleteAtEnd);
+ }
+
+ private void deleteDirs(boolean delete) {
+ if (!delete) {
+ return;
+ }
+
+ for (Path subDir: subDirs) {
+ FileUtils.deleteQuietly(baseDir.toPath().resolve(subDir).toFile());
+ }
+ }
+
+ /**
+ * This is a builder for a {@link SubDirTestWatcher}. Create an instance of the builder, configure it, and then call the {@link Builder#build()} to create a
+ * {@link SubDirTestWatcher}.
+ */
+ public static class Builder {
+ private File baseDir;
+ private boolean createAtBeginning = true;
+ private boolean deleteAtEnd = true;
+ private List<Path> subDirs = Lists.newArrayList();
+
+ /**
+ * Initializes a builder for a {@link SubDirTestWatcher} with the given baseDir.
+ * @param baseDir The baseDir is the parent directory in which all sub directories are created.
+ */
+ public Builder(File baseDir) {
+ this.baseDir = Preconditions.checkNotNull(baseDir);
+ }
+
+ /**
+ * Sets the createAtBeginning flag.
+ * @param createAtBeginning This flag determines whether the {@link SubDirTestWatcher} creates the configured sub directories at a beginning of a test. Setting
+ * This to true will cause the {@link SubDirTestWatcher} to create the configured sub directories at the beginning of each test. Setting
+ * This to false will prevent the {@link SubDirTestWatcher} from attempting to create the configured sub directories at the beginning of
+ * at test. Setting this to false is useful for scenarios where you only want to delete directories created in the middle of your tests. By
+ * default this flag is true.
+ * @return The {@link SubDirTestWatcher.Builder}.
+ */
+ public Builder setCreateAtBeginning(boolean createAtBeginning) {
+ this.createAtBeginning = createAtBeginning;
+ return this;
+ }
+
+ /**
+ * Sets the deleteAtEnd flag.
+ * @param deleteAtEnd This flag determines whether the {@link SubDirTestWatcher} deletes the sub directories it manages at the end of a test.
+ * @return The {@link SubDirTestWatcher.Builder}.
+ */
+ public Builder setDeleteAtEnd(boolean deleteAtEnd) {
+ this.deleteAtEnd = deleteAtEnd;
+ return this;
+ }
+
+ /**
+ * Adds a sub directory to be managed by the {@link SubDirTestWatcher}.
+ * @param subDir The relative path of the sub directory to be added.
+ * @return The {@link SubDirTestWatcher.Builder}.
+ */
+ public Builder addSubDir(Path subDir) {
+ Preconditions.checkNotNull(subDir);
+ subDirs.add(subDir);
+ return this;
+ }
+
+ /**
+ * Builds a {@link SubDirTestWatcher}.
+ * @return A configured {@link SubDirTestWatcher}.
+ */
+ public SubDirTestWatcher build() {
+ Preconditions.checkState(!subDirs.isEmpty(), "The list of subDirs is empty.");
+ return new SubDirTestWatcher(baseDir, createAtBeginning, deleteAtEnd, subDirs);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/common/src/test/java/org/apache/drill/test/TestTools.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/drill/test/TestTools.java b/common/src/test/java/org/apache/drill/test/TestTools.java
new file mode 100644
index 0000000..661b978
--- /dev/null
+++ b/common/src/test/java/org/apache/drill/test/TestTools.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.drill.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.drill.common.util.RepeatTestRule;
+import org.junit.rules.TestName;
+import org.junit.rules.TestRule;
+import org.junit.rules.Timeout;
+
+public class TestTools {
+ public enum FileSource {
+ RESOURCE,
+ PROJECT
+ }
+
+ public static final Path TEST_RESOURCES = Paths.get("src", "test", "resources");
+ public static final Path PROJECT_ROOT = Paths.get("..", "..");
+ public static final Path WORKING_PATH = new File(".").toPath();
+
+ static final boolean IS_DEBUG = java.lang.management.ManagementFactory.getRuntimeMXBean()
+ .getInputArguments()
+ .toString()
+ .indexOf("-agentlib:jdwp") > 0;
+
+ public static TestRule getTimeoutRule(int timeout) {
+ return IS_DEBUG ? new TestName() : new Timeout(timeout);
+ }
+
+ /**
+ * If not enforced, the repeat rule applies only if the test is run in non-debug mode.
+ */
+ public static TestRule getRepeatRule(final boolean enforce) {
+ return enforce || !IS_DEBUG ? new RepeatTestRule() : new TestName();
+ }
+
+ public static File getResourceFile(Path relPath) {
+ return WORKING_PATH
+ .resolve(TEST_RESOURCES)
+ .resolve(relPath)
+ .toFile();
+ }
+
+ public static File getProjectFile(Path relPath) {
+ return WORKING_PATH
+ .resolve(PROJECT_ROOT)
+ .resolve(relPath)
+ .toFile();
+ }
+
+ public static File getFile(Path relPath, FileSource fileSource) {
+ switch (fileSource) {
+ case RESOURCE:
+ return getResourceFile(relPath);
+ case PROJECT:
+ return getProjectFile(relPath);
+ default: {
+ throw new IllegalArgumentException(String.format("Unkown data type %s", fileSource));
+ }
+ }
+ }
+
+ public static void copyDirToDest(Path relPath, File destDir, FileSource fileSource) {
+ File srcDir;
+
+ switch (fileSource) {
+ case RESOURCE:
+ srcDir = getResourceFile(relPath);
+ break;
+ case PROJECT:
+ srcDir = getProjectFile(relPath);
+ break;
+ default: {
+ throw new IllegalArgumentException(String.format("Unkown data type %s", fileSource));
+ }
+ }
+
+ try {
+ FileUtils.copyDirectory(srcDir, destDir);
+ } catch (IOException e) {
+ throw new RuntimeException("This should never happen", e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/common/src/test/java/org/apache/drill/testutils/DirTestWatcher.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/drill/testutils/DirTestWatcher.java b/common/src/test/java/org/apache/drill/testutils/DirTestWatcher.java
deleted file mode 100644
index a5a8806..0000000
--- a/common/src/test/java/org/apache/drill/testutils/DirTestWatcher.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.drill.testutils;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-
-import java.io.File;
-
-/**
- * This JUnit {@link TestWatcher} creates a unique directory for each JUnit test in the project's
- * target folder at the start of each test. This directory can be used as a temporary directory to store
- * files for the test. The directory and its contents are deleted at the end of the test.
- */
-public class DirTestWatcher extends TestWatcher {
- private String dirPath;
- private File dir;
-
- @Override
- protected void starting(Description description) {
- dirPath = String.format("%s/target/%s/%s", new File(".").getAbsolutePath(),
- description.getClassName(), description.getMethodName());
- dir = new File(dirPath);
- dir.mkdirs();
- }
-
- @Override
- protected void finished(Description description) {
- FileUtils.deleteQuietly(dir);
- }
-
- @Override
- protected void failed(Throwable e, Description description) {
- FileUtils.deleteQuietly(dir);
- }
-
- public String getDirPath() {
- return dirPath;
- }
-
- public File getDir() {
- return dir;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/json/BaseJsonTest.java
----------------------------------------------------------------------
diff --git a/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/json/BaseJsonTest.java b/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/json/BaseJsonTest.java
index 2760ffe..27dd7ce 100644
--- a/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/json/BaseJsonTest.java
+++ b/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/json/BaseJsonTest.java
@@ -19,7 +19,7 @@ package com.mapr.drill.maprdb.tests.json;
import java.util.List;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.exec.exception.SchemaChangeException;
import org.apache.drill.exec.rpc.user.QueryDataBatch;
import org.junit.AfterClass;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java b/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java
index 059fb36..63c9e07 100644
--- a/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java
+++ b/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java
@@ -17,7 +17,7 @@
*/
package org.apache.drill.exec.expr.fn.impl.gis;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.junit.Test;
public class TestGeometryFunctions extends BaseTestQuery {
@@ -29,7 +29,7 @@ public class TestGeometryFunctions extends BaseTestQuery {
testBuilder()
.sqlQuery("select ST_AsText(ST_GeomFromText('" + wktPoint + "')) "
- + "from cp.`/sample-data/CA-cities.csv` limit 1")
+ + "from cp.`sample-data/CA-cities.csv` limit 1")
.ordered().baselineColumns("EXPR$0")
.baselineValues(wktPoint)
.build()
@@ -41,7 +41,7 @@ public class TestGeometryFunctions extends BaseTestQuery {
testBuilder()
.sqlQuery("select ST_AsText(ST_Point(-121.895, 37.339)) "
- + "from cp.`/sample-data/CA-cities.csv` limit 1")
+ + "from cp.`sample-data/CA-cities.csv` limit 1")
.ordered().baselineColumns("EXPR$0")
.baselineValues(wktPoint)
.build()
@@ -55,7 +55,7 @@ public class TestGeometryFunctions extends BaseTestQuery {
.sqlQuery("select ST_Within(ST_Point(columns[4], columns[3]),"
+ "ST_GeomFromText('POLYGON((-121.95 37.28, -121.94 37.35, -121.84 37.35, -121.84 37.28, -121.95 37.28))')"
+ ") "
- + "from cp.`/sample-data/CA-cities.csv` where columns[2] = 'San Jose'")
+ + "from cp.`sample-data/CA-cities.csv` where columns[2] = 'San Jose'")
.ordered().baselineColumns("EXPR$0")
.baselineValues(true)
.build()
@@ -66,7 +66,7 @@ public class TestGeometryFunctions extends BaseTestQuery {
.sqlQuery("select ST_Within(" + "ST_Point(columns[4], columns[3]),"
+ "ST_GeomFromText('POLYGON((-121.95 37.28, -121.94 37.35, -121.84 37.35, -121.84 37.28, -121.95 37.28))')"
+ ") "
- + "from cp.`/sample-data/CA-cities.csv` where columns[2] = 'San Francisco'")
+ + "from cp.`sample-data/CA-cities.csv` where columns[2] = 'San Francisco'")
.ordered().baselineColumns("EXPR$0")
.baselineValues(false)
.build()
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/BaseHBaseTest.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/BaseHBaseTest.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/BaseHBaseTest.java
index b957347..9d4b4cd 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/BaseHBaseTest.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/BaseHBaseTest.java
@@ -20,8 +20,8 @@ package org.apache.drill.hbase;
import java.io.IOException;
import java.util.List;
-import org.apache.drill.BaseTestQuery;
-import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.test.BaseTestQuery;
+import org.apache.drill.common.util.DrillFileUtils;
import org.apache.drill.exec.exception.SchemaChangeException;
import org.apache.drill.exec.rpc.user.QueryDataBatch;
import org.apache.drill.exec.store.StoragePluginRegistry;
@@ -71,7 +71,7 @@ public class BaseHBaseTest extends BaseTestQuery {
}
protected String getPlanText(String planFile, String tableName) throws IOException {
- return Files.toString(FileUtils.getResourceAsFile(planFile), Charsets.UTF_8)
+ return Files.toString(DrillFileUtils.getResourceAsFile(planFile), Charsets.UTF_8)
.replaceFirst("\"hbase\\.zookeeper\\.property\\.clientPort\".*:.*\\d+", "\"hbase.zookeeper.property.clientPort\" : " + HBaseTestsSuite.getZookeeperPort())
.replace("[TABLE_NAME]", tableName);
}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java
index 5d94d24..f1bcf3c 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java
@@ -22,7 +22,7 @@ import org.apache.drill.categories.SlowTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.apache.drill.TestBuilder.mapOf;
+import static org.apache.drill.test.TestBuilder.mapOf;
@Category({SlowTest.class, HbaseStorageTest.class})
public class HBaseRecordReaderTest extends BaseHBaseTest {
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java
index 6d1e302..2ef6d68 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java
@@ -25,7 +25,7 @@ import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.HbaseStorageTest;
import org.apache.drill.categories.SlowTest;
import org.apache.drill.exec.proto.UserBitShared.QueryType;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestHiveUDFs.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestHiveUDFs.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestHiveUDFs.java
index 584e339..3872563 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestHiveUDFs.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestHiveUDFs.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.HiveStorageTest;
import org.apache.drill.categories.SlowTest;
import org.apache.drill.exec.record.RecordBatchLoader;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java
index 8242f3f..5654ff0 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java
@@ -20,8 +20,8 @@ package org.apache.drill.exec.fn.hive;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.drill.categories.HiveStorageTest;
-import org.apache.drill.QueryTestUtil;
-import org.apache.drill.TestBuilder;
+import org.apache.drill.test.QueryTestUtil;
+import org.apache.drill.test.TestBuilder;
import org.apache.drill.categories.SlowTest;
import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.common.types.TypeProtos;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/HiveTestBase.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/HiveTestBase.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/HiveTestBase.java
index c33de5d..ddc808e 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/HiveTestBase.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/HiveTestBase.java
@@ -30,8 +30,8 @@ public class HiveTestBase extends PlanTestBase {
protected static HiveTestDataGenerator hiveTest;
@BeforeClass
- public static void generateHive() throws Exception{
- hiveTest = HiveTestDataGenerator.getInstance();
+ public static void generateHive() throws Exception {
+ hiveTest = HiveTestDataGenerator.getInstance(dirTestWatcher.getRootDir());
hiveTest.addHiveTestPlugin(getDrillbitContext().getStorage());
}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
index cf98797..33b8ec0 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
@@ -56,7 +56,6 @@ public class TestHiveStorage extends HiveTestBase {
test(String.format("alter session set `%s` = true", PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY));
}
-
@Test // DRILL-4083
public void testNativeScanWhenNoColumnIsRead() throws Exception {
try {
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestInfoSchemaOnHiveStorage.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestInfoSchemaOnHiveStorage.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestInfoSchemaOnHiveStorage.java
index 228fa24..8e5c77b 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestInfoSchemaOnHiveStorage.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestInfoSchemaOnHiveStorage.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.hive;
import com.google.common.base.Strings;
import org.apache.drill.categories.HiveStorageTest;
-import org.apache.drill.TestBuilder;
+import org.apache.drill.test.TestBuilder;
import org.apache.drill.categories.SlowTest;
import org.apache.hadoop.hive.common.type.HiveVarchar;
import org.junit.Test;
@@ -86,9 +86,6 @@ public class TestInfoSchemaOnHiveStorage extends HiveTestBase {
.baselineValues("dfs.root")
.baselineValues("dfs.tmp")
.baselineValues("sys")
- .baselineValues("dfs_test.home")
- .baselineValues("dfs_test.default")
- .baselineValues("dfs_test.tmp")
.baselineValues("cp.default")
.baselineValues("INFORMATION_SCHEMA")
.go();
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/impersonation/hive/BaseTestHiveImpersonation.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/impersonation/hive/BaseTestHiveImpersonation.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/impersonation/hive/BaseTestHiveImpersonation.java
index 66c595f..3862dc6 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/impersonation/hive/BaseTestHiveImpersonation.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/impersonation/hive/BaseTestHiveImpersonation.java
@@ -18,7 +18,7 @@
package org.apache.drill.exec.impersonation.hive;
import org.apache.calcite.schema.Schema.TableType;
-import org.apache.drill.TestBuilder;
+import org.apache.drill.test.TestBuilder;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.dotdrill.DotDrillType;
import org.apache.drill.exec.impersonation.BaseTestImpersonation;
@@ -31,9 +31,11 @@ import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.hadoop.hive.metastore.MetaStoreUtils;
import org.apache.hadoop.hive.shims.ShimLoader;
+import java.io.File;
import java.util.List;
import java.util.Map;
+import static org.apache.drill.exec.store.hive.HiveTestDataGenerator.createFileWithPermissions;
import static org.apache.hadoop.fs.FileSystem.FS_DEFAULT_NAME_KEY;
import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.METASTOREURIS;
@@ -60,12 +62,16 @@ public class BaseTestHiveImpersonation extends BaseTestImpersonation {
protected static void prepHiveConfAndData() throws Exception {
hiveConf = new HiveConf();
+ File scratchDir = createFileWithPermissions(dirTestWatcher.getRootDir(), "scratch_dir");
+ File localScratchDir = createFileWithPermissions(dirTestWatcher.getRootDir(), "local_scratch_dir");
+ File metaStoreDBDir = new File(dirTestWatcher.getRootDir(), "metastore_db");
+
// Configure metastore persistence db location on local filesystem
- final String dbUrl = String.format("jdbc:derby:;databaseName=%s;create=true", getTempDir("metastore_db"));
+ final String dbUrl = String.format("jdbc:derby:;databaseName=%s;create=true", metaStoreDBDir.getAbsolutePath());
hiveConf.set(ConfVars.METASTORECONNECTURLKEY.varname, dbUrl);
- hiveConf.set(ConfVars.SCRATCHDIR.varname, "file:///" + getTempDir("scratch_dir"));
- hiveConf.set(ConfVars.LOCALSCRATCHDIR.varname, getTempDir("local_scratch_dir"));
+ hiveConf.set(ConfVars.SCRATCHDIR.varname, "file://" + scratchDir.getAbsolutePath());
+ hiveConf.set(ConfVars.LOCALSCRATCHDIR.varname, localScratchDir.getAbsolutePath());
// Set MiniDFS conf in HiveConf
hiveConf.set(FS_DEFAULT_NAME_KEY, dfsConf.get(FS_DEFAULT_NAME_KEY));
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/sql/hive/TestViewSupportOnHiveTables.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/sql/hive/TestViewSupportOnHiveTables.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/sql/hive/TestViewSupportOnHiveTables.java
index 2076c3a..3e70731 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/sql/hive/TestViewSupportOnHiveTables.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/sql/hive/TestViewSupportOnHiveTables.java
@@ -27,22 +27,22 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import static org.apache.drill.exec.util.StoragePluginTestUtils.DFS_TMP_SCHEMA;
+
@Category({SlowTest.class, HiveStorageTest.class})
public class TestViewSupportOnHiveTables extends TestBaseViewSupport {
- private static final String TEMP_SCHEMA = "dfs_test.tmp";
-
protected static HiveTestDataGenerator hiveTest;
@BeforeClass
public static void generateHive() throws Exception{
- hiveTest = HiveTestDataGenerator.getInstance();
+ hiveTest = HiveTestDataGenerator.getInstance(dirTestWatcher.getRootDir());
hiveTest.addHiveTestPlugin(getDrillbitContext().getStorage());
}
@Test
public void viewWithStarInDef_StarInQuery() throws Exception{
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT * FROM hive.kv",
"SELECT * FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 1",
@@ -54,7 +54,7 @@ public class TestViewSupportOnHiveTables extends TestBaseViewSupport {
@Test
public void viewWithStarInDef_SelectFieldsInQuery1() throws Exception{
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT * FROM hive.kv",
"SELECT key, `value` FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 1",
@@ -66,7 +66,7 @@ public class TestViewSupportOnHiveTables extends TestBaseViewSupport {
@Test
public void viewWithStarInDef_SelectFieldsInQuery2() throws Exception{
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT * FROM hive.kv",
"SELECT `value` FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 1",
@@ -78,7 +78,7 @@ public class TestViewSupportOnHiveTables extends TestBaseViewSupport {
@Test
public void viewWithSelectFieldsInDef_StarInQuery() throws Exception{
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT key, `value` FROM hive.kv",
"SELECT * FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 1",
@@ -90,7 +90,7 @@ public class TestViewSupportOnHiveTables extends TestBaseViewSupport {
@Test
public void viewWithSelectFieldsInDef_SelectFieldsInQuery() throws Exception{
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT key, `value` FROM hive.kv",
"SELECT key, `value` FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 1",
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
index 580cf78..4fafadb 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
@@ -19,15 +19,20 @@
package org.apache.drill.exec.store.hive;
import java.io.File;
+import java.io.IOException;
import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.attribute.PosixFilePermission;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Map;
+import java.util.Set;
+import com.google.common.collect.Sets;
import com.google.common.io.Resources;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.common.exceptions.DrillException;
import org.apache.drill.exec.store.StoragePluginRegistry;
import org.apache.hadoop.fs.FileSystem;
@@ -39,21 +44,26 @@ import org.apache.hadoop.hive.ql.session.SessionState;
import com.google.common.collect.Maps;
import org.apache.hadoop.hive.serde.serdeConstants;
-import static org.apache.drill.BaseTestQuery.getTempDir;
import static org.apache.drill.exec.hive.HiveTestUtilities.executeQuery;
public class HiveTestDataGenerator {
private static final String HIVE_TEST_PLUGIN_NAME = "hive";
private static HiveTestDataGenerator instance;
+ private static File baseDir;
private final String dbDir;
private final String whDir;
private final Map<String, String> config;
- public static synchronized HiveTestDataGenerator getInstance() throws Exception {
- if (instance == null) {
- final String dbDir = getTempDir("metastore_db");
- final String whDir = getTempDir("warehouse");
+ public static synchronized HiveTestDataGenerator getInstance(File baseDir) throws Exception {
+ if (instance == null || !HiveTestDataGenerator.baseDir.equals(baseDir)) {
+ HiveTestDataGenerator.baseDir = baseDir;
+
+ File dbDirFile = new File(baseDir, "metastore_db");
+ File whDirFile = new File(baseDir, "warehouse");
+
+ final String dbDir = dbDirFile.getAbsolutePath();
+ final String whDir = whDirFile.getAbsolutePath();
instance = new HiveTestDataGenerator(dbDir, whDir);
instance.generateTestData();
@@ -111,15 +121,33 @@ public class HiveTestDataGenerator {
pluginRegistry.deletePlugin(HIVE_TEST_PLUGIN_NAME);
}
+ public static File createFileWithPermissions(File baseDir, String name) {
+ Set<PosixFilePermission> perms = Sets.newHashSet(PosixFilePermission.values());
+ File dir = new File(baseDir, name);
+ dir.mkdirs();
+
+ try {
+ Files.setPosixFilePermissions(dir.toPath(), perms);
+ } catch (IOException e) {
+ new RuntimeException(e);
+ }
+
+ return dir;
+ }
+
private void generateTestData() throws Exception {
HiveConf conf = new HiveConf(SessionState.class);
+ File scratchDir = createFileWithPermissions(baseDir, "scratch_dir");
+ File localScratchDir = createFileWithPermissions(baseDir, "local_scratch_dir");
+ File part1Dir = createFileWithPermissions(baseDir, "part1");
+
conf.set("javax.jdo.option.ConnectionURL", String.format("jdbc:derby:;databaseName=%s;create=true", dbDir));
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, FileSystem.DEFAULT_FS);
conf.set("hive.metastore.warehouse.dir", whDir);
conf.set("mapred.job.tracker", "local");
- conf.set(ConfVars.SCRATCHDIR.varname, getTempDir("scratch_dir"));
- conf.set(ConfVars.LOCALSCRATCHDIR.varname, getTempDir("local_scratch_dir"));
+ conf.set(ConfVars.SCRATCHDIR.varname, scratchDir.getAbsolutePath());
+ conf.set(ConfVars.LOCALSCRATCHDIR.varname, localScratchDir.getAbsolutePath());
conf.set(ConfVars.DYNAMICPARTITIONINGMODE.varname, "nonstrict");
SessionState ss = new SessionState(conf);
@@ -450,7 +478,7 @@ public class HiveTestDataGenerator {
// Add a partition with custom location
executeQuery(hiveDriver,
String.format("ALTER TABLE partition_pruning_test ADD PARTITION (c=99, d=98, e=97) LOCATION '%s'",
- getTempDir("part1")));
+ part1Dir.getAbsolutePath()));
executeQuery(hiveDriver,
String.format("INSERT INTO TABLE partition_pruning_test PARTITION(c=99, d=98, e=97) " +
"SELECT '%s', '%s' FROM kv LIMIT 1",
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduPlugin.java
----------------------------------------------------------------------
diff --git a/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduPlugin.java b/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduPlugin.java
index c9265d5..b94033a 100644
--- a/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduPlugin.java
+++ b/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduPlugin.java
@@ -17,7 +17,7 @@
*/
package org.apache.drill.store.kudu;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.KuduStorageTest;
import org.junit.Ignore;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoProjectPushDown.java
----------------------------------------------------------------------
diff --git a/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoProjectPushDown.java b/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoProjectPushDown.java
index 848a6a7..4d228c8 100644
--- a/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoProjectPushDown.java
+++ b/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/TestMongoProjectPushDown.java
@@ -17,8 +17,8 @@
*/
package org.apache.drill.exec.store.mongo;
-import static org.apache.drill.TestBuilder.listOf;
-import static org.apache.drill.TestBuilder.mapOf;
+import static org.apache.drill.test.TestBuilder.listOf;
+import static org.apache.drill.test.TestBuilder.mapOf;
import org.apache.drill.categories.MongoStorageTest;
import org.apache.drill.categories.SlowTest;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ClassTransformer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ClassTransformer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ClassTransformer.java
index 3f01a5a..d8da9d8 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ClassTransformer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ClassTransformer.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.exec.compile;
+import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Map;
@@ -24,8 +25,8 @@ import java.util.Set;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.common.util.DrillFileUtils;
import org.apache.drill.common.util.DrillStringUtils;
-import org.apache.drill.common.util.FileUtils;
import org.apache.drill.exec.compile.MergeAdapter.MergedClassResult;
import org.apache.drill.exec.exception.ClassTransformationException;
import org.apache.drill.exec.expr.CodeGenerator;
@@ -171,8 +172,8 @@ public class ClassTransformer {
public ClassNames(String className) {
dot = className;
- slash = className.replace('.', FileUtils.separatorChar);
- clazz = FileUtils.separatorChar + slash + ".class";
+ slash = className.replace('.', DrillFileUtils.SEPARATOR_CHAR);
+ clazz = DrillFileUtils.SEPARATOR_CHAR + slash + ".class";
}
@Override
@@ -310,7 +311,7 @@ public class ClassTransformer {
}
for (String s : result.innerClasses) {
- s = s.replace(FileUtils.separatorChar, '.');
+ s = s.replace(DrillFileUtils.SEPARATOR_CHAR, '.');
names.add(nextSet.getChild(s));
}
classLoader.injectByteCode(nextGenerated.dot, result.bytes);
@@ -319,7 +320,7 @@ public class ClassTransformer {
// adds byte code of the classes that have not been merged to make them accessible for outer class
for (Map.Entry<String, Pair<byte[], ClassNode>> clazz : classesToMerge.entrySet()) {
- classLoader.injectByteCode(clazz.getKey().replace(FileUtils.separatorChar, '.'), clazz.getValue().getKey());
+ classLoader.injectByteCode(clazz.getKey().replace(DrillFileUtils.SEPARATOR_CHAR, '.'), clazz.getValue().getKey());
}
Class<?> c = classLoader.findClass(set.generated.dot);
if (templateDefinition.getExternalInterface().isAssignableFrom(c)) {
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CodeCompiler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CodeCompiler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CodeCompiler.java
index 247fda1..0db00f9 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CodeCompiler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CodeCompiler.java
@@ -22,7 +22,6 @@ import java.util.List;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.exec.exception.ClassTransformationException;
import org.apache.drill.exec.expr.CodeGenerator;
-import org.apache.drill.exec.server.options.OptionManager;
import org.apache.drill.exec.server.options.OptionSet;
import com.google.common.annotations.VisibleForTesting;
@@ -110,6 +109,11 @@ public class CodeCompiler {
public static final String DISABLE_CACHE_CONFIG = COMPILE_BASE + ".disable_cache";
/**
+ * Enables saving generated code for debugging
+ */
+ public static final String ENABLE_SAVE_CODE_FOR_DEBUG_TOPN = COMPILE_BASE + ".codegen.debug.topn";
+
+ /**
* Prefer to generate code as plain Java when the code generator
* supports that mechanism.
*/
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/main/java/org/apache/drill/exec/expr/CodeGenerator.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/CodeGenerator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/CodeGenerator.java
index 899bc4b..66f73b9 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/CodeGenerator.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/CodeGenerator.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import org.apache.drill.exec.compile.ClassBuilder;
import org.apache.drill.exec.compile.TemplateClassDefinition;
import org.apache.drill.exec.compile.sig.MappingSet;
-import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
import org.apache.drill.exec.server.options.OptionSet;
import com.google.common.base.Preconditions;
@@ -90,12 +89,11 @@ public class CodeGenerator<T> {
private String generatedCode;
private String generifiedCode;
- CodeGenerator(TemplateClassDefinition<T> definition, FunctionImplementationRegistry funcRegistry, OptionSet optionManager) {
- this(ClassGenerator.getDefaultMapping(), definition, funcRegistry, optionManager);
+ CodeGenerator(TemplateClassDefinition<T> definition, OptionSet optionManager) {
+ this(ClassGenerator.getDefaultMapping(), definition, optionManager);
}
- CodeGenerator(MappingSet mappingSet, TemplateClassDefinition<T> definition,
- FunctionImplementationRegistry funcRegistry, OptionSet optionManager) {
+ CodeGenerator(MappingSet mappingSet, TemplateClassDefinition<T> definition, OptionSet optionManager) {
Preconditions.checkNotNull(definition.getSignature(),
"The signature for defintion %s was incorrectly initialized.", definition);
this.definition = definition;
@@ -104,8 +102,9 @@ public class CodeGenerator<T> {
try {
this.model = new JCodeModel();
JDefinedClass clazz = model._package(PACKAGE_NAME)._class(className);
- rootGenerator = new ClassGenerator<>(this, mappingSet, definition.getSignature(), new EvaluationVisitor(
- funcRegistry), clazz, model, optionManager);
+ rootGenerator = new ClassGenerator<>(this, mappingSet,
+ definition.getSignature(), new EvaluationVisitor(),
+ clazz, model, optionManager);
} catch (JClassAlreadyExistsException e) {
throw new IllegalStateException(e);
}
@@ -218,29 +217,24 @@ public class CodeGenerator<T> {
public String getClassName() { return className; }
- public static <T> CodeGenerator<T> get(TemplateClassDefinition<T> definition,
- FunctionImplementationRegistry funcRegistry) {
- return get(definition, funcRegistry, null);
+ public static <T> CodeGenerator<T> get(TemplateClassDefinition<T> definition) {
+ return get(definition, null);
}
- public static <T> CodeGenerator<T> get(TemplateClassDefinition<T> definition,
- FunctionImplementationRegistry funcRegistry, OptionSet optionManager) {
- return new CodeGenerator<T>(definition, funcRegistry, optionManager);
+ public static <T> CodeGenerator<T> get(TemplateClassDefinition<T> definition, OptionSet optionManager) {
+ return new CodeGenerator<T>(definition, optionManager);
}
- public static <T> ClassGenerator<T> getRoot(TemplateClassDefinition<T> definition,
- FunctionImplementationRegistry funcRegistry, OptionSet optionManager) {
- return get(definition, funcRegistry, optionManager).getRoot();
+ public static <T> ClassGenerator<T> getRoot(TemplateClassDefinition<T> definition, OptionSet optionManager) {
+ return get(definition, optionManager).getRoot();
}
- public static <T> ClassGenerator<T> getRoot(MappingSet mappingSet, TemplateClassDefinition<T> definition,
- FunctionImplementationRegistry funcRegistry, OptionSet optionManager) {
- return get(mappingSet, definition, funcRegistry, optionManager).getRoot();
+ public static <T> ClassGenerator<T> getRoot(MappingSet mappingSet, TemplateClassDefinition<T> definition, OptionSet optionManager) {
+ return get(mappingSet, definition, optionManager).getRoot();
}
- public static <T> CodeGenerator<T> get(MappingSet mappingSet, TemplateClassDefinition<T> definition,
- FunctionImplementationRegistry funcRegistry, OptionSet optionManager) {
- return new CodeGenerator<T>(mappingSet, definition, funcRegistry, optionManager);
+ public static <T> CodeGenerator<T> get(MappingSet mappingSet, TemplateClassDefinition<T> definition, OptionSet optionManager) {
+ return new CodeGenerator<T>(mappingSet, definition, optionManager);
}
@Override