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


##########
resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/ClientDistributedCacheManagerSuite.scala:
##########
@@ -45,6 +45,63 @@ class ClientDistributedCacheManagerSuite extends 
SparkFunSuite with MockitoSugar
     }
   }
 
+  /*
+  * This this a customized ClientDistributedCacheManager to test statCache.
+  * */
+  class CustomizedClientDistributedCacheManager extends 
ClientDistributedCacheManager {
+    override def addResource(fs: FileSystem, conf: Configuration, destPath: 
Path,
+      localResources: HashMap[String, LocalResource], resourceType: 
LocalResourceType,
+      link: String, statCache: Map[URI, FileStatus], appMasterOnly: Boolean): 
Unit = {
+      statCache.getOrElseUpdate(destPath.toUri(), fs.getFileStatus(destPath))
+    }
+
+    /*
+    * This simulates the isPublic method. It will return true if the result is 
cached in the
+    *  statCache.
+    * */
+    def isPublicResultCached(uri: URI, statCache: Map[URI, FileStatus]): 
Boolean = {
+      statCache.get(uri) match {
+        case Some(_) => true
+        case None => false
+      }
+    }
+  }
+
+  test("SPARK-44272: test addResource added FileStatus to statCache and 
getVisibility can read" +
+    " from statCache") {
+    val distMgr = new CustomizedClientDistributedCacheManager()
+    val fs = mock[FileSystem]
+    val conf = new Configuration()
+    val destPath = new Path("file:///foo.invalid.com:8080/tmp/testing")
+    val localResources = HashMap[String, LocalResource]()
+    val statCache: Map[URI, FileStatus] = HashMap[URI, FileStatus]()
+    assert(distMgr.isPublicResultCached(destPath.toUri(), statCache) === false)
+    distMgr.addResource(fs, conf, destPath, localResources, 
LocalResourceType.FILE, "link",
+      statCache, false)
+    assert(distMgr.isPublicResultCached(destPath.toUri(), statCache) === true)

Review Comment:
   This test is not checking functionality we have introduced - it is testing 
`CustomizedClientDistributedCacheManager`, not `ClientDistributedCacheManager `.
   (For example, we can remove the `extends ClientDistributedCacheManager` from 
`CustomizedClientDistributedCacheManager` definition and the test would still 
pass).
   
   Can you reformulate such that we are testing `ClientDistributedCacheManager 
` ?
   



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