Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for env var filters
  • Loading branch information
mpmolek committed Nov 6, 2018
commit 2a1f3127a701a6a2fad915b5fde0985ce30ef2a1
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ private[spark] object RestSubmissionClient {
*/
private[rest] def filterSystemEnvironment(env: Map[String, String]): Map[String, String] = {
env.filterKeys { k =>
// SPARK_HOME is filtered out because it is usually wrong on the remote machine (SPARK-12345)
// SPARK_HOME and SPARK_CONF_DIR are filtered out because they are usually wrong
// on the remote machine (SPARK-12345) (SPARK-25934)
(k.startsWith("SPARK_") && k != "SPARK_ENV_LOADED" && k != "SPARK_HOME"
&& k != "SPARK_CONF_DIR") || k.startsWith("MESOS_")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test case in StandaloneRestSubmitSuite.scala in order to prevent a future regression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, good idea. I also added a test for filtering "SPARK_HOME" which didn't get a test back when that filter was added.

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,18 @@ class StandaloneRestSubmitSuite extends SparkFunSuite with BeforeAndAfterEach {
assert(filteredVariables == Map("SPARK_VAR" -> "1"))
}

test("client does not send 'SPARK_HOME' env var by default") {
val environmentVariables = Map("SPARK_VAR" -> "1", "SPARK_HOME" -> "1")
val filteredVariables = RestSubmissionClient.filterSystemEnvironment(environmentVariables)
assert(filteredVariables == Map("SPARK_VAR" -> "1"))
}

test("client does not send 'SPARK_CONF_DIR' env var by default") {
val environmentVariables = Map("SPARK_VAR" -> "1", "SPARK_CONF_DIR" -> "1")
val filteredVariables = RestSubmissionClient.filterSystemEnvironment(environmentVariables)
assert(filteredVariables == Map("SPARK_VAR" -> "1"))
}

test("client includes mesos env vars") {
val environmentVariables = Map("SPARK_VAR" -> "1", "MESOS_VAR" -> "1", "OTHER_VAR" -> "1")
val filteredVariables = RestSubmissionClient.filterSystemEnvironment(environmentVariables)
Expand Down