mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Weed out our homegrown test.Tester.
The Go stdlib has testing.TB now, which fulfills the exact same purpose. Change-Id: I0db9c73400e208ca376b932a02b7e3402234b87c
This commit is contained in:
parent
23255f1499
commit
ca6a4fccef
|
@ -14,10 +14,11 @@
|
||||||
package retrieval
|
package retrieval
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prometheus/prometheus/utility"
|
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/prometheus/prometheus/utility"
|
||||||
|
"github.com/prometheus/prometheus/utility/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
type fakeHealthReporter struct {
|
type fakeHealthReporter struct {
|
||||||
|
@ -33,7 +34,7 @@ func (h fakeHealthReporter) State() (state TargetState) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func testHealthScheduler(t test.Tester) {
|
func testHealthScheduler(t testing.TB) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
var scenarios = []struct {
|
var scenarios = []struct {
|
||||||
futureHealthState []TargetState
|
futureHealthState []TargetState
|
||||||
|
|
|
@ -26,7 +26,6 @@ import (
|
||||||
pb "github.com/prometheus/prometheus/config/generated"
|
pb "github.com/prometheus/prometheus/config/generated"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/config"
|
"github.com/prometheus/prometheus/config"
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type fakeTarget struct {
|
type fakeTarget struct {
|
||||||
|
@ -77,7 +76,7 @@ func (t *fakeTarget) Merge(newTarget Target) {}
|
||||||
|
|
||||||
func (t *fakeTarget) EstimatedTimeToExecute() time.Duration { return 0 }
|
func (t *fakeTarget) EstimatedTimeToExecute() time.Duration { return 0 }
|
||||||
|
|
||||||
func testTargetManager(t test.Tester) {
|
func testTargetManager(t testing.TB) {
|
||||||
targetManager := NewTargetManager(nopIngester{}, 3)
|
targetManager := NewTargetManager(nopIngester{}, 3)
|
||||||
testJob1 := config.JobConfig{
|
testJob1 := config.JobConfig{
|
||||||
JobConfig: pb.JobConfig{
|
JobConfig: pb.JobConfig{
|
||||||
|
|
|
@ -17,11 +17,9 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func testTargetPool(t test.Tester) {
|
func testTargetPool(t testing.TB) {
|
||||||
type expectation struct {
|
type expectation struct {
|
||||||
size int
|
size int
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ func (t testTieredStorageCloser) Close() {
|
||||||
|
|
||||||
// This is copied from storage/metric/helpers_test.go, which is unfortunate but
|
// This is copied from storage/metric/helpers_test.go, which is unfortunate but
|
||||||
// presently required to make things work.
|
// presently required to make things work.
|
||||||
func NewTestTieredStorage(t test.Tester) (storage *tiered.TieredStorage, closer test.Closer) {
|
func NewTestTieredStorage(t testing.TB) (storage *tiered.TieredStorage, closer test.Closer) {
|
||||||
var directory test.TemporaryDirectory
|
var directory test.TemporaryDirectory
|
||||||
directory = test.NewTemporaryDirectory("test_tiered_storage", t)
|
directory = test.NewTemporaryDirectory("test_tiered_storage", t)
|
||||||
storage, err := tiered.NewTieredStorage(2500, 1000, 5*time.Second, 0*time.Second, directory.Path())
|
storage, err := tiered.NewTieredStorage(2500, 1000, 5*time.Second, 0*time.Second, directory.Path())
|
||||||
|
@ -91,7 +91,7 @@ func NewTestTieredStorage(t test.Tester) (storage *tiered.TieredStorage, closer
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestStorage(t test.Tester) (storage *tiered.TieredStorage, closer test.Closer) {
|
func newTestStorage(t testing.TB) (storage *tiered.TieredStorage, closer test.Closer) {
|
||||||
storage, closer = NewTestTieredStorage(t)
|
storage, closer = NewTestTieredStorage(t)
|
||||||
if storage == nil {
|
if storage == nil {
|
||||||
t.Fatal("storage == nil")
|
t.Fatal("storage == nil")
|
||||||
|
|
|
@ -16,11 +16,9 @@ package metric
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func testLabelPairs(t test.Tester) {
|
func testLabelPairs(t testing.TB) {
|
||||||
var scenarios = []struct {
|
var scenarios = []struct {
|
||||||
in LabelPairs
|
in LabelPairs
|
||||||
out LabelPairs
|
out LabelPairs
|
||||||
|
|
|
@ -21,10 +21,9 @@ import (
|
||||||
clientmodel "github.com/prometheus/client_golang/model"
|
clientmodel "github.com/prometheus/client_golang/model"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/storage/metric"
|
"github.com/prometheus/prometheus/storage/metric"
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetFingerprintsForLabelSetTests(p metric.Persistence, t test.Tester) {
|
func GetFingerprintsForLabelSetTests(p metric.Persistence, t testing.TB) {
|
||||||
metrics := []clientmodel.Metric{
|
metrics := []clientmodel.Metric{
|
||||||
{
|
{
|
||||||
clientmodel.MetricNameLabel: "test_metric",
|
clientmodel.MetricNameLabel: "test_metric",
|
||||||
|
@ -153,7 +152,7 @@ func GetFingerprintsForLabelSetTests(p metric.Persistence, t test.Tester) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetLabelValuesForLabelNameTests(p metric.Persistence, t test.Tester) {
|
func GetLabelValuesForLabelNameTests(p metric.Persistence, t testing.TB) {
|
||||||
testAppendSamples(p, &clientmodel.Sample{
|
testAppendSamples(p, &clientmodel.Sample{
|
||||||
Value: 0,
|
Value: 0,
|
||||||
Timestamp: 0,
|
Timestamp: 0,
|
||||||
|
@ -197,7 +196,7 @@ func GetLabelValuesForLabelNameTests(p metric.Persistence, t test.Tester) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMetricForFingerprintTests(p metric.Persistence, t test.Tester) {
|
func GetMetricForFingerprintTests(p metric.Persistence, t testing.TB) {
|
||||||
testAppendSamples(p, &clientmodel.Sample{
|
testAppendSamples(p, &clientmodel.Sample{
|
||||||
Value: 0,
|
Value: 0,
|
||||||
Timestamp: 0,
|
Timestamp: 0,
|
||||||
|
@ -308,7 +307,7 @@ func GetMetricForFingerprintTests(p metric.Persistence, t test.Tester) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendRepeatingValuesTests(p metric.Persistence, t test.Tester) {
|
func AppendRepeatingValuesTests(p metric.Persistence, t testing.TB) {
|
||||||
m := clientmodel.Metric{
|
m := clientmodel.Metric{
|
||||||
clientmodel.MetricNameLabel: "errors_total",
|
clientmodel.MetricNameLabel: "errors_total",
|
||||||
"controller": "foo",
|
"controller": "foo",
|
||||||
|
@ -368,7 +367,7 @@ func AppendRepeatingValuesTests(p metric.Persistence, t test.Tester) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendsRepeatingValuesTests(p metric.Persistence, t test.Tester) {
|
func AppendsRepeatingValuesTests(p metric.Persistence, t testing.TB) {
|
||||||
m := clientmodel.Metric{
|
m := clientmodel.Metric{
|
||||||
clientmodel.MetricNameLabel: "errors_total",
|
clientmodel.MetricNameLabel: "errors_total",
|
||||||
"controller": "foo",
|
"controller": "foo",
|
||||||
|
|
|
@ -15,6 +15,7 @@ package tiered
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
clientmodel "github.com/prometheus/client_golang/model"
|
clientmodel "github.com/prometheus/client_golang/model"
|
||||||
|
@ -29,14 +30,14 @@ var (
|
||||||
testInstant = clientmodel.TimestampFromTime(time.Date(1972, 7, 18, 19, 5, 45, 0, usEastern).In(time.UTC))
|
testInstant = clientmodel.TimestampFromTime(time.Date(1972, 7, 18, 19, 5, 45, 0, usEastern).In(time.UTC))
|
||||||
)
|
)
|
||||||
|
|
||||||
func testAppendSamples(p metric.Persistence, s *clientmodel.Sample, t test.Tester) {
|
func testAppendSamples(p metric.Persistence, s *clientmodel.Sample, t testing.TB) {
|
||||||
err := p.AppendSamples(clientmodel.Samples{s})
|
err := p.AppendSamples(clientmodel.Samples{s})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildLevelDBTestPersistencesMaker(name string, t test.Tester) func() (metric.Persistence, test.Closer) {
|
func buildLevelDBTestPersistencesMaker(name string, t testing.TB) func() (metric.Persistence, test.Closer) {
|
||||||
return func() (metric.Persistence, test.Closer) {
|
return func() (metric.Persistence, test.Closer) {
|
||||||
temporaryDirectory := test.NewTemporaryDirectory("get_value_at_time", t)
|
temporaryDirectory := test.NewTemporaryDirectory("get_value_at_time", t)
|
||||||
|
|
||||||
|
@ -49,8 +50,8 @@ func buildLevelDBTestPersistencesMaker(name string, t test.Tester) func() (metri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildLevelDBTestPersistence(name string, f func(p metric.Persistence, t test.Tester)) func(t test.Tester) {
|
func buildLevelDBTestPersistence(name string, f func(p metric.Persistence, t testing.TB)) func(t testing.TB) {
|
||||||
return func(t test.Tester) {
|
return func(t testing.TB) {
|
||||||
|
|
||||||
temporaryDirectory := test.NewTemporaryDirectory(fmt.Sprintf("test_leveldb_%s", name), t)
|
temporaryDirectory := test.NewTemporaryDirectory(fmt.Sprintf("test_leveldb_%s", name), t)
|
||||||
defer temporaryDirectory.Close()
|
defer temporaryDirectory.Close()
|
||||||
|
@ -67,8 +68,8 @@ func buildLevelDBTestPersistence(name string, f func(p metric.Persistence, t tes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildMemoryTestPersistence(f func(p metric.Persistence, t test.Tester)) func(t test.Tester) {
|
func buildMemoryTestPersistence(f func(p metric.Persistence, t testing.TB)) func(t testing.TB) {
|
||||||
return func(t test.Tester) {
|
return func(t testing.TB) {
|
||||||
|
|
||||||
p := NewMemorySeriesStorage(MemorySeriesOptions{})
|
p := NewMemorySeriesStorage(MemorySeriesOptions{})
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ func (t *testTieredStorageCloser) Close() {
|
||||||
t.directory.Close()
|
t.directory.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTestTieredStorage(t test.Tester) (*TieredStorage, test.Closer) {
|
func NewTestTieredStorage(t testing.TB) (*TieredStorage, test.Closer) {
|
||||||
directory := test.NewTemporaryDirectory("test_tiered_storage", t)
|
directory := test.NewTemporaryDirectory("test_tiered_storage", t)
|
||||||
storage, err := NewTieredStorage(2500, 1000, 5*time.Second, 0, directory.Path())
|
storage, err := NewTieredStorage(2500, 1000, 5*time.Second, 0, directory.Path())
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,9 @@ import (
|
||||||
clientmodel "github.com/prometheus/client_golang/model"
|
clientmodel "github.com/prometheus/client_golang/model"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/storage/metric"
|
"github.com/prometheus/prometheus/storage/metric"
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetFingerprintsForLabelSetUsesAndForLabelMatchingTests(p metric.Persistence, t test.Tester) {
|
func GetFingerprintsForLabelSetUsesAndForLabelMatchingTests(p metric.Persistence, t testing.TB) {
|
||||||
metrics := []clientmodel.LabelSet{
|
metrics := []clientmodel.LabelSet{
|
||||||
{clientmodel.MetricNameLabel: "request_metrics_latency_equal_tallying_microseconds", "instance": "http://localhost:9090/metrics.json", "percentile": "0.010000"},
|
{clientmodel.MetricNameLabel: "request_metrics_latency_equal_tallying_microseconds", "instance": "http://localhost:9090/metrics.json", "percentile": "0.010000"},
|
||||||
{clientmodel.MetricNameLabel: "requests_metrics_latency_equal_accumulating_microseconds", "instance": "http://localhost:9090/metrics.json", "percentile": "0.010000"},
|
{clientmodel.MetricNameLabel: "requests_metrics_latency_equal_accumulating_microseconds", "instance": "http://localhost:9090/metrics.json", "percentile": "0.010000"},
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
"github.com/prometheus/prometheus/utility/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetValueAtTimeTests(persistenceMaker func() (metric.ViewablePersistence, test.Closer), t test.Tester) {
|
func GetValueAtTimeTests(persistenceMaker func() (metric.ViewablePersistence, test.Closer), t testing.TB) {
|
||||||
type value struct {
|
type value struct {
|
||||||
year int
|
year int
|
||||||
month time.Month
|
month time.Month
|
||||||
|
@ -356,7 +356,7 @@ func GetValueAtTimeTests(persistenceMaker func() (metric.ViewablePersistence, te
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRangeValuesTests(persistenceMaker func() (metric.ViewablePersistence, test.Closer), onlyBoundaries bool, t test.Tester) {
|
func GetRangeValuesTests(persistenceMaker func() (metric.ViewablePersistence, test.Closer), onlyBoundaries bool, t testing.TB) {
|
||||||
type value struct {
|
type value struct {
|
||||||
year int
|
year int
|
||||||
month time.Month
|
month time.Month
|
||||||
|
@ -899,7 +899,7 @@ func GetRangeValuesTests(persistenceMaker func() (metric.ViewablePersistence, te
|
||||||
|
|
||||||
// Test Definitions Follow
|
// Test Definitions Follow
|
||||||
|
|
||||||
func testMemoryGetValueAtTime(t test.Tester) {
|
func testMemoryGetValueAtTime(t testing.TB) {
|
||||||
persistenceMaker := func() (metric.ViewablePersistence, test.Closer) {
|
persistenceMaker := func() (metric.ViewablePersistence, test.Closer) {
|
||||||
return NewMemorySeriesStorage(MemorySeriesOptions{}), test.NilCloser
|
return NewMemorySeriesStorage(MemorySeriesOptions{}), test.NilCloser
|
||||||
}
|
}
|
||||||
|
@ -927,7 +927,7 @@ func BenchmarkMemoryGetBoundaryValues(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMemoryGetRangeValues(t test.Tester) {
|
func testMemoryGetRangeValues(t testing.TB) {
|
||||||
persistenceMaker := func() (metric.ViewablePersistence, test.Closer) {
|
persistenceMaker := func() (metric.ViewablePersistence, test.Closer) {
|
||||||
return NewMemorySeriesStorage(MemorySeriesOptions{}), test.NilCloser
|
return NewMemorySeriesStorage(MemorySeriesOptions{}), test.NilCloser
|
||||||
}
|
}
|
||||||
|
@ -935,7 +935,7 @@ func testMemoryGetRangeValues(t test.Tester) {
|
||||||
GetRangeValuesTests(persistenceMaker, false, t)
|
GetRangeValuesTests(persistenceMaker, false, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMemoryGetBoundaryValues(t test.Tester) {
|
func testMemoryGetBoundaryValues(t testing.TB) {
|
||||||
persistenceMaker := func() (metric.ViewablePersistence, test.Closer) {
|
persistenceMaker := func() (metric.ViewablePersistence, test.Closer) {
|
||||||
return NewMemorySeriesStorage(MemorySeriesOptions{}), test.NilCloser
|
return NewMemorySeriesStorage(MemorySeriesOptions{}), test.NilCloser
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ import (
|
||||||
|
|
||||||
const stochasticMaximumVariance = 8
|
const stochasticMaximumVariance = 8
|
||||||
|
|
||||||
func BasicLifecycleTests(p metric.Persistence, t test.Tester) {
|
func BasicLifecycleTests(p metric.Persistence, t testing.TB) {
|
||||||
if p == nil {
|
if p == nil {
|
||||||
t.Errorf("Received nil Metric Persistence.\n")
|
t.Errorf("Received nil Metric Persistence.\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadEmptyTests(p metric.Persistence, t test.Tester) {
|
func ReadEmptyTests(p metric.Persistence, t testing.TB) {
|
||||||
hasLabelPair := func(x int) (success bool) {
|
hasLabelPair := func(x int) (success bool) {
|
||||||
fingerprints, err := p.GetFingerprintsForLabelMatchers(metric.LabelMatchers{{
|
fingerprints, err := p.GetFingerprintsForLabelMatchers(metric.LabelMatchers{{
|
||||||
Type: metric.Equal,
|
Type: metric.Equal,
|
||||||
|
@ -89,7 +89,7 @@ func ReadEmptyTests(p metric.Persistence, t test.Tester) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendSampleAsPureSparseAppendTests(p metric.Persistence, t test.Tester) {
|
func AppendSampleAsPureSparseAppendTests(p metric.Persistence, t testing.TB) {
|
||||||
appendSample := func(x int) (success bool) {
|
appendSample := func(x int) (success bool) {
|
||||||
v := clientmodel.SampleValue(x)
|
v := clientmodel.SampleValue(x)
|
||||||
ts := clientmodel.TimestampFromUnix(int64(x))
|
ts := clientmodel.TimestampFromUnix(int64(x))
|
||||||
|
@ -118,7 +118,7 @@ func AppendSampleAsPureSparseAppendTests(p metric.Persistence, t test.Tester) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendSampleAsSparseAppendWithReadsTests(p metric.Persistence, t test.Tester) {
|
func AppendSampleAsSparseAppendWithReadsTests(p metric.Persistence, t testing.TB) {
|
||||||
appendSample := func(x int) (success bool) {
|
appendSample := func(x int) (success bool) {
|
||||||
v := clientmodel.SampleValue(x)
|
v := clientmodel.SampleValue(x)
|
||||||
ts := clientmodel.TimestampFromUnix(int64(x))
|
ts := clientmodel.TimestampFromUnix(int64(x))
|
||||||
|
@ -170,7 +170,7 @@ func AppendSampleAsSparseAppendWithReadsTests(p metric.Persistence, t test.Teste
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendSampleAsPureSingleEntityAppendTests(p metric.Persistence, t test.Tester) {
|
func AppendSampleAsPureSingleEntityAppendTests(p metric.Persistence, t testing.TB) {
|
||||||
appendSample := func(x int) bool {
|
appendSample := func(x int) bool {
|
||||||
sample := &clientmodel.Sample{
|
sample := &clientmodel.Sample{
|
||||||
Value: clientmodel.SampleValue(x),
|
Value: clientmodel.SampleValue(x),
|
||||||
|
@ -237,7 +237,7 @@ func (t timeslice) Less(i, j int) bool {
|
||||||
return t[i].Before(t[j])
|
return t[i].Before(t[j])
|
||||||
}
|
}
|
||||||
|
|
||||||
func StochasticTests(persistenceMaker func() (metric.Persistence, test.Closer), t test.Tester) {
|
func StochasticTests(persistenceMaker func() (metric.Persistence, test.Closer), t testing.TB) {
|
||||||
stochastic := func(x int) (success bool) {
|
stochastic := func(x int) (success bool) {
|
||||||
p, closer := persistenceMaker()
|
p, closer := persistenceMaker()
|
||||||
defer closer.Close()
|
defer closer.Close()
|
||||||
|
@ -528,7 +528,7 @@ func BenchmarkLevelDBAppendSampleAsPureSingleEntityAppend(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLevelDBStochastic(t test.Tester) {
|
func testLevelDBStochastic(t testing.TB) {
|
||||||
persistenceMaker := func() (metric.Persistence, test.Closer) {
|
persistenceMaker := func() (metric.Persistence, test.Closer) {
|
||||||
temporaryDirectory := test.NewTemporaryDirectory("test_leveldb_stochastic", t)
|
temporaryDirectory := test.NewTemporaryDirectory("test_leveldb_stochastic", t)
|
||||||
|
|
||||||
|
@ -613,7 +613,7 @@ func BenchmarkMemoryAppendSampleAsPureSingleEntityAppend(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMemoryStochastic(t test.Tester) {
|
func testMemoryStochastic(t testing.TB) {
|
||||||
persistenceMaker := func() (metric.Persistence, test.Closer) {
|
persistenceMaker := func() (metric.Persistence, test.Closer) {
|
||||||
return NewMemorySeriesStorage(MemorySeriesOptions{}), test.NilCloser
|
return NewMemorySeriesStorage(MemorySeriesOptions{}), test.NilCloser
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import (
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/stats"
|
"github.com/prometheus/prometheus/stats"
|
||||||
"github.com/prometheus/prometheus/storage/metric"
|
"github.com/prometheus/prometheus/storage/metric"
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildSamples(from, to clientmodel.Timestamp, interval time.Duration, m clientmodel.Metric) (v clientmodel.Samples) {
|
func buildSamples(from, to clientmodel.Timestamp, interval time.Duration, m clientmodel.Metric) (v clientmodel.Samples) {
|
||||||
|
@ -57,7 +56,7 @@ func buildValues(firstValue clientmodel.SampleValue, from, to clientmodel.Timest
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMakeView(t test.Tester, flushToDisk bool) {
|
func testMakeView(t testing.TB, flushToDisk bool) {
|
||||||
type in struct {
|
type in struct {
|
||||||
atTime []getValuesAtTimeOp
|
atTime []getValuesAtTimeOp
|
||||||
atInterval []getValuesAtIntervalOp
|
atInterval []getValuesAtIntervalOp
|
||||||
|
|
|
@ -18,11 +18,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
clientmodel "github.com/prometheus/client_golang/model"
|
clientmodel "github.com/prometheus/client_golang/model"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/utility/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func testBuilder(t test.Tester) {
|
func testBuilder(t testing.TB) {
|
||||||
type atTime struct {
|
type atTime struct {
|
||||||
fingerprint string
|
fingerprint string
|
||||||
time clientmodel.Timestamp
|
time clientmodel.Timestamp
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
"code.google.com/p/goprotobuf/proto"
|
"code.google.com/p/goprotobuf/proto"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/storage/raw/leveldb"
|
"github.com/prometheus/prometheus/storage/raw/leveldb"
|
||||||
|
@ -50,7 +51,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
preparer struct {
|
preparer struct {
|
||||||
tester test.Tester
|
tester testing.TB
|
||||||
}
|
}
|
||||||
|
|
||||||
cassetteFactory struct {
|
cassetteFactory struct {
|
||||||
|
@ -108,7 +109,7 @@ func (f *cassetteFactory) Next() (key proto.Message, value interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPreparer creates a new Preparer for use in testing scenarios.
|
// NewPreparer creates a new Preparer for use in testing scenarios.
|
||||||
func NewPreparer(t test.Tester) Preparer {
|
func NewPreparer(t testing.TB) Preparer {
|
||||||
return preparer{t}
|
return preparer{t}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ package test
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -50,7 +51,7 @@ type (
|
||||||
// their interactions.
|
// their interactions.
|
||||||
temporaryDirectory struct {
|
temporaryDirectory struct {
|
||||||
path string
|
path string
|
||||||
tester Tester
|
tester testing.TB
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ func (t temporaryDirectory) Path() string {
|
||||||
|
|
||||||
// NewTemporaryDirectory creates a new temporary directory for transient POSIX
|
// NewTemporaryDirectory creates a new temporary directory for transient POSIX
|
||||||
// activities.
|
// activities.
|
||||||
func NewTemporaryDirectory(name string, t Tester) (handler TemporaryDirectory) {
|
func NewTemporaryDirectory(name string, t testing.TB) (handler TemporaryDirectory) {
|
||||||
var (
|
var (
|
||||||
directory string
|
directory string
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
// Copyright 2013 Prometheus Team
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package test
|
|
||||||
|
|
||||||
type Tester interface {
|
|
||||||
Error(args ...interface{})
|
|
||||||
Errorf(format string, args ...interface{})
|
|
||||||
Fatal(args ...interface{})
|
|
||||||
Fatalf(format string, args ...interface{})
|
|
||||||
}
|
|
Loading…
Reference in a new issue