Skip to content

Commit 252fa0f

Browse files
committed
Uses temporary directory as Thrift server PID directory
1 parent 1b3d1e3 commit 252fa0f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.scalatest.{BeforeAndAfterAll, FunSuite}
3939
import org.apache.spark.Logging
4040
import org.apache.spark.sql.catalyst.util
4141
import org.apache.spark.sql.hive.HiveShim
42+
import org.apache.spark.util.Utils
4243

4344
object TestData {
4445
def getTestDataFilePath(name: String) = {
@@ -273,6 +274,7 @@ abstract class HiveThriftServer2Test extends FunSuite with BeforeAndAfterAll wit
273274
private var metastorePath: File = _
274275
private def metastoreJdbcUri = s"jdbc:derby:;databaseName=$metastorePath;create=true"
275276

277+
private val pidDir: File = Utils.createTempDir("thriftserver-pid")
276278
private var logPath: File = _
277279
private var logTailingProcess: Process = _
278280
private var diagnosisBuffer: ArrayBuffer[String] = ArrayBuffer.empty[String]
@@ -320,7 +322,7 @@ abstract class HiveThriftServer2Test extends FunSuite with BeforeAndAfterAll wit
320322
"SPARK_TESTING" -> "0",
321323
// Points SPARK_PID_DIR to SPARK_HOME, otherwise only 1 Thrift server instance can be started
322324
// at a time, which is not Jenkins friendly.
323-
"SPARK_PID_DIR" -> "../../")
325+
"SPARK_PID_DIR" -> pidDir.getCanonicalPath)
324326

325327
logPath = Process(command, None, env: _*).lines.collectFirst {
326328
case line if line.contains(LOG_FILE_MARK) => new File(line.drop(LOG_FILE_MARK.length))
@@ -353,7 +355,7 @@ abstract class HiveThriftServer2Test extends FunSuite with BeforeAndAfterAll wit
353355

354356
private def stopThriftServer(): Unit = {
355357
// The `spark-daemon.sh' script uses kill, which is not synchronous, have to wait for a while.
356-
Process(stopScript, None, "SPARK_PID_DIR" -> "../../").run().exitValue()
358+
Process(stopScript, None, "SPARK_PID_DIR" -> pidDir.getCanonicalPath).run().exitValue()
357359
Thread.sleep(3.seconds.toMillis)
358360

359361
warehousePath.delete()

0 commit comments

Comments
 (0)