mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Revert change to model/textparse/protobufparse_test.go
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
This commit is contained in:
parent
dfabc69303
commit
e9b2d87443
|
@ -15,6 +15,7 @@ package textparse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -25,9 +26,8 @@ import (
|
||||||
"github.com/prometheus/prometheus/model/exemplar"
|
"github.com/prometheus/prometheus/model/exemplar"
|
||||||
"github.com/prometheus/prometheus/model/histogram"
|
"github.com/prometheus/prometheus/model/histogram"
|
||||||
"github.com/prometheus/prometheus/model/labels"
|
"github.com/prometheus/prometheus/model/labels"
|
||||||
"github.com/prometheus/prometheus/util/testutil"
|
|
||||||
|
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/prometheus/prompb/io/prometheus/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProtobufParse(t *testing.T) {
|
func TestProtobufParse(t *testing.T) {
|
||||||
|
@ -449,6 +449,7 @@ metric: <
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
varintBuf := make([]byte, binary.MaxVarintLen32)
|
||||||
inputBuf := &bytes.Buffer{}
|
inputBuf := &bytes.Buffer{}
|
||||||
|
|
||||||
for _, tmf := range textMetricFamilies {
|
for _, tmf := range textMetricFamilies {
|
||||||
|
@ -456,8 +457,13 @@ metric: <
|
||||||
// From text to proto message.
|
// From text to proto message.
|
||||||
require.NoError(t, proto.UnmarshalText(tmf, pb))
|
require.NoError(t, proto.UnmarshalText(tmf, pb))
|
||||||
// From proto message to binary protobuf.
|
// From proto message to binary protobuf.
|
||||||
err := testutil.AddMetricFamilyToProtobuf(inputBuf, pb)
|
protoBuf, err := proto.Marshal(pb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Write first length, then binary protobuf.
|
||||||
|
varintLength := binary.PutUvarint(varintBuf, uint64(len(protoBuf)))
|
||||||
|
inputBuf.Write(varintBuf[:varintLength])
|
||||||
|
inputBuf.Write(protoBuf)
|
||||||
}
|
}
|
||||||
|
|
||||||
exp := []struct {
|
exp := []struct {
|
||||||
|
|
Loading…
Reference in a new issue