Skip to content

Commit

Permalink
Better exception message from failed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Or committed Nov 11, 2014
1 parent 6e03de3 commit 8fe6719
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.io._

import scala.collection.mutable.ArrayBuffer

import org.apache.spark.{SparkConf, SparkContext, SparkEnv, SparkException, TestUtils}
import org.apache.spark._
import org.apache.spark.deploy.SparkSubmit._
import org.apache.spark.util.Utils
import org.scalatest.FunSuite
Expand Down Expand Up @@ -451,24 +451,24 @@ class SparkSubmitSuite extends FunSuite with Matchers {
}
}

object JarCreationTest {
object JarCreationTest extends Logging {
def main(args: Array[String]) {
Utils.configTestLog4j("INFO")
val conf = new SparkConf()
val sc = new SparkContext(conf)
val result = sc.makeRDD(1 to 100, 10).mapPartitions { x =>
var foundClasses = false
var exception: String = null
try {
Class.forName("SparkSubmitClassA", true, Thread.currentThread().getContextClassLoader)
Class.forName("SparkSubmitClassA", true, Thread.currentThread().getContextClassLoader)
foundClasses = true
} catch {
case _: Throwable => // catch all
case t: Throwable =>
exception = t + "\n" + t.getStackTraceString
}
Seq(foundClasses).iterator
Option(exception).toSeq.iterator
}.collect()
if (result.contains(false)) {
throw new Exception("Could not load user defined classes inside of executors")
if (result.nonEmpty) {
throw new Exception("Could not load user class from jar:\n" + result(0))
}
}
}
Expand Down

0 comments on commit 8fe6719

Please sign in to comment.