diff --git a/tests/libmonitoring/metric_matcher.go b/tests/libmonitoring/metric_matcher.go index 415cc175c620..40a1e38e2fb4 100644 --- a/tests/libmonitoring/metric_matcher.go +++ b/tests/libmonitoring/metric_matcher.go @@ -1,3 +1,19 @@ +/* +Copyright The KubeVirt Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package libmonitoring import ( @@ -9,7 +25,7 @@ import ( const ( prometheusMetricNameLabel = "__name__" - prometheusHistogramBucketPrefix = "_bucket" + prometheusHistogramBucketSuffix = "_bucket" ) type MetricMatcher struct { @@ -50,17 +66,13 @@ func (matcher *MetricMatcher) Match(actual interface{}) (success bool, err error nameToMatch := matcher.Metric.GetOpts().Name if matcher.Metric.GetType() == operatormetrics.HistogramType || matcher.Metric.GetType() == operatormetrics.HistogramVecType { - nameToMatch = nameToMatch + prometheusHistogramBucketPrefix + nameToMatch = nameToMatch + prometheusHistogramBucketSuffix } if actualName != nameToMatch { return false, nil } - if matcher.Labels == nil { - return true, nil - } - for k, v := range matcher.Labels { actualValue, ok := actualMetric.Metric[k] if !ok { diff --git a/tests/libmonitoring/prometheus.go b/tests/libmonitoring/prometheus.go index 68bfc4574958..9cc442c217f8 100644 --- a/tests/libmonitoring/prometheus.go +++ b/tests/libmonitoring/prometheus.go @@ -79,7 +79,7 @@ func WaitForMetricValueWithLabels(client kubecli.KubevirtClient, metric string, return -1 } return i - }, 5*time.Minute, 1*time.Second).Should(BeNumerically("==", expectedValue)) + }, 3*time.Minute, 1*time.Second).Should(BeNumerically("==", expectedValue)) } func GetMetricValueWithLabels(cli kubecli.KubevirtClient, query string, labels map[string]string) (float64, error) { diff --git a/tests/monitoring/metrics.go b/tests/monitoring/metrics.go index a6925dd6e391..a400f30e39cc 100644 --- a/tests/monitoring/metrics.go +++ b/tests/monitoring/metrics.go @@ -1,3 +1,19 @@ +/* +Copyright The KubeVirt Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package monitoring import ( @@ -29,7 +45,6 @@ import ( ) var _ = Describe("[sig-monitoring]Metrics", decorators.SigMonitoring, func() { - var err error var virtClient kubecli.KubevirtClient var metrics *libmonitoring.QueryRequestResult @@ -61,7 +76,7 @@ var _ = Describe("[sig-monitoring]Metrics", decorators.SigMonitoring, func() { It("should contain virt components metrics", func() { metrics = fetchPrometheusMetrics(virtClient) - err = virtoperator.SetupMetrics() + err := virtoperator.SetupMetrics() Expect(err).ToNot(HaveOccurred()) err = virtapi.SetupMetrics()