Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Brouwer <[email protected]>
  • Loading branch information
rickbrouwer committed Nov 26, 2024
1 parent 3a7c955 commit 812e8ce
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions tests/sequential/prometheus_metrics/prometheus_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,28 +608,20 @@ func testScalerErrors(t *testing.T, data templateData) {
KubectlApplyWithTemplate(t, data, "wrongScaledJobTemplate", wrongScaledJobTemplate)

family := fetchAndParsePrometheusMetrics(t, fmt.Sprintf("curl --insecure %s", kedaOperatorPrometheusURL))
val, ok := family["keda_scaler_errors_total"]
assert.True(t, ok, "keda_scaler_errors_total not available")
valDetail, okDetail := family["keda_scaler_detail_errors_total"]
assert.True(t, okDetail, "keda_scaler_detail_errors_total not available")
if ok && okDetail {
errCounterVal1 := getErrorMetricsValue(val)
if okDetail {
errCounterValDetail1 := getErrorMetricsValue(valDetail)

// wait for 20 seconds to correctly fetch metrics.
time.Sleep(20 * time.Second)

family = fetchAndParsePrometheusMetrics(t, fmt.Sprintf("curl --insecure %s", kedaOperatorPrometheusURL))
val, ok := family["keda_scaler_errors_total"]
assert.True(t, ok, "keda_scaler_errors_total not available")
valDetail, okDetail := family["keda_scaler_detail_errors_total"]
assert.True(t, okDetail, "keda_scaler_detail_errors_total not available")
if ok && okDetail {
errCounterVal2 := getErrorMetricsValue(val)
if okDetail {
errCounterValDetail2 := getErrorMetricsValue(valDetail)
assert.NotEqual(t, errCounterVal2, float64(0))
assert.NotEqual(t, errCounterValDetail2, float64(0))
assert.GreaterOrEqual(t, errCounterVal2, errCounterVal1)
assert.GreaterOrEqual(t, errCounterValDetail2, errCounterValDetail1)
}
}
Expand Down Expand Up @@ -716,24 +708,6 @@ func testScalerMetricLatency(t *testing.T) {

family := fetchAndParsePrometheusMetrics(t, fmt.Sprintf("curl --insecure %s", kedaOperatorPrometheusURL))

val, ok := family["keda_scaler_metrics_latency"]
assert.True(t, ok, "keda_scaler_metrics_latency not available")
if ok {
var found bool
metrics := val.GetMetric()
for _, metric := range metrics {
labels := metric.GetLabel()
for _, label := range labels {
if (*label.Name == labelScaledObject && *label.Value == scaledObjectName) ||
(*label.Name == labelScaledJob && *label.Value == scaledJobName) {
assert.Equal(t, float64(0), *metric.Gauge.Value)
found = true
}
}
}
assert.Equal(t, true, found)
}

val, ok = family["keda_scaler_metrics_latency_seconds"]

Check failure on line 711 in tests/sequential/prometheus_metrics/prometheus_metrics_test.go

View workflow job for this annotation

GitHub Actions / Static Checks

undefined: val

Check failure on line 711 in tests/sequential/prometheus_metrics/prometheus_metrics_test.go

View workflow job for this annotation

GitHub Actions / Static Checks

undefined: ok
assert.True(t, ok, "keda_scaler_metrics_latency_seconds not available")

Check failure on line 712 in tests/sequential/prometheus_metrics/prometheus_metrics_test.go

View workflow job for this annotation

GitHub Actions / Static Checks

undefined: ok
if ok {

Check failure on line 713 in tests/sequential/prometheus_metrics/prometheus_metrics_test.go

View workflow job for this annotation

GitHub Actions / Static Checks

undefined: ok
Expand Down

0 comments on commit 812e8ce

Please sign in to comment.