From 5aa61c3cfe43502a57118a27148b576a755d5bbb Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Tue, 28 Jan 2025 17:13:55 -0500 Subject: [PATCH] Make tests faster --- .../spin_off_subqueries_test.go | 49 +++---------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/pkg/frontend/querymiddleware/spin_off_subqueries_test.go b/pkg/frontend/querymiddleware/spin_off_subqueries_test.go index adb34fe80a..fecf3284f6 100644 --- a/pkg/frontend/querymiddleware/spin_off_subqueries_test.go +++ b/pkg/frontend/querymiddleware/spin_off_subqueries_test.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "io" - "math" "net/http" "net/http/httptest" "os" @@ -29,13 +28,11 @@ import ( func TestSubquerySpinOff_Correctness(t *testing.T) { var ( - numSeries = 1000 - numStaleSeries = 100 - numConvHistograms = 1000 - numStaleConvHistograms = 100 - histogramBuckets = []float64{1.0, 2.0, 4.0, 10.0, 100.0, math.Inf(1)} - numNativeHistograms = 1000 - numStaleNativeHistograms = 100 + numSeries = 1000 + numStaleSeries = 100 + samplesStart = time.Now().Add(-2 * 24 * time.Hour) + samplesEnd = time.Now().Add(30 * time.Minute) + samplesStep = 30 * time.Second ) tests := map[string]struct { @@ -134,11 +131,7 @@ func TestSubquerySpinOff_Correctness(t *testing.T) { }, } - samplesStart := time.Now().Add(-3 * 24 * time.Hour) - samplesEnd := time.Now().Add(30 * time.Minute) - samplesStep := 30 * time.Second - - series := make([]storage.Series, 0, numSeries+(numConvHistograms*len(histogramBuckets))+numNativeHistograms) + series := make([]storage.Series, 0, numSeries) seriesID := 0 // Add counter series. @@ -170,36 +163,6 @@ func TestSubquerySpinOff_Correctness(t *testing.T) { time.Now().Add(5*time.Minute), samplesEnd, samplesStep, factor(2))) seriesID++ - // Add conventional histogram series. - for i := 0; i < numConvHistograms; i++ { - for bucketIdx, bucketLe := range histogramBuckets { - // We expect each bucket to have a value higher than the previous one. - gen := factor(float64(i) * float64(bucketIdx) * 0.1) - if i >= numConvHistograms-numStaleConvHistograms { - // Wrap the generator to inject the staleness marker between minute 10 and 20. - gen = stale(time.Now().Add(10*time.Minute), time.Now().Add(20*time.Minute), gen) - } - - series = append(series, newSeries(newTestConventionalHistogramLabels(seriesID, bucketLe), - samplesStart, samplesEnd, samplesStep, gen)) - } - - // Increase the series ID after all per-bucket series have been created. - seriesID++ - } - - // Add native histogram series. - for i := 0; i < numNativeHistograms; i++ { - gen := factor(float64(i) * 0.1) - if i >= numNativeHistograms-numStaleNativeHistograms { - // Wrap the generator to inject the staleness marker between minute 10 and 20. - gen = stale(time.Now().Add(10*time.Minute), time.Now().Add(20*time.Minute), gen) - } - - series = append(series, newNativeHistogramSeries(newTestNativeHistogramLabels(seriesID), samplesStart, samplesEnd, samplesStep, gen)) - seriesID++ - } - // Create a queryable on the fixtures. queryable := storageSeriesQueryable(series)