Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-23000] [TEST] Keep Derby DB Location Unchanged After Session Cloning #20328

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix.
  • Loading branch information
gatorsmile committed Jan 19, 2018
commit a7359a9634966851c14be02cbd6468e5c41a4347
Original file line number Diff line number Diff line change
@@ -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
@@ -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
Original file line number Diff line number Diff line change
@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

... ++ existingSharedState.map { state =>
  val connKey = state.sparkContext.hadoopConfiguration.get(ConfVars.METASTORECONNECTURLKEY.varname)
  ConfVars.METASTORECONNECTURLKEY.varname -> connKey
}.getOrElse(Map.empty)

// 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)
Original file line number Diff line number Diff line change
@@ -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
@@ -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")
}
}