Updating server dependancies (#5249)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
ca3211bc04
Коммит
701d1ab638
68
vendor/github.com/prometheus/common/expfmt/decode_test.go
сгенерированный
поставляемый
68
vendor/github.com/prometheus/common/expfmt/decode_test.go
сгенерированный
поставляемый
@@ -21,6 +21,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
|
||||
"github.com/prometheus/common/model"
|
||||
)
|
||||
|
||||
@@ -365,3 +368,68 @@ func BenchmarkDiscriminatorHTTPHeader(b *testing.B) {
|
||||
testDiscriminatorHTTPHeader(b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractSamples(t *testing.T) {
|
||||
var (
|
||||
goodMetricFamily1 = &dto.MetricFamily{
|
||||
Name: proto.String("foo"),
|
||||
Help: proto.String("Help for foo."),
|
||||
Type: dto.MetricType_COUNTER.Enum(),
|
||||
Metric: []*dto.Metric{
|
||||
&dto.Metric{
|
||||
Counter: &dto.Counter{
|
||||
Value: proto.Float64(4711),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
goodMetricFamily2 = &dto.MetricFamily{
|
||||
Name: proto.String("bar"),
|
||||
Help: proto.String("Help for bar."),
|
||||
Type: dto.MetricType_GAUGE.Enum(),
|
||||
Metric: []*dto.Metric{
|
||||
&dto.Metric{
|
||||
Gauge: &dto.Gauge{
|
||||
Value: proto.Float64(3.14),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
badMetricFamily = &dto.MetricFamily{
|
||||
Name: proto.String("bad"),
|
||||
Help: proto.String("Help for bad."),
|
||||
Type: dto.MetricType(42).Enum(),
|
||||
Metric: []*dto.Metric{
|
||||
&dto.Metric{
|
||||
Gauge: &dto.Gauge{
|
||||
Value: proto.Float64(2.7),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
opts = &DecodeOptions{
|
||||
Timestamp: 42,
|
||||
}
|
||||
)
|
||||
|
||||
got, err := ExtractSamples(opts, goodMetricFamily1, goodMetricFamily2)
|
||||
if err != nil {
|
||||
t.Error("Unexpected error from ExtractSamples:", err)
|
||||
}
|
||||
want := model.Vector{
|
||||
&model.Sample{Metric: model.Metric{model.MetricNameLabel: "foo"}, Value: 4711, Timestamp: 42},
|
||||
&model.Sample{Metric: model.Metric{model.MetricNameLabel: "bar"}, Value: 3.14, Timestamp: 42},
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("unexpected samples extracted, got: %v, want: %v", got, want)
|
||||
}
|
||||
|
||||
got, err = ExtractSamples(opts, goodMetricFamily1, badMetricFamily, goodMetricFamily2)
|
||||
if err == nil {
|
||||
t.Error("Expected error from ExtractSamples")
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("unexpected samples extracted, got: %v, want: %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user