@@ -56,30 +56,30 @@ func TestConfigPrometheusMonitoring(t *testing.T) {
56
56
err = fakeClient .Get (context .TODO (), client .ObjectKeyFromObject (configMap ), configMap )
57
57
assert .NoError (t , err , "failed to get ConfigMap %s" , configMapName )
58
58
59
- if test .app .Spec .Monitoring .Prometheus .ConfigFile == nil &&
59
+ if test .app .Spec .Monitoring .Prometheus != nil && test . app . Spec . Monitoring . Prometheus .ConfigFile == nil &&
60
60
test .app .Spec .Monitoring .MetricsPropertiesFile == nil {
61
61
assert .Len (t , configMap .Data , 2 , "expected 2 data items" )
62
62
}
63
63
64
- if test .app .Spec .Monitoring .Prometheus .ConfigFile != nil &&
64
+ if test .app .Spec .Monitoring .Prometheus != nil && test . app . Spec . Monitoring . Prometheus .ConfigFile != nil &&
65
65
test .app .Spec .Monitoring .MetricsPropertiesFile == nil {
66
66
assert .Len (t , configMap .Data , 1 , "expected 1 data item" )
67
67
}
68
68
69
- if test .app .Spec .Monitoring .Prometheus .ConfigFile == nil &&
69
+ if test .app .Spec .Monitoring .Prometheus != nil && test . app . Spec . Monitoring . Prometheus .ConfigFile == nil &&
70
70
test .app .Spec .Monitoring .MetricsPropertiesFile != nil {
71
71
assert .Len (t , configMap .Data , 1 , "expected 1 data item" )
72
72
}
73
73
74
- if test .app .Spec .Monitoring .MetricsPropertiesFile == nil {
74
+ if test .app .Spec .Monitoring .Prometheus != nil && test . app . Spec . Monitoring . MetricsPropertiesFile == nil {
75
75
assert .Equal (t , test .metricsProperties , configMap .Data [common .MetricsPropertiesKey ], "metrics.properties mismatch" )
76
76
}
77
77
78
- if test .app .Spec .Monitoring .Prometheus .ConfigFile == nil {
78
+ if test .app .Spec .Monitoring .Prometheus != nil && test . app . Spec . Monitoring . Prometheus .ConfigFile == nil {
79
79
assert .Equal (t , test .prometheusConfig , configMap .Data [common .PrometheusConfigKey ], "prometheus.yaml mismatch" )
80
80
}
81
81
82
- if test .app .Spec .Monitoring .ExposeDriverMetrics {
82
+ if test .app .Spec .Monitoring .Prometheus != nil && test . app . Spec . Monitoring . ExposeDriverMetrics {
83
83
assert .Len (t , test .app .Spec .Driver .Annotations , 3 , "expected 3 driver annotations" )
84
84
assert .Equal (t , test .port , test .app .Spec .Driver .Annotations [common .PrometheusPortAnnotation ], "java agent port mismatch" )
85
85
assert .Equal (t , test .driverJavaOptions , * test .app .Spec .Driver .JavaOptions , "driver Java options mismatch" )
@@ -309,6 +309,32 @@ func TestConfigPrometheusMonitoring(t *testing.T) {
309
309
driverJavaOptions : "-javaagent:/prometheus/exporter.jar=1000:/etc/metrics/conf/prometheus.yaml" ,
310
310
executorJavaOptions : "-javaagent:/prometheus/exporter.jar=1000:/etc/metrics/conf/prometheus.yaml" ,
311
311
},
312
+ {
313
+ app : & v1beta2.SparkApplication {
314
+ ObjectMeta : metav1.ObjectMeta {
315
+ Name : "app2" ,
316
+ Namespace : "default" ,
317
+ },
318
+ Spec : v1beta2.SparkApplicationSpec {
319
+ Driver : v1beta2.DriverSpec {
320
+ JavaOptions : util .StringPtr ("-XX:+PrintGCDetails -XX:+PrintGCTimeStamps" ),
321
+ },
322
+ Executor : v1beta2.ExecutorSpec {
323
+ JavaOptions : util .StringPtr ("-XX:+PrintGCDetails -XX:+PrintGCTimeStamps" ),
324
+ },
325
+ Monitoring : & v1beta2.MonitoringSpec {
326
+ ExposeDriverMetrics : false ,
327
+ ExposeExecutorMetrics : false ,
328
+ MetricsProperties : util .StringPtr ("testcase2dummy" ),
329
+ },
330
+ },
331
+ },
332
+ metricsProperties : "testcase2dummy" ,
333
+ prometheusConfig : "" ,
334
+ port : "8090" ,
335
+ driverJavaOptions : "-XX:+PrintGCDetails -XX:+PrintGCTimeStamps " ,
336
+ executorJavaOptions : "-XX:+PrintGCDetails -XX:+PrintGCTimeStamps " ,
337
+ },
312
338
}
313
339
314
340
for _ , test := range testcases {
0 commit comments