Skip to content

Commit

Permalink
Adjusting e2e and integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
  • Loading branch information
pedro-stanaka committed Sep 26, 2022
1 parent c4eb864 commit 0d19ff2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
5 changes: 0 additions & 5 deletions pkg/store/bucket_test.go
Expand Up @@ -2210,10 +2210,6 @@ func TestSeries_ChuncksHaveHashRepresentation(t *testing.T) {
name: "calculate checksum",
calculateChecksum: true,
},
{
name: "do not calculate checksum",
calculateChecksum: false,
},
}

for _, tc := range testCases {
Expand All @@ -2224,7 +2220,6 @@ func TestSeries_ChuncksHaveHashRepresentation(t *testing.T) {
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "__name__", Value: "test"},
},
CalculateChunkChecksums: tc.calculateChecksum,
}

srv := newStoreSeriesServer(context.Background())
Expand Down
6 changes: 3 additions & 3 deletions pkg/store/prometheus.go
Expand Up @@ -234,13 +234,13 @@ func (p *PrometheusStore) Series(r *storepb.SeriesRequest, s storepb.Store_Serie
// remote read.
contentType := httpResp.Header.Get("Content-Type")
if strings.HasPrefix(contentType, "application/x-protobuf") {
return p.handleSampledPrometheusResponse(s, httpResp, queryPrometheusSpan, extLset, r.CalculateChunkChecksums)
return p.handleSampledPrometheusResponse(s, httpResp, queryPrometheusSpan, extLset, enableChunkHashCalculation)
}

if !strings.HasPrefix(contentType, "application/x-streamed-protobuf; proto=prometheus.ChunkedReadResponse") {
return errors.Errorf("not supported remote read content type: %s", contentType)
}
return p.handleStreamedPrometheusResponse(s, shardMatcher, httpResp, queryPrometheusSpan, extLset, r.CalculateChunkChecksums)
return p.handleStreamedPrometheusResponse(s, shardMatcher, httpResp, queryPrometheusSpan, extLset, enableChunkHashCalculation)
}

func (p *PrometheusStore) queryPrometheus(s storepb.Store_SeriesServer, r *storepb.SeriesRequest) error {
Expand Down Expand Up @@ -294,7 +294,7 @@ func (p *PrometheusStore) queryPrometheus(s storepb.Store_SeriesServer, r *store
Samples: prompb.SamplesFromSamplePairs(vector.Values),
}

chks, err := p.chunkSamples(series, MaxSamplesPerChunk, r.CalculateChunkChecksums)
chks, err := p.chunkSamples(series, MaxSamplesPerChunk, enableChunkHashCalculation)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/store/storepb/testutil/series.go
Expand Up @@ -6,6 +6,7 @@ package storetestutil
import (
"context"
"fmt"
"github.com/cespare/xxhash"
"math"
"math/rand"
"os"
Expand Down Expand Up @@ -140,7 +141,7 @@ func CreateHeadWithSeries(t testing.TB, j int, opts HeadGenOptions) (*tsdb.Head,
expected[len(expected)-1].Chunks = append(expected[len(expected)-1].Chunks, storepb.AggrChunk{
MinTime: c.MinTime,
MaxTime: c.MaxTime,
Raw: &storepb.Chunk{Type: storepb.Chunk_XOR, Data: chEnc.Bytes()},
Raw: &storepb.Chunk{Type: storepb.Chunk_XOR, Data: chEnc.Bytes(), Hash: xxhash.Sum64(chEnc.Bytes())},
})
}
}
Expand Down
16 changes: 1 addition & 15 deletions pkg/store/tsdb_test.go
Expand Up @@ -92,25 +92,11 @@ func TestTSDBStore_Series_ChunkChecksum(t *testing.T) {
{Type: storepb.LabelMatcher_EQ, Name: "a", Value: "1"},
},
}
err = tsdbStore.Series(req, srv)
testutil.Ok(t, err)

for _, chk := range srv.SeriesSet[0].Chunks {
testutil.Equals(t, uint64(0), chk.Raw.Hash)
}

req = &storepb.SeriesRequest{
MinTime: 1,
MaxTime: 3,
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "a", Value: "1"},
},
}

err = tsdbStore.Series(req, srv)
testutil.Ok(t, err)

for _, chk := range srv.SeriesSet[1].Chunks {
for _, chk := range srv.SeriesSet[0].Chunks {
want := xxhash.Sum64(chk.Raw.Data)
testutil.Equals(t, want, chk.Raw.Hash)
}
Expand Down

0 comments on commit 0d19ff2

Please sign in to comment.