-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19707][SPARK-18922][TESTS][SQL][CORE] Fix test failures/the invalid path check for sc.addJar on Windows #17987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -301,13 +301,13 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu | |
| sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local")) | ||
| sc.addJar(tmpJar.getAbsolutePath) | ||
|
|
||
| // Invaid jar path will only print the error log, will not add to file server. | ||
| // Invalid jar path will only print the error log, will not add to file server. | ||
| sc.addJar("dummy.jar") | ||
| sc.addJar("") | ||
| sc.addJar(tmpDir.getAbsolutePath) | ||
|
|
||
| sc.listJars().size should be (1) | ||
| sc.listJars().head should include (tmpJar.getName) | ||
| assert(sc.listJars().size == 1) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This gives a better error message. Before After |
||
| assert(sc.listJars().head.contains(tmpJar.getName)) | ||
| } | ||
|
|
||
| test("Cancelling job group should not cause SparkContext to shutdown (SPARK-6414)") { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,27 +37,50 @@ class LocalDirsSuite extends SparkFunSuite with BeforeAndAfter { | |
| Utils.clearLocalRootDirs() | ||
| } | ||
|
|
||
| private def assumeNonExistentAndNotCreatable(f: File): Unit = { | ||
| try { | ||
| assume(!f.exists() && !f.mkdirs()) | ||
| } finally { | ||
| Utils.deleteRecursively(f) | ||
| } | ||
| } | ||
|
|
||
| test("Utils.getLocalDir() returns a valid directory, even if some local dirs are missing") { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem here is, scala> val a = new java.io.File("/NENEXISTENT_PATH")
a: java.io.File = \NENEXISTENT_PATH
scala> a.exists()
res3: Boolean = false
scala> a.mkdirs()
res4: Boolean = true
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not too sure which path I should provide here for Windows. So, I added |
||
| // Regression test for SPARK-2974 | ||
| assert(!new File("/NONEXISTENT_PATH").exists()) | ||
| val f = new File("/NONEXISTENT_PATH") | ||
| assumeNonExistentAndNotCreatable(f) | ||
|
|
||
| val conf = new SparkConf(false) | ||
| .set("spark.local.dir", s"/NONEXISTENT_PATH,${System.getProperty("java.io.tmpdir")}") | ||
| assert(new File(Utils.getLocalDir(conf)).exists()) | ||
|
|
||
| // This directory should not be created. | ||
| assert(!f.exists()) | ||
| } | ||
|
|
||
| test("SPARK_LOCAL_DIRS override also affects driver") { | ||
| // Regression test for SPARK-2975 | ||
| assert(!new File("/NONEXISTENT_PATH").exists()) | ||
| // Regression test for SPARK-2974 | ||
| val f = new File("/NONEXISTENT_PATH") | ||
| assumeNonExistentAndNotCreatable(f) | ||
|
|
||
| // spark.local.dir only contains invalid directories, but that's not a problem since | ||
| // SPARK_LOCAL_DIRS will override it on both the driver and workers: | ||
| val conf = new SparkConfWithEnv(Map("SPARK_LOCAL_DIRS" -> System.getProperty("java.io.tmpdir"))) | ||
| .set("spark.local.dir", "/NONEXISTENT_PATH") | ||
| assert(new File(Utils.getLocalDir(conf)).exists()) | ||
|
|
||
| // This directory should not be created. | ||
| assert(!f.exists()) | ||
| } | ||
|
|
||
| test("Utils.getLocalDir() throws an exception if any temporary directory cannot be retrieved") { | ||
| val path1 = "/NONEXISTENT_PATH_ONE" | ||
| val path2 = "/NONEXISTENT_PATH_TWO" | ||
| val f1 = new File(path1) | ||
| val f2 = new File(path2) | ||
| assumeNonExistentAndNotCreatable(f1) | ||
| assumeNonExistentAndNotCreatable(f2) | ||
|
|
||
| assert(!new File(path1).exists()) | ||
| assert(!new File(path2).exists()) | ||
| val conf = new SparkConf(false).set("spark.local.dir", s"$path1,$path2") | ||
|
|
@@ -67,5 +90,9 @@ class LocalDirsSuite extends SparkFunSuite with BeforeAndAfter { | |
| // If any temporary directory could not be retrieved under the given paths above, it should | ||
| // throw an exception with the message that includes the paths. | ||
| assert(message.contains(s"$path1,$path2")) | ||
|
|
||
| // These directories should not be created. | ||
| assert(!f1.exists()) | ||
| assert(!f2.exists()) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I tried to move this try-catch logic into
addJarFileand used this for local paths with backslashes on Windows. This is covered inadd jar with invalid pathinSparkContextSuite.