mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Add test for unregistering queue manager metrics
Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
This commit is contained in:
parent
dfad1da296
commit
c1f9917e90
|
@ -22,6 +22,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -31,6 +32,7 @@ import (
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/golang/snappy"
|
"github.com/golang/snappy"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
client_testutil "github.com/prometheus/client_golang/prometheus/testutil"
|
client_testutil "github.com/prometheus/client_golang/prometheus/testutil"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"github.com/prometheus/prometheus/config"
|
"github.com/prometheus/prometheus/config"
|
||||||
|
@ -685,3 +687,19 @@ func TestCalculateDesiredShards(t *testing.T) {
|
||||||
}
|
}
|
||||||
testutil.Assert(t, pendingSamples == 0, "Remote write never caught up, there are still %d pending samples.", pendingSamples)
|
testutil.Assert(t, pendingSamples == 0, "Remote write never caught up, there are still %d pending samples.", pendingSamples)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestQueueManagerMetrics(t *testing.T) {
|
||||||
|
reg := prometheus.NewPedanticRegistry()
|
||||||
|
metrics := newQueueManagerMetrics(reg, "name", "http://localhost:1234")
|
||||||
|
|
||||||
|
// Make sure metrics pass linting.
|
||||||
|
problems, err := client_testutil.GatherAndLint(reg)
|
||||||
|
testutil.Ok(t, err)
|
||||||
|
testutil.Equals(t, 0, len(problems), "Metric linting problems detected: %v", problems)
|
||||||
|
|
||||||
|
// Make sure all metrics were unregistered. A failure here means you need
|
||||||
|
// unregister a metric in `queueManagerMetrics.unregister()`.
|
||||||
|
metrics.unregister()
|
||||||
|
err = client_testutil.GatherAndCompare(reg, strings.NewReader(""))
|
||||||
|
testutil.Ok(t, err)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue