Makefile: add -s flag to go fmt in make fmt command

This commit is contained in:
Aliaksandr Valialkin 2019-05-25 21:43:35 +03:00
parent a10d27eccd
commit 121a920a18
3 changed files with 32 additions and 32 deletions

View file

@ -33,8 +33,8 @@ package: \
package-vminsert package-vminsert
fmt: fmt:
go fmt $(PKG_PREFIX)/lib/... gofmt -l -w -s ./lib
go fmt $(PKG_PREFIX)/app/... gofmt -l -w -s ./app
vet: vet:
go vet $(PKG_PREFIX)/lib/... go vet $(PKG_PREFIX)/lib/...

View file

@ -45,7 +45,7 @@ func TestRollupResultCache(t *testing.T) {
t.Run("start-overlap", func(t *testing.T) { t.Run("start-overlap", func(t *testing.T) {
ResetRollupResultCache() ResetRollupResultCache()
tss := []*timeseries{ tss := []*timeseries{
&timeseries{ {
Timestamps: []int64{800, 1000, 1200}, Timestamps: []int64{800, 1000, 1200},
Values: []float64{0, 1, 2}, Values: []float64{0, 1, 2},
}, },
@ -56,7 +56,7 @@ func TestRollupResultCache(t *testing.T) {
t.Fatalf("unexpected newStart; got %d; want %d", newStart, 1400) t.Fatalf("unexpected newStart; got %d; want %d", newStart, 1400)
} }
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200}, Timestamps: []int64{1000, 1200},
Values: []float64{1, 2}, Values: []float64{1, 2},
}, },
@ -68,7 +68,7 @@ func TestRollupResultCache(t *testing.T) {
t.Run("end-overlap", func(t *testing.T) { t.Run("end-overlap", func(t *testing.T) {
ResetRollupResultCache() ResetRollupResultCache()
tss := []*timeseries{ tss := []*timeseries{
&timeseries{ {
Timestamps: []int64{1800, 2000, 2200, 2400}, Timestamps: []int64{1800, 2000, 2200, 2400},
Values: []float64{333, 0, 1, 2}, Values: []float64{333, 0, 1, 2},
}, },
@ -87,7 +87,7 @@ func TestRollupResultCache(t *testing.T) {
t.Run("full-cover", func(t *testing.T) { t.Run("full-cover", func(t *testing.T) {
ResetRollupResultCache() ResetRollupResultCache()
tss := []*timeseries{ tss := []*timeseries{
&timeseries{ {
Timestamps: []int64{1200, 1400, 1600}, Timestamps: []int64{1200, 1400, 1600},
Values: []float64{0, 1, 2}, Values: []float64{0, 1, 2},
}, },
@ -106,7 +106,7 @@ func TestRollupResultCache(t *testing.T) {
t.Run("before-start", func(t *testing.T) { t.Run("before-start", func(t *testing.T) {
ResetRollupResultCache() ResetRollupResultCache()
tss := []*timeseries{ tss := []*timeseries{
&timeseries{ {
Timestamps: []int64{200, 400, 600}, Timestamps: []int64{200, 400, 600},
Values: []float64{0, 1, 2}, Values: []float64{0, 1, 2},
}, },
@ -125,7 +125,7 @@ func TestRollupResultCache(t *testing.T) {
t.Run("after-end", func(t *testing.T) { t.Run("after-end", func(t *testing.T) {
ResetRollupResultCache() ResetRollupResultCache()
tss := []*timeseries{ tss := []*timeseries{
&timeseries{ {
Timestamps: []int64{2200, 2400, 2600}, Timestamps: []int64{2200, 2400, 2600},
Values: []float64{0, 1, 2}, Values: []float64{0, 1, 2},
}, },
@ -144,7 +144,7 @@ func TestRollupResultCache(t *testing.T) {
t.Run("bigger-than-start-end", func(t *testing.T) { t.Run("bigger-than-start-end", func(t *testing.T) {
ResetRollupResultCache() ResetRollupResultCache()
tss := []*timeseries{ tss := []*timeseries{
&timeseries{ {
Timestamps: []int64{800, 1000, 1200, 1400, 1600, 1800, 2000, 2200}, Timestamps: []int64{800, 1000, 1200, 1400, 1600, 1800, 2000, 2200},
Values: []float64{0, 1, 2, 3, 4, 5, 6, 7}, Values: []float64{0, 1, 2, 3, 4, 5, 6, 7},
}, },
@ -155,7 +155,7 @@ func TestRollupResultCache(t *testing.T) {
t.Fatalf("unexpected newStart; got %d; want %d", newStart, 2200) t.Fatalf("unexpected newStart; got %d; want %d", newStart, 2200)
} }
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{1, 2, 3, 4, 5, 6}, Values: []float64{1, 2, 3, 4, 5, 6},
}, },
@ -167,7 +167,7 @@ func TestRollupResultCache(t *testing.T) {
t.Run("start-end-match", func(t *testing.T) { t.Run("start-end-match", func(t *testing.T) {
ResetRollupResultCache() ResetRollupResultCache()
tss := []*timeseries{ tss := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{1, 2, 3, 4, 5, 6}, Values: []float64{1, 2, 3, 4, 5, 6},
}, },
@ -178,7 +178,7 @@ func TestRollupResultCache(t *testing.T) {
t.Fatalf("unexpected newStart; got %d; want %d", newStart, 2200) t.Fatalf("unexpected newStart; got %d; want %d", newStart, 2200)
} }
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{1, 2, 3, 4, 5, 6}, Values: []float64{1, 2, 3, 4, 5, 6},
}, },
@ -209,19 +209,19 @@ func TestRollupResultCache(t *testing.T) {
t.Run("multi-timeseries", func(t *testing.T) { t.Run("multi-timeseries", func(t *testing.T) {
ResetRollupResultCache() ResetRollupResultCache()
tss1 := []*timeseries{ tss1 := []*timeseries{
&timeseries{ {
Timestamps: []int64{800, 1000, 1200}, Timestamps: []int64{800, 1000, 1200},
Values: []float64{0, 1, 2}, Values: []float64{0, 1, 2},
}, },
} }
tss2 := []*timeseries{ tss2 := []*timeseries{
&timeseries{ {
Timestamps: []int64{1800, 2000, 2200, 2400}, Timestamps: []int64{1800, 2000, 2200, 2400},
Values: []float64{333, 0, 1, 2}, Values: []float64{333, 0, 1, 2},
}, },
} }
tss3 := []*timeseries{ tss3 := []*timeseries{
&timeseries{ {
Timestamps: []int64{1200, 1400, 1600}, Timestamps: []int64{1200, 1400, 1600},
Values: []float64{0, 1, 2}, Values: []float64{0, 1, 2},
}, },
@ -234,7 +234,7 @@ func TestRollupResultCache(t *testing.T) {
t.Fatalf("unexpected newStart; got %d; want %d", newStart, 1400) t.Fatalf("unexpected newStart; got %d; want %d", newStart, 1400)
} }
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200}, Timestamps: []int64{1000, 1200},
Values: []float64{1, 2}, Values: []float64{1, 2},
}, },
@ -255,14 +255,14 @@ func TestMergeTimeseries(t *testing.T) {
t.Run("bStart=ec.Start", func(t *testing.T) { t.Run("bStart=ec.Start", func(t *testing.T) {
a := []*timeseries{} a := []*timeseries{}
b := []*timeseries{ b := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{1, 2, 3, 4, 5, 6}, Values: []float64{1, 2, 3, 4, 5, 6},
}, },
} }
tss := mergeTimeseries(a, b, 1000, ec) tss := mergeTimeseries(a, b, 1000, ec)
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{1, 2, 3, 4, 5, 6}, Values: []float64{1, 2, 3, 4, 5, 6},
}, },
@ -272,14 +272,14 @@ func TestMergeTimeseries(t *testing.T) {
t.Run("a-empty", func(t *testing.T) { t.Run("a-empty", func(t *testing.T) {
a := []*timeseries{} a := []*timeseries{}
b := []*timeseries{ b := []*timeseries{
&timeseries{ {
Timestamps: []int64{1400, 1600, 1800, 2000}, Timestamps: []int64{1400, 1600, 1800, 2000},
Values: []float64{3, 4, 5, 6}, Values: []float64{3, 4, 5, 6},
}, },
} }
tss := mergeTimeseries(a, b, bStart, ec) tss := mergeTimeseries(a, b, bStart, ec)
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{nan, nan, 3, 4, 5, 6}, Values: []float64{nan, nan, 3, 4, 5, 6},
}, },
@ -288,7 +288,7 @@ func TestMergeTimeseries(t *testing.T) {
}) })
t.Run("b-empty", func(t *testing.T) { t.Run("b-empty", func(t *testing.T) {
a := []*timeseries{ a := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200}, Timestamps: []int64{1000, 1200},
Values: []float64{2, 1}, Values: []float64{2, 1},
}, },
@ -296,7 +296,7 @@ func TestMergeTimeseries(t *testing.T) {
b := []*timeseries{} b := []*timeseries{}
tss := mergeTimeseries(a, b, bStart, ec) tss := mergeTimeseries(a, b, bStart, ec)
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{2, 1, nan, nan, nan, nan}, Values: []float64{2, 1, nan, nan, nan, nan},
}, },
@ -305,20 +305,20 @@ func TestMergeTimeseries(t *testing.T) {
}) })
t.Run("non-empty", func(t *testing.T) { t.Run("non-empty", func(t *testing.T) {
a := []*timeseries{ a := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200}, Timestamps: []int64{1000, 1200},
Values: []float64{2, 1}, Values: []float64{2, 1},
}, },
} }
b := []*timeseries{ b := []*timeseries{
&timeseries{ {
Timestamps: []int64{1400, 1600, 1800, 2000}, Timestamps: []int64{1400, 1600, 1800, 2000},
Values: []float64{3, 4, 5, 6}, Values: []float64{3, 4, 5, 6},
}, },
} }
tss := mergeTimeseries(a, b, bStart, ec) tss := mergeTimeseries(a, b, bStart, ec)
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{2, 1, 3, 4, 5, 6}, Values: []float64{2, 1, 3, 4, 5, 6},
}, },
@ -327,14 +327,14 @@ func TestMergeTimeseries(t *testing.T) {
}) })
t.Run("non-empty-distinct-metric-names", func(t *testing.T) { t.Run("non-empty-distinct-metric-names", func(t *testing.T) {
a := []*timeseries{ a := []*timeseries{
&timeseries{ {
Timestamps: []int64{1000, 1200}, Timestamps: []int64{1000, 1200},
Values: []float64{2, 1}, Values: []float64{2, 1},
}, },
} }
a[0].MetricName.MetricGroup = []byte("bar") a[0].MetricName.MetricGroup = []byte("bar")
b := []*timeseries{ b := []*timeseries{
&timeseries{ {
Timestamps: []int64{1400, 1600, 1800, 2000}, Timestamps: []int64{1400, 1600, 1800, 2000},
Values: []float64{3, 4, 5, 6}, Values: []float64{3, 4, 5, 6},
}, },
@ -342,14 +342,14 @@ func TestMergeTimeseries(t *testing.T) {
b[0].MetricName.MetricGroup = []byte("foo") b[0].MetricName.MetricGroup = []byte("foo")
tss := mergeTimeseries(a, b, bStart, ec) tss := mergeTimeseries(a, b, bStart, ec)
tssExpected := []*timeseries{ tssExpected := []*timeseries{
&timeseries{ {
MetricName: storage.MetricName{ MetricName: storage.MetricName{
MetricGroup: []byte("foo"), MetricGroup: []byte("foo"),
}, },
Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000},
Values: []float64{nan, nan, 3, 4, 5, 6}, Values: []float64{nan, nan, 3, 4, 5, 6},
}, },
&timeseries{ {
MetricName: storage.MetricName{ MetricName: storage.MetricName{
MetricGroup: []byte("bar"), MetricGroup: []byte("bar"),
}, },

View file

@ -112,15 +112,15 @@ func testAppendPartsToMerge(t *testing.T, maxPartsToMerge int, initialRowsCount,
// Verify appending to prefix // Verify appending to prefix
prefix := []*partWrapper{ prefix := []*partWrapper{
&partWrapper{ {
p: &part{ p: &part{
ph: partHeader{ ph: partHeader{
RowsCount: 1234, RowsCount: 1234,
}, },
}, },
}, },
&partWrapper{}, {},
&partWrapper{}, {},
} }
pms = appendPartsToMerge(prefix, pws, maxPartsToMerge, 1e9) pms = appendPartsToMerge(prefix, pws, maxPartsToMerge, 1e9)
if !reflect.DeepEqual(pms[:len(prefix)], prefix) { if !reflect.DeepEqual(pms[:len(prefix)], prefix) {