Skip to content
Snippets Groups Projects
Commit 574c0d28 authored by Ankur Dave's avatar Ankur Dave
Browse files

Use SparkConf in GraphX tests (via LocalSparkContext)

parent 55101f58
No related branches found
No related tags found
No related merge requests found
...@@ -3,20 +3,20 @@ package org.apache.spark.graphx ...@@ -3,20 +3,20 @@ package org.apache.spark.graphx
import org.scalatest.Suite import org.scalatest.Suite
import org.scalatest.BeforeAndAfterEach import org.scalatest.BeforeAndAfterEach
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext import org.apache.spark.SparkContext
/** /**
* Provides a method to run tests against a {@link SparkContext} variable that is correctly stopped * Provides a method to run tests against a {@link SparkContext} variable that is correctly stopped
* after each test. * after each test.
*/ */
trait LocalSparkContext { trait LocalSparkContext {
System.setProperty("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
System.setProperty("spark.kryo.registrator", "org.apache.spark.graphx.GraphKryoRegistrator")
/** Runs `f` on a new SparkContext and ensures that it is stopped afterwards. */ /** Runs `f` on a new SparkContext and ensures that it is stopped afterwards. */
def withSpark[T](f: SparkContext => T) = { def withSpark[T](f: SparkContext => T) = {
val sc = new SparkContext("local", "test") val conf = new SparkConf()
.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
.set("spark.kryo.registrator", "org.apache.spark.graphx.GraphKryoRegistrator")
val sc = new SparkContext("local", "test", conf)
try { try {
f(sc) f(sc)
} finally { } finally {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment