Files
my-rook-config/pkg/operator/k8sutil/prometheus_test.go
T
Redouane Kachach daec93eaaa monitoring: increasing metrics scraping interval from 5s to 10s
let's increase the monitoring interval to match the default interval
used by Prometheus when deployed by Ceph: 10s

Closes: https://github.com/rook/rook/issues/13883

Signed-off-by: Redouane Kachach <rkachach@redhat.com>
2024-03-13 13:29:01 +01:00

41 lines
1.4 KiB
Go

/*
Copyright 2020 The Rook Authors. All rights reserved.
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 k8sutil for Kubernetes helpers.
package k8sutil
import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/stretchr/testify/assert"
"testing"
)
func TestGetServiceMonitor(t *testing.T) {
name := "rook-ceph-mgr"
namespace := "rook-ceph"
port := "http-metrics"
interval := monitoringv1.Duration("10s")
servicemonitor := GetServiceMonitor(name, namespace, port)
assert.Equal(t, name, servicemonitor.GetName())
assert.Equal(t, namespace, servicemonitor.GetNamespace())
assert.Equal(t, port, servicemonitor.Spec.Endpoints[0].Port)
assert.Equal(t, interval, servicemonitor.Spec.Endpoints[0].Interval)
assert.NotNil(t, servicemonitor.GetLabels())
assert.NotNil(t, servicemonitor.Spec.NamespaceSelector.MatchNames)
assert.NotNil(t, servicemonitor.Spec.Selector.MatchLabels)
assert.NotNil(t, servicemonitor.Spec.Endpoints)
}