Skip to content

Commit

Permalink
lint fix; changed func signature
Browse files Browse the repository at this point in the history
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
  • Loading branch information
metonymic-smokey committed Nov 5, 2021
1 parent fe3355e commit 1bd7b17
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions pkg/compact/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/oklog/ulid"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -184,11 +183,14 @@ func createBlockMeta(id uint64, minTime, maxTime int64, labels map[string]string
m := &metadata.Meta{
BlockMeta: tsdb.BlockMeta{
ULID: ulid.MustNew(id, nil),
MinTime: int64(time.Duration(minTime) * time.Hour / time.Millisecond),
MaxTime: int64(time.Duration(maxTime) * time.Hour / time.Millisecond),
MinTime: minTime,
MaxTime: maxTime,
},
Thanos: metadata.Thanos{
Labels: labels,
Downsample: metadata.ThanosDownsample{
Resolution: resolution,
},
},
}

Expand Down Expand Up @@ -234,14 +236,14 @@ func TestCompactProgressCalculate(t *testing.T) {
{
testName: "first_test",
input: []*metadata.Meta{
createBlockMeta(0, 0, 2, map[string]string{"a": "1"}, 0),
createBlockMeta(1, 2, 4, map[string]string{"a": "1"}, 0),
createBlockMeta(2, 4, 6, map[string]string{"b": "2"}, 0),
createBlockMeta(3, 6, 8, map[string]string{"b": "2"}, 0),
createBlockMeta(4, 8, 10, map[string]string{"b": "2"}, 0),
createBlockMeta(5, 10, 12, map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(6, 12, 20, map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(7, 20, 28, map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(0, 0, int64(time.Duration(2)*time.Hour/time.Millisecond), map[string]string{"a": "1"}, 0),
createBlockMeta(1, int64(time.Duration(2)*time.Hour/time.Millisecond), int64(time.Duration(4)*time.Hour/time.Millisecond), map[string]string{"a": "1"}, 0),
createBlockMeta(2, int64(time.Duration(4)*time.Hour/time.Millisecond), int64(time.Duration(6)*time.Hour/time.Millisecond), map[string]string{"b": "2"}, 0),
createBlockMeta(3, int64(time.Duration(6)*time.Hour/time.Millisecond), int64(time.Duration(8)*time.Hour/time.Millisecond), map[string]string{"b": "2"}, 0),
createBlockMeta(4, int64(time.Duration(8)*time.Hour/time.Millisecond), int64(time.Duration(10)*time.Hour/time.Millisecond), map[string]string{"b": "2"}, 0),
createBlockMeta(5, int64(time.Duration(10)*time.Hour/time.Millisecond), int64(time.Duration(12)*time.Hour/time.Millisecond), map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(6, int64(time.Duration(12)*time.Hour/time.Millisecond), int64(time.Duration(20)*time.Hour/time.Millisecond), map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(7, int64(time.Duration(20)*time.Hour/time.Millisecond), int64(time.Duration(28)*time.Hour/time.Millisecond), map[string]string{"a": "1", "b": "2"}, 1),
},
expected: map[string]planResult{
keys[0]: {
Expand All @@ -261,12 +263,12 @@ func TestCompactProgressCalculate(t *testing.T) {
{
testName: "second_test",
input: []*metadata.Meta{
createBlockMeta(0, 0, 2, map[string]string{"a": "1"}, 0),
createBlockMeta(1, 2, 4, map[string]string{"b": "2"}, 0),
createBlockMeta(2, 4, 6, map[string]string{"b": "2"}, 0),
createBlockMeta(3, 6, 10, map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(4, 10, 14, map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(5, 14, 16, map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(0, 0, int64(time.Duration(2)*time.Hour/time.Millisecond), map[string]string{"a": "1"}, 0),
createBlockMeta(1, int64(time.Duration(2)*time.Hour/time.Millisecond), int64(time.Duration(4)*time.Hour/time.Millisecond), map[string]string{"b": "2"}, 0),
createBlockMeta(2, int64(time.Duration(4)*time.Hour/time.Millisecond), int64(time.Duration(6)*time.Hour/time.Millisecond), map[string]string{"b": "2"}, 0),
createBlockMeta(3, int64(time.Duration(6)*time.Hour/time.Millisecond), int64(time.Duration(10)*time.Hour/time.Millisecond), map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(4, int64(time.Duration(10)*time.Hour/time.Millisecond), int64(time.Duration(14)*time.Hour/time.Millisecond), map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(5, int64(time.Duration(14)*time.Hour/time.Millisecond), int64(time.Duration(16)*time.Hour/time.Millisecond), map[string]string{"a": "1", "b": "2"}, 1),
},
expected: map[string]planResult{
keys[0]: {
Expand All @@ -286,11 +288,11 @@ func TestCompactProgressCalculate(t *testing.T) {
{
testName: "third_test",
input: []*metadata.Meta{
createBlockMeta(0, 0, 2, map[string]string{"a": "1"}, 0),
createBlockMeta(1, 2, 4, map[string]string{"b": "2"}, 0),
createBlockMeta(2, 4, 6, map[string]string{"b": "2"}, 0),
createBlockMeta(3, 6, 8, map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(4, 8, 10, map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(0, 0, int64(time.Duration(2)*time.Hour/time.Millisecond), map[string]string{"a": "1"}, 0),
createBlockMeta(1, int64(time.Duration(2)*time.Hour/time.Millisecond), int64(time.Duration(4)*time.Hour/time.Millisecond), map[string]string{"b": "2"}, 0),
createBlockMeta(2, int64(time.Duration(4)*time.Hour/time.Millisecond), int64(time.Duration(6)*time.Hour/time.Millisecond), map[string]string{"b": "2"}, 0),
createBlockMeta(3, int64(time.Duration(6)*time.Hour/time.Millisecond), int64(time.Duration(8)*time.Hour/time.Millisecond), map[string]string{"a": "1", "b": "2"}, 1),
createBlockMeta(4, int64(time.Duration(8)*time.Hour/time.Millisecond), int64(time.Duration(10)*time.Hour/time.Millisecond), map[string]string{"a": "1", "b": "2"}, 1),
},
expected: map[string]planResult{
keys[0]: {
Expand Down Expand Up @@ -595,11 +597,10 @@ func TestDownsampleProgressCalculate(t *testing.T) {
err = ds.ProgressCalculate(context.Background(), groups)
testutil.Ok(t, err)
metrics := ds.DownsampleProgressMetrics
for _, key := range keys {
for key := range tcase.expected {
a, err := metrics.NumberOfBlocksDownsampled.GetMetricWithLabelValues(key)
if err != nil {
level.Warn(logger).Log("msg", "could not get number of blocks")
}

testutil.Ok(t, err)
testutil.Equals(t, tcase.expected[key], promtestutil.ToFloat64(a))
}
}); !ok {
Expand Down

0 comments on commit 1bd7b17

Please sign in to comment.