Revert "Fix tests to adhere to the recent change in prometheus/common"
This reverts commit 2c9811f88e
.
This is necessary because the changes in prometheus/common got reverted.
Signed-off-by: beorn7 <beorn@soundcloud.com>
This commit is contained in:
parent
3c4408c8b8
commit
8785922956
|
@ -109,11 +109,11 @@ error collecting metric Desc{fqName: "invalid_metric", help: "not helpful", cons
|
||||||
`
|
`
|
||||||
wantOKBody := `# HELP name docstring
|
wantOKBody := `# HELP name docstring
|
||||||
# TYPE name counter
|
# TYPE name counter
|
||||||
name{constname="constvalue",labelname="val1"} 1.0
|
name{constname="constvalue",labelname="val1"} 1
|
||||||
name{constname="constvalue",labelname="val2"} 1.0
|
name{constname="constvalue",labelname="val2"} 1
|
||||||
# HELP the_count Ah-ah-ah! Thunder and lightning!
|
# HELP the_count Ah-ah-ah! Thunder and lightning!
|
||||||
# TYPE the_count counter
|
# TYPE the_count counter
|
||||||
the_count 0.0
|
the_count 0
|
||||||
`
|
`
|
||||||
|
|
||||||
errorHandler.ServeHTTP(writer, request)
|
errorHandler.ServeHTTP(writer, request)
|
||||||
|
@ -163,11 +163,11 @@ func TestInstrumentMetricHandler(t *testing.T) {
|
||||||
t.Errorf("got HTTP status code %d, want %d", got, want)
|
t.Errorf("got HTTP status code %d, want %d", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
want := "promhttp_metric_handler_requests_in_flight 1.0\n"
|
want := "promhttp_metric_handler_requests_in_flight 1\n"
|
||||||
if got := writer.Body.String(); !strings.Contains(got, want) {
|
if got := writer.Body.String(); !strings.Contains(got, want) {
|
||||||
t.Errorf("got body %q, does not contain %q", got, want)
|
t.Errorf("got body %q, does not contain %q", got, want)
|
||||||
}
|
}
|
||||||
want = "promhttp_metric_handler_requests_total{code=\"200\"} 0.0\n"
|
want = "promhttp_metric_handler_requests_total{code=\"200\"} 0\n"
|
||||||
if got := writer.Body.String(); !strings.Contains(got, want) {
|
if got := writer.Body.String(); !strings.Contains(got, want) {
|
||||||
t.Errorf("got body %q, does not contain %q", got, want)
|
t.Errorf("got body %q, does not contain %q", got, want)
|
||||||
}
|
}
|
||||||
|
@ -178,11 +178,11 @@ func TestInstrumentMetricHandler(t *testing.T) {
|
||||||
t.Errorf("got HTTP status code %d, want %d", got, want)
|
t.Errorf("got HTTP status code %d, want %d", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
want = "promhttp_metric_handler_requests_in_flight 1.0\n"
|
want = "promhttp_metric_handler_requests_in_flight 1\n"
|
||||||
if got := writer.Body.String(); !strings.Contains(got, want) {
|
if got := writer.Body.String(); !strings.Contains(got, want) {
|
||||||
t.Errorf("got body %q, does not contain %q", got, want)
|
t.Errorf("got body %q, does not contain %q", got, want)
|
||||||
}
|
}
|
||||||
want = "promhttp_metric_handler_requests_total{code=\"200\"} 1.0\n"
|
want = "promhttp_metric_handler_requests_total{code=\"200\"} 1\n"
|
||||||
if got := writer.Body.String(); !strings.Contains(got, want) {
|
if got := writer.Body.String(); !strings.Contains(got, want) {
|
||||||
t.Errorf("got body %q, does not contain %q", got, want)
|
t.Errorf("got body %q, does not contain %q", got, want)
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ func testHandler(t testing.TB) {
|
||||||
externalMetricFamilyAsBytes := externalBuf.Bytes()
|
externalMetricFamilyAsBytes := externalBuf.Bytes()
|
||||||
externalMetricFamilyAsText := []byte(`# HELP externalname externaldocstring
|
externalMetricFamilyAsText := []byte(`# HELP externalname externaldocstring
|
||||||
# TYPE externalname counter
|
# TYPE externalname counter
|
||||||
externalname{externalconstname="externalconstvalue",externallabelname="externalval1"} 1.0
|
externalname{externalconstname="externalconstvalue",externallabelname="externalval1"} 1
|
||||||
`)
|
`)
|
||||||
externalMetricFamilyAsProtoText := []byte(`name: "externalname"
|
externalMetricFamilyAsProtoText := []byte(`name: "externalname"
|
||||||
help: "externaldocstring"
|
help: "externaldocstring"
|
||||||
|
@ -167,8 +167,8 @@ metric: <
|
||||||
expectedMetricFamilyAsBytes := buf.Bytes()
|
expectedMetricFamilyAsBytes := buf.Bytes()
|
||||||
expectedMetricFamilyAsText := []byte(`# HELP name docstring
|
expectedMetricFamilyAsText := []byte(`# HELP name docstring
|
||||||
# TYPE name counter
|
# TYPE name counter
|
||||||
name{constname="constvalue",labelname="val1"} 1.0
|
name{constname="constvalue",labelname="val1"} 1
|
||||||
name{constname="constvalue",labelname="val2"} 1.0
|
name{constname="constvalue",labelname="val2"} 1
|
||||||
`)
|
`)
|
||||||
expectedMetricFamilyAsProtoText := []byte(`name: "name"
|
expectedMetricFamilyAsProtoText := []byte(`name: "name"
|
||||||
help: "docstring"
|
help: "docstring"
|
||||||
|
@ -267,8 +267,8 @@ collected metric "name" { label:<name:"constname" value:"\377" > label:<name:"la
|
||||||
complex{quantile="0.5"} NaN
|
complex{quantile="0.5"} NaN
|
||||||
complex{quantile="0.9"} NaN
|
complex{quantile="0.9"} NaN
|
||||||
complex{quantile="0.99"} NaN
|
complex{quantile="0.99"} NaN
|
||||||
complex_sum 0.0
|
complex_sum 0
|
||||||
complex_count 0.0
|
complex_count 0
|
||||||
`)
|
`)
|
||||||
histogram := prometheus.NewHistogram(prometheus.HistogramOpts{
|
histogram := prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||||
Name: "complex",
|
Name: "complex",
|
||||||
|
@ -288,7 +288,7 @@ complex_count 0.0
|
||||||
}
|
}
|
||||||
externalMetricFamilyWithBucketSuffixAsText := []byte(`# HELP complex_bucket externaldocstring
|
externalMetricFamilyWithBucketSuffixAsText := []byte(`# HELP complex_bucket externaldocstring
|
||||||
# TYPE complex_bucket counter
|
# TYPE complex_bucket counter
|
||||||
complex_bucket 1.0
|
complex_bucket 1
|
||||||
`)
|
`)
|
||||||
externalMetricFamilyWithCountSuffix := &dto.MetricFamily{
|
externalMetricFamilyWithCountSuffix := &dto.MetricFamily{
|
||||||
Name: proto.String("complex_count"),
|
Name: proto.String("complex_count"),
|
||||||
|
@ -883,33 +883,33 @@ func TestHistogramVecRegisterGatherConcurrency(t *testing.T) {
|
||||||
func TestWriteToTextfile(t *testing.T) {
|
func TestWriteToTextfile(t *testing.T) {
|
||||||
expectedOut := `# HELP test_counter test counter
|
expectedOut := `# HELP test_counter test counter
|
||||||
# TYPE test_counter counter
|
# TYPE test_counter counter
|
||||||
test_counter{name="qux"} 1.0
|
test_counter{name="qux"} 1
|
||||||
# HELP test_gauge test gauge
|
# HELP test_gauge test gauge
|
||||||
# TYPE test_gauge gauge
|
# TYPE test_gauge gauge
|
||||||
test_gauge{name="baz"} 1.1
|
test_gauge{name="baz"} 1.1
|
||||||
# HELP test_hist test histogram
|
# HELP test_hist test histogram
|
||||||
# TYPE test_hist histogram
|
# TYPE test_hist histogram
|
||||||
test_hist_bucket{name="bar",le="0.005"} 0.0
|
test_hist_bucket{name="bar",le="0.005"} 0
|
||||||
test_hist_bucket{name="bar",le="0.01"} 0.0
|
test_hist_bucket{name="bar",le="0.01"} 0
|
||||||
test_hist_bucket{name="bar",le="0.025"} 0.0
|
test_hist_bucket{name="bar",le="0.025"} 0
|
||||||
test_hist_bucket{name="bar",le="0.05"} 0.0
|
test_hist_bucket{name="bar",le="0.05"} 0
|
||||||
test_hist_bucket{name="bar",le="0.1"} 0.0
|
test_hist_bucket{name="bar",le="0.1"} 0
|
||||||
test_hist_bucket{name="bar",le="0.25"} 0.0
|
test_hist_bucket{name="bar",le="0.25"} 0
|
||||||
test_hist_bucket{name="bar",le="0.5"} 0.0
|
test_hist_bucket{name="bar",le="0.5"} 0
|
||||||
test_hist_bucket{name="bar",le="1.0"} 1.0
|
test_hist_bucket{name="bar",le="1"} 1
|
||||||
test_hist_bucket{name="bar",le="2.5"} 1.0
|
test_hist_bucket{name="bar",le="2.5"} 1
|
||||||
test_hist_bucket{name="bar",le="5.0"} 2.0
|
test_hist_bucket{name="bar",le="5"} 2
|
||||||
test_hist_bucket{name="bar",le="10.0"} 2.0
|
test_hist_bucket{name="bar",le="10"} 2
|
||||||
test_hist_bucket{name="bar",le="+Inf"} 2.0
|
test_hist_bucket{name="bar",le="+Inf"} 2
|
||||||
test_hist_sum{name="bar"} 3.64
|
test_hist_sum{name="bar"} 3.64
|
||||||
test_hist_count{name="bar"} 2.0
|
test_hist_count{name="bar"} 2
|
||||||
# HELP test_summary test summary
|
# HELP test_summary test summary
|
||||||
# TYPE test_summary summary
|
# TYPE test_summary summary
|
||||||
test_summary{name="foo",quantile="0.5"} 10.0
|
test_summary{name="foo",quantile="0.5"} 10
|
||||||
test_summary{name="foo",quantile="0.9"} 20.0
|
test_summary{name="foo",quantile="0.9"} 20
|
||||||
test_summary{name="foo",quantile="0.99"} 20.0
|
test_summary{name="foo",quantile="0.99"} 20
|
||||||
test_summary_sum{name="foo"} 30.0
|
test_summary_sum{name="foo"} 30
|
||||||
test_summary_count{name="foo"} 2.0
|
test_summary_count{name="foo"} 2
|
||||||
`
|
`
|
||||||
|
|
||||||
registry := prometheus.NewRegistry()
|
registry := prometheus.NewRegistry()
|
||||||
|
@ -975,6 +975,6 @@ test_summary_count{name="foo"} 2.0
|
||||||
fileContents := string(fileBytes)
|
fileContents := string(fileBytes)
|
||||||
|
|
||||||
if fileContents != expectedOut {
|
if fileContents != expectedOut {
|
||||||
t.Error("file contents didn't match expected result")
|
t.Error("file contents didn't match unexpected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ func TestCollectAndCompare(t *testing.T) {
|
||||||
|
|
||||||
expected := `
|
expected := `
|
||||||
|
|
||||||
some_total{ label1 = "value1" } 1.0
|
some_total{ label1 = "value1" } 1
|
||||||
`
|
`
|
||||||
|
|
||||||
if err := CollectAndCompare(c, strings.NewReader(metadata+expected), "some_total"); err != nil {
|
if err := CollectAndCompare(c, strings.NewReader(metadata+expected), "some_total"); err != nil {
|
||||||
|
@ -157,7 +157,7 @@ func TestCollectAndCompareNoLabel(t *testing.T) {
|
||||||
|
|
||||||
expected := `
|
expected := `
|
||||||
|
|
||||||
some_total 1.0
|
some_total 1
|
||||||
`
|
`
|
||||||
|
|
||||||
if err := CollectAndCompare(c, strings.NewReader(metadata+expected), "some_total"); err != nil {
|
if err := CollectAndCompare(c, strings.NewReader(metadata+expected), "some_total"); err != nil {
|
||||||
|
@ -185,10 +185,10 @@ func TestCollectAndCompareHistogram(t *testing.T) {
|
||||||
# TYPE some_histogram histogram
|
# TYPE some_histogram histogram
|
||||||
`,
|
`,
|
||||||
expect: `
|
expect: `
|
||||||
some_histogram{le="1"} 0.0
|
some_histogram{le="1"} 0
|
||||||
some_histogram{le="2"} 0.0
|
some_histogram{le="2"} 0
|
||||||
some_histogram{le="3"} 1.0
|
some_histogram{le="3"} 1
|
||||||
some_histogram_bucket{le="+Inf"} 1.0
|
some_histogram_bucket{le="+Inf"} 1
|
||||||
some_histogram_sum 2.5
|
some_histogram_sum 2.5
|
||||||
some_histogram_count 1
|
some_histogram_count 1
|
||||||
|
|
||||||
|
@ -208,12 +208,12 @@ func TestCollectAndCompareHistogram(t *testing.T) {
|
||||||
# TYPE some_histogram histogram
|
# TYPE some_histogram histogram
|
||||||
`,
|
`,
|
||||||
expect: `
|
expect: `
|
||||||
some_histogram_bucket{test="test",le="1"} 0.0
|
some_histogram_bucket{test="test",le="1"} 0
|
||||||
some_histogram_bucket{test="test",le="2"} 0.0
|
some_histogram_bucket{test="test",le="2"} 0
|
||||||
some_histogram_bucket{test="test",le="3"} 1.0
|
some_histogram_bucket{test="test",le="3"} 1
|
||||||
some_histogram_bucket{test="test",le="+Inf"} 1.0
|
some_histogram_bucket{test="test",le="+Inf"} 1
|
||||||
some_histogram_sum{test="test"} 2.5
|
some_histogram_sum{test="test"} 2.5
|
||||||
some_histogram_count{test="test"} 1.0
|
some_histogram_count{test="test"} 1
|
||||||
|
|
||||||
`,
|
`,
|
||||||
observation: 2.5,
|
observation: 2.5,
|
||||||
|
@ -256,7 +256,7 @@ func TestNoMetricFilter(t *testing.T) {
|
||||||
c.Inc()
|
c.Inc()
|
||||||
|
|
||||||
expected := `
|
expected := `
|
||||||
some_total{label1="value1"} 1.0
|
some_total{label1="value1"} 1
|
||||||
`
|
`
|
||||||
|
|
||||||
if err := CollectAndCompare(c, strings.NewReader(metadata+expected)); err != nil {
|
if err := CollectAndCompare(c, strings.NewReader(metadata+expected)); err != nil {
|
||||||
|
@ -280,7 +280,7 @@ func TestMetricNotFound(t *testing.T) {
|
||||||
c.Inc()
|
c.Inc()
|
||||||
|
|
||||||
expected := `
|
expected := `
|
||||||
some_other_metric{label1="value1"} 1.0
|
some_other_metric{label1="value1"} 1
|
||||||
`
|
`
|
||||||
|
|
||||||
expectedError := `
|
expectedError := `
|
||||||
|
@ -288,13 +288,13 @@ metric output does not match expectation; want:
|
||||||
|
|
||||||
# HELP some_other_metric A value that represents a counter.
|
# HELP some_other_metric A value that represents a counter.
|
||||||
# TYPE some_other_metric counter
|
# TYPE some_other_metric counter
|
||||||
some_other_metric{label1="value1"} 1.0
|
some_other_metric{label1="value1"} 1
|
||||||
|
|
||||||
got:
|
got:
|
||||||
|
|
||||||
# HELP some_total A value that represents a counter.
|
# HELP some_total A value that represents a counter.
|
||||||
# TYPE some_total counter
|
# TYPE some_total counter
|
||||||
some_total{label1="value1"} 1.0
|
some_total{label1="value1"} 1
|
||||||
`
|
`
|
||||||
|
|
||||||
err := CollectAndCompare(c, strings.NewReader(metadata+expected))
|
err := CollectAndCompare(c, strings.NewReader(metadata+expected))
|
||||||
|
|
Loading…
Reference in New Issue