cloud-fan commented on a change in pull request #31053:
URL: https://github.com/apache/spark/pull/31053#discussion_r557037436



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/SparkSessionBuilderSuite.scala
##########
@@ -196,6 +198,71 @@ class SparkSessionBuilderSuite extends SparkFunSuite with 
BeforeAndAfterEach {
     assert(postFirstCreation == postSecondCreation)
   }
 
+  test("SPARK-32165: SparkContext only register one SQLAppStatusListener") {
+    val conf = new SparkConf()
+      .setMaster("local")
+      .setAppName("test-register-one-SQLAppStatusListener")
+    val context = new SparkContext(conf)
+    SparkSession
+      .builder()
+      .sparkContext(context)
+      .master("local")
+      .getOrCreate()
+      // Touches the sessionState so it initiate SQLAppStatusListener and 
ExecutionListenerBus
+      .sessionState
+
+    assert(countListener("SQLAppStatusListener", context) === 1)
+    assert(countListener("ExecutionListenerBus", context) === 1)
+    val postFirstCreation = context.listenerBus.listeners.size()
+    SparkSession.clearActiveSession()
+    SparkSession.clearDefaultSession()
+
+    SparkSession
+      .builder()
+      .sparkContext(context)
+      .master("local")
+      .getOrCreate()
+      .sessionState
+    assert(countListener("SQLAppStatusListener", context) === 1)
+    assert(countListener("ExecutionListenerBus", context) === 2)
+    val postSecondCreation = context.listenerBus.listeners.size()
+    SparkSession.clearActiveSession()
+    SparkSession.clearDefaultSession()
+    // Minus 1 because the listener `ExecutionListenerBus` is created per 
SparkSession
+    assert(postFirstCreation == postSecondCreation - 1)

Review comment:
       is it duplicated with checking 
`assert(countListener("ExecutionListenerBus", context) === 2)`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to