@ -16,6 +16,7 @@ package metric
import (
"flag"
"fmt"
"sort"
"testing"
"time"
@ -34,7 +35,7 @@ func generateTestSamples(endTime clientmodel.Timestamp, numTs int, samplesPerTs
startTime := endTime . Add ( - interval * time . Duration ( samplesPerTs - 1 ) )
for ts := 0 ; ts < numTs ; ts ++ {
metric := clientmodel . Metric { }
metric [ "name" ] = clientmodel . LabelValue ( fmt . Sprintf ( "metric_%d" , ts ) )
metric [ clientmodel . MetricNameLabel ] = clientmodel . LabelValue ( fmt . Sprintf ( "metric_%d" , ts ) )
for i := 0 ; i < samplesPerTs ; i ++ {
sample := & clientmodel . Sample {
Metric : metric ,
@ -44,6 +45,7 @@ func generateTestSamples(endTime clientmodel.Timestamp, numTs int, samplesPerTs
samples = append ( samples , sample )
}
}
sort . Sort ( samples )
return samples
}
@ -92,7 +94,7 @@ func checkStorageSaneAndEquivalent(t *testing.T, name string, ts *TieredStorage,
}
entire , err := ts . DiskStorage . MetricSamples . ForEach ( & MetricSamplesDecoder { } , & AcceptAllFilter { } , cc )
if err != nil {
t . Fatalf ( "%s: Error dump ing samples: %s", name , err )
t . Fatalf ( "%s: Error check ing samples: %s", name , err )
}
if ! entire {
t . Fatalf ( "%s: Didn't scan entire corpus" , name )