1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-20 19:29:10 +00:00

Fix TestListenLocal with new liveness and readiness probes

This commit is contained in:
Matthias Loibl 2019-09-23 19:04:55 +02:00
parent 5eb9cb53db
commit 8011f6364c
No known key found for this signature in database
GPG key ID: 78A796CA74CA38BA

View file

@ -382,12 +382,42 @@ func TestListenLocal(t *testing.T) {
t.Fatal("Prometheus not listening on loopback when it should.")
}
if sset.Spec.Template.Spec.Containers[0].ReadinessProbe != nil {
t.Fatal("Prometheus readiness probe expected to be empty")
actualReadinessProbe := sset.Spec.Template.Spec.Containers[0].ReadinessProbe
expectedReadinessProbe := &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{
`sh`,
`-c`,
`if [ -x "$(command -v curl)" ]; then curl http://localhost:9090/-/ready; elif [ -x "$(command -v wget)" ]; then wget -q http://localhost:9090/-/ready; else exit 1; fi`,
},
},
},
TimeoutSeconds: 3,
PeriodSeconds: 5,
FailureThreshold: 120,
}
if !reflect.DeepEqual(actualReadinessProbe, expectedReadinessProbe) {
t.Fatalf("Readiness probe doesn't match expected. \n\nExpected: %+v\n\nGot: %+v", expectedReadinessProbe, actualReadinessProbe)
}
if sset.Spec.Template.Spec.Containers[0].LivenessProbe != nil {
t.Fatal("Prometheus readiness probe expected to be empty")
actualLivenessProbe := sset.Spec.Template.Spec.Containers[0].LivenessProbe
expectedLivenessProbe := &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{
`sh`,
`-c`,
`if [ -x "$(command -v curl)" ]; then curl http://localhost:9090/-/healthy; elif [ -x "$(command -v wget)" ]; then wget -q http://localhost:9090/-/healthy; else exit 1; fi`,
},
},
},
TimeoutSeconds: 3,
PeriodSeconds: 5,
FailureThreshold: 6,
}
if !reflect.DeepEqual(actualLivenessProbe, expectedLivenessProbe) {
t.Fatalf("Liveness probe doesn't match expected. \n\nExpected: %v\n\nGot: %v", expectedLivenessProbe, actualLivenessProbe)
}
if len(sset.Spec.Template.Spec.Containers[0].Ports) != 0 {