aboutsummaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
authorWeiqing Yang <yangweiqing001@gmail.com>2016-10-08 12:12:35 +0100
committerSean Owen <sowen@cloudera.com>2016-10-08 12:12:35 +0100
commit8a6bbe095b6a9aa33989c0deaa5ed0128d70320f (patch)
tree8e3f1bf702fe83ecf344854016692ef1e15aeb4f /core/src/test
parent4201ddcc07ca2e9af78bf4a74fdb3900c1783347 (diff)
downloadspark-8a6bbe095b6a9aa33989c0deaa5ed0128d70320f.tar.gz
spark-8a6bbe095b6a9aa33989c0deaa5ed0128d70320f.tar.bz2
spark-8a6bbe095b6a9aa33989c0deaa5ed0128d70320f.zip
[MINOR][SQL] Use resource path for test_script.sh
## What changes were proposed in this pull request? This PR modified the test case `test("script")` to use resource path for `test_script.sh`. Make the test case portable (even in IntelliJ). ## How was this patch tested? Passed the test case. Before: Run `test("script")` in IntelliJ: ``` Caused by: org.apache.spark.SparkException: Subprocess exited with status 127. Error: bash: src/test/resources/test_script.sh: No such file or directory ``` After: Test passed. Author: Weiqing Yang <yangweiqing001@gmail.com> Closes #15246 from weiqingy/hivetest.
Diffstat (limited to 'core/src/test')
-rw-r--r--core/src/test/scala/org/apache/spark/SparkFunSuite.scala11
-rw-r--r--core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala6
-rw-r--r--core/src/test/scala/org/apache/spark/ui/UISuite.scala3
3 files changed, 16 insertions, 4 deletions
diff --git a/core/src/test/scala/org/apache/spark/SparkFunSuite.scala b/core/src/test/scala/org/apache/spark/SparkFunSuite.scala
index cd876807f8..18077c08c9 100644
--- a/core/src/test/scala/org/apache/spark/SparkFunSuite.scala
+++ b/core/src/test/scala/org/apache/spark/SparkFunSuite.scala
@@ -18,6 +18,8 @@
package org.apache.spark
// scalastyle:off
+import java.io.File
+
import org.scalatest.{BeforeAndAfterAll, FunSuite, Outcome}
import org.apache.spark.internal.Logging
@@ -41,6 +43,15 @@ abstract class SparkFunSuite
}
}
+ // helper function
+ protected final def getTestResourceFile(file: String): File = {
+ new File(getClass.getClassLoader.getResource(file).getFile)
+ }
+
+ protected final def getTestResourcePath(file: String): String = {
+ getTestResourceFile(file).getCanonicalPath
+ }
+
/**
* Log the suite name and the test name before and after each test.
*
diff --git a/core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala b/core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala
index 5b316b2f6b..a595bc174a 100644
--- a/core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala
+++ b/core/src/test/scala/org/apache/spark/deploy/history/HistoryServerSuite.scala
@@ -59,8 +59,8 @@ class HistoryServerSuite extends SparkFunSuite with BeforeAndAfter with Matchers
with JsonTestUtils with Eventually with WebBrowser with LocalSparkContext
with ResetSystemProperties {
- private val logDir = new File("src/test/resources/spark-events")
- private val expRoot = new File("src/test/resources/HistoryServerExpectations/")
+ private val logDir = getTestResourcePath("spark-events")
+ private val expRoot = getTestResourceFile("HistoryServerExpectations")
private var provider: FsHistoryProvider = null
private var server: HistoryServer = null
@@ -68,7 +68,7 @@ class HistoryServerSuite extends SparkFunSuite with BeforeAndAfter with Matchers
def init(): Unit = {
val conf = new SparkConf()
- .set("spark.history.fs.logDirectory", logDir.getAbsolutePath)
+ .set("spark.history.fs.logDirectory", logDir)
.set("spark.history.fs.update.interval", "0")
.set("spark.testing", "true")
provider = new FsHistoryProvider(conf)
diff --git a/core/src/test/scala/org/apache/spark/ui/UISuite.scala b/core/src/test/scala/org/apache/spark/ui/UISuite.scala
index dbb8dca4c8..4abcfb7e51 100644
--- a/core/src/test/scala/org/apache/spark/ui/UISuite.scala
+++ b/core/src/test/scala/org/apache/spark/ui/UISuite.scala
@@ -53,9 +53,10 @@ class UISuite extends SparkFunSuite {
}
private def sslEnabledConf(): (SparkConf, SSLOptions) = {
+ val keyStoreFilePath = getTestResourcePath("spark.keystore")
val conf = new SparkConf()
.set("spark.ssl.ui.enabled", "true")
- .set("spark.ssl.ui.keyStore", "./src/test/resources/spark.keystore")
+ .set("spark.ssl.ui.keyStore", keyStoreFilePath)
.set("spark.ssl.ui.keyStorePassword", "123456")
.set("spark.ssl.ui.keyPassword", "123456")
(conf, new SecurityManager(conf).getSSLOptions("ui"))