-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-21345][SQL][TEST][test-maven] SparkSessionBuilderSuite should clean up stopped sessions. #18567
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-21345][SQL][TEST][test-maven] SparkSessionBuilderSuite should clean up stopped sessions. #18567
Changes from 4 commits
443b33e
1d5a0d0
9825810
802163d
4f4b452
04f47ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,13 +17,15 @@ | |
|
|
||
| package org.apache.spark.sql | ||
|
|
||
| import org.scalatest.BeforeAndAfterEach | ||
|
|
||
| import org.apache.spark.{SparkConf, SparkContext, SparkFunSuite} | ||
| import org.apache.spark.sql.internal.SQLConf | ||
|
|
||
| /** | ||
| * Test cases for the builder pattern of [[SparkSession]]. | ||
| */ | ||
| class SparkSessionBuilderSuite extends SparkFunSuite { | ||
| class SparkSessionBuilderSuite extends SparkFunSuite with BeforeAndAfterEach { | ||
|
|
||
| private var initialSession: SparkSession = _ | ||
|
|
||
|
|
@@ -36,18 +38,22 @@ class SparkSessionBuilderSuite extends SparkFunSuite { | |
| initialSession.sparkContext | ||
| } | ||
|
|
||
| override def afterEach(): Unit = { | ||
| // This suite should not interfere with the other test suites. | ||
| SparkSession.clearDefaultSession() | ||
| SparkSession.clearActiveSession() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we also stop the session?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to update the unit test case because SparkContext requires |
||
| } | ||
|
|
||
| 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") { | ||
|
|
@@ -56,7 +62,6 @@ class SparkSessionBuilderSuite extends SparkFunSuite { | |
| 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") { | ||
|
|
@@ -73,7 +78,6 @@ class SparkSessionBuilderSuite extends SparkFunSuite { | |
| SparkSession.clearActiveSession() | ||
|
|
||
| assert(SparkSession.builder().getOrCreate() == defaultSession) | ||
| SparkSession.clearDefaultSession() | ||
| } | ||
|
|
||
| test("create a new session if the default session has been stopped") { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this is only used in the first test case? shall we just move it to the first test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also used in
sparkContextandsparkContextis used in 3 test cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes. The other two reference are just
stop. I will move this.