WARN SparkContext:正在构造另一个 SparkContext(或在其构造函数中抛出异常)

WARN SparkContext: Another SparkContext is being constructed (or threw an exception in its constructor)

我对我的 DataFrame 转换代码(使用 https://github.com/holdenk/spark-testing-base )进行了两个集成测试,当在 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:

并且:

17/04/06 11:29:05 ERROR SparkContext: Error initializing SparkContext.
akka.actor.InvalidActorNameException: actor name [ExecutorEndpoint] is not unique!

并且:

java.lang.NullPointerException
at org.apache.spark.network.netty.NettyBlockTransferService.close(NettyBlockTransferService.scala:152)

第二个测试 运行s 中途并中止并显示以下消息(此代码 运行 在实际集群 BTW 上很好):

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)

这是完整构建输出的 pastebin:https://pastebin.com/drG20kcB

如何 运行 我的 spark 集成测试一起进行?

谢谢!

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

我需要这个:

test {
  maxParallelForks = 1
}

但是,如果有一种方法可以为 gradle 中的特定测试子集打开并行执行,我会更喜欢该解决方案。

我正在使用 ScalaTest 和 WordSpec BTW。