Skip to content

Commit 8fe6719

Browse files
author
Andrew Or
committed
Better exception message from failed test
1 parent 6e03de3 commit 8fe6719

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import java.io._
2121

2222
import scala.collection.mutable.ArrayBuffer
2323

24-
import org.apache.spark.{SparkConf, SparkContext, SparkEnv, SparkException, TestUtils}
24+
import org.apache.spark._
2525
import org.apache.spark.deploy.SparkSubmit._
2626
import org.apache.spark.util.Utils
2727
import org.scalatest.FunSuite
@@ -451,24 +451,24 @@ class SparkSubmitSuite extends FunSuite with Matchers {
451451
}
452452
}
453453

454-
object JarCreationTest {
454+
object JarCreationTest extends Logging {
455455
def main(args: Array[String]) {
456456
Utils.configTestLog4j("INFO")
457457
val conf = new SparkConf()
458458
val sc = new SparkContext(conf)
459459
val result = sc.makeRDD(1 to 100, 10).mapPartitions { x =>
460-
var foundClasses = false
460+
var exception: String = null
461461
try {
462462
Class.forName("SparkSubmitClassA", true, Thread.currentThread().getContextClassLoader)
463463
Class.forName("SparkSubmitClassA", true, Thread.currentThread().getContextClassLoader)
464-
foundClasses = true
465464
} catch {
466-
case _: Throwable => // catch all
465+
case t: Throwable =>
466+
exception = t + "\n" + t.getStackTraceString
467467
}
468-
Seq(foundClasses).iterator
468+
Option(exception).toSeq.iterator
469469
}.collect()
470-
if (result.contains(false)) {
471-
throw new Exception("Could not load user defined classes inside of executors")
470+
if (result.nonEmpty) {
471+
throw new Exception("Could not load user class from jar:\n" + result(0))
472472
}
473473
}
474474
}

0 commit comments

Comments
 (0)