Skip to content

Commit

Permalink
Add test to ensure that conf and env var settings are merged, not ove…
Browse files Browse the repository at this point in the history
…rriden.
  • Loading branch information
JoshRosen committed Jan 26, 2015
1 parent d6f3113 commit b9973da
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,21 @@ class SparkListenerSuite extends FunSuite with LocalSparkContext with Matchers
}.size should be (1)
}

test("spark.extraListeners and SPARK_EXTRA_LISTENERS configurations are merged") {
// This test ensures that we don't accidentally change the behavior such that one setting
// overrides the other:
val SPARK_EXTRA_LISTENERS = classOf[ListenerThatAcceptsSparkConf].getName
val conf = spy(new SparkConf().setMaster("local").setAppName("test")
.set("spark.extraListeners", classOf[BasicJobCounter].getName))
when(conf.getenv("SPARK_EXTRA_LISTENERS")).thenReturn(SPARK_EXTRA_LISTENERS)
when(conf.clone).thenReturn(conf) // so that our mock is still used
sc = new SparkContext(conf)
sc.listenerBus.sparkListeners.collect { case x: BasicJobCounter => x}.size should be (1)
sc.listenerBus.sparkListeners.collect {
case x: ListenerThatAcceptsSparkConf => x
}.size should be (1)
}

/**
* Assert that the given list of numbers has an average that is greater than zero.
*/
Expand Down

0 comments on commit b9973da

Please sign in to comment.