jerrypeng commented on code in PR #56008:
URL: https://github.com/apache/spark/pull/56008#discussion_r3308007701


##########
core/src/test/scala/org/apache/spark/StreamingShuffleOutputTrackerSuite.scala:
##########
@@ -0,0 +1,323 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark
+
+import org.scalatest.BeforeAndAfter
+import org.scalatest.matchers.should.Matchers
+
+import 
org.apache.spark.internal.config.SHUFFLE_MAPOUTPUT_DISPATCHER_NUM_THREADS
+import org.apache.spark.rpc.RpcEnv
+
+class StreamingShuffleOutputTrackerSuite
+  extends SparkFunSuite
+  with LocalSparkContext
+  with ThreadAudit
+  with BeforeAndAfter
+  with Matchers {
+
+  before {
+    doThreadPreAudit()
+  }
+
+  after {
+    doThreadPostAudit()
+  }
+
+  protected val conf = new SparkConf
+
+  protected def newTrackerMaster(sparkConf: SparkConf = conf) = {
+    new StreamingShuffleOutputTrackerMaster(sparkConf)
+  }
+
+  protected def newTrackerWorker(
+      sparkConf: SparkConf = conf): StreamingShuffleOutputTrackerWorker = {
+    new StreamingShuffleOutputTrackerWorker(sparkConf)
+  }
+
+  def createRpcEnv(
+      name: String,
+      host: String = "localhost",
+      port: Int = 0,
+      securityManager: SecurityManager = new SecurityManager(conf)): RpcEnv = {
+    RpcEnv.create(name, host, port, conf, securityManager)
+  }
+
+  test("master start and stop") {
+    val rpcEnv = createRpcEnv("test")
+    val tracker = newTrackerMaster()
+    tracker.trackerEndpoint = rpcEnv.setupEndpoint(
+      StreamingShuffleOutputTracker.ENDPOINT_NAME,
+      new StreamingShuffleOutputTrackerMasterEndpoint(rpcEnv, tracker, conf))
+    tracker.stop()
+    rpcEnv.shutdown()
+  }
+
+  test("test tracker workflow") {
+    val master = newTrackerMaster()
+    val worker = newTrackerWorker()
+
+    val rpcEnv = createRpcEnv("test")

Review Comment:
   Addressed together with the thread-pool comment above: createRpcEnv now 
registers each created env in a private rpcEnvsToShutdown ArrayBuffer, and the 
suite's after block calls shutdown() on every registered env after stopping the 
trackers. The first test ("master start and stop") had explicit tracker.stop() 
/ rpcEnv.shutdown() calls — I removed those since cleanup is now centralized, 
but the behavior is the same.



-- 
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.

To unsubscribe, e-mail: [email protected]

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