I followed this article to write some spark tests which running on local: http://mkuthan.github.io/blog/2015/03/01/spark-unit-testing/
The main code is like:
class SparkExampleSpec extends FlatSpec with BeforeAndAfter {
private val master = "local[2]"
private val appName = "example-spark"
private var sc: SparkContext = _
before {
val conf = new SparkConf()
.setMaster(master)
.setAppName(appName)
sc = new SparkContext(conf)
}
after {
if (sc != null) {
sc.stop()
}
}
(...)
But I found when my tests increased, it will report OutOfMemoryError
and the process is blocked.
How to fix it?
PS: Some of the tests generates some RDD, but doesn't collect
them, like:
val rdd = sparkContext.makeRDD(someData)
// not calling `rdd.collect()`
Is it a possible problem?