Skip to content

Commit 6cd13ed

Browse files
committed
NO-JIRA: fix TestPrometheusRemoteWrite to align the image used for the remote write receiver with k8s'
instead of the operator's upstream default image This broke once prometheus-operator's default image is a prom 3 see openshift/prometheus-operator#321 (comment)
1 parent 67ef637 commit 6cd13ed

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

test/e2e/framework/prometheus.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"k8s.io/apimachinery/pkg/util/intstr"
3333
)
3434

35-
func (f Framework) MakePrometheusWithWebTLSRemoteReceive(name, tlsSecretName string) *monitoringv1.Prometheus {
35+
func (f Framework) MakePrometheusWithWebTLSRemoteReceive(name, tlsSecretName string, image *string) *monitoringv1.Prometheus {
3636
// This is not required in the Prometheus spec, but we inspect that value in
3737
// WaitForPrometheus. Omitting it causes this code to derefence a nil.
3838
replicas := int32(1)
@@ -47,6 +47,7 @@ func (f Framework) MakePrometheusWithWebTLSRemoteReceive(name, tlsSecretName str
4747
},
4848
Spec: monitoringv1.PrometheusSpec{
4949
CommonPrometheusFields: monitoringv1.CommonPrometheusFields{
50+
Image: image,
5051
Replicas: &replicas,
5152
ServiceAccountName: "prometheus-k8s",
5253
Secrets: []string{tlsSecretName},

test/e2e/prometheus_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ type remoteWriteTest struct {
123123
func TestPrometheusRemoteWrite(t *testing.T) {
124124
ctx := context.Background()
125125

126+
// Get the Prometheus image to use, use the same than k8s's.
127+
k8sProm, err := f.MonitoringClient.Prometheuses(f.Ns).Get(ctx, "k8s", metav1.GetOptions{})
128+
if err != nil {
129+
t.Fatal(err)
130+
}
131+
image := k8sProm.Spec.Image
132+
126133
name := "rwe2e"
127134

128135
// deploy a service for our remote write target
@@ -291,7 +298,7 @@ func TestPrometheusRemoteWrite(t *testing.T) {
291298

292299
t.Run(tc.name, func(t *testing.T) {
293300
// deploy remote write target
294-
prometheusReceiver := f.MakePrometheusWithWebTLSRemoteReceive(name, secName)
301+
prometheusReceiver := f.MakePrometheusWithWebTLSRemoteReceive(name, secName, image)
295302
if err := f.OperatorClient.CreateOrUpdatePrometheus(ctx, prometheusReceiver); err != nil {
296303
t.Fatal(err)
297304
}

0 commit comments

Comments
 (0)