Skip to content
Snippets Groups Projects
Commit d3cdf912 authored by Cheng Hao's avatar Cheng Hao Committed by Michael Armbrust
Browse files

[SPARK-3529] [SQL] Delete the temp files after test exit

There are lots of temporal files created by TestHive under the /tmp by default, which may cause potential performance issue for testing. This PR will automatically delete them after test exit.

Author: Cheng Hao <hao.cheng@intel.com>

Closes #2393 from chenghao-intel/delete_temp_on_exit and squashes the following commits:

3a6511f [Cheng Hao] Remove the temp dir after text exit
parent 56102dc2
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ import org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe
import org.apache.hadoop.hive.serde2.avro.AvroSerDe
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.util.Utils
import org.apache.spark.sql.catalyst.analysis._
import org.apache.spark.sql.catalyst.plans.logical.{CacheTableCommand, LogicalPlan, NativeCommand}
import org.apache.spark.sql.catalyst.util._
......@@ -71,11 +72,14 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
setConf("javax.jdo.option.ConnectionURL",
s"jdbc:derby:;databaseName=$metastorePath;create=true")
setConf("hive.metastore.warehouse.dir", warehousePath)
Utils.registerShutdownDeleteDir(new File(warehousePath))
Utils.registerShutdownDeleteDir(new File(metastorePath))
}
val testTempDir = File.createTempFile("testTempFiles", "spark.hive.tmp")
testTempDir.delete()
testTempDir.mkdir()
Utils.registerShutdownDeleteDir(testTempDir)
// For some hive test case which contain ${system:test.tmp.dir}
System.setProperty("test.tmp.dir", testTempDir.getCanonicalPath)
......@@ -121,8 +125,7 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
val hiveFilesTemp = File.createTempFile("catalystHiveFiles", "")
hiveFilesTemp.delete()
hiveFilesTemp.mkdir()
hiveFilesTemp.deleteOnExit()
Utils.registerShutdownDeleteDir(hiveFilesTemp)
val inRepoTests = if (System.getProperty("user.dir").endsWith("sql" + File.separator + "hive")) {
new File("src" + File.separator + "test" + File.separator + "resources" + File.separator)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment