mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
Fix tests.
This commit is contained in:
parent
06dc1e8797
commit
9811e90d65
|
@ -19,6 +19,7 @@ import (
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"github.com/prometheus/prometheus/config"
|
"github.com/prometheus/prometheus/config"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
)
|
)
|
||||||
|
@ -126,6 +127,7 @@ func TestEndpointsDiscoveryAdd(t *testing.T) {
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "testpod",
|
Name: "testpod",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
|
UID: types.UID("deadbeef"),
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
NodeName: "testnode",
|
NodeName: "testnode",
|
||||||
|
@ -210,6 +212,7 @@ func TestEndpointsDiscoveryAdd(t *testing.T) {
|
||||||
"__meta_kubernetes_pod_container_port_name": "mainport",
|
"__meta_kubernetes_pod_container_port_name": "mainport",
|
||||||
"__meta_kubernetes_pod_container_port_number": "9000",
|
"__meta_kubernetes_pod_container_port_number": "9000",
|
||||||
"__meta_kubernetes_pod_container_port_protocol": "TCP",
|
"__meta_kubernetes_pod_container_port_protocol": "TCP",
|
||||||
|
"__meta_kubernetes_pod_uid": "deadbeef",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__address__": "1.2.3.4:9001",
|
"__address__": "1.2.3.4:9001",
|
||||||
|
@ -222,6 +225,7 @@ func TestEndpointsDiscoveryAdd(t *testing.T) {
|
||||||
"__meta_kubernetes_pod_container_port_name": "sideport",
|
"__meta_kubernetes_pod_container_port_name": "sideport",
|
||||||
"__meta_kubernetes_pod_container_port_number": "9001",
|
"__meta_kubernetes_pod_container_port_number": "9001",
|
||||||
"__meta_kubernetes_pod_container_port_protocol": "TCP",
|
"__meta_kubernetes_pod_container_port_protocol": "TCP",
|
||||||
|
"__meta_kubernetes_pod_uid": "deadbeef",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Labels: model.LabelSet{
|
Labels: model.LabelSet{
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"github.com/prometheus/prometheus/config"
|
"github.com/prometheus/prometheus/config"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
)
|
)
|
||||||
|
@ -43,6 +44,7 @@ func makeMultiPortPod() *v1.Pod {
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Labels: map[string]string{"testlabel": "testvalue"},
|
Labels: map[string]string{"testlabel": "testvalue"},
|
||||||
Annotations: map[string]string{"testannotation": "testannotationvalue"},
|
Annotations: map[string]string{"testannotation": "testannotationvalue"},
|
||||||
|
UID: types.UID("abc123"),
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
NodeName: "testnode",
|
NodeName: "testnode",
|
||||||
|
@ -85,6 +87,7 @@ func makePod() *v1.Pod {
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "testpod",
|
Name: "testpod",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
|
UID: types.UID("abc123"),
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
NodeName: "testnode",
|
NodeName: "testnode",
|
||||||
|
@ -151,6 +154,7 @@ func TestPodDiscoveryInitial(t *testing.T) {
|
||||||
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
||||||
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
||||||
"__meta_kubernetes_pod_ready": "true",
|
"__meta_kubernetes_pod_ready": "true",
|
||||||
|
"__meta_kubernetes_pod_uid": "abc123",
|
||||||
},
|
},
|
||||||
Source: "pod/default/testpod",
|
Source: "pod/default/testpod",
|
||||||
},
|
},
|
||||||
|
@ -182,6 +186,7 @@ func TestPodDiscoveryAdd(t *testing.T) {
|
||||||
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
||||||
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
||||||
"__meta_kubernetes_pod_ready": "true",
|
"__meta_kubernetes_pod_ready": "true",
|
||||||
|
"__meta_kubernetes_pod_uid": "abc123",
|
||||||
},
|
},
|
||||||
Source: "pod/default/testpod",
|
Source: "pod/default/testpod",
|
||||||
},
|
},
|
||||||
|
@ -214,6 +219,7 @@ func TestPodDiscoveryDelete(t *testing.T) {
|
||||||
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
||||||
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
||||||
"__meta_kubernetes_pod_ready": "true",
|
"__meta_kubernetes_pod_ready": "true",
|
||||||
|
"__meta_kubernetes_pod_uid": "abc123",
|
||||||
},
|
},
|
||||||
Source: "pod/default/testpod",
|
Source: "pod/default/testpod",
|
||||||
},
|
},
|
||||||
|
@ -251,6 +257,7 @@ func TestPodDiscoveryDeleteUnknownCacheState(t *testing.T) {
|
||||||
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
||||||
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
||||||
"__meta_kubernetes_pod_ready": "true",
|
"__meta_kubernetes_pod_ready": "true",
|
||||||
|
"__meta_kubernetes_pod_uid": "abc123",
|
||||||
},
|
},
|
||||||
Source: "pod/default/testpod",
|
Source: "pod/default/testpod",
|
||||||
},
|
},
|
||||||
|
@ -312,6 +319,7 @@ func TestPodDiscoveryUpdate(t *testing.T) {
|
||||||
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
||||||
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
||||||
"__meta_kubernetes_pod_ready": "unknown",
|
"__meta_kubernetes_pod_ready": "unknown",
|
||||||
|
"__meta_kubernetes_pod_uid": "",
|
||||||
},
|
},
|
||||||
Source: "pod/default/testpod",
|
Source: "pod/default/testpod",
|
||||||
},
|
},
|
||||||
|
@ -334,6 +342,7 @@ func TestPodDiscoveryUpdate(t *testing.T) {
|
||||||
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
||||||
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
||||||
"__meta_kubernetes_pod_ready": "true",
|
"__meta_kubernetes_pod_ready": "true",
|
||||||
|
"__meta_kubernetes_pod_uid": "abc123",
|
||||||
},
|
},
|
||||||
Source: "pod/default/testpod",
|
Source: "pod/default/testpod",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue