pingsutw commented on a change in pull request #32845:
URL: https://github.com/apache/spark/pull/32845#discussion_r649857002
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,30 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ val sep = File.separator
+ val tmpDir = Utils.createTempDir(dir.getAbsolutePath + sep + "." + sep
+ ".")
Review comment:
Yeah, update the test
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,30 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ val sep = File.separator
+ val tmpDir = Utils.createTempDir(dir.getAbsolutePath + sep + "." + sep
+ ".")
+ val tmpJar = File.createTempFile("test", ".jar", tmpDir)
+ val tmpFile = File.createTempFile("test", ".txt", tmpDir)
+
+ sc = new SparkContext(new
SparkConf().setAppName("test").setMaster("local"))
Review comment:
Make scene. I added a new test to `RpcEnvSuite.scala`.
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,30 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ val sep = File.separator
+ val tmpDir = Utils.createTempDir(dir.getAbsolutePath + sep + "." + sep
+ ".")
+ val tmpJar = File.createTempFile("test", ".jar", tmpDir)
+ val tmpFile = File.createTempFile("test", ".txt", tmpDir)
+
+ sc = new SparkContext(new
SparkConf().setAppName("test").setMaster("local"))
Review comment:
Make scene, Thanks.
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,30 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ val sep = File.separator
+ val tmpDir = Utils.createTempDir(dir.getAbsolutePath + sep + "." + sep
+ ".")
Review comment:
is this correct?
```scala
// Check those files are not canonical
assert(tmpAbsoluteDir.getAbsolutePath !== tmpAbsoluteDir.getCanonicalPath)
assert(tmpJar.getAbsolutePath !== tmpJar.getCanonicalPath)
assert(tmpFile.getAbsolutePath !== tmpFile.getCanonicalPath)
```
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,30 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ val sep = File.separator
+ val tmpDir = Utils.createTempDir(dir.getAbsolutePath + sep + "." + sep
+ ".")
Review comment:
is this correct?
```scala
// Check those files and directory are not canonical
assert(tmpAbsoluteDir.getAbsolutePath !== tmpAbsoluteDir.getCanonicalPath)
assert(tmpJar.getAbsolutePath !== tmpJar.getCanonicalPath)
assert(tmpFile.getAbsolutePath !== tmpFile.getCanonicalPath)
```
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,35 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ sc = new SparkContext(new
SparkConf().setAppName("test").setMaster("local"))
+
+ val sep = File.separator
+ val tmpCanonicalDir = Utils.createTempDir(dir.getAbsolutePath + sep +
"test space")
+ val tmpAbsoluteDir = new File(tmpCanonicalDir.getAbsolutePath + sep +
'.' + sep)
+ val tmpJar = File.createTempFile("test", ".jar", tmpAbsoluteDir)
+ val tmpFile = File.createTempFile("test", ".txt", tmpAbsoluteDir)
+
+ assert(tmpJar.getAbsolutePath != tmpJar.getCanonicalPath)
+ assert(tmpFile.getAbsolutePath != tmpFile.getCanonicalPath)
+
+ sc.addJar(tmpJar.getAbsolutePath)
+ sc.addFile(tmpFile.getAbsolutePath)
+
+ assert(sc.listJars().size == 1)
+ assert(sc.listFiles().size == 1)
Review comment:
Thanks for the suggestion and review. :+1:
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,30 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ val sep = File.separator
+ val tmpDir = Utils.createTempDir(dir.getAbsolutePath + sep + "." + sep
+ ".")
+ val tmpJar = File.createTempFile("test", ".jar", tmpDir)
+ val tmpFile = File.createTempFile("test", ".txt", tmpDir)
+
+ sc = new SparkContext(new
SparkConf().setAppName("test").setMaster("local"))
Review comment:
Make sense, Thanks.
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,30 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ val sep = File.separator
+ val tmpDir = Utils.createTempDir(dir.getAbsolutePath + sep + "." + sep
+ ".")
+ val tmpJar = File.createTempFile("test", ".jar", tmpDir)
+ val tmpFile = File.createTempFile("test", ".txt", tmpDir)
+
+ sc = new SparkContext(new
SparkConf().setAppName("test").setMaster("local"))
Review comment:
Make sense. I added a new test to `RpcEnvSuite.scala`.
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,30 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ val sep = File.separator
+ val tmpDir = Utils.createTempDir(dir.getAbsolutePath + sep + "." + sep
+ ".")
+ val tmpJar = File.createTempFile("test", ".jar", tmpDir)
+ val tmpFile = File.createTempFile("test", ".txt", tmpDir)
+
+ sc = new SparkContext(new
SparkConf().setAppName("test").setMaster("local"))
Review comment:
@sarutak Thanks for the review. Removed it.
--
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]