From 0cdef95d5550476c2972d55f6e19df2b7cd4ee54 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Fri, 17 Feb 2023 14:58:26 +0200 Subject: [PATCH] all: fix math/rand deprecations Change-Id: I4b966375697c0d409ce24cc7604f806973f8f22a --- cmd/uplink/ulimit_other.go | 4 +--- multinode/multinodedb/dbx/gen.sh | 2 +- multinode/multinodedb/dbx/multinodedb.dbx.go | 2 +- satellite/gracefulexit/gracefulexit_test.go | 3 --- satellite/repair/queue/queue2_test.go | 1 - testsuite/storjscan/go.mod | 2 +- testsuite/storjscan/storjscantest/run.go | 3 --- versioncontrol/peer_test.go | 8 +++----- 8 files changed, 7 insertions(+), 18 deletions(-) diff --git a/cmd/uplink/ulimit_other.go b/cmd/uplink/ulimit_other.go index a221def9a..1e45d64f4 100644 --- a/cmd/uplink/ulimit_other.go +++ b/cmd/uplink/ulimit_other.go @@ -6,6 +6,4 @@ package main -func raiseUlimits() { - return -} +func raiseUlimits() {} diff --git a/multinode/multinodedb/dbx/gen.sh b/multinode/multinodedb/dbx/gen.sh index 0bf858f25..50eb94b24 100644 --- a/multinode/multinodedb/dbx/gen.sh +++ b/multinode/multinodedb/dbx/gen.sh @@ -4,7 +4,7 @@ set -e pipefail dbx schema -d pgx -d sqlite3 multinodedb.dbx . dbx golang -d pgx -d sqlite3 -p dbx -t templates multinodedb.dbx . -( printf '%s\n' '//lint:file-ignore U1000,ST1012 generated file'; cat multinodedb.dbx.go ) > multinodedb.dbx.go.tmp && mv multinodedb.dbx.go.tmp multinodedb.dbx.go +( printf '%s\n' '//lint:file-ignore U1000,ST1012,SA1019 generated file'; cat multinodedb.dbx.go ) > multinodedb.dbx.go.tmp && mv multinodedb.dbx.go.tmp multinodedb.dbx.go gofmt -r "*sql.Tx -> tagsql.Tx" -w multinodedb.dbx.go gofmt -r "*sql.Rows -> tagsql.Rows" -w multinodedb.dbx.go perl -0777 -pi \ diff --git a/multinode/multinodedb/dbx/multinodedb.dbx.go b/multinode/multinodedb/dbx/multinodedb.dbx.go index 8d996970e..a0d3209d8 100644 --- a/multinode/multinodedb/dbx/multinodedb.dbx.go +++ b/multinode/multinodedb/dbx/multinodedb.dbx.go @@ -1,4 +1,4 @@ -//lint:file-ignore U1000,ST1012 generated file +//lint:file-ignore U1000,ST1012,SA1019 generated file // AUTOGENERATED BY storj.io/dbx // DO NOT EDIT. diff --git a/satellite/gracefulexit/gracefulexit_test.go b/satellite/gracefulexit/gracefulexit_test.go index 0503c867f..7d9a2a67e 100644 --- a/satellite/gracefulexit/gracefulexit_test.go +++ b/satellite/gracefulexit/gracefulexit_test.go @@ -296,7 +296,6 @@ func TestGracefulExit_CopiedObjects(t *testing.T) { // TestGracefulExit_Enqueue_And_DeleteAllFinishedTransferQueueItems_batch // ensures that deletion works as expected using different batch sizes. func TestGracefulExit_Enqueue_And_DeleteAllFinishedTransferQueueItems_batchsize(t *testing.T) { - rand.Seed(time.Now().UnixNano()) var testCases = []struct { name string batchSize int @@ -400,8 +399,6 @@ func generateExitedNodes(t *testing.T, ctx *testcontext.Context, db satellite.DB // the CRDB batch logic for delete all the transfer queue items of exited nodes // works as expected. func TestGracefulExit_DeleteAllFinishedTransferQueueItems_batch(t *testing.T) { - rand.Seed(time.Now().UnixNano()) - satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { const ( addr = "127.0.1.0:8080" diff --git a/satellite/repair/queue/queue2_test.go b/satellite/repair/queue/queue2_test.go index cd18face5..e89d32776 100644 --- a/satellite/repair/queue/queue2_test.go +++ b/satellite/repair/queue/queue2_test.go @@ -160,7 +160,6 @@ func testorderHealthyPieces(t *testing.T, connStr string) { {uuid.UUID{'h'}, 10, time.Now().Add(-8 * time.Hour)}, } // shuffle list since select order should not depend on insert order - rand.Seed(time.Now().UnixNano()) rand.Shuffle(len(injuredSegList), func(i, j int) { injuredSegList[i], injuredSegList[j] = injuredSegList[j], injuredSegList[i] }) diff --git a/testsuite/storjscan/go.mod b/testsuite/storjscan/go.mod index 98615b548..5f5c7d724 100644 --- a/testsuite/storjscan/go.mod +++ b/testsuite/storjscan/go.mod @@ -5,7 +5,6 @@ go 1.18 replace storj.io/storj => ../../ require ( - github.com/spacemonkeygo/monkit/v3 v3.0.19 github.com/stretchr/testify v1.8.0 github.com/zeebo/errs v1.3.0 go.uber.org/zap v1.21.0 @@ -108,6 +107,7 @@ require ( github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/shopspring/decimal v1.2.0 // indirect + github.com/spacemonkeygo/monkit/v3 v3.0.19 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spf13/cobra v1.1.3 // indirect github.com/spf13/pflag v1.0.5 // indirect diff --git a/testsuite/storjscan/storjscantest/run.go b/testsuite/storjscan/storjscantest/run.go index 399539179..d98b0384a 100644 --- a/testsuite/storjscan/storjscantest/run.go +++ b/testsuite/storjscan/storjscantest/run.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/spacemonkeygo/monkit/v3" "github.com/zeebo/errs" "go.uber.org/zap" "golang.org/x/sync/errgroup" @@ -29,8 +28,6 @@ import ( "storj.io/uplink" ) -var mon = monkit.Package() - // Stack contains references to storjscan app and eth test network. type Stack struct { Log *zap.Logger diff --git a/versioncontrol/peer_test.go b/versioncontrol/peer_test.go index d5e2b86ad..b58512650 100644 --- a/versioncontrol/peer_test.go +++ b/versioncontrol/peer_test.go @@ -7,7 +7,6 @@ import ( "context" "encoding/hex" "io" - "math/rand" "net/http" "reflect" "strings" @@ -18,6 +17,7 @@ import ( "golang.org/x/sync/errgroup" "storj.io/common/testcontext" + "storj.io/common/testrand" "storj.io/storj/versioncontrol" ) @@ -363,7 +363,7 @@ func randRollout(t *testing.T) versioncontrol.RolloutConfig { return versioncontrol.RolloutConfig{ Seed: randSeedString(t), - Cursor: rand.Intn(101), + Cursor: testrand.Intn(101), } } @@ -371,8 +371,6 @@ func randSeedString(t *testing.T) string { t.Helper() seed := make([]byte, 32) - _, err := rand.Read(seed) - require.NoError(t, err) - + testrand.Read(seed) return hex.EncodeToString(seed) }