From 3889e829e6d1a858c71b3b649eed615b41be2480 Mon Sep 17 00:00:00 2001 From: "a.arifullin" Date: Thu, 14 Sep 2023 14:08:43 +0300 Subject: [PATCH] [#667] writecache: Add logs for report error func in tests Signed-off-by: Airat Arifullin a.arifullin@yadro.com --- .../writecache/writecachebadger/flush_test.go | 6 +++++- .../writecache/writecachebbolt/flush_test.go | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/local_object_storage/writecache/writecachebadger/flush_test.go b/pkg/local_object_storage/writecache/writecachebadger/flush_test.go index 855d2214..392654e4 100644 --- a/pkg/local_object_storage/writecache/writecachebadger/flush_test.go +++ b/pkg/local_object_storage/writecache/writecachebadger/flush_test.go @@ -14,9 +14,12 @@ import ( oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test" "github.com/dgraph-io/badger/v4" "github.com/stretchr/testify/require" + "go.uber.org/zap" ) func TestFlush(t *testing.T) { + testlogger := test.NewLogger(t, true) + createCacheFn := func(t *testing.T, smallSize uint64, mb *meta.DB, bs writecache.MainStorage, opts ...Option) writecache.Cache { return New( append([]Option{ @@ -30,8 +33,9 @@ func TestFlush(t *testing.T) { errCountOpt := func() (Option, *atomic.Uint32) { cnt := &atomic.Uint32{} - return WithReportErrorFunc(func(string, error) { + return WithReportErrorFunc(func(msg string, err error) { cnt.Add(1) + testlogger.Warn(msg, zap.Uint32("error_count", cnt.Load()), zap.Error(err)) }), cnt } diff --git a/pkg/local_object_storage/writecache/writecachebbolt/flush_test.go b/pkg/local_object_storage/writecache/writecachebbolt/flush_test.go index 5db4df31..533cec1d 100644 --- a/pkg/local_object_storage/writecache/writecachebbolt/flush_test.go +++ b/pkg/local_object_storage/writecache/writecachebbolt/flush_test.go @@ -17,13 +17,16 @@ import ( oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test" "github.com/stretchr/testify/require" "go.etcd.io/bbolt" + "go.uber.org/zap" ) func TestFlush(t *testing.T) { + testlogger := test.NewLogger(t, true) + createCacheFn := func(t *testing.T, smallSize uint64, mb *meta.DB, bs writecache.MainStorage, opts ...Option) writecache.Cache { return New( append([]Option{ - WithLogger(test.NewLogger(t, true)), + WithLogger(testlogger), WithPath(filepath.Join(t.TempDir(), "writecache")), WithSmallObjectSize(smallSize), WithMetabase(mb), @@ -33,8 +36,9 @@ func TestFlush(t *testing.T) { errCountOpt := func() (Option, *atomic.Uint32) { cnt := &atomic.Uint32{} - return WithReportErrorFunc(func(string, error) { + return WithReportErrorFunc(func(msg string, err error) { cnt.Add(1) + testlogger.Warn(msg, zap.Uint32("error_count", cnt.Load()), zap.Error(err)) }), cnt }