mridulm commented on code in PR #37922:
URL: https://github.com/apache/spark/pull/37922#discussion_r1068018231


##########
core/src/test/scala/org/apache/spark/MapOutputTrackerSuite.scala:
##########
@@ -913,6 +918,59 @@ class MapOutputTrackerSuite extends SparkFunSuite with 
LocalSparkContext {
     slaveRpcEnv.shutdown()
   }
 
+  test("SPARK-40480: shuffle remove should cleanup merged files as well") {
+    val newConf = new SparkConf
+    newConf.set("spark.shuffle.push.enabled", "true")
+    newConf.set("spark.shuffle.service.enabled", "true")
+    newConf.set(SERIALIZER, "org.apache.spark.serializer.KryoSerializer")
+    newConf.set(IS_TESTING, true)
+
+    val SHUFFLE_ID = 10
+    // needs TorrentBroadcast so need a SparkContext
+    withSpark(new SparkContext("local", "MapOutputTrackerSuite", newConf)) { 
sc =>
+      val rpcEnv = sc.env.rpcEnv
+      val masterTracker = 
sc.env.mapOutputTracker.asInstanceOf[MapOutputTrackerMaster]
+
+      val blockStoreClient = mock(classOf[ExternalBlockStoreClient])
+      val blockManagerMasterEndpoint = new BlockManagerMasterEndpoint(
+        rpcEnv,
+        sc.isLocal,
+        sc.conf,
+        sc.listenerBus,
+        Some(blockStoreClient),
+        // We dont care about this ...
+        new concurrent.TrieMap[BlockManagerId, BlockManagerInfo](),
+        masterTracker,
+        sc.env.shuffleManager,
+        true
+      )
+      rpcEnv.stop(sc.env.blockManager.master.driverEndpoint)
+      sc.env.blockManager.master.driverEndpoint =
+        rpcEnv.setupEndpoint(BlockManagerMaster.DRIVER_ENDPOINT_NAME,
+          blockManagerMasterEndpoint)
+
+      masterTracker.registerShuffle(SHUFFLE_ID, 10, 10)
+      val mergerLocs = (1 to 10).map(x => BlockManagerId(s"exec-$x", 
s"host-$x", x))
+      masterTracker.registerShufflePushMergerLocations(SHUFFLE_ID, mergerLocs)
+
+      
assert(masterTracker.getShufflePushMergerLocations(SHUFFLE_ID).map(_.host).toSet
 ==
+        mergerLocs.map(_.host).toSet)
+
+      val foundHosts = JCollections.synchronizedSet(new JHashSet[String]())
+      when(blockStoreClient.removeShuffleMerge(any(), any(), any(), 
any())).thenAnswer(
+        (m: InvocationOnMock) => {
+          val host = m.getArgument(0).asInstanceOf[String]
+          val shuffleId = m.getArgument(2).asInstanceOf[Int]
+          assert(shuffleId == SHUFFLE_ID)
+          foundHosts.add(host)
+          true
+        })
+
+      sc.cleaner.get.doCleanupShuffle(SHUFFLE_ID, blocking = true)
+      assert(foundHosts.asScala == mergerLocs.map(_.host).toSet)
+    }
+  }

Review Comment:
   There is a bug in this test - sorry about that.
   Please take a look here: 
https://github.com/apache/spark/commit/26b2d1897ec2449ad202e61fc815708829837d98



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