Skip to content

Commit eb48edf

Browse files
Marcelo Vanzinjerryshao
authored andcommitted
[SPARK-23787][TESTS] Fix file download test in SparkSubmitSuite for Hadoop 2.9.
This particular test assumed that Hadoop libraries did not support http as a file system. Hadoop 2.9 does, so the test failed. The test now forces a non-existent implementation for the http fs, which forces the expected error. There were also a couple of other issues in the same test: SparkSubmit arguments in the wrong order, and the wrong check later when asserting, which was being masked by the previous issues. Author: Marcelo Vanzin <[email protected]> Closes apache#20895 from vanzin/SPARK-23787.
1 parent 087fb31 commit eb48edf

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -959,25 +959,28 @@ class SparkSubmitSuite
959959
}
960960

961961
test("download remote resource if it is not supported by yarn service") {
962-
testRemoteResources(isHttpSchemeBlacklisted = false, supportMockHttpFs = false)
962+
testRemoteResources(enableHttpFs = false, blacklistHttpFs = false)
963963
}
964964

965965
test("avoid downloading remote resource if it is supported by yarn service") {
966-
testRemoteResources(isHttpSchemeBlacklisted = false, supportMockHttpFs = true)
966+
testRemoteResources(enableHttpFs = true, blacklistHttpFs = false)
967967
}
968968

969969
test("force download from blacklisted schemes") {
970-
testRemoteResources(isHttpSchemeBlacklisted = true, supportMockHttpFs = true)
970+
testRemoteResources(enableHttpFs = true, blacklistHttpFs = true)
971971
}
972972

973-
private def testRemoteResources(isHttpSchemeBlacklisted: Boolean,
974-
supportMockHttpFs: Boolean): Unit = {
973+
private def testRemoteResources(
974+
enableHttpFs: Boolean,
975+
blacklistHttpFs: Boolean): Unit = {
975976
val hadoopConf = new Configuration()
976977
updateConfWithFakeS3Fs(hadoopConf)
977-
if (supportMockHttpFs) {
978+
if (enableHttpFs) {
978979
hadoopConf.set("fs.http.impl", classOf[TestFileSystem].getCanonicalName)
979-
hadoopConf.set("fs.http.impl.disable.cache", "true")
980+
} else {
981+
hadoopConf.set("fs.http.impl", getClass().getName() + ".DoesNotExist")
980982
}
983+
hadoopConf.set("fs.http.impl.disable.cache", "true")
981984

982985
val tmpDir = Utils.createTempDir()
983986
val mainResource = File.createTempFile("tmpPy", ".py", tmpDir)
@@ -986,20 +989,19 @@ class SparkSubmitSuite
986989
val tmpHttpJar = TestUtils.createJarWithFiles(Map("test.resource" -> "USER"), tmpDir)
987990
val tmpHttpJarPath = s"http://${new File(tmpHttpJar.toURI).getAbsolutePath}"
988991

992+
val forceDownloadArgs = if (blacklistHttpFs) {
993+
Seq("--conf", "spark.yarn.dist.forceDownloadSchemes=http")
994+
} else {
995+
Nil
996+
}
997+
989998
val args = Seq(
990999
"--class", UserClasspathFirstTest.getClass.getName.stripPrefix("$"),
9911000
"--name", "testApp",
9921001
"--master", "yarn",
9931002
"--deploy-mode", "client",
994-
"--jars", s"$tmpS3JarPath,$tmpHttpJarPath",
995-
s"s3a://$mainResource"
996-
) ++ (
997-
if (isHttpSchemeBlacklisted) {
998-
Seq("--conf", "spark.yarn.dist.forceDownloadSchemes=http,https")
999-
} else {
1000-
Nil
1001-
}
1002-
)
1003+
"--jars", s"$tmpS3JarPath,$tmpHttpJarPath"
1004+
) ++ forceDownloadArgs ++ Seq(s"s3a://$mainResource")
10031005

10041006
val appArgs = new SparkSubmitArguments(args)
10051007
val (_, _, conf, _) = SparkSubmit.prepareSubmitEnvironment(appArgs, Some(hadoopConf))
@@ -1009,7 +1011,7 @@ class SparkSubmitSuite
10091011
// The URI of remote S3 resource should still be remote.
10101012
assert(jars.contains(tmpS3JarPath))
10111013

1012-
if (supportMockHttpFs) {
1014+
if (enableHttpFs && !blacklistHttpFs) {
10131015
// If Http FS is supported by yarn service, the URI of remote http resource should
10141016
// still be remote.
10151017
assert(jars.contains(tmpHttpJarPath))

0 commit comments

Comments
 (0)