Apache spark 警告SparkContext:正在构造另一个SparkContext(或在其构造函数中引发异常)

Apache spark 警告SparkContext:正在构造另一个SparkContext(或在其构造函数中引发异常),apache-spark,gradle,gradlew,Apache Spark,Gradle,Gradlew,我的DataFrametransformation代码(使用)有两个集成测试,它们在IntelliJ中单独运行时都运行良好 但是,当我运行gradle构建时,对于第一个测试,我看到以下消息: 17/04/06 11:29:02 WARN SparkContext: Another SparkContext is being constructed (or threw an exception in its constructor). This may indicate an error, si

我的
DataFrame
transformation代码(使用)有两个集成测试,它们在IntelliJ中单独运行时都运行良好

但是,当我运行gradle构建时,对于第一个测试,我看到以下消息:

17/04/06 11:29:02 WARN SparkContext: Another SparkContext is being constructed (or threw an exception in its constructor).  This may indicate an error, since only one SparkContext may be running in this JVM (see SPARK-2243). The other SparkContext was created at:
以及:

以及:

第二个测试中途运行并中止,并显示以下消息(顺便说一句,此代码在实际集群上运行良好):

org.apache.spark.SparkException:作业因阶段失败而中止:任务序列化失败:java.lang.NullPointerException
org.apache.spark.broadcast.TorrentBroadcast.(TorrentBroadcast.scala:80)
以下是完整生成输出的粘贴箱:

如何一起运行spark集成测试

谢谢

PS:如果可能相关的话,我正在使用gradle包装器(
/gradlew clean build

我需要这个:

test {
  maxParallelForks = 1
}
然而,如果有一种方法可以在gradle中为特定的测试子集实现并行执行,我更愿意使用这种解决方案


顺便说一句,我正在将ScalaTest与WordSpec一起使用。

我的spark集成测试扩展了这个基类:
抽象类SparkIntegrationTest使用DataFrameSuiteBase将UnitTest与SharedParkContext一起扩展
java.lang.NullPointerException
at org.apache.spark.network.netty.NettyBlockTransferService.close(NettyBlockTransferService.scala:152)
org.apache.spark.SparkException: Job aborted due to stage failure: Task serialization failed: java.lang.NullPointerException
org.apache.spark.broadcast.TorrentBroadcast.<init>(TorrentBroadcast.scala:80)
test {
  maxParallelForks = 1
}