Files
my-rook-config/pkg/operator/k8sutil/prometheus_test.go
T
Divyansh Kamboj b17df46f5e monitoring: set port for servicemonitor for ceph-exporter
ceph-exporter's ServiceMonitor and Service CRD contain different port
name, which results in no metrics being collected by prometheus.

this commit makes GetCephMonitor configurable, which we use to set
consistent port names in ServiceMonitor and Service for ceph-exporter.

Signed-off-by: Divyansh Kamboj <dkamboj@redhat.com>
(cherry picked from commit 708dd29a97)
2023-09-01 17:59:33 +00:00

39 lines
1.2 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 (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetServiceMonitor(t *testing.T) {
name := "rook-ceph-mgr"
namespace := "rook-ceph"
port := "http-metrics"
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.NotNil(t, servicemonitor.GetLabels())
assert.NotNil(t, servicemonitor.Spec.NamespaceSelector.MatchNames)
assert.NotNil(t, servicemonitor.Spec.Selector.MatchLabels)
assert.NotNil(t, servicemonitor.Spec.Endpoints)
}