Skip to content

Commit 5400ec2

Browse files
committed
test:e2e: Ensure QueryLogFile is set in spec
1 parent dfca243 commit 5400ec2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: test/e2e/config_test.go

+29
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ func TestClusterMonitorPrometheusK8Config(t *testing.T) {
237237
data := fmt.Sprintf(`prometheusK8s:
238238
logLevel: debug
239239
retention: 10h
240+
queryLogFile: /tmp/test.log
240241
tolerations:
241242
- operator: "Exists"
242243
externalLabels:
@@ -294,6 +295,10 @@ func TestClusterMonitorPrometheusK8Config(t *testing.T) {
294295
name: "assert remote write url value in set in CR",
295296
f: assertRemoteWriteWasSet(f.Ns, crName, "https://test.remotewrite.com/api/write"),
296297
},
298+
{
299+
name: "assert query log file value is set and correct",
300+
f: assertQueryLogWasSet(f.Ns, crName, "/tmp/test.log"),
301+
},
297302
{
298303
name: "assert rule for Thanos sidecar exists",
299304
f: f.AssertPrometheusRuleExists(thanosRule, f.Ns),
@@ -730,6 +735,7 @@ func TestUserWorkloadMonitorPrometheusK8Config(t *testing.T) {
730735
"config.yaml": fmt.Sprintf(`prometheus:
731736
logLevel: debug
732737
retention: 10h
738+
queryLogFile: /tmp/test.log
733739
tolerations:
734740
- operator: "Exists"
735741
externalLabels:
@@ -794,6 +800,10 @@ func TestUserWorkloadMonitorPrometheusK8Config(t *testing.T) {
794800
name: "assert remote write url value in set in CR",
795801
f: assertRemoteWriteWasSet(f.UserWorkloadMonitoringNs, crName, "https://test.remotewrite.com/api/write"),
796802
},
803+
{
804+
name: "assert query log file value is set and correct",
805+
f: assertQueryLogWasSet(f.UserWorkloadMonitoringNs, crName, "/tmp/test.log"),
806+
},
797807
} {
798808
t.Run(scenario.name, scenario.f)
799809
}
@@ -1110,3 +1120,22 @@ func assertRemoteWriteWasSet(namespace, crName, urlValue string) func(t *testing
11101120
}
11111121
}
11121122
}
1123+
1124+
func assertQueryLogWasSet(namespace, crName, value string) func(t *testing.T) {
1125+
return func(t *testing.T) {
1126+
err := framework.Poll(time.Second, time.Minute*5, func() error {
1127+
prom, err := f.MonitoringClient.Prometheuses(namespace).Get(context.Background(), crName, metav1.GetOptions{})
1128+
if err != nil {
1129+
t.Fatal("failed to get required prometheus cr", err)
1130+
}
1131+
1132+
if prom.Spec.QueryLogFile != value {
1133+
return fmt.Errorf("expected query log file value not found")
1134+
}
1135+
return nil
1136+
})
1137+
if err != nil {
1138+
t.Fatal(err)
1139+
}
1140+
}
1141+
}

0 commit comments

Comments
 (0)