|
|
@ -14,9 +14,10 @@ |
|
|
|
package tsdb |
|
|
|
package tsdb |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
prom_testutil "github.com/prometheus/client_golang/prometheus/testutil" |
|
|
|
|
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prom_testutil "github.com/prometheus/client_golang/prometheus/testutil" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/prometheus/prometheus/tsdb/chunkenc" |
|
|
|
"github.com/prometheus/prometheus/tsdb/chunkenc" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require" |
|
|
|
"github.com/stretchr/testify/require" |
|
|
@ -55,50 +56,50 @@ var sampleTypeScenarios = map[string]sampleTypeScenario{ |
|
|
|
return sample{t: ts, f: float64(value)} |
|
|
|
return sample{t: ts, f: float64(value)} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
//intHistogram: {
|
|
|
|
// intHistogram: {
|
|
|
|
// sampleType: sampleMetricTypeHistogram,
|
|
|
|
// sampleType: sampleMetricTypeHistogram,
|
|
|
|
// appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) {
|
|
|
|
// appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) {
|
|
|
|
// s := sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))}
|
|
|
|
// s := sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))}
|
|
|
|
// ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil)
|
|
|
|
// ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil)
|
|
|
|
// return ref, s, err
|
|
|
|
// return ref, s, err
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// sampleFunc: func(ts, value int64) sample {
|
|
|
|
// sampleFunc: func(ts, value int64) sample {
|
|
|
|
// return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))}
|
|
|
|
// return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))}
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
//},
|
|
|
|
// },
|
|
|
|
//floatHistogram: {
|
|
|
|
// floatHistogram: {
|
|
|
|
// sampleType: sampleMetricTypeHistogram,
|
|
|
|
// sampleType: sampleMetricTypeHistogram,
|
|
|
|
// appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) {
|
|
|
|
// appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) {
|
|
|
|
// s := sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))}
|
|
|
|
// s := sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))}
|
|
|
|
// ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh)
|
|
|
|
// ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh)
|
|
|
|
// return ref, s, err
|
|
|
|
// return ref, s, err
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// sampleFunc: func(ts, value int64) sample {
|
|
|
|
// sampleFunc: func(ts, value int64) sample {
|
|
|
|
// return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))}
|
|
|
|
// return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))}
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
//},
|
|
|
|
// },
|
|
|
|
//gaugeIntHistogram: {
|
|
|
|
// gaugeIntHistogram: {
|
|
|
|
// sampleType: sampleMetricTypeHistogram,
|
|
|
|
// sampleType: sampleMetricTypeHistogram,
|
|
|
|
// appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) {
|
|
|
|
// appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) {
|
|
|
|
// s := sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(int(value))}
|
|
|
|
// s := sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(int(value))}
|
|
|
|
// ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil)
|
|
|
|
// ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil)
|
|
|
|
// return ref, s, err
|
|
|
|
// return ref, s, err
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// sampleFunc: func(ts, value int64) sample {
|
|
|
|
// sampleFunc: func(ts, value int64) sample {
|
|
|
|
// return sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(int(value))}
|
|
|
|
// return sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(int(value))}
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
//},
|
|
|
|
// },
|
|
|
|
//gaugeFloatHistogram: {
|
|
|
|
// gaugeFloatHistogram: {
|
|
|
|
// sampleType: sampleMetricTypeHistogram,
|
|
|
|
// sampleType: sampleMetricTypeHistogram,
|
|
|
|
// appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) {
|
|
|
|
// appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) {
|
|
|
|
// s := sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(int(value))}
|
|
|
|
// s := sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(int(value))}
|
|
|
|
// ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh)
|
|
|
|
// ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh)
|
|
|
|
// return ref, s, err
|
|
|
|
// return ref, s, err
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// sampleFunc: func(ts, value int64) sample {
|
|
|
|
// sampleFunc: func(ts, value int64) sample {
|
|
|
|
// return sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(int(value))}
|
|
|
|
// return sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(int(value))}
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
//},
|
|
|
|
// },
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// requireEqualSamples checks that the actual series are equal to the expected ones. It ignores the counter reset hints for histograms.
|
|
|
|
// requireEqualSamples checks that the actual series are equal to the expected ones. It ignores the counter reset hints for histograms.
|
|
|
|