[#895] test: Fix NewLogger arguments list

`debug` is always true.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-01-09 11:37:41 +03:00 committed by Evgenii Stratonikov
parent a8e52ef7aa
commit f1b2b8bffa
32 changed files with 60 additions and 65 deletions

View file

@ -19,7 +19,7 @@ func TestEpochTimer(t *testing.T) {
}
args := &epochTimerArgs{
l: test.NewLogger(t, true),
l: test.NewLogger(t),
alphabetState: alphaState,
newEpochHandlers: []newEpochHandler{neh.Handle},
cnrWrapper: cnrStopper,

View file

@ -48,7 +48,7 @@ func TestProcessorEmitsGasToNetmapAndAlphabet(t *testing.T) {
params := &alphabet.Params{
ParsedWallets: parsedWallets,
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 2,
StorageEmission: emission,
IRList: &testIndexer{index: index},
@ -125,7 +125,7 @@ func TestProcessorEmitsGasToNetmapIfNoParsedWallets(t *testing.T) {
params := &alphabet.Params{
ParsedWallets: parsedWallets,
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 2,
StorageEmission: emission,
IRList: &testIndexer{index: index},
@ -186,7 +186,7 @@ func TestProcessorDoesntEmitGasIfNoNetmapOrParsedWallets(t *testing.T) {
params := &alphabet.Params{
ParsedWallets: parsedWallets,
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 2,
StorageEmission: emission,
IRList: &testIndexer{index: index},

View file

@ -21,7 +21,7 @@ func TestProcessorCallsFrostFSContractForLockEvent(t *testing.T) {
bsc := util.Uint160{100}
processor, err := New(&Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 2,
FrostFSClient: cl,
BalanceSC: bsc,
@ -47,7 +47,7 @@ func TestProcessorDoesntCallFrostFSContractIfNotAlphabet(t *testing.T) {
bsc := util.Uint160{100}
processor, err := New(&Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 2,
FrostFSClient: cl,
BalanceSC: bsc,

View file

@ -38,7 +38,7 @@ func TestPutEvent(t *testing.T) {
mc := &testMorphClient{}
proc, err := New(&Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 2,
AlphabetState: &testAlphabetState{isAlphabet: true},
NetworkState: nst,
@ -99,7 +99,7 @@ func TestDeleteEvent(t *testing.T) {
mc := &testMorphClient{}
proc, err := New(&Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 2,
AlphabetState: &testAlphabetState{isAlphabet: true},
NetworkState: nst,
@ -171,7 +171,7 @@ func TestSetEACLEvent(t *testing.T) {
mc := &testMorphClient{}
proc, err := New(&Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 2,
AlphabetState: &testAlphabetState{isAlphabet: true},
NetworkState: nst,

View file

@ -193,7 +193,7 @@ func TestHandleConfig(t *testing.T) {
func newTestProc(t *testing.T, nonDefault func(p *Params)) (*Processor, error) {
p := &Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 1,
FrostFSContract: util.Uint160{0},
BalanceClient: &testBalaceClient{},

View file

@ -42,7 +42,7 @@ func TestHandleAlphabetSyncEvent(t *testing.T) {
proc, err := New(
&Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
EpochState: es,
AlphabetState: as,
Voter: v,
@ -123,7 +123,7 @@ func TestHandleAlphabetDesignateEvent(t *testing.T) {
proc, err := New(
&Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
EpochState: es,
AlphabetState: as,
Voter: v,

View file

@ -279,7 +279,7 @@ func newTestProc(t *testing.T, nonDefault func(p *Params)) (*Processor, error) {
eh := &testEventHandler{}
p := &Params{
Log: test.NewLogger(t, true),
Log: test.NewLogger(t),
PoolSize: 1,
CleanupEnabled: false,
CleanupThreshold: 3,

View file

@ -63,7 +63,7 @@ func TestBlobovnicza(t *testing.T) {
WithPath(p),
WithObjectSizeLimit(objSizeLim),
WithFullSizeLimit(sizeLim),
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
)
defer os.Remove(p)

View file

@ -17,7 +17,7 @@ func TestBlobovniczaTree_Concurrency(t *testing.T) {
const n = 1000
st := NewBlobovniczaTree(
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithObjectSizeLimit(1024),
WithBlobovniczaShallowWidth(10),
WithBlobovniczaShallowDepth(1),

View file

@ -17,7 +17,7 @@ import (
func TestExistsInvalidStorageID(t *testing.T) {
dir := t.TempDir()
b := NewBlobovniczaTree(
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithObjectSizeLimit(1024),
WithBlobovniczaShallowWidth(2),
WithBlobovniczaShallowDepth(2),

View file

@ -13,7 +13,7 @@ func TestGeneric(t *testing.T) {
helper := func(t *testing.T, dir string) common.Storage {
return NewBlobovniczaTree(
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithObjectSizeLimit(maxObjectSize),
WithBlobovniczaShallowWidth(2),
WithBlobovniczaShallowDepth(2),
@ -40,7 +40,7 @@ func TestControl(t *testing.T) {
newTree := func(t *testing.T) common.Storage {
return NewBlobovniczaTree(
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithObjectSizeLimit(maxObjectSize),
WithBlobovniczaShallowWidth(2),
WithBlobovniczaShallowDepth(2),

View file

@ -129,7 +129,7 @@ func testRebuildFailoverObjectDeletedFromSource(t *testing.T) {
func testRebuildFailoverValidate(t *testing.T, dir string, obj *objectSDK.Object, mustUpdateStorageID bool) {
b := NewBlobovniczaTree(
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithObjectSizeLimit(2048),
WithBlobovniczaShallowWidth(2),
WithBlobovniczaShallowDepth(2),

View file

@ -41,7 +41,7 @@ func TestBlobovniczaTreeRebuild(t *testing.T) {
func testBlobovniczaTreeRebuildHelper(t *testing.T, sourceDepth, sourceWidth, targetDepth, targetWidth uint64, shouldMigrate bool) {
dir := t.TempDir()
b := NewBlobovniczaTree(
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithObjectSizeLimit(2048),
WithBlobovniczaShallowWidth(sourceWidth),
WithBlobovniczaShallowDepth(sourceDepth),
@ -81,7 +81,7 @@ func testBlobovniczaTreeRebuildHelper(t *testing.T, sourceDepth, sourceWidth, ta
require.NoError(t, b.Close())
b = NewBlobovniczaTree(
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithObjectSizeLimit(2048),
WithBlobovniczaShallowWidth(targetWidth),
WithBlobovniczaShallowDepth(targetDepth),

View file

@ -15,7 +15,7 @@ import (
func TestSimpleLifecycle(t *testing.T) {
s := New(
WithRootPath("memstore"),
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
)
t.Cleanup(func() { _ = s.Close() })
require.NoError(t, s.Open(false))

View file

@ -49,7 +49,7 @@ func TestInitializationFailure(t *testing.T) {
return []shard.Option{
shard.WithID(sid),
shard.WithLogger(test.NewLogger(t, true)),
shard.WithLogger(test.NewLogger(t)),
shard.WithBlobStorOptions(
blobstor.WithStorages(storages)),
shard.WithMetaBaseOptions(
@ -289,7 +289,7 @@ func engineWithShards(t *testing.T, path string, num int) (*StorageEngine, []str
te := testNewEngine(t).
setShardsNumOpts(t, num, func(id int) []shard.Option {
return []shard.Option{
shard.WithLogger(test.NewLogger(t, true)),
shard.WithLogger(test.NewLogger(t)),
shard.WithBlobStorOptions(
blobstor.WithStorages(newStorages(filepath.Join(addPath, strconv.Itoa(id)), errSmallSize))),
shard.WithMetaBaseOptions(

View file

@ -53,7 +53,7 @@ func TestDeleteBigObject(t *testing.T) {
s3 := testNewShard(t, 3)
e := testNewEngine(t).setInitializedShards(t, s1, s2, s3).engine
e.log = test.NewLogger(t, true)
e.log = test.NewLogger(t)
defer e.Close(context.Background())
for i := range children {

View file

@ -79,7 +79,7 @@ type testEngineWrapper struct {
}
func testNewEngine(t testing.TB, opts ...Option) *testEngineWrapper {
engine := New(WithLogger(test.NewLogger(t, true)))
engine := New(WithLogger(test.NewLogger(t)))
for _, opt := range opts {
opt(engine.cfg)
}
@ -198,7 +198,7 @@ func testNewShard(t testing.TB, id int) *shard.Shard {
func testDefaultShardOptions(t testing.TB, id int) []shard.Option {
return []shard.Option{
shard.WithLogger(test.NewLogger(t, true)),
shard.WithLogger(test.NewLogger(t)),
shard.WithBlobStorOptions(
blobstor.WithStorages(
newStorages(t.TempDir(), 1<<20))),

View file

@ -55,7 +55,7 @@ func newEngineWithErrorThreshold(t testing.TB, dir string, errThreshold uint32)
largeFileStorage: largeFileStorage,
}
return []shard.Option{
shard.WithLogger(test.NewLogger(t, true)),
shard.WithLogger(test.NewLogger(t)),
shard.WithBlobStorOptions(blobstor.WithStorages(storages)),
shard.WithMetaBaseOptions(
meta.WithPath(filepath.Join(dir, fmt.Sprintf("%d.metabase", id))),

View file

@ -30,7 +30,7 @@ func newEngineEvacuate(t *testing.T, shardNum int, objPerShard int) (*StorageEng
te := testNewEngine(t).
setShardsNumOpts(t, shardNum, func(id int) []shard.Option {
return []shard.Option{
shard.WithLogger(test.NewLogger(t, true)),
shard.WithLogger(test.NewLogger(t)),
shard.WithBlobStorOptions(
blobstor.WithStorages([]blobstor.SubStorage{{
Storage: fstree.New(

View file

@ -65,7 +65,7 @@ func TestListWithCursor(t *testing.T) {
t.Parallel()
e := testNewEngine(t).setShardsNumOpts(t, tt.shardNum, func(id int) []shard.Option {
return []shard.Option{
shard.WithLogger(test.NewLogger(t, true)),
shard.WithLogger(test.NewLogger(t)),
shard.WithBlobStorOptions(
blobstor.WithStorages(
newStorages(t.TempDir(), 1<<20))),

View file

@ -64,7 +64,7 @@ func TestShardOpen(t *testing.T) {
newShard := func() *Shard {
return New(
WithID(NewIDFromBytes([]byte{})),
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithBlobStorOptions(
blobstor.WithStorages([]blobstor.SubStorage{
{Storage: st},

View file

@ -30,13 +30,13 @@ func Test_ObjectNotFoundIfNotDeletedFromMetabase(t *testing.T) {
rootPath := t.TempDir()
var sh *Shard
l := test.NewLogger(t, true)
l := test.NewLogger(t)
blobOpts := []blobstor.Option{
blobstor.WithLogger(test.NewLogger(t, true)),
blobstor.WithLogger(test.NewLogger(t)),
blobstor.WithStorages([]blobstor.SubStorage{
{
Storage: blobovniczatree.NewBlobovniczaTree(
blobovniczatree.WithLogger(test.NewLogger(t, true)),
blobovniczatree.WithLogger(test.NewLogger(t)),
blobovniczatree.WithRootPath(filepath.Join(rootPath, "blob", "blobovnicza")),
blobovniczatree.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1)),

View file

@ -78,7 +78,7 @@ func testShardGetRange(t *testing.T, hasWriteCache bool) {
blobstor.WithStorages([]blobstor.SubStorage{
{
Storage: blobovniczatree.NewBlobovniczaTree(
blobovniczatree.WithLogger(test.NewLogger(t, true)),
blobovniczatree.WithLogger(test.NewLogger(t)),
blobovniczatree.WithRootPath(filepath.Join(t.TempDir(), "blob", "blobovnicza")),
blobovniczatree.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1)),

View file

@ -27,7 +27,7 @@ func TestShardReload(t *testing.T) {
p := t.Name()
defer os.RemoveAll(p)
l := test.NewLogger(t, true)
l := test.NewLogger(t)
blobOpts := []blobstor.Option{
blobstor.WithLogger(l),
blobstor.WithStorages([]blobstor.SubStorage{

View file

@ -56,11 +56,11 @@ func newCustomShard(t testing.TB, enableWriteCache bool, o shardOptions) *Shard
if o.bsOpts == nil {
o.bsOpts = []blobstor.Option{
blobstor.WithLogger(test.NewLogger(t, true)),
blobstor.WithLogger(test.NewLogger(t)),
blobstor.WithStorages([]blobstor.SubStorage{
{
Storage: blobovniczatree.NewBlobovniczaTree(
blobovniczatree.WithLogger(test.NewLogger(t, true)),
blobovniczatree.WithLogger(test.NewLogger(t)),
blobovniczatree.WithRootPath(filepath.Join(o.rootPath, "blob", "blobovnicza")),
blobovniczatree.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1)),
@ -78,7 +78,7 @@ func newCustomShard(t testing.TB, enableWriteCache bool, o shardOptions) *Shard
opts := []Option{
WithID(NewIDFromBytes([]byte{})),
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithBlobStorOptions(o.bsOpts...),
WithMetaBaseOptions(
append([]meta.Option{

View file

@ -24,7 +24,7 @@ import (
)
func TestFlush(t *testing.T) {
testlogger := test.NewLogger(t, true)
testlogger := test.NewLogger(t)
createCacheFn := func(t *testing.T, smallSize uint64, mb *meta.DB, bs MainStorage, opts ...Option) Cache {
return New(

View file

@ -10,7 +10,7 @@ import (
func TestGeneric(t *testing.T) {
storagetest.TestAll(t, func(t *testing.T) storagetest.Component {
return New(
WithLogger(test.NewLogger(t, true)),
WithLogger(test.NewLogger(t)),
WithFlushWorkersCount(2),
WithPath(t.TempDir()))
})

View file

@ -20,7 +20,7 @@ func TestEventHandling(t *testing.T) {
notaryRequestsCh := make(chan *result.NotaryRequestEvent)
l, err := NewListener(ListenerParams{
Logger: test.NewLogger(t, true),
Logger: test.NewLogger(t),
Subscriber: &testSubscriber{
blockCh: blockCh,
notificationCh: notificationCh,
@ -102,7 +102,7 @@ func TestErrorPassing(t *testing.T) {
t.Run("notification error", func(t *testing.T) {
nErr := fmt.Errorf("notification error")
l, err := NewListener(ListenerParams{
Logger: test.NewLogger(t, true),
Logger: test.NewLogger(t),
Subscriber: &testSubscriber{
blockCh: blockCh,
notificationCh: notificationCh,
@ -126,7 +126,7 @@ func TestErrorPassing(t *testing.T) {
t.Run("block error", func(t *testing.T) {
bErr := fmt.Errorf("notification error")
l, err := NewListener(ListenerParams{
Logger: test.NewLogger(t, true),
Logger: test.NewLogger(t),
Subscriber: &testSubscriber{
blockCh: blockCh,
notificationCh: notificationCh,

View file

@ -270,7 +270,7 @@ func TestGetLocalOnly(t *testing.T) {
newSvc := func(storage *testStorage) *Service {
return &Service{
log: test.NewLogger(t, true),
log: test.NewLogger(t),
localStorage: storage,
}
}
@ -532,7 +532,7 @@ func TestGetRemoteSmall(t *testing.T) {
const curEpoch = 13
return &Service{
log: test.NewLogger(t, true),
log: test.NewLogger(t),
localStorage: newTestStorage(),
traverserGenerator: &testTraverserGenerator{
c: cnr,
@ -1663,7 +1663,7 @@ func TestGetFromPastEpoch(t *testing.T) {
const curEpoch = 13
svc := &Service{
log: test.NewLogger(t, true),
log: test.NewLogger(t),
localStorage: newTestStorage(),
epochSource: testEpochReceiver(curEpoch),
traverserGenerator: &testTraverserGenerator{

View file

@ -161,7 +161,7 @@ func TestGetLocalOnly(t *testing.T) {
newSvc := func(storage *testStorage) *Service {
svc := &Service{cfg: new(cfg)}
svc.log = test.NewLogger(t, true)
svc.log = test.NewLogger(t)
svc.localStorage = storage
return svc
@ -277,7 +277,7 @@ func TestGetRemoteSmall(t *testing.T) {
newSvc := func(b *testPlacementBuilder, c *testClientCache) *Service {
svc := &Service{cfg: new(cfg)}
svc.log = test.NewLogger(t, true)
svc.log = test.NewLogger(t)
svc.localStorage = newTestStorage()
const curEpoch = 13
@ -430,7 +430,7 @@ func TestGetFromPastEpoch(t *testing.T) {
c22.addResult(idCnr, ids22, nil)
svc := &Service{cfg: new(cfg)}
svc.log = test.NewLogger(t, true)
svc.log = test.NewLogger(t)
svc.localStorage = newTestStorage()
const curEpoch = 13
@ -543,7 +543,7 @@ func TestGetWithSessionToken(t *testing.T) {
w := new(simpleIDWriter)
svc := &Service{cfg: new(cfg)}
svc.log = test.NewLogger(t, true)
svc.log = test.NewLogger(t)
svc.localStorage = localStorage
const curEpoch = 13

View file

@ -100,7 +100,7 @@ func TestMessageSign(t *testing.T) {
s := &Service{
cfg: cfg{
log: test.NewLogger(t, true),
log: test.NewLogger(t),
key: &privs[0].PrivateKey,
nmSource: dummyNetmapSource{},
cnrSource: dummyContainerSource{

View file

@ -10,20 +10,15 @@ import (
)
// NewLogger creates a new logger.
//
// If debug, development logger is created.
func NewLogger(t testing.TB, debug bool) *logger.Logger {
var l logger.Logger
l.Logger = zap.L()
if debug {
func NewLogger(t testing.TB) *logger.Logger {
cfg := zap.NewDevelopmentConfig()
cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
log, err := cfg.Build()
require.NoError(t, err, "could not prepare logger")
var l logger.Logger
l.Logger = log
}
return &l
}