Skip to content

Commit bee20df

Browse files
committed
Remove setProperty calls in SparkContextSchedulerCreationSuite
1 parent 655587c commit bee20df

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

core/src/test/scala/org/apache/spark/SparkContextSchedulerCreationSuite.scala

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ import org.apache.spark.scheduler.{SchedulerBackend, TaskScheduler, TaskSchedule
2323
import org.apache.spark.scheduler.cluster.{SimrSchedulerBackend, SparkDeploySchedulerBackend}
2424
import org.apache.spark.scheduler.cluster.mesos.{CoarseMesosSchedulerBackend, MesosSchedulerBackend}
2525
import org.apache.spark.scheduler.local.LocalBackend
26-
import org.apache.spark.util.ResetSystemProperties
2726

2827
class SparkContextSchedulerCreationSuite
29-
extends FunSuite with LocalSparkContext with PrivateMethodTester with Logging
30-
with ResetSystemProperties {
28+
extends FunSuite with LocalSparkContext with PrivateMethodTester with Logging {
3129

32-
def createTaskScheduler(master: String): TaskSchedulerImpl = {
30+
def createTaskScheduler(master: String): TaskSchedulerImpl =
31+
createTaskScheduler(master, new SparkConf())
32+
33+
def createTaskScheduler(master: String, conf: SparkConf): TaskSchedulerImpl = {
3334
// Create local SparkContext to setup a SparkEnv. We don't actually want to start() the
3435
// real schedulers, so we don't want to create a full SparkContext with the desired scheduler.
35-
sc = new SparkContext("local", "test")
36+
sc = new SparkContext("local", "test", conf)
3637
val createTaskSchedulerMethod =
3738
PrivateMethod[Tuple2[SchedulerBackend, TaskScheduler]]('createTaskScheduler)
3839
val (_, sched) = SparkContext invokePrivate createTaskSchedulerMethod(sc, master)
@@ -104,8 +105,8 @@ class SparkContextSchedulerCreationSuite
104105
}
105106

106107
test("local-default-parallelism") {
107-
System.setProperty("spark.default.parallelism", "16")
108-
val sched = createTaskScheduler("local")
108+
val conf = new SparkConf().set("spark.default.parallelism", "16")
109+
val sched = createTaskScheduler("local", conf)
109110

110111
sched.backend match {
111112
case s: LocalBackend => assert(s.defaultParallelism() === 16)
@@ -151,9 +152,10 @@ class SparkContextSchedulerCreationSuite
151152
testYarn("yarn-client", "org.apache.spark.scheduler.cluster.YarnClientClusterScheduler")
152153
}
153154

154-
def testMesos(master: String, expectedClass: Class[_]) {
155+
def testMesos(master: String, expectedClass: Class[_], coarse: Boolean) {
156+
val conf = new SparkConf().set("spark.mesos.coarse", coarse.toString)
155157
try {
156-
val sched = createTaskScheduler(master)
158+
val sched = createTaskScheduler(master, conf)
157159
assert(sched.backend.getClass === expectedClass)
158160
} catch {
159161
case e: UnsatisfiedLinkError =>
@@ -164,17 +166,14 @@ class SparkContextSchedulerCreationSuite
164166
}
165167

166168
test("mesos fine-grained") {
167-
System.setProperty("spark.mesos.coarse", "false")
168-
testMesos("mesos://localhost:1234", classOf[MesosSchedulerBackend])
169+
testMesos("mesos://localhost:1234", classOf[MesosSchedulerBackend], coarse = false)
169170
}
170171

171172
test("mesos coarse-grained") {
172-
System.setProperty("spark.mesos.coarse", "true")
173-
testMesos("mesos://localhost:1234", classOf[CoarseMesosSchedulerBackend])
173+
testMesos("mesos://localhost:1234", classOf[CoarseMesosSchedulerBackend], coarse = true)
174174
}
175175

176176
test("mesos with zookeeper") {
177-
System.setProperty("spark.mesos.coarse", "false")
178-
testMesos("zk://localhost:1234,localhost:2345", classOf[MesosSchedulerBackend])
177+
testMesos("zk://localhost:1234,localhost:2345", classOf[MesosSchedulerBackend], coarse = false)
179178
}
180179
}

0 commit comments

Comments
 (0)