Skip to content

Commit ff417fa

Browse files
committed
test:e2e: Ensure QueryLogFile is set in spec
1 parent 49f6afd commit ff417fa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/e2e/config_test.go

+32
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func TestClusterMonitorPrometheusK8Config(t *testing.T) {
151151
data := fmt.Sprintf(`prometheusK8s:
152152
logLevel: debug
153153
retention: 10h
154+
queryLogFile: /tmp/test.log
154155
tolerations:
155156
- operator: "Exists"
156157
externalLabels:
@@ -199,6 +200,10 @@ func TestClusterMonitorPrometheusK8Config(t *testing.T) {
199200
name: "assert remote write url value in set in CR",
200201
assertion: assertRemoteWriteWasSet(f.Ns, crName, "https://test.remotewrite.com/api/write"),
201202
},
203+
{
204+
name: "assert query log file value is set and correct",
205+
assertion: assertQueryLogValueEquals(f.Ns, crName, "/tmp/test.log"),
206+
},
202207
{
203208
name: "assert rule for Thanos sidecar exists",
204209
assertion: f.AssertPrometheusRuleExists(thanosRule, f.Ns),
@@ -523,6 +528,7 @@ func TestUserWorkloadMonitorPrometheusK8Config(t *testing.T) {
523528
enforcedTargetLimit: 10
524529
logLevel: debug
525530
retention: 10h
531+
queryLogFile: /tmp/test.log
526532
tolerations:
527533
- operator: "Exists"
528534
externalLabels:
@@ -577,6 +583,10 @@ func TestUserWorkloadMonitorPrometheusK8Config(t *testing.T) {
577583
name: "assert enforced target limit is configured",
578584
assertion: assertEnforcedTargetLimit(10),
579585
},
586+
{
587+
name: "assert query log file value is set and correct",
588+
assertion: assertQueryLogValueEquals(f.UserWorkloadMonitoringNs, crName, "/tmp/test.log"),
589+
},
580590
} {
581591
t.Run(tc.name, tc.assertion)
582592
}
@@ -813,3 +823,25 @@ func assertEnforcedTargetLimit(limit uint64) func(*testing.T) {
813823
}
814824
}
815825
}
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

Comments
 (0)