cmd/tools/segment-verify: fix global race in TestCommandLineTool.
This should stop the failures when TestCommandLineTool is run with parallel test execution enabled. Change-Id: Id80d5eacb78fcec886be786ae8b182517b17fbc6
This commit is contained in:
parent
e65345336f
commit
8be7414a52
@ -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",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user