Skip to content

Commit

Permalink
[SPARK-14935][CORE] DistributedSuite "local-cluster format" shouldn't…
Browse files Browse the repository at this point in the history
… actually launch clusters

https://issues.apache.org/jira/browse/SPARK-14935

In DistributedSuite, the "local-cluster format" test actually launches a bunch of clusters, but this doesn't seem necessary for what should just be a unit test of a regex. We should clean up the code so that this is testable without actually launching a cluster, which should buy us about 20 seconds per build.

Passed unit test on my local machine

Author: Xin Ren <[email protected]>

Closes apache#12744 from keypointt/SPARK-14935.
  • Loading branch information
keypointt authored and JoshRosen committed Apr 28, 2016
1 parent bed0b00 commit 5743352
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions core/src/test/scala/org/apache/spark/DistributedSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@ class DistributedSuite extends SparkFunSuite with Matchers with LocalSparkContex
}

test("local-cluster format") {
sc = new SparkContext("local-cluster[2,1,1024]", "test")
assert(sc.parallelize(1 to 2, 2).count() == 2)
resetSparkContext()
sc = new SparkContext("local-cluster[2 , 1 , 1024]", "test")
assert(sc.parallelize(1 to 2, 2).count() == 2)
resetSparkContext()
sc = new SparkContext("local-cluster[2, 1, 1024]", "test")
assert(sc.parallelize(1 to 2, 2).count() == 2)
resetSparkContext()
sc = new SparkContext("local-cluster[ 2, 1, 1024 ]", "test")
assert(sc.parallelize(1 to 2, 2).count() == 2)
resetSparkContext()
import SparkMasterRegex._

val masterStrings = Seq(
"local-cluster[2,1,1024]",
"local-cluster[2 , 1 , 1024]",
"local-cluster[2, 1, 1024]",
"local-cluster[ 2, 1, 1024 ]"
)

masterStrings.foreach {
case LOCAL_CLUSTER_REGEX(numSlaves, coresPerSlave, memoryPerSlave) =>
assert(numSlaves.toInt == 2)
assert(coresPerSlave.toInt == 1)
assert(memoryPerSlave.toInt == 1024)
}
}

test("simple groupByKey") {
Expand Down

0 comments on commit 5743352

Please sign in to comment.