Skip to content

[Test] Better exception message from SparkSubmitSuite #3212

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,25 @@ 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
exception = exception.replaceAll("\n", "\n\t")
}
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @andrewor14 , only show one class not found? Is it better to show all classes not found when there are more than one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception is likely the same anyway. It'll be very verbose if we include all of them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the two classes are the same, I missed that :(

}
}
}
Expand Down