This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 355ab6a [SPARK-32804][LAUNCHER][FOLLOWUP] Fix
SparkSubmitCommandBuilderSuite test failure without jars
355ab6a is described below
commit 355ab6ae94a972011d56b8449c612fd7ad30d860
Author: KevinSmile <[email protected]>
AuthorDate: Wed Sep 16 23:39:41 2020 +0900
[SPARK-32804][LAUNCHER][FOLLOWUP] Fix SparkSubmitCommandBuilderSuite test
failure without jars
### What changes were proposed in this pull request?
It's a followup of https://github.com/apache/spark/pull/29653.
Tests in `SparkSubmitCommandBuilderSuite` may fail if you didn't build
first and have jars before test,
so if `isTesting` we should set a dummy `SparkLauncher.NO_RESOURCE`.
### Why are the changes needed?
Fix tests failure.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
mvn clean test (test without jars built first).
Closes #29769 from KevinSmile/bug-fix-master.
Authored-by: KevinSmile <[email protected]>
Signed-off-by: HyukjinKwon <[email protected]>
---
.../apache/spark/launcher/SparkSubmitCommandBuilder.java | 13 +++++++++----
.../spark/launcher/SparkSubmitCommandBuilderSuite.java | 4 ++--
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git
a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
b/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
index 43e7f8d..d6ed1e3 100644
---
a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
+++
b/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
@@ -404,12 +404,17 @@ class SparkSubmitCommandBuilder extends
AbstractCommandBuilder {
}
private String findExamplesAppJar() {
- for (String exampleJar : findExamplesJars()) {
- if (new File(exampleJar).getName().startsWith("spark-examples")) {
- return exampleJar;
+ boolean isTesting = "1".equals(getenv("SPARK_TESTING"));
+ if (isTesting) {
+ return SparkLauncher.NO_RESOURCE;
+ } else {
+ for (String exampleJar : findExamplesJars()) {
+ if (new File(exampleJar).getName().startsWith("spark-examples")) {
+ return exampleJar;
+ }
}
+ throw new IllegalStateException("Failed to find examples' main app
jar.");
}
- throw new IllegalStateException("Failed to find examples' main app jar.");
}
private List<String> findExamplesJars() {
diff --git
a/launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java
b/launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java
index 6cd089e..07a9dae1 100644
---
a/launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java
+++
b/launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java
@@ -259,8 +259,8 @@ public class SparkSubmitCommandBuilderSuite extends
BaseSuite {
findArgValue(cmd, parser.CLASS));
assertEquals("cluster", findArgValue(cmd, parser.DEPLOY_MODE));
String primaryResource = cmd.get(cmd.size() - 2);
- assertTrue(new
File(primaryResource).getName().startsWith("spark-examples"));
- assertFalse(cmd.contains(SparkLauncher.NO_RESOURCE));
+ assertTrue(primaryResource.equals(SparkLauncher.NO_RESOURCE)
+ || new
File(primaryResource).getName().startsWith("spark-examples"));
}
@Test(expected = IllegalArgumentException.class)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]