forked from TrueCloudLab/frostfs-node
[#1316] lint: Fix warnings
Renamed parameters `min/max` to avoid conflicts with predeclared identifiers. Replaced background context with parent context without cancellation in closer functions in frostfs-node. Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com> Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
08593f664b
commit
8423e0f6f9
11 changed files with 27 additions and 26 deletions
|
@ -12,7 +12,8 @@ run:
|
||||||
# output configuration options
|
# output configuration options
|
||||||
output:
|
output:
|
||||||
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
|
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
|
||||||
format: tab
|
formats:
|
||||||
|
- format: tab
|
||||||
|
|
||||||
# all available settings of specific linters
|
# all available settings of specific linters
|
||||||
linters-settings:
|
linters-settings:
|
||||||
|
|
|
@ -1070,7 +1070,7 @@ func initLocalStorage(ctx context.Context, c *cfg) {
|
||||||
c.onShutdown(func() {
|
c.onShutdown(func() {
|
||||||
c.log.Info(logs.FrostFSNodeClosingComponentsOfTheStorageEngine)
|
c.log.Info(logs.FrostFSNodeClosingComponentsOfTheStorageEngine)
|
||||||
|
|
||||||
err := ls.Close(context.Background())
|
err := ls.Close(context.WithoutCancel(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Info(logs.FrostFSNodeStorageEngineClosingFailure,
|
c.log.Info(logs.FrostFSNodeStorageEngineClosingFailure,
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
|
|
@ -21,7 +21,7 @@ func initTracing(ctx context.Context, c *cfg) {
|
||||||
c.closers = append(c.closers, closer{
|
c.closers = append(c.closers, closer{
|
||||||
name: "tracing",
|
name: "tracing",
|
||||||
fn: func() {
|
fn: func() {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), time.Second*5)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
err := tracing.Shutdown(ctx) // cfg context cancels before close
|
err := tracing.Shutdown(ctx) // cfg context cancels before close
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -27,21 +27,21 @@ type objectDesc struct {
|
||||||
storageID []byte
|
storageID []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAll(t *testing.T, cons Constructor, min, max uint64) {
|
func TestAll(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
||||||
t.Run("get", func(t *testing.T) {
|
t.Run("get", func(t *testing.T) {
|
||||||
TestGet(t, cons, min, max)
|
TestGet(t, cons, minSize, maxSize)
|
||||||
})
|
})
|
||||||
t.Run("get range", func(t *testing.T) {
|
t.Run("get range", func(t *testing.T) {
|
||||||
TestGetRange(t, cons, min, max)
|
TestGetRange(t, cons, minSize, maxSize)
|
||||||
})
|
})
|
||||||
t.Run("delete", func(t *testing.T) {
|
t.Run("delete", func(t *testing.T) {
|
||||||
TestDelete(t, cons, min, max)
|
TestDelete(t, cons, minSize, maxSize)
|
||||||
})
|
})
|
||||||
t.Run("exists", func(t *testing.T) {
|
t.Run("exists", func(t *testing.T) {
|
||||||
TestExists(t, cons, min, max)
|
TestExists(t, cons, minSize, maxSize)
|
||||||
})
|
})
|
||||||
t.Run("iterate", func(t *testing.T) {
|
t.Run("iterate", func(t *testing.T) {
|
||||||
TestIterate(t, cons, min, max)
|
TestIterate(t, cons, minSize, maxSize)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ func TestInfo(t *testing.T, cons Constructor, expectedType string, expectedPath
|
||||||
require.Equal(t, expectedPath, s.Path())
|
require.Equal(t, expectedPath, s.Path())
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepare(t *testing.T, count int, s common.Storage, min, max uint64) []objectDesc {
|
func prepare(t *testing.T, count int, s common.Storage, minSize, maxSize uint64) []objectDesc {
|
||||||
objects := make([]objectDesc, count)
|
objects := make([]objectDesc, count)
|
||||||
|
|
||||||
r := mrand.New(mrand.NewSource(0))
|
r := mrand.New(mrand.NewSource(0))
|
||||||
for i := range objects {
|
for i := range objects {
|
||||||
objects[i].obj = NewObject(min + uint64(r.Intn(int(max-min+1)))) // not too large
|
objects[i].obj = NewObject(minSize + uint64(r.Intn(int(maxSize-minSize+1)))) // not too large
|
||||||
objects[i].addr = objectCore.AddressOf(objects[i].obj)
|
objects[i].addr = objectCore.AddressOf(objects[i].obj)
|
||||||
|
|
||||||
raw, err := objects[i].obj.Marshal()
|
raw, err := objects[i].obj.Marshal()
|
||||||
|
|
|
@ -13,12 +13,12 @@ import (
|
||||||
|
|
||||||
// TestControl checks correctness of a read-only mode.
|
// TestControl checks correctness of a read-only mode.
|
||||||
// cons must return a storage which is NOT opened.
|
// cons must return a storage which is NOT opened.
|
||||||
func TestControl(t *testing.T, cons Constructor, min, max uint64) {
|
func TestControl(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
||||||
s := cons(t)
|
s := cons(t)
|
||||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||||
require.NoError(t, s.Init())
|
require.NoError(t, s.Init())
|
||||||
|
|
||||||
objects := prepare(t, 10, s, min, max)
|
objects := prepare(t, 10, s, minSize, maxSize)
|
||||||
require.NoError(t, s.Close())
|
require.NoError(t, s.Close())
|
||||||
|
|
||||||
require.NoError(t, s.Open(mode.ComponentReadOnly))
|
require.NoError(t, s.Open(mode.ComponentReadOnly))
|
||||||
|
@ -34,7 +34,7 @@ func TestControl(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
|
|
||||||
t.Run("put fails", func(t *testing.T) {
|
t.Run("put fails", func(t *testing.T) {
|
||||||
var prm common.PutPrm
|
var prm common.PutPrm
|
||||||
prm.Object = NewObject(min + uint64(rand.Intn(int(max-min+1))))
|
prm.Object = NewObject(minSize + uint64(rand.Intn(int(maxSize-minSize+1))))
|
||||||
prm.Address = objectCore.AddressOf(prm.Object)
|
prm.Address = objectCore.AddressOf(prm.Object)
|
||||||
|
|
||||||
_, err := s.Put(context.Background(), prm)
|
_, err := s.Put(context.Background(), prm)
|
||||||
|
|
|
@ -11,13 +11,13 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDelete(t *testing.T, cons Constructor, min, max uint64) {
|
func TestDelete(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
||||||
s := cons(t)
|
s := cons(t)
|
||||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||||
require.NoError(t, s.Init())
|
require.NoError(t, s.Init())
|
||||||
defer func() { require.NoError(t, s.Close()) }()
|
defer func() { require.NoError(t, s.Close()) }()
|
||||||
|
|
||||||
objects := prepare(t, 4, s, min, max)
|
objects := prepare(t, 4, s, minSize, maxSize)
|
||||||
|
|
||||||
t.Run("delete non-existent", func(t *testing.T) {
|
t.Run("delete non-existent", func(t *testing.T) {
|
||||||
var prm common.DeletePrm
|
var prm common.DeletePrm
|
||||||
|
|
|
@ -10,13 +10,13 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExists(t *testing.T, cons Constructor, min, max uint64) {
|
func TestExists(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
||||||
s := cons(t)
|
s := cons(t)
|
||||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||||
require.NoError(t, s.Init())
|
require.NoError(t, s.Init())
|
||||||
defer func() { require.NoError(t, s.Close()) }()
|
defer func() { require.NoError(t, s.Close()) }()
|
||||||
|
|
||||||
objects := prepare(t, 1, s, min, max)
|
objects := prepare(t, 1, s, minSize, maxSize)
|
||||||
|
|
||||||
t.Run("missing object", func(t *testing.T) {
|
t.Run("missing object", func(t *testing.T) {
|
||||||
prm := common.ExistsPrm{Address: oidtest.Address()}
|
prm := common.ExistsPrm{Address: oidtest.Address()}
|
||||||
|
|
|
@ -11,13 +11,13 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGet(t *testing.T, cons Constructor, min, max uint64) {
|
func TestGet(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
||||||
s := cons(t)
|
s := cons(t)
|
||||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||||
require.NoError(t, s.Init())
|
require.NoError(t, s.Init())
|
||||||
defer func() { require.NoError(t, s.Close()) }()
|
defer func() { require.NoError(t, s.Close()) }()
|
||||||
|
|
||||||
objects := prepare(t, 2, s, min, max)
|
objects := prepare(t, 2, s, minSize, maxSize)
|
||||||
|
|
||||||
t.Run("missing object", func(t *testing.T) {
|
t.Run("missing object", func(t *testing.T) {
|
||||||
gPrm := common.GetPrm{Address: oidtest.Address()}
|
gPrm := common.GetPrm{Address: oidtest.Address()}
|
||||||
|
|
|
@ -13,13 +13,13 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
func TestGetRange(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
||||||
s := cons(t)
|
s := cons(t)
|
||||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||||
require.NoError(t, s.Init())
|
require.NoError(t, s.Init())
|
||||||
defer func() { require.NoError(t, s.Close()) }()
|
defer func() { require.NoError(t, s.Close()) }()
|
||||||
|
|
||||||
objects := prepare(t, 1, s, min, max)
|
objects := prepare(t, 1, s, minSize, maxSize)
|
||||||
|
|
||||||
t.Run("missing object", func(t *testing.T) {
|
t.Run("missing object", func(t *testing.T) {
|
||||||
gPrm := common.GetRangePrm{Address: oidtest.Address()}
|
gPrm := common.GetRangePrm{Address: oidtest.Address()}
|
||||||
|
|
|
@ -10,13 +10,13 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIterate(t *testing.T, cons Constructor, min, max uint64) {
|
func TestIterate(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
||||||
s := cons(t)
|
s := cons(t)
|
||||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||||
require.NoError(t, s.Init())
|
require.NoError(t, s.Init())
|
||||||
defer func() { require.NoError(t, s.Close()) }()
|
defer func() { require.NoError(t, s.Close()) }()
|
||||||
|
|
||||||
objects := prepare(t, 10, s, min, max)
|
objects := prepare(t, 10, s, minSize, maxSize)
|
||||||
|
|
||||||
// Delete random object to ensure it is not iterated over.
|
// Delete random object to ensure it is not iterated over.
|
||||||
const delID = 2
|
const delID = 2
|
||||||
|
|
|
@ -641,8 +641,8 @@ func (c *Client) notaryTxValidationLimit() (uint32, error) {
|
||||||
return 0, fmt.Errorf("can't get current blockchain height: %w", err)
|
return 0, fmt.Errorf("can't get current blockchain height: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
min := bc + c.notary.txValidTime
|
minTime := bc + c.notary.txValidTime
|
||||||
rounded := (min/c.notary.roundTime + 1) * c.notary.roundTime
|
rounded := (minTime/c.notary.roundTime + 1) * c.notary.roundTime
|
||||||
|
|
||||||
return rounded, nil
|
return rounded, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue