-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-18895][TESTS] Fix resource-closing-related and path-related test failures in identified ones on Windows #16305
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 |
|---|---|---|
|
|
@@ -176,26 +176,31 @@ private[deploy] object RPackageUtils extends Logging { | |
| val file = new File(Utils.resolveURI(jarPath)) | ||
| if (file.exists()) { | ||
| val jar = new JarFile(file) | ||
| if (checkManifestForR(jar)) { | ||
| print(s"$file contains R source code. Now installing package.", printStream, Level.INFO) | ||
| val rSource = extractRFolder(jar, printStream, verbose) | ||
| if (RUtils.rPackages.isEmpty) { | ||
| RUtils.rPackages = Some(Utils.createTempDir().getAbsolutePath) | ||
| } | ||
| try { | ||
| if (!rPackageBuilder(rSource, printStream, verbose, RUtils.rPackages.get)) { | ||
| print(s"ERROR: Failed to build R package in $file.", printStream) | ||
| print(RJarDoc, printStream) | ||
| Utils.tryWithSafeFinally { | ||
| if (checkManifestForR(jar)) { | ||
| print(s"$file contains R source code. Now installing package.", printStream, Level.INFO) | ||
| val rSource = extractRFolder(jar, printStream, verbose) | ||
| if (RUtils.rPackages.isEmpty) { | ||
| RUtils.rPackages = Some(Utils.createTempDir().getAbsolutePath) | ||
| } | ||
| } finally { // clean up | ||
| if (!rSource.delete()) { | ||
| logWarning(s"Error deleting ${rSource.getPath()}") | ||
| try { | ||
| if (!rPackageBuilder(rSource, printStream, verbose, RUtils.rPackages.get)) { | ||
| print(s"ERROR: Failed to build R package in $file.", printStream) | ||
| print(RJarDoc, printStream) | ||
| } | ||
| } finally { | ||
| // clean up | ||
| if (!rSource.delete()) { | ||
| logWarning(s"Error deleting ${rSource.getPath()}") | ||
| } | ||
| } | ||
| } else { | ||
| if (verbose) { | ||
| print(s"$file doesn't contain R source code, skipping...", printStream) | ||
| } | ||
| } | ||
| } else { | ||
| if (verbose) { | ||
| print(s"$file doesn't contain R source code, skipping...", printStream) | ||
| } | ||
| } { | ||
| jar.close() | ||
| } | ||
| } else { | ||
| print(s"WARN: $file resolved as dependency, but not found.", printStream, Level.WARNING) | ||
|
|
@@ -231,8 +236,12 @@ private[deploy] object RPackageUtils extends Logging { | |
| val zipOutputStream = new ZipOutputStream(new FileOutputStream(zipFile, false)) | ||
| try { | ||
| filesToBundle.foreach { file => | ||
| // get the relative paths for proper naming in the zip file | ||
| val relPath = file.getAbsolutePath.replaceFirst(dir.getAbsolutePath, "") | ||
| // Get the relative paths for proper naming in the ZIP file. Note that | ||
| // we convert dir to URI to force / and then remove trailing / that show up for | ||
| // directories because the separator should always be / for according to ZIP | ||
| // specification and therefore `relPath` here should be, for example, | ||
| // "/packageTest/def.R" or "/test.R". | ||
| val relPath = file.toURI.toString.replaceFirst(dir.toURI.toString.stripSuffix("/"), "") | ||
|
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. It should always be
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. cc @shivaram, could I please ask to take a look for this one? This fixes the test,
Contributor
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. Yeah I think using
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. Oh, I thought you meant writing a comment in the codes.. :). it just replaces the
Contributor
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. You can put it in the code as well :) Something like
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. For example, Before
After
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. Sure, thanks! |
||
| val fis = new FileInputStream(file) | ||
| val zipEntry = new ZipEntry(relPath) | ||
| zipOutputStream.putNextEntry(zipEntry) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,19 +119,20 @@ class EventLoggingListenerSuite extends SparkFunSuite with LocalSparkContext wit | |
| } | ||
|
|
||
| test("Event log name") { | ||
| val baseDirUri = Utils.resolveURI("/base-dir") | ||
| // without compression | ||
| assert(s"file:/base-dir/app1" === EventLoggingListener.getLogPath( | ||
| Utils.resolveURI("/base-dir"), "app1", None)) | ||
| assert(s"${baseDirUri.toString}/app1" === EventLoggingListener.getLogPath( | ||
| baseDirUri, "app1", None)) | ||
|
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. On Windows, it compares whereas on Linux and Mac, |
||
| // with compression | ||
| assert(s"file:/base-dir/app1.lzf" === | ||
| EventLoggingListener.getLogPath(Utils.resolveURI("/base-dir"), "app1", None, Some("lzf"))) | ||
| assert(s"${baseDirUri.toString}/app1.lzf" === | ||
| EventLoggingListener.getLogPath(baseDirUri, "app1", None, Some("lzf"))) | ||
| // illegal characters in app ID | ||
| assert(s"file:/base-dir/a-fine-mind_dollar_bills__1" === | ||
| EventLoggingListener.getLogPath(Utils.resolveURI("/base-dir"), | ||
| assert(s"${baseDirUri.toString}/a-fine-mind_dollar_bills__1" === | ||
| EventLoggingListener.getLogPath(baseDirUri, | ||
| "a fine:mind$dollar{bills}.1", None)) | ||
| // illegal characters in app ID with compression | ||
| assert(s"file:/base-dir/a-fine-mind_dollar_bills__1.lz4" === | ||
| EventLoggingListener.getLogPath(Utils.resolveURI("/base-dir"), | ||
| assert(s"${baseDirUri.toString}/a-fine-mind_dollar_bills__1.lz4" === | ||
| EventLoggingListener.getLogPath(baseDirUri, | ||
| "a fine:mind$dollar{bills}.1", None, Some("lz4"))) | ||
| } | ||
|
|
||
|
|
@@ -289,7 +290,7 @@ object EventLoggingListenerSuite { | |
| val conf = new SparkConf | ||
| conf.set("spark.eventLog.enabled", "true") | ||
| conf.set("spark.eventLog.testing", "true") | ||
| conf.set("spark.eventLog.dir", logDir.toString) | ||
| conf.set("spark.eventLog.dir", logDir.toUri.toString) | ||
| compressionCodec.foreach { codec => | ||
| conf.set("spark.eventLog.compress", "true") | ||
| conf.set("spark.io.compression.codec", codec) | ||
|
|
||
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.
Actual change is as below:
Utils.tryWithSafeFinally { ... } { jar.close() }