diff --git a/cmd/tools/segment-verify/main.go b/cmd/tools/segment-verify/main.go index 87d7f5868..2a26cb97d 100644 --- a/cmd/tools/segment-verify/main.go +++ b/cmd/tools/segment-verify/main.go @@ -142,10 +142,13 @@ type ReadCSVConfig struct { } func verifySegments(cmd *cobra.Command, args []string) error { - ctx, _ := process.Ctx(cmd) log := zap.L() + return verifySegmentsInContext(ctx, log, cmd, satelliteCfg, rangeCfg) +} + +func verifySegmentsInContext(ctx context.Context, log *zap.Logger, cmd *cobra.Command, satelliteCfg Satellite, rangeCfg RangeConfig) error { // open default satellite database db, err := satellitedb.Open(ctx, log.Named("db"), satelliteCfg.Database, satellitedb.Options{ ApplicationName: "segment-verify", diff --git a/cmd/tools/segment-verify/main_test.go b/cmd/tools/segment-verify/main_test.go index bc9ac13ca..81910c529 100644 --- a/cmd/tools/segment-verify/main_test.go +++ b/cmd/tools/segment-verify/main_test.go @@ -20,6 +20,7 @@ import ( "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" "storj.io/common/memory" "storj.io/common/storj" @@ -57,12 +58,14 @@ func TestCommandLineTool(t *testing.T) { problemPiecesCSV := ctx.File("problempieces.csv") // set up global config that the main func will use + satelliteCfg := satelliteCfg satelliteCfg.Config = satellite.Config satelliteCfg.Database = dbConnString satelliteCfg.Metainfo.DatabaseURL = metaDBConnString satelliteCfg.Identity.KeyPath = ctx.File("identity-key") satelliteCfg.Identity.CertPath = ctx.File("identity-cert") require.NoError(t, satelliteCfg.Identity.Save(satellite.Identity)) + rangeCfg := rangeCfg rangeCfg.Verify = VerifierConfig{ PerPieceTimeout: time.Second, OrderRetryThrottle: 500 * time.Millisecond, @@ -119,7 +122,8 @@ func TestCommandLineTool(t *testing.T) { require.Len(t, result.Segments, uplinkCount*nodeCount) // perform the verify! - err = verifySegments(&cobra.Command{Use: "range"}, nil) + log := zaptest.NewLogger(t) + err = verifySegmentsInContext(ctx, log, &cobra.Command{Use: "range"}, satelliteCfg, rangeCfg) require.NoError(t, err) // open the CSVs to check that we get the expected results