Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Lei <lei.justin@gmail.com>
  • Loading branch information
leizor committed Jan 19, 2024
1 parent 470ebd7 commit 09bca48
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion storage/remote/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"bufio"
"bytes"
"context"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -349,7 +350,7 @@ func (c *Client) Read(ctx context.Context, query *prompb.Query, sortSeries bool)
s := NewChunkedReader(httpResp.Body, c.chunkedReadLimit, nil)
return NewChunkedSeriesSet(s, httpResp.Body, query.StartTimestampMs, query.EndTimestampMs, func(err error) {
code := strconv.Itoa(httpResp.StatusCode)
if err != io.EOF {
if !errors.Is(err, io.EOF) {
code = "aborted_stream"
}
c.readQueriesTotal.WithLabelValues("chunked", code).Inc()
Expand Down
4 changes: 2 additions & 2 deletions storage/remote/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func TestReadClient(t *testing.T) {
s := ss.At()

l := s.Labels()
require.Equal(t, len(test.expectedLabels[i]), l.Len())
require.Len(t, test.expectedLabels[i], l.Len())
for k, v := range test.expectedLabels[i] {
require.True(t, l.Has(k))
require.Equal(t, v, l.Get(k))
Expand All @@ -388,7 +388,7 @@ func TestReadClient(t *testing.T) {
j++
}

require.Equal(t, len(test.expectedSamples[i]), j)
require.Len(t, test.expectedSamples[i], j)

i++
}
Expand Down
2 changes: 1 addition & 1 deletion storage/remote/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ func (s *chunkedSeriesSet) Next() bool {

err := s.chunkedReader.NextProto(res)
if err != nil {
if err != io.EOF {
if !errors.Is(err, io.EOF) {
s.err = err
_, _ = io.Copy(io.Discard, s.respBody)
}
Expand Down
24 changes: 12 additions & 12 deletions storage/remote/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,13 +852,13 @@ func TestChunkedSeriesIterator(t *testing.T) {

it := newChunkedSeriesIterator(chks, 2000, 12000)

require.Nil(t, it.err)
require.NoError(t, it.err)
require.NotNil(t, it.cur)

// Initial next; advance to first valid sample of first chunk.
res := it.Next()
require.Equal(t, chunkenc.ValFloat, res)
require.Nil(t, it.Err())
require.NoError(t, it.Err())

ts, v := it.At()
require.Equal(t, int64(2000), ts)
Expand All @@ -867,7 +867,7 @@ func TestChunkedSeriesIterator(t *testing.T) {
// Next to the second sample of the first chunk.
res = it.Next()
require.Equal(t, chunkenc.ValFloat, res)
require.Nil(t, it.Err())
require.NoError(t, it.Err())

ts, v = it.At()
require.Equal(t, int64(3000), ts)
Expand All @@ -892,7 +892,7 @@ func TestChunkedSeriesIterator(t *testing.T) {
// Next to the first sample of the second chunk.
res = it.Next()
require.Equal(t, chunkenc.ValFloat, res)
require.Nil(t, it.Err())
require.NoError(t, it.Err())

ts, v = it.At()
require.Equal(t, int64(5000), ts)
Expand All @@ -901,7 +901,7 @@ func TestChunkedSeriesIterator(t *testing.T) {
// Seek to the second sample of the third chunk.
res = it.Seek(10999)
require.Equal(t, chunkenc.ValFloat, res)
require.Nil(t, it.Err())
require.NoError(t, it.Err())

ts, v = it.At()
require.Equal(t, int64(11000), ts)
Expand All @@ -910,12 +910,12 @@ func TestChunkedSeriesIterator(t *testing.T) {
// Attempt to seek to something past the last sample (should return false and exhaust the iterator).
res = it.Seek(99999)
require.Equal(t, chunkenc.ValNone, res)
require.Nil(t, it.Err())
require.NoError(t, it.Err())

// Attempt to next past the last sample (should return false as the iterator is exhausted).
res = it.Next()
require.Equal(t, chunkenc.ValNone, res)
require.Nil(t, it.Err())
require.NoError(t, it.Err())
})

t.Run("invalid chunk encoding error", func(t *testing.T) {
Expand Down Expand Up @@ -971,7 +971,7 @@ func TestChunkedSeries(t *testing.T) {
res := it.Next() // Behavior is undefined w/o the initial call to Next.

require.Equal(t, chunkenc.ValFloat, res)
require.Nil(t, it.Err())
require.NoError(t, it.Err())

ts, v := it.At()
require.Equal(t, int64(0), ts)
Expand Down Expand Up @@ -1007,12 +1007,12 @@ func TestChunkedSeriesSet(t *testing.T) {
}

ss := NewChunkedSeriesSet(r, io.NopCloser(buf), 0, 14000, func(error) {})
require.Nil(t, ss.Err())
require.NoError(t, ss.Err())
require.Nil(t, ss.Warnings())

res := ss.Next()
require.True(t, res)
require.Nil(t, ss.Err())
require.NoError(t, ss.Err())

s := ss.At()
require.Equal(t, 1, s.Labels().Len())
Expand All @@ -1030,7 +1030,7 @@ func TestChunkedSeriesSet(t *testing.T) {
numResponses++
}
require.Equal(t, numTestChunks, numResponses)
require.Nil(t, ss.Err())
require.NoError(t, ss.Err())
})

t.Run("chunked reader error", func(t *testing.T) {
Expand Down Expand Up @@ -1062,7 +1062,7 @@ func TestChunkedSeriesSet(t *testing.T) {
}

ss := NewChunkedSeriesSet(r, io.NopCloser(buf), 0, 14000, func(error) {})
require.Nil(t, ss.Err())
require.NoError(t, ss.Err())
require.Nil(t, ss.Warnings())

res := ss.Next()
Expand Down

0 comments on commit 09bca48

Please sign in to comment.