tests/e2e: Add e2e test to make sure all deprecated metrics are being

dropped
This commit is contained in:
Lili Cosic
2020-01-06 17:33:50 +01:00
parent 6562b02da8
commit 1af59f3130
2 changed files with 67 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ package e2e
import (
"log"
"os"
"strings"
"testing"
"time"
@@ -57,7 +58,6 @@ func testMain(m *testing.M) int {
}
func TestQueryPrometheus(t *testing.T) {
t.Parallel()
queries := []struct {
query string
expectN int
@@ -72,8 +72,8 @@ func TestQueryPrometheus(t *testing.T) {
query: `up{job="apiserver"} == 1`,
expectN: 1,
}, {
query: `up{job="kube-state-metrics"} == 1`,
expectN: 1,
query: `up{job="kube-state-metrics"} == 1`,
expectN: 1,
}, {
query: `up{job="prometheus-k8s"} == 1`,
expectN: 1,
@@ -116,3 +116,25 @@ func TestQueryPrometheus(t *testing.T) {
t.Fatal(err)
}
}
func TestDroppedMetrics(t *testing.T) {
// query metadata for all metrics and their metadata
md, err := promClient.metadata("{job=~\".+\"}")
if err != nil {
log.Fatal(err)
}
for _, k := range md.Data {
// check if the metric' help text contains Deprecated
if strings.Contains(k.Help, "Deprecated") {
// query prometheus for the Deprecated metric
n, err := promClient.query(k.Metric)
if err != nil {
log.Fatal(err)
}
if n > 0 {
t.Fatalf("deprecated metric with name: %s and help text: %s exists.", k.Metric, k.Help)
}
}
}
}