@@ -41,20 +41,26 @@ class ConfigurationHeuristicTest extends FunSpec with Matchers {
4141
4242 val configurationHeuristic = new ConfigurationHeuristic (heuristicConfigurationData)
4343
44- describe(" . apply" ) {
44+ describe(" apply with NO Severity " ) {
4545 val configurationProperties = Map (
4646 " spark.serializer" -> " org.apache.spark.serializer.KryoSerializer" ,
4747 " spark.storage.memoryFraction" -> " 0.3" ,
4848 " spark.driver.memory" -> " 2G" ,
4949 " spark.executor.instances" -> " 900" ,
5050 " spark.executor.memory" -> " 1g" ,
51- " spark.shuffle.memoryFraction" -> " 0.5"
51+ " spark.shuffle.memoryFraction" -> " 0.5" ,
52+ " spark.shuffle.service.enabled" -> " true" ,
53+ " spark.dynamicAllocation.enabled" -> " true"
5254 )
5355
5456 val data = newFakeSparkApplicationData(configurationProperties)
5557 val heuristicResult = configurationHeuristic.apply(data)
5658 val heuristicResultDetails = heuristicResult.getHeuristicResultDetails
5759
60+ it(" returns the size of result details" ) {
61+ heuristicResultDetails.size() should be(6 )
62+ }
63+
5864 it(" returns the severity" ) {
5965 heuristicResult.getSeverity should be(Severity .NONE )
6066 }
@@ -89,10 +95,50 @@ class ConfigurationHeuristicTest extends FunSpec with Matchers {
8995 details.getValue should include(" 10" )
9096 }
9197
92- it(" returns the serializer" ) {
98+ it(" returns the dynamic allocation flag" ) {
99+ val details = heuristicResultDetails.get(5 )
100+ details.getName should include(" spark.dynamicAllocation.enabled" )
101+ details.getValue should be(" true" )
102+ }
103+ }
104+
105+ describe(" apply with Severity" ) {
106+ val configurationProperties = Map (
107+ " spark.serializer" -> " dummySerializer" ,
108+ " spark.shuffle.service.enabled" -> " false" ,
109+ " spark.dynamicAllocation.enabled" -> " true"
110+ )
111+
112+ val data = newFakeSparkApplicationData(configurationProperties)
113+ val heuristicResult = configurationHeuristic.apply(data)
114+ val heuristicResultDetails = heuristicResult.getHeuristicResultDetails
115+
116+ it(" returns the size of result details" ) {
117+ heuristicResultDetails.size() should be(8 )
118+ }
119+
120+ it(" returns the severity" ) {
121+ heuristicResult.getSeverity should be(Severity .SEVERE )
122+ }
123+
124+ it(" returns the dynamic allocation flag" ) {
93125 val details = heuristicResultDetails.get(5 )
126+ details.getName should include(" spark.dynamicAllocation.enabled" )
127+ details.getValue should be(" true" )
128+ }
129+
130+ it(" returns the serializer" ) {
131+ val details = heuristicResultDetails.get(6 )
94132 details.getName should include(" spark.serializer" )
95- details.getValue should be(" org.apache.spark.serializer.KryoSerializer" )
133+ details.getValue should be(" dummySerializer" )
134+ details.getDetails should be(" KyroSerializer is Not Enabled." )
135+ }
136+
137+ it(" returns the shuffle service flag" ) {
138+ val details = heuristicResultDetails.get(7 )
139+ details.getName should include(" spark.shuffle.service.enabled" )
140+ details.getValue should be(" false" )
141+ details.getDetails should be(" Spark shuffle service is not enabled." )
96142 }
97143 }
98144
@@ -148,34 +194,78 @@ class ConfigurationHeuristicTest extends FunSpec with Matchers {
148194 evaluator.serializer should be(Some (" org.apache.spark.serializer.KryoSerializer" ))
149195 }
150196
151- it(" has no serializer when it's absent" ) {
197+ it(" has no serializer, dynamic allocation flag, and shuffle flag when they are absent" ) {
152198 val evaluator = newEvaluatorWithConfigurationProperties(Map .empty)
153199 evaluator.serializer should be(None )
200+ evaluator.isDynamicAllocationEnabled should be(Some (false ))
201+ evaluator.isShuffleServiceEnabled should be(Some (false ))
202+ evaluator.serializerSeverity should be(Severity .MODERATE )
203+ evaluator.shuffleAndDynamicAllocationSeverity should be(Severity .MODERATE )
204+ evaluator.severity should be(Severity .MODERATE )
154205 }
155206
156- it(" has the severity of the serializer setting when it matches our recommendation" ) {
207+ it(" has no dynamic allocation flag and shuffle flag, and serializer setting matches our recommendation" ) {
157208 val evaluator = newEvaluatorWithConfigurationProperties(Map (" spark.serializer" -> " org.apache.spark.serializer.KryoSerializer" ))
209+ evaluator.serializer should be(Some (" org.apache.spark.serializer.KryoSerializer" ))
210+ evaluator.isDynamicAllocationEnabled should be(Some (false ))
211+ evaluator.isShuffleServiceEnabled should be(Some (false ))
158212 evaluator.serializerSeverity should be(Severity .NONE )
213+ evaluator.shuffleAndDynamicAllocationSeverity should be(Severity .MODERATE )
214+ evaluator.severity should be(Severity .MODERATE )
159215 }
160216
161- it(" has the severity of the serializer setting when it doesn't match our recommendation and is non-null" ) {
217+ it(" has no dynamic allocation flag and shuffle flag, and serializer setting doesn't match our recommendation and is non-null" ) {
162218 val evaluator = newEvaluatorWithConfigurationProperties(Map (" spark.serializer" -> " org.apache.spark.serializer.FooSerializer" ))
219+ evaluator.serializer should be(Some (" org.apache.spark.serializer.FooSerializer" ))
220+ evaluator.isDynamicAllocationEnabled should be(Some (false ))
221+ evaluator.isShuffleServiceEnabled should be(Some (false ))
163222 evaluator.serializerSeverity should be(Severity .MODERATE )
223+ evaluator.shuffleAndDynamicAllocationSeverity should be(Severity .MODERATE )
224+ evaluator.severity should be(Severity .MODERATE )
164225 }
165226
166- it(" has the severity of the serializer setting when it is null" ) {
167- val evaluator = newEvaluatorWithConfigurationProperties(Map .empty)
227+ it(" true dynamic allocation flag and shuffle flag, and serializer setting matches our recommendation" ) {
228+ val evaluator = newEvaluatorWithConfigurationProperties(Map (" spark.serializer" -> " org.apache.spark.serializer.KryoSerializer" ,
229+ " spark.shuffle.service.enabled" -> " true" , " spark.dynamicAllocation.enabled" -> " true" ))
230+ evaluator.serializer should be(Some (" org.apache.spark.serializer.KryoSerializer" ))
231+ evaluator.isDynamicAllocationEnabled should be(Some (true ))
232+ evaluator.isShuffleServiceEnabled should be(Some (true ))
168233 evaluator.serializerSeverity should be(Severity .NONE )
234+ evaluator.shuffleAndDynamicAllocationSeverity should be(Severity .NONE )
235+ evaluator.severity should be(Severity .NONE )
169236 }
170237
171- it(" computes the overall severity when there are some issues" ) {
172- val evaluator = newEvaluatorWithConfigurationProperties(Map (" spark.serializer" -> " org.apache.spark.serializer.FooSerializer" ))
238+ it(" true dynamic allocation flag and shuffle flag, and serializer setting is absent" ) {
239+ val evaluator = newEvaluatorWithConfigurationProperties(Map (" spark.shuffle.service.enabled" -> " true" ,
240+ " spark.dynamicAllocation.enabled" -> " true" ))
241+ evaluator.serializer should be(None )
242+ evaluator.isDynamicAllocationEnabled should be(Some (true ))
243+ evaluator.isShuffleServiceEnabled should be(Some (true ))
244+ evaluator.serializerSeverity should be(Severity .MODERATE )
245+ evaluator.shuffleAndDynamicAllocationSeverity should be(Severity .NONE )
173246 evaluator.severity should be(Severity .MODERATE )
174247 }
175248
176- it(" computes the overall severity when there are no issues" ) {
177- val evaluator = newEvaluatorWithConfigurationProperties(Map .empty)
178- evaluator.severity should be(Severity .NONE )
249+ it(" true dynamic allocation flag and false shuffle flag, and serializer setting matches our recommendation" ) {
250+ val evaluator = newEvaluatorWithConfigurationProperties(Map (" spark.serializer" -> " org.apache.spark.serializer.KryoSerializer" ,
251+ " spark.shuffle.service.enabled" -> " false" , " spark.dynamicAllocation.enabled" -> " true" ))
252+ evaluator.serializer should be(Some (" org.apache.spark.serializer.KryoSerializer" ))
253+ evaluator.isDynamicAllocationEnabled should be(Some (true ))
254+ evaluator.isShuffleServiceEnabled should be(Some (false ))
255+ evaluator.serializerSeverity should be(Severity .NONE )
256+ evaluator.shuffleAndDynamicAllocationSeverity should be(Severity .SEVERE )
257+ evaluator.severity should be(Severity .SEVERE )
258+ }
259+
260+ it(" false dynamic allocation flag and shuffle flag, and serializer setting matches our recommendation" ) {
261+ val evaluator = newEvaluatorWithConfigurationProperties(Map (" spark.serializer" -> " org.apache.spark.serializer.KryoSerializer" ,
262+ " spark.shuffle.service.enabled" -> " false" , " spark.dynamicAllocation.enabled" -> " false" ))
263+ evaluator.serializer should be(Some (" org.apache.spark.serializer.KryoSerializer" ))
264+ evaluator.isDynamicAllocationEnabled should be(Some (false ))
265+ evaluator.isShuffleServiceEnabled should be(Some (false ))
266+ evaluator.serializerSeverity should be(Severity .NONE )
267+ evaluator.shuffleAndDynamicAllocationSeverity should be(Severity .MODERATE )
268+ evaluator.severity should be(Severity .MODERATE )
179269 }
180270 }
181271 }
0 commit comments