@@ -91,18 +91,36 @@ class StreamingContextSuite extends FunSuite with BeforeAndAfter with Timeouts w
9191 }
9292
9393 test(" from checkpoint" ) {
94- val myConf = SparkContext .updatedConf(new SparkConf (false ), master, appName)
94+ // Create Checkpoint and verify whether SparkConf configuration is captured
95+ val myConf = SparkContext .updatedConf(new SparkConf (loadDefaults = false ), master, appName)
9596 myConf.set(" spark.cleaner.ttl" , " 10" )
96- val ssc1 = new StreamingContext (myConf, batchDuration)
97- addInputStream(ssc1).register()
98- ssc1.start()
99- val cp = new Checkpoint (ssc1, Time (1000 ))
97+ ssc = new StreamingContext (myConf, batchDuration)
98+ addInputStream(ssc).register()
99+ ssc.start()
100+ val cp = new Checkpoint (ssc, Time (1000 ))
101+ ssc.stop()
100102 assert(cp.sparkConfPairs.toMap.getOrElse(" spark.cleaner.ttl" , " -1" ) === " 10" )
101- ssc1.stop()
103+
104+ // Verify SparkConf recreated from Checkpoint has the same configuration
102105 val newCp = Utils .deserialize[Checkpoint ](Utils .serialize(cp))
103106 assert(newCp.sparkConf.getInt(" spark.cleaner.ttl" , - 1 ) === 10 )
104107 ssc = new StreamingContext (null , newCp, null )
105108 assert(ssc.conf.getInt(" spark.cleaner.ttl" , - 1 ) === 10 )
109+ assert(ssc.conf.get(" spark.master" ) === master)
110+ ssc.stop()
111+
112+ // Verify SparkConf recreated from Checkpoint picks up new master
113+ try {
114+ val newMaster = " local[100]"
115+ System .setProperty(" spark.master" , newMaster)
116+ val anotherNewCp = Utils .deserialize[Checkpoint ](Utils .serialize(cp))
117+ ssc = new StreamingContext (null , anotherNewCp, null )
118+ assert(ssc.conf.getInt(" spark.cleaner.ttl" , - 1 ) === 10 )
119+ assert(ssc.conf.get(" spark.master" ) === newMaster)
120+ ssc.stop()
121+ } finally {
122+ System .clearProperty(" spark.master" )
123+ }
106124 }
107125
108126 test(" start and stop state check" ) {
0 commit comments