Skip to content

Commit 08f47ca

Browse files
author
Marcelo Vanzin
committed
Cleanup SPARK_YARN_MODE in tests.
1 parent 121bcf8 commit 08f47ca

File tree

3 files changed

+3
-34
lines changed

3 files changed

+3
-34
lines changed

resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/BaseYarnClusterSuite.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,14 @@ abstract class BaseYarnClusterSuite
6262
protected var hadoopConfDir: File = _
6363
private var logConfDir: File = _
6464

65-
var oldSystemProperties: Properties = null
66-
6765
def newYarnConfig(): YarnConfiguration
6866

6967
override def beforeAll() {
7068
super.beforeAll()
71-
oldSystemProperties = SerializationUtils.clone(System.getProperties)
7269

7370
tempDir = Utils.createTempDir()
7471
logConfDir = new File(tempDir, "log4j")
7572
logConfDir.mkdir()
76-
System.setProperty("SPARK_YARN_MODE", "true")
7773

7874
val logConfFile = new File(logConfDir, "log4j.properties")
7975
Files.write(LOG4J_CONF, logConfFile, StandardCharsets.UTF_8)
@@ -124,7 +120,6 @@ abstract class BaseYarnClusterSuite
124120
try {
125121
yarnCluster.stop()
126122
} finally {
127-
System.setProperties(oldSystemProperties)
128123
super.afterAll()
129124
}
130125
}

resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/ClientSuite.scala

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import java.util.Properties
2424
import scala.collection.JavaConverters._
2525
import scala.collection.mutable.{HashMap => MutableHashMap}
2626

27-
import org.apache.commons.lang3.SerializationUtils
2827
import org.apache.hadoop.conf.Configuration
2928
import org.apache.hadoop.fs.Path
3029
import org.apache.hadoop.mapreduce.MRJobConfig
@@ -36,34 +35,18 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration
3635
import org.apache.hadoop.yarn.util.Records
3736
import org.mockito.Matchers.{eq => meq, _}
3837
import org.mockito.Mockito._
39-
import org.scalatest.{BeforeAndAfterAll, Matchers}
38+
import org.scalatest.Matchers
4039

4140
import org.apache.spark.{SparkConf, SparkFunSuite, TestUtils}
4241
import org.apache.spark.deploy.yarn.config._
43-
import org.apache.spark.util.{ResetSystemProperties, SparkConfWithEnv, Utils}
42+
import org.apache.spark.util.{SparkConfWithEnv, Utils}
4443

45-
class ClientSuite extends SparkFunSuite with Matchers with BeforeAndAfterAll
46-
with ResetSystemProperties {
44+
class ClientSuite extends SparkFunSuite with Matchers {
4745

4846
import Client._
4947

5048
var oldSystemProperties: Properties = null
5149

52-
override def beforeAll(): Unit = {
53-
super.beforeAll()
54-
oldSystemProperties = SerializationUtils.clone(System.getProperties)
55-
System.setProperty("SPARK_YARN_MODE", "true")
56-
}
57-
58-
override def afterAll(): Unit = {
59-
try {
60-
System.setProperties(oldSystemProperties)
61-
oldSystemProperties = null
62-
} finally {
63-
super.afterAll()
64-
}
65-
}
66-
6750
test("default Yarn application classpath") {
6851
getDefaultYarnApplicationClasspath should be(Fixtures.knownDefYarnAppCP)
6952
}

resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/security/YARNHadoopDelegationTokenManagerSuite.scala

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,10 @@ class YARNHadoopDelegationTokenManagerSuite extends SparkFunSuite with Matchers
3131

3232
override def beforeAll(): Unit = {
3333
super.beforeAll()
34-
35-
System.setProperty("SPARK_YARN_MODE", "true")
36-
3734
sparkConf = new SparkConf()
3835
hadoopConf = new Configuration()
3936
}
4037

41-
override def afterAll(): Unit = {
42-
super.afterAll()
43-
44-
System.clearProperty("SPARK_YARN_MODE")
45-
}
46-
4738
test("Correctly loads credential providers") {
4839
credentialManager = new YARNHadoopDelegationTokenManager(
4940
sparkConf,

0 commit comments

Comments
 (0)