Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1256#discussion_r14844641
  
    --- Diff: core/src/test/scala/org/apache/spark/SparkConfSuite.scala ---
    @@ -30,6 +30,33 @@ class SparkConfSuite extends FunSuite with 
LocalSparkContext {
         }
       }
     
    +  test("loading from file") {
    +    class TestSparkConf(loadDefaults: Boolean, fileName: Option[String]) 
extends
    +    SparkConf(loadDefaults, fileName) {
    +
    +      override def loadPropertiesFromFile(fileName: String, isOverride: 
Boolean = false) {
    +        val seq = fileName.split(",").map { t =>
    +          val ts = t.split(":")
    +          (ts(0), ts(1))
    +        }
    +        for ((k, v) <- seq if k.startsWith("spark.")) {
    +          if (isOverride || getOption(k).isEmpty) {
    +            set(k, v)
    +          }
    +        }
    +      }
    +    }
    +    assert(new TestSparkConf(true, Some("spark.test.fileNameLoad:true")).
    +      get("spark.test.fileNameLoad") === "true")
    +    try {
    +      System.setProperty("spark.test.fileNameLoad", "false")
    +      val conf = new TestSparkConf(true, 
Some("spark.test.fileNameLoad:true"))
    +      assert(conf.get("spark.test.fileNameLoad") === "false")
    +    } finally {
    +      System.clearProperty("spark.test.fileNameLoad")
    +    }
    +  }
    +
    --- End diff --
    
    I'd like to see a test that enforces the precedence rules you're defining, 
and also calls `loadPropertiesFromFile()` with overriding both on and off and 
makes sure everything works.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to