storj/satellite/gc-bf_test.go
Egon Elbre 9e0fff5e22 satellite/gcbf: fix data race in TestGCBFUseRangedLoop
Satellites[0].GCBF is already started when testplanet boots up,
so calling Run separately ends up causing a data race.

Instead create a new instance, that should avoid this issue.

Fixes https://github.com/storj/storj/issues/6435

Change-Id: I6603ef63da7a6ab8bdb952cf5aaca17eb0392e2c
2023-11-01 19:07:20 +02:00

46 lines
1.1 KiB
Go

// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
package satellite_test
import (
"testing"
"github.com/stretchr/testify/require"
"storj.io/common/testcontext"
"storj.io/storj/private/revocation"
"storj.io/storj/private/testplanet"
"storj.io/storj/satellite"
)
func TestGCBFUseRangedLoop(t *testing.T) {
testplanet.Run(t, testplanet.Config{
SatelliteCount: 1,
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
config := planet.Satellites[0].Config
revocationDB, err := revocation.OpenDBFromCfg(ctx, config.Server.Config)
require.NoError(t, err)
defer ctx.Check(revocationDB.Close)
config.GarbageCollectionBF.RunOnce = true
gcbf, err := satellite.NewGarbageCollectionBF(
planet.Log().Named("test-gcbf"),
// hopefully we can share the databases
planet.Satellites[0].GCBF.DB,
planet.Satellites[0].Metabase.DB,
revocationDB,
planet.NewVersionInfo(),
&config,
nil,
)
require.NoError(t, err)
defer ctx.Check(gcbf.Close)
err = gcbf.Run(ctx)
require.NoError(t, err)
})
}