1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 19:49:46 +00:00

prometheus: add test for label propagation

This commit is contained in:
Frederic Branczyk 2017-01-19 11:02:12 +01:00
parent 9545b98bcc
commit 3f42845b99
No known key found for this signature in database
GPG key ID: CA14788B1E48B256
2 changed files with 44 additions and 4 deletions

View file

@ -1,15 +1,25 @@
all: build
REPO?=quay.io/coreos/prometheus-operator
TAG?=$(shell git rev-parse --short HEAD)
NAMESPACE?=prometheus-operator-e2e-tests-$(shell LC_CTYPE=C tr -dc a-z0-9 < /dev/urandom | head -c 13 ; echo '')
CLUSTER_IP?=$(shell minikube ip)
pkgs = $(shell go list ./... | grep -v /vendor/ | grep -v /test/)
all: check-license format build test
build:
./scripts/check_license.sh
go build github.com/coreos/prometheus-operator/cmd/operator
test:
@go test -short $(pkgs)
format:
go fmt $(pkgs)
check-license:
./scripts/check_license.sh
container:
GOOS=linux $(MAKE) build
docker build -t $(REPO):$(TAG) .
@ -28,4 +38,4 @@ clean-e2e:
kubectl -n $(NAMESPACE) delete prometheus,alertmanager,servicemonitor,statefulsets,deploy,svc,endpoints,pods,cm --all
kubectl delete namespace $(NAMESPACE)
.PHONY: all build container e2e clean-e2e
.PHONY: all build test format check-license container e2e-test e2e-status e2e clean-e2e

View file

@ -0,0 +1,30 @@
package prometheus
import (
"reflect"
"testing"
"k8s.io/client-go/pkg/api/v1"
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1alpha1"
)
func TestStatefulSetLabelingAndAnnotations(t *testing.T) {
labels := map[string]string{
"testlabel": "testlabelvalue",
}
annotations := map[string]string{
"testannotation": "testannotationvalue",
}
sset := makeStatefulSet(v1alpha1.Prometheus{
ObjectMeta: v1.ObjectMeta{
Labels: labels,
Annotations: annotations,
},
}, nil)
if !reflect.DeepEqual(labels, sset.Labels) || !reflect.DeepEqual(annotations, sset.Annotations) {
t.Fatal("Labels or Annotations are not properly being propagated to the StatefulSet")
}
}