@@ -151,6 +151,7 @@ func TestClusterMonitorPrometheusK8Config(t *testing.T) {
151
151
data := fmt .Sprintf (`prometheusK8s:
152
152
logLevel: debug
153
153
retention: 10h
154
+ queryLogFile: /tmp/test.log
154
155
tolerations:
155
156
- operator: "Exists"
156
157
externalLabels:
@@ -199,6 +200,10 @@ func TestClusterMonitorPrometheusK8Config(t *testing.T) {
199
200
name : "assert remote write url value in set in CR" ,
200
201
assertion : assertRemoteWriteWasSet (f .Ns , crName , "https://test.remotewrite.com/api/write" ),
201
202
},
203
+ {
204
+ name : "assert query log file value is set and correct" ,
205
+ assertion : assertQueryLogValueEquals (f .Ns , crName , "/tmp/test.log" ),
206
+ },
202
207
{
203
208
name : "assert rule for Thanos sidecar exists" ,
204
209
assertion : f .AssertPrometheusRuleExists (thanosRule , f .Ns ),
@@ -523,6 +528,7 @@ func TestUserWorkloadMonitorPrometheusK8Config(t *testing.T) {
523
528
enforcedTargetLimit: 10
524
529
logLevel: debug
525
530
retention: 10h
531
+ queryLogFile: /tmp/test.log
526
532
tolerations:
527
533
- operator: "Exists"
528
534
externalLabels:
@@ -577,6 +583,10 @@ func TestUserWorkloadMonitorPrometheusK8Config(t *testing.T) {
577
583
name : "assert enforced target limit is configured" ,
578
584
assertion : assertEnforcedTargetLimit (10 ),
579
585
},
586
+ {
587
+ name : "assert query log file value is set and correct" ,
588
+ assertion : assertQueryLogValueEquals (f .UserWorkloadMonitoringNs , crName , "/tmp/test.log" ),
589
+ },
580
590
} {
581
591
t .Run (tc .name , tc .assertion )
582
592
}
@@ -813,3 +823,25 @@ func assertEnforcedTargetLimit(limit uint64) func(*testing.T) {
813
823
}
814
824
}
815
825
}
826
+
827
+ func assertQueryLogValueEquals (namespace , crName , value string ) func (t * testing.T ) {
828
+ return func (t * testing.T ) {
829
+ err := framework .Poll (time .Second , time .Minute * 5 , func () error {
830
+ prom , err := f .MonitoringClient .Prometheuses (namespace ).Get (context .Background (), crName , metav1.GetOptions {})
831
+ if err != nil {
832
+ t .Fatal ("failed to get required prometheus cr" , err )
833
+ }
834
+
835
+ if prom .Spec .QueryLogFile != value {
836
+ return fmt .Errorf (
837
+ "expected query log file value not found wanted '%s', got '%s'" ,
838
+ value , prom .Spec .QueryLogFile ,
839
+ )
840
+ }
841
+ return nil
842
+ })
843
+ if err != nil {
844
+ t .Fatal (err )
845
+ }
846
+ }
847
+ }
0 commit comments