Skip to content

Commit d439c18

Browse files
committed
chore(extended/prometheus): make test more lenient
1 parent 2af38a7 commit d439c18

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/extended/prometheus/prometheus.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,18 @@ var _ = g.Describe("[sig-instrumentation][Late] Platform Prometheus targets", fu
111111
o.Expect(err).NotTo(o.HaveOccurred())
112112
o.Expect(len(targets.Data.ActiveTargets)).Should(o.BeNumerically(">=", 5))
113113

114-
expected := sets.New[int](http.StatusUnauthorized, http.StatusForbidden)
114+
expected := sets.New(http.StatusUnauthorized, http.StatusForbidden)
115115
for _, target := range targets.Data.ActiveTargets {
116116
ns := target.Labels["namespace"]
117117
o.Expect(ns).NotTo(o.BeEmpty())
118118
if monitoringAuthTestNamespace != "" && ns != monitoringAuthTestNamespace {
119119
continue
120120
}
121+
job := target.Labels["job"]
121122
pod := target.Labels["pod"]
122-
e2e.Logf("Checking via pod exec status code from the scrape url %s for pod %s/%s without authorization (skip=%t)", target.ScrapeUrl, ns, pod, namespacesToSkip.Has(ns))
123-
err := wait.PollUntilContextTimeout(context.Background(), 10*time.Second, time.Minute, true, func(context.Context) (bool, error) {
123+
err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, time.Minute, true, func(context.Context) (bool, error) {
124124
statusCode, execError := helper.URLStatusCodeExecViaPod(execPod.Namespace, execPod.Name, target.ScrapeUrl)
125-
e2e.Logf("The scrape url %s for pod %s/%s without authorization returned %d, %v (skip=%t)", target.ScrapeUrl, ns, pod, statusCode, execError, namespacesToSkip.Has(ns))
125+
e2e.Logf("Scraping target %s of pod %s/%s/%s without auth returned %d, err: %v (skip=%t)", target.ScrapeUrl, ns, job, pod, statusCode, execError, namespacesToSkip.Has(ns))
126126
if expected.Has(statusCode) {
127127
return true, nil
128128
}
@@ -135,8 +135,10 @@ var _ = g.Describe("[sig-instrumentation][Late] Platform Prometheus targets", fu
135135
}
136136
return false, fmt.Errorf("expecting status code %v but returned %d", expected.UnsortedList(), statusCode)
137137
})
138-
if err != nil && !namespacesToSkip.Has(ns) {
139-
errs = append(errs, fmt.Errorf("the scrape url %s for pod %s/%s is accessible without authorization: %w", target.ScrapeUrl, ns, pod, err))
138+
// Decided to ignore targets that Prometheus itself failed to scrape; may be leftovers from earlier tests.
139+
// See: https://issues.redhat.com/browse/OCPBUGS-61193
140+
if err != nil && target.Health == "up" && !namespacesToSkip.Has(ns) {
141+
errs = append(errs, fmt.Errorf("Scraping target %s of pod %s/%s/%s is possible without auth: %w", target.ScrapeUrl, ns, job, pod, err))
140142
}
141143
}
142144

0 commit comments

Comments
 (0)