Skip to content

Commit 9430134

Browse files
committed
[AURON #1757] BaseAuronSQLSuite: reset suite workspace and set warehouse dir
1 parent 8ab5b5a commit 9430134

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

spark-extension-shims-spark/src/test/scala/org.apache.auron/BaseAuronSQLSuite.scala

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,37 @@
1616
*/
1717
package org.apache.auron
1818

19+
import org.apache.commons.io.FileUtils
1920
import org.apache.spark.SparkConf
2021
import org.apache.spark.sql.test.SharedSparkSession
2122

23+
import java.io.File
24+
2225
trait BaseAuronSQLSuite extends SharedSparkSession {
26+
protected val suiteWorkspace: String = getClass.getResource("/").getPath + "auron-tests-workdir"
27+
protected val warehouseDir: String = suiteWorkspace + "/spark-warehouse"
28+
protected val metastoreDir: String = suiteWorkspace + "/meta"
29+
30+
protected def resetSuiteWorkspace(): Unit = {
31+
val workdir = new File(suiteWorkspace)
32+
if (workdir.exists()) {
33+
FileUtils.forceDelete(workdir)
34+
}
35+
FileUtils.forceMkdir(workdir)
36+
FileUtils.forceMkdir(new File(warehouseDir))
37+
FileUtils.forceMkdir(new File(metastoreDir))
38+
}
39+
40+
override def beforeAll(): Unit = {
41+
// Prepare a clean workspace before SparkSession initialization
42+
resetSuiteWorkspace()
43+
super.beforeAll()
44+
spark.sparkContext.setLogLevel("WARN")
45+
}
46+
47+
override def afterAll(): Unit = {
48+
super.afterAll()
49+
}
2350

2451
override protected def sparkConf: SparkConf = {
2552
super.sparkConf
@@ -29,6 +56,6 @@ trait BaseAuronSQLSuite extends SharedSparkSession {
2956
"org.apache.spark.sql.execution.auron.shuffle.AuronShuffleManager")
3057
.set("spark.memory.offHeap.enabled", "false")
3158
.set("spark.auron.enable", "true")
59+
.set("spark.sql.warehouse.dir", warehouseDir)
3260
}
33-
3461
}

spark-extension-shims-spark/src/test/scala/org/apache/spark/sql/execution/BuildInfoInSparkUISuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ class BuildInfoInSparkUISuite extends AuronQueryTest with BaseAuronSQLSuite {
2929

3030
var testDir: File = _
3131

32-
override protected def sparkConf: SparkConf = {
32+
override def sparkConf: SparkConf = {
3333
super.sparkConf.set("spark.eventLog.dir", testDir.toString)
3434
}
3535

36-
override protected def beforeAll(): Unit = {
36+
override def beforeAll(): Unit = {
3737
testDir = Utils.createTempDir(namePrefix = "spark-events")
3838
super.beforeAll()
3939
}
4040

41-
override protected def afterAll(): Unit = {
41+
override def afterAll(): Unit = {
4242
Utils.deleteRecursively(testDir)
4343
}
4444

0 commit comments

Comments
 (0)