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-21345][SQL][TEST][test-maven] SparkSessionBuilderSuite should clean up stopped sessions. #18567

Closed
wants to merge 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class SparkSessionBuilderSuite extends SparkFunSuite {
val session2 = SparkSession.builder().config("spark-config1", "b").getOrCreate()
assert(session1 == session2)
assert(session1.conf.get("spark-config1") == "b")
SparkSession.clearActiveSession()
SparkSession.clearDefaultSession()
}

Expand All @@ -73,6 +74,7 @@ class SparkSessionBuilderSuite extends SparkFunSuite {
SparkSession.clearActiveSession()

assert(SparkSession.builder().getOrCreate() == defaultSession)
SparkSession.clearActiveSession()
Copy link
Member

Choose a reason for hiding this comment

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

Line 76 sets the active session?

Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Jul 7, 2017

Choose a reason for hiding this comment

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

I thought line 76 may reach here. Do you want me to remove this?

Copy link
Member

Choose a reason for hiding this comment

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

That line will not set active session, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, right. I'll remove this.

SparkSession.clearDefaultSession()
}

Expand All @@ -83,6 +85,8 @@ class SparkSessionBuilderSuite extends SparkFunSuite {
val newSession = SparkSession.builder().master("local").getOrCreate()
assert(newSession != defaultSession)
newSession.stop()
SparkSession.clearActiveSession()
SparkSession.clearDefaultSession()
}

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

test("create SparkContext first then SparkSession") {
Expand All @@ -106,6 +112,8 @@ class SparkSessionBuilderSuite extends SparkFunSuite {
assert(!sparkContext2.conf.contains("key2"))
assert(sparkContext2.conf.get("key1") == "value1")
session.stop()
SparkSession.clearActiveSession()
SparkSession.clearDefaultSession()
}

test("create SparkContext first then pass context to SparkSession") {
Expand All @@ -122,13 +130,17 @@ class SparkSessionBuilderSuite extends SparkFunSuite {
assert(!session.sparkContext.conf.contains("key2"))
assert(session.sparkContext.conf.get("spark.app.name") == "test")
session.stop()
SparkSession.clearActiveSession()
SparkSession.clearDefaultSession()
}

test("SPARK-15887: hive-site.xml should be loaded") {
val session = SparkSession.builder().master("local").getOrCreate()
assert(session.sessionState.newHadoopConf().get("hive.in.test") == "true")
assert(session.sparkContext.hadoopConfiguration.get("hive.in.test") == "true")
session.stop()
SparkSession.clearActiveSession()
SparkSession.clearDefaultSession()
}

test("SPARK-15991: Set global Hadoop conf") {
Expand Down