Skip to content

Commit

Permalink
Clear afterEach instead of checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
dongjoon-hyun committed Jul 8, 2017
1 parent 9825810 commit 802163d
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,20 @@ class SparkSessionBuilderSuite extends SparkFunSuite with BeforeAndAfterEach {

override def afterEach(): Unit = {
// This suite should not interfere with the other test suites.
assert(SparkSession.getDefaultSession === None)
assert(SparkSession.getActiveSession === None)
SparkSession.clearDefaultSession()
SparkSession.clearActiveSession()
}

test("create with config options and propagate them to SparkContext and SparkSession") {
// Creating a new session with config - this works by just calling the lazy val
sparkContext
assert(initialSession.sparkContext.conf.get("some-config") == "v2")
assert(initialSession.conf.get("some-config") == "v2")
SparkSession.clearDefaultSession()
}

test("use global default session") {
val session = SparkSession.builder().getOrCreate()
assert(SparkSession.builder().getOrCreate() == session)
SparkSession.clearDefaultSession()
}

test("config options are propagated to existing SparkSession") {
Expand All @@ -64,7 +62,6 @@ class SparkSessionBuilderSuite extends SparkFunSuite with BeforeAndAfterEach {
val session2 = SparkSession.builder().config("spark-config1", "b").getOrCreate()
assert(session1 == session2)
assert(session1.conf.get("spark-config1") == "b")
SparkSession.clearDefaultSession()
}

test("use session from active thread session and propagate config options") {
Expand All @@ -81,7 +78,6 @@ class SparkSessionBuilderSuite extends SparkFunSuite with BeforeAndAfterEach {
SparkSession.clearActiveSession()

assert(SparkSession.builder().getOrCreate() == defaultSession)
SparkSession.clearDefaultSession()
}

test("create a new session if the default session has been stopped") {
Expand All @@ -100,7 +96,6 @@ class SparkSessionBuilderSuite extends SparkFunSuite with BeforeAndAfterEach {
val newSession = SparkSession.builder().master("local").getOrCreate()
assert(newSession != activeSession)
newSession.stop()
SparkSession.clearActiveSession()
}

test("create SparkContext first then SparkSession") {
Expand Down

0 comments on commit 802163d

Please sign in to comment.