From 2155ac9bf1e0d0f0793d71e80f6a4f5317025804 Mon Sep 17 00:00:00 2001 From: Vilius Pranckaitis Date: Fri, 7 May 2021 09:30:26 +0300 Subject: [PATCH 1/3] [lint] Add missing build tags to linter configuration --- .golangci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 5c47ad63df..904c7aaf3a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,7 +13,11 @@ run: tests: true # list of build tags, all linters use it. Default is empty list. - build-tags: [] + build-tags: + - big + - compatibility + - dtest + - integration # which dirs to skip: they won't be analyzed; # can use regexp here: generated.*, regexp is applied on full path; From 601284c842bbae4fd70a714fbb30f93e6dd27949 Mon Sep 17 00:00:00 2001 From: Vilius Pranckaitis Date: Fri, 7 May 2021 09:42:10 +0300 Subject: [PATCH 2/3] fix lint errors --- .../integration/placement_change_test.go | 5 +++-- src/dbnode/integration/bootstrap_retries_test.go | 6 +++--- .../index_multiple_node_high_concurrency_test.go | 2 +- .../peers_bootstrap_none_available_test.go | 2 +- .../peers_bootstrap_partial_data_test.go | 7 +++---- .../integration/series_wired_list_panic_test.go | 8 +++----- src/dbnode/integration/write_quorum_test.go | 2 +- .../write_read_high_concurrency_test.go | 2 +- src/dbnode/integration/write_tagged_quorum_test.go | 2 +- .../bootstrapper/commitlog/source_prop_test.go | 3 ++- src/dbnode/storage/index/block_prop_test.go | 14 +++++++++----- src/dbnode/storage/series/series_parallel_test.go | 2 +- 12 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/aggregator/integration/placement_change_test.go b/src/aggregator/integration/placement_change_test.go index c3e0a4fd0f..4e0e0a6145 100644 --- a/src/aggregator/integration/placement_change_test.go +++ b/src/aggregator/integration/placement_change_test.go @@ -27,6 +27,9 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "go.uber.org/zap" + aggclient "github.com/m3db/m3/src/aggregator/client" "github.com/m3db/m3/src/cluster/kv/mem" "github.com/m3db/m3/src/cluster/placement" @@ -38,8 +41,6 @@ import ( "github.com/m3db/m3/src/x/instrument" xtest "github.com/m3db/m3/src/x/test" xtime "github.com/m3db/m3/src/x/time" - "github.com/stretchr/testify/require" - "go.uber.org/zap" ) func TestPlacementChange(t *testing.T) { diff --git a/src/dbnode/integration/bootstrap_retries_test.go b/src/dbnode/integration/bootstrap_retries_test.go index de8c9d2046..8ebdc18d0f 100644 --- a/src/dbnode/integration/bootstrap_retries_test.go +++ b/src/dbnode/integration/bootstrap_retries_test.go @@ -61,7 +61,7 @@ func TestBootstrapRetriesDueToError(t *testing.T) { go func() { // Wait for server to get started by the main test method. - setup.WaitUntilServerIsUp() + require.NoError(t, setup.WaitUntilServerIsUp()) // First bootstrap pass. Bootstrapper produces an error. Check if DB is not marked bootstrapped. signalCh <- true @@ -104,7 +104,7 @@ func TestBootstrapRetriesDueToObsoleteRanges(t *testing.T) { go func() { // Wait for server to get started by the main test method. - setup.WaitUntilServerIsUp() + require.NoError(t, setup.WaitUntilServerIsUp()) // First bootstrap pass, persist ranges. Check if DB is not marked bootstrapped and advance clock. signalCh <- struct{}{} @@ -161,7 +161,7 @@ func TestBootstrapRetriesDueToUnfulfilledRanges(t *testing.T) { go func() { // Wait for server to get started by the main test method. - setup.WaitUntilServerIsUp() + require.NoError(t, setup.WaitUntilServerIsUp()) // First bootstrap pass. Bootstrap produces unfulfilled ranges for persist range. // Check if DB is not marked bootstrapped. diff --git a/src/dbnode/integration/index_multiple_node_high_concurrency_test.go b/src/dbnode/integration/index_multiple_node_high_concurrency_test.go index 0d87618722..811233ad64 100644 --- a/src/dbnode/integration/index_multiple_node_high_concurrency_test.go +++ b/src/dbnode/integration/index_multiple_node_high_concurrency_test.go @@ -72,7 +72,7 @@ func TestIndexMultipleNodeHighConcurrency(t *testing.T) { node(t, 2, newClusterShardsRange(minShard, maxShard, shard.Available)), } // nodes = m3db nodes - nodes, closeFn, clientopts := makeMultiNodeSetup(t, numShards, true, true, instances) + nodes, closeFn, clientopts := makeMultiNodeSetup(t, numShards, true, true, instances) //nolint:govet clientopts = clientopts.SetReadConsistencyLevel(lvl) defer closeFn() diff --git a/src/dbnode/integration/peers_bootstrap_none_available_test.go b/src/dbnode/integration/peers_bootstrap_none_available_test.go index aab492547d..264d9060e3 100644 --- a/src/dbnode/integration/peers_bootstrap_none_available_test.go +++ b/src/dbnode/integration/peers_bootstrap_none_available_test.go @@ -106,7 +106,7 @@ func TestPeersBootstrapNoneAvailable(t *testing.T) { defer closeFn() setups.parallel(func(s TestSetup) { - s.StartServer() + require.NoError(t, s.StartServer()) }) log.Debug("servers are now up") diff --git a/src/dbnode/integration/peers_bootstrap_partial_data_test.go b/src/dbnode/integration/peers_bootstrap_partial_data_test.go index 60fd12d6d7..2d547fd070 100644 --- a/src/dbnode/integration/peers_bootstrap_partial_data_test.go +++ b/src/dbnode/integration/peers_bootstrap_partial_data_test.go @@ -26,14 +26,13 @@ import ( "testing" "time" - xtime "github.com/m3db/m3/src/x/time" + "github.com/stretchr/testify/require" "github.com/m3db/m3/src/dbnode/integration/generate" "github.com/m3db/m3/src/dbnode/namespace" "github.com/m3db/m3/src/dbnode/retention" xtest "github.com/m3db/m3/src/x/test" - - "github.com/stretchr/testify/require" + xtime "github.com/m3db/m3/src/x/time" ) // This test simulates a case where node fails / reboots while fetching data from peers. @@ -72,7 +71,7 @@ func TestPeersBootstrapPartialData(t *testing.T) { DisablePeersBootstrapper: false, }, } - setups, closeFn := NewDefaultBootstrappableTestSetups(t, opts, setupOpts) + setups, closeFn := NewDefaultBootstrappableTestSetups(t, opts, setupOpts) //nolint:govet defer closeFn() // Write test data to first node diff --git a/src/dbnode/integration/series_wired_list_panic_test.go b/src/dbnode/integration/series_wired_list_panic_test.go index f3a26ad7eb..a298aaee2e 100644 --- a/src/dbnode/integration/series_wired_list_panic_test.go +++ b/src/dbnode/integration/series_wired_list_panic_test.go @@ -27,6 +27,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/m3db/m3/src/dbnode/generated/thrift/rpc" "github.com/m3db/m3/src/dbnode/integration/generate" "github.com/m3db/m3/src/dbnode/namespace" @@ -36,17 +38,13 @@ import ( "github.com/m3db/m3/src/dbnode/storage/block" "github.com/m3db/m3/src/x/ident" xtime "github.com/m3db/m3/src/x/time" - - "github.com/stretchr/testify/require" ) const ( numSeries = 10 ) -var ( - nsID = ident.StringID("ns0") -) +var nsID = ident.StringID("ns0") func TestWiredListPanic(t *testing.T) { // This test is used to repro https://github.com/m3db/m3/issues/2573. diff --git a/src/dbnode/integration/write_quorum_test.go b/src/dbnode/integration/write_quorum_test.go index af2411bded..f5074b7872 100644 --- a/src/dbnode/integration/write_quorum_test.go +++ b/src/dbnode/integration/write_quorum_test.go @@ -237,7 +237,7 @@ func makeTestWrite( node.SetOpts(node.Opts().SetNumShards(numShards)) for _, ns := range node.Namespaces() { // write empty data files to disk so nodes could bootstrap - writeTestDataToDisk(ns, node, generate.SeriesBlocksByStart{}, 0) + require.NoError(t, writeTestDataToDisk(ns, node, generate.SeriesBlocksByStart{}, 0)) } } diff --git a/src/dbnode/integration/write_read_high_concurrency_test.go b/src/dbnode/integration/write_read_high_concurrency_test.go index 0d622ce1ba..9eeb7f6170 100644 --- a/src/dbnode/integration/write_read_high_concurrency_test.go +++ b/src/dbnode/integration/write_read_high_concurrency_test.go @@ -60,7 +60,7 @@ func TestWriteReadHighConcurrencyTestMultiNS(t *testing.T) { node(t, 2, newClusterShardsRange(minShard, maxShard, shard.Available)), } ) - nodes, closeFn, clientopts := makeMultiNodeSetup(t, numShards, true, true, instances) + nodes, closeFn, clientopts := makeMultiNodeSetup(t, numShards, true, true, instances) //nolint:govet clientopts = clientopts. SetWriteConsistencyLevel(topology.ConsistencyLevelAll). SetReadConsistencyLevel(topology.ReadConsistencyLevelAll) diff --git a/src/dbnode/integration/write_tagged_quorum_test.go b/src/dbnode/integration/write_tagged_quorum_test.go index 303d4c2a9d..b4bd7c307c 100644 --- a/src/dbnode/integration/write_tagged_quorum_test.go +++ b/src/dbnode/integration/write_tagged_quorum_test.go @@ -261,7 +261,7 @@ func makeTestWriteTagged( for _, node := range nodes { for _, ns := range node.Namespaces() { // write empty data files to disk so nodes could bootstrap - writeTestDataToDisk(ns, node, generate.SeriesBlocksByStart{}, 0) + require.NoError(t, writeTestDataToDisk(ns, node, generate.SeriesBlocksByStart{}, 0)) } } diff --git a/src/dbnode/storage/bootstrap/bootstrapper/commitlog/source_prop_test.go b/src/dbnode/storage/bootstrap/bootstrapper/commitlog/source_prop_test.go index 57146b5786..7928b0dce8 100644 --- a/src/dbnode/storage/bootstrap/bootstrapper/commitlog/source_prop_test.go +++ b/src/dbnode/storage/bootstrap/bootstrapper/commitlog/source_prop_test.go @@ -23,6 +23,7 @@ package commitlog import ( + "errors" "fmt" "io" "io/ioutil" @@ -194,7 +195,7 @@ func TestCommitLogSourcePropCorrectlyBootstrapsFromCommitlog(t *testing.T) { reader, ok := encoder.Stream(ctx) if ok { bytes, err := xio.ToBytes(reader) - if err != io.EOF { + if errors.Is(err, io.EOF) { return false, err } encodersBySeries[seriesID] = bytes diff --git a/src/dbnode/storage/index/block_prop_test.go b/src/dbnode/storage/index/block_prop_test.go index d555e327c3..d203b60309 100644 --- a/src/dbnode/storage/index/block_prop_test.go +++ b/src/dbnode/storage/index/block_prop_test.go @@ -128,20 +128,24 @@ func TestPostingsListCacheDoesNotAffectBlockQueryResults(t *testing.T) { require.NoError(t, err) for !queryIter.Done() { err = uncachedBlock.QueryWithIter(ctx, - queryOpts, queryIter, uncachedResults, time.Now().Add(time.Millisecond * 10), emptyLogFields) + queryOpts, queryIter, uncachedResults, time.Now().Add(time.Millisecond*10), emptyLogFields) if err != nil { - return false, fmt.Errorf("error querying uncached block: %v", err) + return false, fmt.Errorf("error querying uncached block: %w", err) } } cachedResults := NewQueryResults(nil, QueryResultsOptions{}, testOpts) ctx = context.NewBackground() queryIter, err = cachedBlock.QueryIter(ctx, indexQuery) + if err != nil { + return false, err + } + for !queryIter.Done() { err = cachedBlock.QueryWithIter(ctx, queryOpts, queryIter, cachedResults, - time.Now().Add(time.Millisecond * 10), emptyLogFields) + time.Now().Add(time.Millisecond*10), emptyLogFields) if err != nil { - return false, fmt.Errorf("error querying cached block: %v", err) + return false, fmt.Errorf("error querying cached block: %w", err) } } @@ -378,7 +382,7 @@ func TestAggregateDocLimits(t *testing.T) { aggIter, QueryOptions{}, results, - time.Now().Add(time.Millisecond * 10), + time.Now().Add(time.Millisecond*10), emptyLogFields) if err != nil { diff --git a/src/dbnode/storage/series/series_parallel_test.go b/src/dbnode/storage/series/series_parallel_test.go index 1a0848e428..68fc5a70df 100644 --- a/src/dbnode/storage/series/series_parallel_test.go +++ b/src/dbnode/storage/series/series_parallel_test.go @@ -28,7 +28,6 @@ import ( "time" "github.com/golang/mock/gomock" - xtest "github.com/m3db/m3/src/x/test" "github.com/stretchr/testify/require" "github.com/m3db/m3/src/dbnode/namespace" @@ -36,6 +35,7 @@ import ( "github.com/m3db/m3/src/dbnode/ts" "github.com/m3db/m3/src/x/context" "github.com/m3db/m3/src/x/ident" + xtest "github.com/m3db/m3/src/x/test" xtime "github.com/m3db/m3/src/x/time" ) From e50df1e6017bc65567be1f43e93061be3e29e7d9 Mon Sep 17 00:00:00 2001 From: Vilius Pranckaitis Date: Fri, 7 May 2021 10:19:01 +0300 Subject: [PATCH 3/3] fix test --- .../bootstrap/bootstrapper/commitlog/source_prop_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbnode/storage/bootstrap/bootstrapper/commitlog/source_prop_test.go b/src/dbnode/storage/bootstrap/bootstrapper/commitlog/source_prop_test.go index 7928b0dce8..e46d0c7434 100644 --- a/src/dbnode/storage/bootstrap/bootstrapper/commitlog/source_prop_test.go +++ b/src/dbnode/storage/bootstrap/bootstrapper/commitlog/source_prop_test.go @@ -195,7 +195,7 @@ func TestCommitLogSourcePropCorrectlyBootstrapsFromCommitlog(t *testing.T) { reader, ok := encoder.Stream(ctx) if ok { bytes, err := xio.ToBytes(reader) - if errors.Is(err, io.EOF) { + if !errors.Is(err, io.EOF) { return false, err } encodersBySeries[seriesID] = bytes