Skip to content

Commit

Permalink
fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
gatorsmile committed Jan 19, 2018
1 parent 568055d commit a7359a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.apache.spark.sql

import org.scalatest.BeforeAndAfterAll
import org.scalatest.BeforeAndAfterEach
import scala.collection.mutable.ArrayBuffer

import org.apache.spark.SparkFunSuite
Expand All @@ -28,8 +26,7 @@ import org.apache.spark.sql.catalyst.rules.Rule
import org.apache.spark.sql.execution.QueryExecution
import org.apache.spark.sql.util.QueryExecutionListener

class SessionStateSuite extends SparkFunSuite
with BeforeAndAfterEach with BeforeAndAfterAll {
class SessionStateSuite extends SparkFunSuite {

/**
* A shared SparkSession for all tests in this suite. Make sure you reset any changes to this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,16 @@ private[hive] class TestHiveSparkSession(
}

{ // set the metastore temporary configuration
val metastoreTempConf = HiveUtils.newTemporaryConfiguration(useInMemoryDerby = false) ++ Map(
var metastoreTempConf = HiveUtils.newTemporaryConfiguration(useInMemoryDerby = false) ++ Map(
ConfVars.METASTORE_INTEGER_JDO_PUSHDOWN.varname -> "true",
// scratch directory used by Hive's metastore client
ConfVars.SCRATCHDIR.varname -> TestHiveContext.makeScratchDir().toURI.toString,
ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY.varname -> "1")
// After session cloning, the JDBC connect string for a JDBC metastore should not be changed.
existingSharedState.foreach { state =>
metastoreTempConf += ConfVars.METASTORECONNECTURLKEY.varname ->
state.sparkContext.hadoopConfiguration.get(ConfVars.METASTORECONNECTURLKEY.varname)
}

metastoreTempConf.foreach { case (k, v) =>
sc.hadoopConfiguration.set(k, v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@

package org.apache.spark.sql.hive

import org.scalatest.BeforeAndAfterEach
import org.apache.hadoop.hive.conf.HiveConf.ConfVars

import org.apache.spark.sql._
import org.apache.spark.sql.hive.test.TestHiveSingleton

/**
* Run all tests from `SessionStateSuite` with a Hive based `SessionState`.
*/
class HiveSessionStateSuite extends SessionStateSuite
with TestHiveSingleton with BeforeAndAfterEach {
class HiveSessionStateSuite extends SessionStateSuite with TestHiveSingleton {

override def beforeAll(): Unit = {
// Reuse the singleton session
Expand All @@ -39,4 +38,15 @@ class HiveSessionStateSuite extends SessionStateSuite
activeSession = null
super.afterAll()
}

test("Clone then newSession") {
val sparkSession = hiveContext.sparkSession
val oldValue =
sparkSession.sparkContext.hadoopConfiguration.get(ConfVars.METASTORECONNECTURLKEY.varname)
sparkSession.cloneSession()
sparkSession.metadataHive
val newValue =
sparkSession.sparkContext.hadoopConfiguration.get(ConfVars.METASTORECONNECTURLKEY.varname)
assert(oldValue == newValue, "cloneSession should not affect the Derby directory")
}
}

0 comments on commit a7359a9

Please sign in to comment.