[#772] node: Apply gofumpt

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-10-31 14:56:55 +03:00
parent 00aa6d9749
commit 79088baa06
136 changed files with 293 additions and 239 deletions

View file

@ -50,12 +50,12 @@ func initConfig(cmd *cobra.Command, _ []string) error {
} }
pathDir := filepath.Dir(configPath) pathDir := filepath.Dir(configPath)
err = os.MkdirAll(pathDir, 0700) err = os.MkdirAll(pathDir, 0o700)
if err != nil { if err != nil {
return fmt.Errorf("create dir %s: %w", pathDir, err) return fmt.Errorf("create dir %s: %w", pathDir, err)
} }
f, err := os.OpenFile(configPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_SYNC, 0600) f, err := os.OpenFile(configPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_SYNC, 0o600)
if err != nil { if err != nil {
return fmt.Errorf("open %s: %w", configPath, err) return fmt.Errorf("open %s: %w", configPath, err)
} }

View file

@ -76,7 +76,7 @@ func initializeWallets(v *viper.Viper, walletDir string, size int) ([]string, er
} }
p := filepath.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json") p := filepath.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json")
f, err := os.OpenFile(p, os.O_CREATE, 0644) f, err := os.OpenFile(p, os.O_CREATE, 0o644)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't create wallet file: %w", err) return nil, fmt.Errorf("can't create wallet file: %w", err)
} }

View file

@ -83,7 +83,7 @@ func newLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet
go bc.Run() go bc.Run()
if cmd.Name() != "init" { if cmd.Name() != "init" {
f, err := os.OpenFile(dumpPath, os.O_RDONLY, 0600) f, err := os.OpenFile(dumpPath, os.O_RDONLY, 0o600)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't open local dump: %w", err) return nil, fmt.Errorf("can't open local dump: %w", err)
} }

View file

@ -15,8 +15,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
var ( var rootCmd = &cobra.Command{
rootCmd = &cobra.Command{
Use: "frostfs-adm", Use: "frostfs-adm",
Short: "FrostFS Administrative Tool", Short: "FrostFS Administrative Tool",
Long: `FrostFS Administrative Tool provides functions to setup and Long: `FrostFS Administrative Tool provides functions to setup and
@ -24,7 +23,6 @@ manage FrostFS network deployment.`,
RunE: entryPoint, RunE: entryPoint,
SilenceUsage: true, SilenceUsage: true,
} }
)
func init() { func init() {
cobra.OnInitialize(func() { initConfig(rootCmd) }) cobra.OnInitialize(func() { initConfig(rootCmd) })

View file

@ -145,7 +145,7 @@ func storageConfig(cmd *cobra.Command, args []string) {
} }
out := applyTemplate(c) out := applyTemplate(c)
fatalOnErr(os.WriteFile(outPath, out, 0644)) fatalOnErr(os.WriteFile(outPath, out, 0o644))
cmd.Println("Node is ready for work! Run `frostfs-node -config " + outPath + "`") cmd.Println("Node is ready for work! Run `frostfs-node -config " + outPath + "`")
} }

View file

@ -106,7 +106,7 @@ func createEACL(cmd *cobra.Command, _ []string) {
return return
} }
err = os.WriteFile(outArg, buf.Bytes(), 0644) err = os.WriteFile(outArg, buf.Bytes(), 0o644)
if err != nil { if err != nil {
cmd.PrintErrln(err) cmd.PrintErrln(err)
os.Exit(1) os.Exit(1)

View file

@ -130,6 +130,6 @@ func createToken(cmd *cobra.Command, _ []string) {
} }
out, _ := cmd.Flags().GetString(outFlag) out, _ := cmd.Flags().GetString(outFlag)
err = os.WriteFile(out, data, 0644) err = os.WriteFile(out, data, 0o644)
commonCmd.ExitOnErr(cmd, "can't write token to file: %w", err) commonCmd.ExitOnErr(cmd, "can't write token to file: %w", err)
} }

View file

@ -51,7 +51,7 @@ var getContainerInfoCmd = &cobra.Command{
data = cnr.Marshal() data = cnr.Marshal()
} }
err = os.WriteFile(containerPathTo, data, 0644) err = os.WriteFile(containerPathTo, data, 0o644)
commonCmd.ExitOnErr(cmd, "can't write container to file: %w", err) commonCmd.ExitOnErr(cmd, "can't write container to file: %w", err)
} }
}, },

View file

@ -52,7 +52,7 @@ var getExtendedACLCmd = &cobra.Command{
cmd.Println("dumping data to file:", containerPathTo) cmd.Println("dumping data to file:", containerPathTo)
err = os.WriteFile(containerPathTo, data, 0644) err = os.WriteFile(containerPathTo, data, 0o644)
commonCmd.ExitOnErr(cmd, "could not write eACL to file: %w", err) commonCmd.ExitOnErr(cmd, "could not write eACL to file: %w", err)
}, },
} }

View file

@ -20,7 +20,7 @@ var containerNodesCmd = &cobra.Command{
Short: "Show nodes for container", Short: "Show nodes for container",
Long: "Show nodes taking part in a container at the current epoch.", Long: "Show nodes taking part in a container at the current epoch.",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
var cnr, pkey = getContainer(cmd) cnr, pkey := getContainer(cmd)
if pkey == nil { if pkey == nil {
pkey = key.GetOrGenerate(cmd) pkey = key.GetOrGenerate(cmd)

View file

@ -132,7 +132,7 @@ func createOutWriter(cmd *cobra.Command, filename string) (out io.Writer, closer
out = os.Stdout out = os.Stdout
closer = func() {} closer = func() {}
} else { } else {
f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644)
if err != nil { if err != nil {
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err)) commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't open file '%s': %w", filename, err))
} }

View file

@ -213,7 +213,8 @@ func getRequiredPlacement(cmd *cobra.Command, objInfo *objectNodesInfo, placemen
} }
func getActualPlacement(cmd *cobra.Command, netmap *netmapSDK.NetMap, requiredPlacement map[uint64]netmapSDK.NodeInfo, func getActualPlacement(cmd *cobra.Command, netmap *netmapSDK.NetMap, requiredPlacement map[uint64]netmapSDK.NodeInfo,
pk *ecdsa.PrivateKey, objInfo *objectNodesInfo) map[uint64]boolError { pk *ecdsa.PrivateKey, objInfo *objectNodesInfo,
) map[uint64]boolError {
result := make(map[uint64]boolError) result := make(map[uint64]boolError)
resultMtx := &sync.Mutex{} resultMtx := &sync.Mutex{}

View file

@ -31,7 +31,8 @@ func init() {
objectHashCmd, objectHashCmd,
objectRangeCmd, objectRangeCmd,
objectLockCmd, objectLockCmd,
objectNodesCmd} objectNodesCmd,
}
Cmd.AddCommand(objectChildCommands...) Cmd.AddCommand(objectChildCommands...)

View file

@ -81,7 +81,7 @@ func createSession(cmd *cobra.Command, _ []string) {
} }
filename, _ := cmd.Flags().GetString(outFlag) filename, _ := cmd.Flags().GetString(outFlag)
err = os.WriteFile(filename, data, 0644) err = os.WriteFile(filename, data, 0o644)
commonCmd.ExitOnErr(cmd, "can't write token to file: %w", err) commonCmd.ExitOnErr(cmd, "can't write token to file: %w", err)
} }

View file

@ -48,7 +48,7 @@ func convertEACLTable(cmd *cobra.Command, _ []string) {
return return
} }
err = os.WriteFile(to, data, 0644) err = os.WriteFile(to, data, 0o644)
commonCmd.ExitOnErr(cmd, "can't write exteded ACL table to file: %w", err) commonCmd.ExitOnErr(cmd, "can't write exteded ACL table to file: %w", err)
cmd.Printf("extended ACL table was successfully dumped to %s\n", to) cmd.Printf("extended ACL table was successfully dumped to %s\n", to)

View file

@ -78,7 +78,7 @@ func keyerGenerate(filename string, d *keyer.Dashboard) error {
} }
if filename != "" { if filename != "" {
return os.WriteFile(filename, key, 0600) return os.WriteFile(filename, key, 0o600)
} }
return nil return nil

View file

@ -56,7 +56,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) {
return return
} }
err = os.WriteFile(to, data, 0644) err = os.WriteFile(to, data, 0o644)
commonCmd.ExitOnErr(cmd, "can't write signed bearer token to file: %w", err) commonCmd.ExitOnErr(cmd, "can't write signed bearer token to file: %w", err)
cmd.Printf("signed bearer token was successfully dumped to %s\n", to) cmd.Printf("signed bearer token was successfully dumped to %s\n", to)

View file

@ -76,7 +76,7 @@ func signSessionToken(cmd *cobra.Command, _ []string) {
return return
} }
err = os.WriteFile(to, data, 0644) err = os.WriteFile(to, data, 0o644)
if err != nil { if err != nil {
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't write signed session token to %s: %w", to, err)) commonCmd.ExitOnErr(cmd, "", fmt.Errorf("can't write signed session token to %s: %w", to, err))
} }

View file

@ -13,7 +13,7 @@ import (
func newConfig() (*viper.Viper, error) { func newConfig() (*viper.Viper, error) {
var err error var err error
var dv = viper.New() dv := viper.New()
defaultConfiguration(dv) defaultConfiguration(dv)

View file

@ -59,7 +59,7 @@ func WriteObjectToFile(cmd *cobra.Command, path string, data []byte) {
} }
ExitOnErr(cmd, Errf("could not write file: %w", ExitOnErr(cmd, Errf("could not write file: %w",
os.WriteFile(path, data, 0644))) os.WriteFile(path, data, 0o644)))
cmd.Printf("\nSaved payload to '%s' file\n", path) cmd.Printf("\nSaved payload to '%s' file\n", path)
} }

View file

@ -22,7 +22,7 @@ func TestApiclientSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
require.Equal(t, 15*time.Second, apiclientconfig.DialTimeout(c)) require.Equal(t, 15*time.Second, apiclientconfig.DialTimeout(c))
require.Equal(t, 20*time.Second, apiclientconfig.StreamTimeout(c)) require.Equal(t, 20*time.Second, apiclientconfig.StreamTimeout(c))
require.Equal(t, 30*time.Second, apiclientconfig.ReconnectTimeout(c)) require.Equal(t, 30*time.Second, apiclientconfig.ReconnectTimeout(c))

View file

@ -38,7 +38,6 @@ func New(configFile, configDir, envPrefix string) *Config {
configViper.WithConfigFile(configFile), configViper.WithConfigFile(configFile),
configViper.WithConfigDir(configDir), configViper.WithConfigDir(configDir),
configViper.WithEnvPrefix(envPrefix)) configViper.WithEnvPrefix(envPrefix))
if err != nil { if err != nil {
panic(err) panic(err)
} }

View file

@ -15,8 +15,8 @@ func TestConfigDir(t *testing.T) {
cfgFileName0 := path.Join(dir, "cfg_00.json") cfgFileName0 := path.Join(dir, "cfg_00.json")
cfgFileName1 := path.Join(dir, "cfg_01.yml") cfgFileName1 := path.Join(dir, "cfg_01.yml")
require.NoError(t, os.WriteFile(cfgFileName0, []byte(`{"storage":{"shard_pool_size":15}}`), 0777)) require.NoError(t, os.WriteFile(cfgFileName0, []byte(`{"storage":{"shard_pool_size":15}}`), 0o777))
require.NoError(t, os.WriteFile(cfgFileName1, []byte("logger:\n level: debug"), 0777)) require.NoError(t, os.WriteFile(cfgFileName1, []byte("logger:\n level: debug"), 0o777))
c := New("", dir, "") c := New("", dir, "")
require.Equal(t, "debug", cast.ToString(c.Sub("logger").Value("level"))) require.Equal(t, "debug", cast.ToString(c.Sub("logger").Value("level")))

View file

@ -35,7 +35,7 @@ func TestContractsSection(t *testing.T) {
expProxy, err := util.Uint160DecodeStringLE("ad7c6b55b737b696e5c82c85445040964a03e97f") expProxy, err := util.Uint160DecodeStringLE("ad7c6b55b737b696e5c82c85445040964a03e97f")
require.NoError(t, err) require.NoError(t, err)
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
balance := contractsconfig.Balance(c) balance := contractsconfig.Balance(c)
container := contractsconfig.Container(c) container := contractsconfig.Container(c)
netmap := contractsconfig.Netmap(c) netmap := contractsconfig.Netmap(c)

View file

@ -24,7 +24,7 @@ func TestControlSection(t *testing.T) {
pubs[0], _ = keys.NewPublicKeyFromString("035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11") pubs[0], _ = keys.NewPublicKeyFromString("035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11")
pubs[1], _ = keys.NewPublicKeyFromString("028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6") pubs[1], _ = keys.NewPublicKeyFromString("028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6")
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
require.Equal(t, pubs, controlconfig.AuthorizedKeys(c)) require.Equal(t, pubs, controlconfig.AuthorizedKeys(c))
require.Equal(t, "localhost:8090", controlconfig.GRPC(c).Endpoint()) require.Equal(t, "localhost:8090", controlconfig.GRPC(c).Endpoint())
} }

View file

@ -42,7 +42,7 @@ func TestEngineSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
num := 0 num := 0
require.EqualValues(t, 100, engineconfig.ShardErrorThreshold(c)) require.EqualValues(t, 100, engineconfig.ShardErrorThreshold(c))
@ -78,7 +78,7 @@ func TestEngineSection(t *testing.T) {
require.EqualValues(t, 3221225472, wc.SizeLimit()) require.EqualValues(t, 3221225472, wc.SizeLimit())
require.Equal(t, "tmp/0/meta", meta.Path()) require.Equal(t, "tmp/0/meta", meta.Path())
require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm()) require.Equal(t, fs.FileMode(0o644), meta.BoltDB().Perm())
require.Equal(t, 100, meta.BoltDB().MaxBatchSize()) require.Equal(t, 100, meta.BoltDB().MaxBatchSize())
require.Equal(t, 10*time.Millisecond, meta.BoltDB().MaxBatchDelay()) require.Equal(t, 10*time.Millisecond, meta.BoltDB().MaxBatchDelay())
@ -89,7 +89,7 @@ func TestEngineSection(t *testing.T) {
require.Equal(t, 2, len(ss)) require.Equal(t, 2, len(ss))
blz := blobovniczaconfig.From((*config.Config)(ss[0])) blz := blobovniczaconfig.From((*config.Config)(ss[0]))
require.Equal(t, "tmp/0/blob/blobovnicza", ss[0].Path()) require.Equal(t, "tmp/0/blob/blobovnicza", ss[0].Path())
require.EqualValues(t, 0644, blz.BoltDB().Perm()) require.EqualValues(t, 0o644, blz.BoltDB().Perm())
require.EqualValues(t, 4194304, blz.Size()) require.EqualValues(t, 4194304, blz.Size())
require.EqualValues(t, 1, blz.ShallowDepth()) require.EqualValues(t, 1, blz.ShallowDepth())
require.EqualValues(t, 4, blz.ShallowWidth()) require.EqualValues(t, 4, blz.ShallowWidth())
@ -97,7 +97,7 @@ func TestEngineSection(t *testing.T) {
require.EqualValues(t, 10, blz.LeafWidth()) require.EqualValues(t, 10, blz.LeafWidth())
require.Equal(t, "tmp/0/blob", ss[1].Path()) require.Equal(t, "tmp/0/blob", ss[1].Path())
require.EqualValues(t, 0644, ss[1].Perm()) require.EqualValues(t, 0o644, ss[1].Perm())
fst := fstreeconfig.From((*config.Config)(ss[1])) fst := fstreeconfig.From((*config.Config)(ss[1]))
require.EqualValues(t, 5, fst.Depth()) require.EqualValues(t, 5, fst.Depth())
@ -112,7 +112,7 @@ func TestEngineSection(t *testing.T) {
require.Equal(t, mode.ReadOnly, sc.Mode()) require.Equal(t, mode.ReadOnly, sc.Mode())
case 1: case 1:
require.Equal(t, "tmp/1/blob/pilorama.db", pl.Path()) require.Equal(t, "tmp/1/blob/pilorama.db", pl.Path())
require.Equal(t, fs.FileMode(0644), pl.Perm()) require.Equal(t, fs.FileMode(0o644), pl.Perm())
require.True(t, pl.NoSync()) require.True(t, pl.NoSync())
require.Equal(t, 5*time.Millisecond, pl.MaxBatchDelay()) require.Equal(t, 5*time.Millisecond, pl.MaxBatchDelay())
require.Equal(t, 100, pl.MaxBatchSize()) require.Equal(t, 100, pl.MaxBatchSize())
@ -127,7 +127,7 @@ func TestEngineSection(t *testing.T) {
require.EqualValues(t, 4294967296, wc.SizeLimit()) require.EqualValues(t, 4294967296, wc.SizeLimit())
require.Equal(t, "tmp/1/meta", meta.Path()) require.Equal(t, "tmp/1/meta", meta.Path())
require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm()) require.Equal(t, fs.FileMode(0o644), meta.BoltDB().Perm())
require.Equal(t, 200, meta.BoltDB().MaxBatchSize()) require.Equal(t, 200, meta.BoltDB().MaxBatchSize())
require.Equal(t, 20*time.Millisecond, meta.BoltDB().MaxBatchDelay()) require.Equal(t, 20*time.Millisecond, meta.BoltDB().MaxBatchDelay())
@ -146,7 +146,7 @@ func TestEngineSection(t *testing.T) {
require.EqualValues(t, 10, blz.LeafWidth()) require.EqualValues(t, 10, blz.LeafWidth())
require.Equal(t, "tmp/1/blob", ss[1].Path()) require.Equal(t, "tmp/1/blob", ss[1].Path())
require.EqualValues(t, 0644, ss[1].Perm()) require.EqualValues(t, 0o644, ss[1].Perm())
fst := fstreeconfig.From((*config.Config)(ss[1])) fst := fstreeconfig.From((*config.Config)(ss[1]))
require.EqualValues(t, 5, fst.Depth()) require.EqualValues(t, 5, fst.Depth())

View file

@ -9,7 +9,7 @@ import (
type Config config.Config type Config config.Config
// PermDefault are default permission bits for BlobStor data. // PermDefault are default permission bits for BlobStor data.
const PermDefault = 0660 const PermDefault = 0o660
func From(x *config.Config) *Config { func From(x *config.Config) *Config {
return (*Config)(x) return (*Config)(x)

View file

@ -13,7 +13,7 @@ type Config config.Config
const ( const (
// PermDefault is a default permission bits for metabase file. // PermDefault is a default permission bits for metabase file.
PermDefault = 0660 PermDefault = 0o660
) )
// Perm returns the value of "perm" config parameter as a fs.FileMode. // Perm returns the value of "perm" config parameter as a fs.FileMode.

View file

@ -13,7 +13,7 @@ type Config config.Config
const ( const (
// PermDefault is a default permission bits for metabase file. // PermDefault is a default permission bits for metabase file.
PermDefault = 0660 PermDefault = 0o660
) )
// From wraps config section into Config. // From wraps config section into Config.

View file

@ -17,7 +17,7 @@ func TestGRPCSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
num := 0 num := 0
IterateEndpoints(c, func(sc *Config) { IterateEndpoints(c, func(sc *Config) {

View file

@ -17,7 +17,7 @@ func TestLoggerSection_Level(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
v := loggerconfig.Level(c) v := loggerconfig.Level(c)
require.Equal(t, "debug", v) require.Equal(t, "debug", v)
} }

View file

@ -22,7 +22,7 @@ func TestMetricsSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
to := metricsconfig.ShutdownTimeout(c) to := metricsconfig.ShutdownTimeout(c)
addr := metricsconfig.Address(c) addr := metricsconfig.Address(c)

View file

@ -23,14 +23,12 @@ func TestMorphSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var ( rpcs := []client.Endpoint{
rpcs = []client.Endpoint{
{"wss://rpc1.morph.frostfs.info:40341/ws", 1}, {"wss://rpc1.morph.frostfs.info:40341/ws", 1},
{"wss://rpc2.morph.frostfs.info:40341/ws", 2}, {"wss://rpc2.morph.frostfs.info:40341/ws", 2},
} }
)
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
require.Equal(t, rpcs, morphconfig.RPCEndpoint(c)) require.Equal(t, rpcs, morphconfig.RPCEndpoint(c))
require.Equal(t, 30*time.Second, morphconfig.DialTimeout(c)) require.Equal(t, 30*time.Second, morphconfig.DialTimeout(c))
require.Equal(t, 15*time.Second, morphconfig.CacheTTL(c)) require.Equal(t, 15*time.Second, morphconfig.CacheTTL(c))

View file

@ -56,7 +56,7 @@ func TestNodeSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
key := Key(c) key := Key(c)
addrs := BootstrapAddresses(c) addrs := BootstrapAddresses(c)
attributes := Attributes(c) attributes := Attributes(c)

View file

@ -21,7 +21,7 @@ func TestObjectSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
require.Equal(t, 100, objectconfig.Put(c).PoolSizeRemote()) require.Equal(t, 100, objectconfig.Put(c).PoolSizeRemote())
require.Equal(t, 200, objectconfig.Put(c).PoolSizeLocal()) require.Equal(t, 200, objectconfig.Put(c).PoolSizeLocal())
require.EqualValues(t, 10, objectconfig.TombstoneLifetime(c)) require.EqualValues(t, 10, objectconfig.TombstoneLifetime(c))

View file

@ -19,7 +19,7 @@ func TestPolicerSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
require.Equal(t, 15*time.Second, policerconfig.HeadTimeout(c)) require.Equal(t, 15*time.Second, policerconfig.HeadTimeout(c))
} }

View file

@ -25,7 +25,7 @@ func TestProfilerSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
to := profilerconfig.ShutdownTimeout(c) to := profilerconfig.ShutdownTimeout(c)
addr := profilerconfig.Address(c) addr := profilerconfig.Address(c)

View file

@ -20,7 +20,7 @@ func TestReplicatorSection(t *testing.T) {
const path = "../../../../config/example/node" const path = "../../../../config/example/node"
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
require.Equal(t, 15*time.Second, replicatorconfig.PutTimeout(c)) require.Equal(t, 15*time.Second, replicatorconfig.PutTimeout(c))
require.Equal(t, 10, replicatorconfig.PoolSize(c)) require.Equal(t, 10, replicatorconfig.PoolSize(c))
} }

View file

@ -35,7 +35,7 @@ func TestTreeSection(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
expectedKeys = append(expectedKeys, key) expectedKeys = append(expectedKeys, key)
var fileConfigTest = func(c *config.Config) { fileConfigTest := func(c *config.Config) {
treeSec := treeconfig.Tree(c) treeSec := treeconfig.Tree(c)
require.True(t, treeSec.Enabled()) require.True(t, treeSec.Enabled())

View file

@ -239,7 +239,8 @@ func listenMorphNotifications(ctx context.Context, c *cfg) {
} }
func registerNotificationHandlers(scHash util.Uint160, lis event.Listener, parsers map[event.Type]event.NotificationParser, func registerNotificationHandlers(scHash util.Uint160, lis event.Listener, parsers map[event.Type]event.NotificationParser,
subs map[event.Type][]event.Handler) { subs map[event.Type][]event.Handler,
) {
for typ, handlers := range subs { for typ, handlers := range subs {
pi := event.NotificationParserInfo{} pi := event.NotificationParserInfo{}
pi.SetType(typ) pi.SetType(typ)

View file

@ -353,7 +353,8 @@ func createSearchSvcV2(sSearch *searchsvc.Service, keyStorage *util.KeyStorage)
} }
func createGetService(c *cfg, keyStorage *util.KeyStorage, traverseGen *util.TraverserGenerator, func createGetService(c *cfg, keyStorage *util.KeyStorage, traverseGen *util.TraverserGenerator,
coreConstructor *cache.ClientCache) *getsvc.Service { coreConstructor *cache.ClientCache,
) *getsvc.Service {
ls := c.cfgObject.cfgLocalStorage.localStorage ls := c.cfgObject.cfgLocalStorage.localStorage
return getsvc.New( return getsvc.New(
@ -375,7 +376,8 @@ func createGetServiceV2(sGet *getsvc.Service, keyStorage *util.KeyStorage) *gets
} }
func createDeleteService(c *cfg, keyStorage *util.KeyStorage, sGet *getsvc.Service, func createDeleteService(c *cfg, keyStorage *util.KeyStorage, sGet *getsvc.Service,
sSearch *searchsvc.Service, sPut *putsvc.Service) *deletesvc.Service { sSearch *searchsvc.Service, sPut *putsvc.Service,
) *deletesvc.Service {
return deletesvc.New( return deletesvc.New(
sGet, sGet,
sSearch, sSearch,
@ -396,7 +398,8 @@ func createDeleteServiceV2(sDelete *deletesvc.Service) *deletesvcV2.Service {
} }
func createSplitService(c *cfg, sPutV2 *putsvcV2.Service, sGetV2 *getsvcV2.Service, func createSplitService(c *cfg, sPutV2 *putsvcV2.Service, sGetV2 *getsvcV2.Service,
sSearchV2 *searchsvcV2.Service, sDeleteV2 *deletesvcV2.Service) *objectService.TransportSplitter { sSearchV2 *searchsvcV2.Service, sDeleteV2 *deletesvcV2.Service,
) *objectService.TransportSplitter {
return objectService.NewTransportSplitter( return objectService.NewTransportSplitter(
c.cfgGRPC.maxChunkSize, c.cfgGRPC.maxChunkSize,
c.cfgGRPC.maxAddrAmount, c.cfgGRPC.maxAddrAmount,

View file

@ -59,7 +59,7 @@ func validateConfig(c *config.Config) error {
default: default:
return fmt.Errorf("unexpected storage type: %s (shard %d)", blobstor[i].Type(), shardNum) return fmt.Errorf("unexpected storage type: %s (shard %d)", blobstor[i].Type(), shardNum)
} }
if blobstor[i].Perm()&0600 != 0600 { if blobstor[i].Perm()&0o600 != 0o600 {
return fmt.Errorf("invalid permissions for blobstor component: %s, "+ return fmt.Errorf("invalid permissions for blobstor component: %s, "+
"expected at least rw- for the owner (shard %d)", "expected at least rw- for the owner (shard %d)",
blobstor[i].Perm(), shardNum) blobstor[i].Perm(), shardNum)

View file

@ -10,7 +10,8 @@ import (
// PrettyPrintNodeInfo print information about network node with given indent and index. // PrettyPrintNodeInfo print information about network node with given indent and index.
// To avoid printing attribute list use short parameter. // To avoid printing attribute list use short parameter.
func PrettyPrintNodeInfo(cmd *cobra.Command, node netmap.NodeInfo, func PrettyPrintNodeInfo(cmd *cobra.Command, node netmap.NodeInfo,
index int, indent string, short bool) { index int, indent string, short bool,
) {
var strState string var strState string
switch { switch {

View file

@ -22,7 +22,8 @@ func NodeInfoFromRawNetmapElement(dst *NodeInfo, info interface {
IterateAddresses(func(string) bool) IterateAddresses(func(string) bool)
NumberOfAddresses() int NumberOfAddresses() int
ExternalAddresses() []string ExternalAddresses() []string
}) error { },
) error {
var a network.AddressGroup var a network.AddressGroup
err := a.FromIterator(info) err := a.FromIterator(info)
@ -49,7 +50,8 @@ func NodeInfoFromNetmapElement(dst *NodeInfo, info interface {
PublicKey() []byte PublicKey() []byte
Addresses() network.AddressGroup Addresses() network.AddressGroup
ExternalAddresses() network.AddressGroup ExternalAddresses() network.AddressGroup
}) { },
) {
nodeInfoFromKeyAddr(dst, info.PublicKey(), info.Addresses(), info.ExternalAddresses()) nodeInfoFromKeyAddr(dst, info.PublicKey(), info.Addresses(), info.ExternalAddresses())
} }

View file

@ -43,7 +43,8 @@ func (c SenderClassifier) Classify(
ownerID *user.ID, ownerID *user.ID,
ownerKey *keys.PublicKey, ownerKey *keys.PublicKey,
idCnr cid.ID, idCnr cid.ID,
cnr container.Container) (res *ClassifyResult, err error) { cnr container.Container,
) (res *ClassifyResult, err error) {
ownerKeyInBytes := ownerKey.Bytes() ownerKeyInBytes := ownerKey.Bytes()
// TODO: #767 get owner from frostfs.id if present // TODO: #767 get owner from frostfs.id if present
@ -114,7 +115,8 @@ func (c SenderClassifier) isInnerRingKey(owner []byte) (bool, error) {
func (c SenderClassifier) isContainerKey( func (c SenderClassifier) isContainerKey(
owner, idCnr []byte, owner, idCnr []byte,
cnr container.Container) (bool, error) { cnr container.Container,
) (bool, error) {
nm, err := core.GetLatestNetworkMap(c.netmap) // first check current netmap nm, err := core.GetLatestNetworkMap(c.netmap) // first check current netmap
if err != nil { if err != nil {
return false, err return false, err
@ -140,7 +142,8 @@ func (c SenderClassifier) isContainerKey(
func lookupKeyInContainer( func lookupKeyInContainer(
nm *netmap.NetMap, nm *netmap.NetMap,
owner, idCnr []byte, owner, idCnr []byte,
cnr container.Container) (bool, error) { cnr container.Container,
) (bool, error) {
cnrVectors, err := nm.ContainerNodes(cnr.PlacementPolicy(), idCnr) cnrVectors, err := nm.ContainerNodes(cnr.PlacementPolicy(), idCnr)
if err != nil { if err != nil {
return false, err return false, err

View file

@ -117,6 +117,7 @@ type testEpochState struct {
func (s *testEpochState) EpochCounter() uint64 { func (s *testEpochState) EpochCounter() uint64 {
return s.counter return s.counter
} }
func (s *testEpochState) EpochDuration() uint64 { func (s *testEpochState) EpochDuration() uint64 {
return s.duration return s.duration
} }

View file

@ -60,5 +60,4 @@ fee:
require.Equal(t, fixedn.Fixed8(10), config.MainChainFee(), "main chain fee invalid") require.Equal(t, fixedn.Fixed8(10), config.MainChainFee(), "main chain fee invalid")
require.Equal(t, fixedn.Fixed8(0), config.SideChainFee(), "side chain fee invalid") require.Equal(t, fixedn.Fixed8(0), config.SideChainFee(), "side chain fee invalid")
}) })
} }

View file

@ -35,7 +35,8 @@ import (
func (s *Server) initNetmapProcessor(cfg *viper.Viper, func (s *Server) initNetmapProcessor(cfg *viper.Viper,
cnrClient *container.Client, cnrClient *container.Client,
alphaSync event.Handler) error { alphaSync event.Handler,
) error {
locodeValidator, err := s.newLocodeValidator(cfg) locodeValidator, err := s.newLocodeValidator(cfg)
if err != nil { if err != nil {
return err return err
@ -250,7 +251,8 @@ func (s *Server) initAlphabetProcessor(cfg *viper.Viper) error {
} }
func (s *Server) initContainerProcessor(cfg *viper.Viper, cnrClient *container.Client, func (s *Server) initContainerProcessor(cfg *viper.Viper, cnrClient *container.Client,
frostfsIDClient *frostfsid.Client) error { frostfsIDClient *frostfsid.Client,
) error {
// container processor // container processor
containerProcessor, err := cont.New(&cont.Params{ containerProcessor, err := cont.New(&cont.Params{
Log: s.log, Log: s.log,

View file

@ -328,7 +328,8 @@ func (s *Server) registerStarter(f func() error) {
// New creates instance of inner ring sever structure. // New creates instance of inner ring sever structure.
func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan<- error, func New(ctx context.Context, log *logger.Logger, cfg *viper.Viper, errChan chan<- error,
metrics *metrics.InnerRingServiceMetrics) (*Server, error) { metrics *metrics.InnerRingServiceMetrics,
) (*Server, error) {
var err error var err error
server := &Server{ server := &Server{
log: log, log: log,

View file

@ -256,6 +256,7 @@ func (c *testMorphClient) Invoke(contract util.Uint160, fee fixedn.Fixed8, metho
}) })
return nil return nil
} }
func (c *testMorphClient) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error { func (c *testMorphClient) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error {
c.transferedGas = append(c.transferedGas, transferGas{ c.transferedGas = append(c.transferedGas, transferGas{
receiver: receiver, receiver: receiver,

View file

@ -73,8 +73,7 @@ func (s *testAlphabetState) IsAlphabet() bool {
return s.isAlphabet return s.isAlphabet
} }
type testPresicionConverter struct { type testPresicionConverter struct{}
}
func (c *testPresicionConverter) ToFixed8(v int64) int64 { func (c *testPresicionConverter) ToFixed8(v int64) int64 {
return v return v

View file

@ -319,6 +319,7 @@ func (e *testPutEvent) Signature() []byte {
func (e *testPutEvent) SessionToken() []byte { func (e *testPutEvent) SessionToken() []byte {
return e.st return e.st
} }
func (e *testPutEvent) NotaryRequest() *payload.P2PNotaryRequest { func (e *testPutEvent) NotaryRequest() *payload.P2PNotaryRequest {
return e.nr return e.nr
} }

View file

@ -301,8 +301,7 @@ func (s *testAlphabetState) IsAlphabet() bool {
return s.isAlphabet return s.isAlphabet
} }
type testPrecisionConverter struct { type testPrecisionConverter struct{}
}
func (c *testPrecisionConverter) ToBalancePrecision(v int64) int64 { func (c *testPrecisionConverter) ToBalancePrecision(v int64) int64 {
return v return v
@ -318,10 +317,12 @@ func (c *testBalaceClient) Mint(p balance.MintPrm) error {
c.mint = append(c.mint, p) c.mint = append(c.mint, p)
return nil return nil
} }
func (c *testBalaceClient) Lock(p balance.LockPrm) error { func (c *testBalaceClient) Lock(p balance.LockPrm) error {
c.lock = append(c.lock, p) c.lock = append(c.lock, p)
return nil return nil
} }
func (c *testBalaceClient) Burn(p balance.BurnPrm) error { func (c *testBalaceClient) Burn(p balance.BurnPrm) error {
c.burn = append(c.burn, p) c.burn = append(c.burn, p)
return nil return nil
@ -349,6 +350,7 @@ type testMorphClient struct {
func (c *testMorphClient) GasBalance() (res int64, err error) { func (c *testMorphClient) GasBalance() (res int64, err error) {
return c.balance, nil return c.balance, nil
} }
func (c *testMorphClient) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error { func (c *testMorphClient) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error {
c.transferGas = append(c.transferGas, transferGas{ c.transferGas = append(c.transferGas, transferGas{
receiver: receiver, receiver: receiver,

View file

@ -309,12 +309,15 @@ type testEpochState struct {
func (s *testEpochState) SetEpochCounter(c uint64) { func (s *testEpochState) SetEpochCounter(c uint64) {
s.counter = c s.counter = c
} }
func (s *testEpochState) EpochCounter() uint64 { func (s *testEpochState) EpochCounter() uint64 {
return s.counter return s.counter
} }
func (s *testEpochState) SetEpochDuration(d uint64) { func (s *testEpochState) SetEpochDuration(d uint64) {
s.duration = d s.duration = d
} }
func (s *testEpochState) EpochDuration() uint64 { func (s *testEpochState) EpochDuration() uint64 {
return s.duration return s.duration
} }

View file

@ -20,8 +20,7 @@ type DeletePrm struct {
} }
// DeleteRes groups the resulting values of Delete operation. // DeleteRes groups the resulting values of Delete operation.
type DeleteRes struct { type DeleteRes struct{}
}
// SetAddress sets the address of the requested object. // SetAddress sets the address of the requested object.
func (p *DeletePrm) SetAddress(addr oid.Address) { func (p *DeletePrm) SetAddress(addr oid.Address) {

View file

@ -12,9 +12,7 @@ import (
// Exists check if object with the specified address is stored in b. // Exists check if object with the specified address is stored in b.
func (b *Blobovnicza) Exists(ctx context.Context, addr oid.Address) (bool, error) { func (b *Blobovnicza) Exists(ctx context.Context, addr oid.Address) (bool, error) {
var ( exists := false
exists = false
)
_, span := tracing.StartSpanFromContext(ctx, "Blobovnicza.Exists", _, span := tracing.StartSpanFromContext(ctx, "Blobovnicza.Exists",
trace.WithAttributes( trace.WithAttributes(

View file

@ -116,8 +116,7 @@ func (x *IteratePrm) IgnoreErrors() {
} }
// IterateRes groups the resulting values of Iterate operation. // IterateRes groups the resulting values of Iterate operation.
type IterateRes struct { type IterateRes struct{}
}
// Iterate goes through all stored objects, and passes IterationElement to parameterized handler until error return. // Iterate goes through all stored objects, and passes IterationElement to parameterized handler until error return.
// //

View file

@ -20,8 +20,7 @@ type PutPrm struct {
} }
// PutRes groups the resulting values of Put operation. // PutRes groups the resulting values of Put operation.
type PutRes struct { type PutRes struct{}
}
// SetAddress sets the address of the saving object. // SetAddress sets the address of the saving object.
func (p *PutPrm) SetAddress(addr oid.Address) { func (p *PutPrm) SetAddress(addr oid.Address) {

View file

@ -55,7 +55,7 @@ func TestExistsInvalidStorageID(t *testing.T) {
// An invalid boltdb file is created so that it returns an error when opened // An invalid boltdb file is created so that it returns an error when opened
require.NoError(t, os.MkdirAll(filepath.Join(dir, relBadFileDir), os.ModePerm)) require.NoError(t, os.MkdirAll(filepath.Join(dir, relBadFileDir), os.ModePerm))
require.NoError(t, os.WriteFile(filepath.Join(dir, relBadFileDir, badFileName), []byte("not a boltdb file content"), 0777)) require.NoError(t, os.WriteFile(filepath.Join(dir, relBadFileDir, badFileName), []byte("not a boltdb file content"), 0o777))
res, err := b.Exists(context.Background(), common.ExistsPrm{Address: addr, StorageID: []byte(filepath.Join(relBadFileDir, badFileName))}) res, err := b.Exists(context.Background(), common.ExistsPrm{Address: addr, StorageID: []byte(filepath.Join(relBadFileDir, badFileName))})
require.Error(t, err) require.Error(t, err)

View file

@ -28,7 +28,8 @@ type sharedDB struct {
} }
func newSharedDB(options []blobovnicza.Option, path string, readOnly bool, func newSharedDB(options []blobovnicza.Option, path string, readOnly bool,
metrics blobovnicza.Metrics, openDBCounter *openDBCounter, closedFlag *atomic.Bool, log *logger.Logger) *sharedDB { metrics blobovnicza.Metrics, openDBCounter *openDBCounter, closedFlag *atomic.Bool, log *logger.Logger,
) *sharedDB {
return &sharedDB{ return &sharedDB{
guard: &sync.RWMutex{}, guard: &sync.RWMutex{},
@ -110,7 +111,8 @@ type levelDbManager struct {
} }
func newLevelDBManager(width uint64, options []blobovnicza.Option, rootPath string, lvlPath string, func newLevelDBManager(width uint64, options []blobovnicza.Option, rootPath string, lvlPath string,
readOnly bool, metrics blobovnicza.Metrics, openDBCounter *openDBCounter, closedFlog *atomic.Bool, log *logger.Logger) *levelDbManager { readOnly bool, metrics blobovnicza.Metrics, openDBCounter *openDBCounter, closedFlog *atomic.Bool, log *logger.Logger,
) *levelDbManager {
result := &levelDbManager{ result := &levelDbManager{
databases: make([]*sharedDB, width), databases: make([]*sharedDB, width),
} }

View file

@ -28,7 +28,7 @@ type cfg struct {
type Option func(*cfg) type Option func(*cfg)
const ( const (
defaultPerm = 0700 defaultPerm = 0o700
defaultOpenedCacheSize = 50 defaultOpenedCacheSize = 50
defaultBlzShallowDepth = 2 defaultBlzShallowDepth = 2
defaultBlzShallowWidth = 16 defaultBlzShallowWidth = 16

View file

@ -77,7 +77,7 @@ var _ common.Storage = (*FSTree)(nil)
func New(opts ...Option) *FSTree { func New(opts ...Option) *FSTree {
f := &FSTree{ f := &FSTree{
Info: Info{ Info: Info{
Permissions: 0700, Permissions: 0o700,
RootPath: "./", RootPath: "./",
}, },
Config: nil, Config: nil,

View file

@ -7,7 +7,6 @@ import (
) )
func TestGeneric(t *testing.T) { func TestGeneric(t *testing.T) {
newMetabase := func(t *testing.T) storagetest.Component { newMetabase := func(t *testing.T) storagetest.Component {
return New( return New(
WithStorages(defaultStorages(t.TempDir(), 128))) WithStorages(defaultStorages(t.TempDir(), 128)))

View file

@ -18,9 +18,7 @@ import (
// If the descriptor is present, only one sub-storage is tried, // If the descriptor is present, only one sub-storage is tried,
// Otherwise, each sub-storage is tried in order. // Otherwise, each sub-storage is tried in order.
func (b *BlobStor) Get(ctx context.Context, prm common.GetPrm) (res common.GetRes, err error) { func (b *BlobStor) Get(ctx context.Context, prm common.GetPrm) (res common.GetRes, err error) {
var ( startedAt := time.Now()
startedAt = time.Now()
)
defer func() { defer func() {
b.metrics.Get(time.Since(startedAt), len(res.RawData), err == nil, prm.StorageID != nil) b.metrics.Get(time.Since(startedAt), len(res.RawData), err == nil, prm.StorageID != nil)
}() }()

View file

@ -19,9 +19,7 @@ import (
// If the descriptor is present, only one sub-storage is tried, // If the descriptor is present, only one sub-storage is tried,
// Otherwise, each sub-storage is tried in order. // Otherwise, each sub-storage is tried in order.
func (b *BlobStor) GetRange(ctx context.Context, prm common.GetRangePrm) (res common.GetRangeRes, err error) { func (b *BlobStor) GetRange(ctx context.Context, prm common.GetRangePrm) (res common.GetRangeRes, err error) {
var ( startedAt := time.Now()
startedAt = time.Now()
)
defer func() { defer func() {
b.metrics.GetRange(time.Since(startedAt), len(res.Data), err == nil, prm.StorageID != nil) b.metrics.GetRange(time.Since(startedAt), len(res.Data), err == nil, prm.StorageID != nil)
}() }()

View file

@ -91,7 +91,7 @@ func runTestIgnoreLogicalErrors(t *testing.T, s common.Storage, objects []object
seen := make(map[string]objectDesc) seen := make(map[string]objectDesc)
var n int var n int
var logicErr = errors.New("logic error") logicErr := errors.New("logic error")
var iterPrm common.IteratePrm var iterPrm common.IteratePrm
iterPrm.IgnoreErrors = true iterPrm.IgnoreErrors = true
iterPrm.Handler = func(elem common.IterationElement) error { iterPrm.Handler = func(elem common.IterationElement) error {

View file

@ -6,8 +6,10 @@ import (
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
) )
const deleteOp = "DELETE" const (
const putOp = "PUT" deleteOp = "DELETE"
putOp = "PUT"
)
func logOp(l *logger.Logger, op string, addr oid.Address, typ string, sID []byte) { func logOp(l *logger.Logger, op string, addr oid.Address, typ string, sID []byte) {
storagelog.Write(l, storagelog.Write(l,

View file

@ -30,7 +30,7 @@ func (e *StorageEngine) open(ctx context.Context) error {
defer e.mtx.Unlock() defer e.mtx.Unlock()
var wg sync.WaitGroup var wg sync.WaitGroup
var errCh = make(chan shardInitError, len(e.shards)) errCh := make(chan shardInitError, len(e.shards))
for id, sh := range e.shards { for id, sh := range e.shards {
wg.Add(1) wg.Add(1)
@ -75,7 +75,7 @@ func (e *StorageEngine) Init(ctx context.Context) error {
e.mtx.Lock() e.mtx.Lock()
defer e.mtx.Unlock() defer e.mtx.Unlock()
var errCh = make(chan shardInitError, len(e.shards)) errCh := make(chan shardInitError, len(e.shards))
var eg errgroup.Group var eg errgroup.Group
if e.cfg.lowMem && e.anyShardRequiresRefill() { if e.cfg.lowMem && e.anyShardRequiresRefill() {
eg.SetLimit(1) eg.SetLimit(1)

View file

@ -62,7 +62,7 @@ func TestInitializationFailure(t *testing.T) {
OpenFile: opts.openFileMetabase, OpenFile: opts.openFileMetabase,
}), }),
meta.WithPath(filepath.Join(t.TempDir(), "metabase")), meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
meta.WithPermissions(0700), meta.WithPermissions(0o700),
meta.WithEpochState(epochState{})), meta.WithEpochState(epochState{})),
shard.WithWriteCache(true), shard.WithWriteCache(true),
shard.WithWriteCacheOptions(wcOpts), shard.WithWriteCacheOptions(wcOpts),
@ -228,7 +228,6 @@ func TestPersistentShardID(t *testing.T) {
require.Equal(t, te.shards[1].id, newTe.shards[0].id) require.Equal(t, te.shards[1].id, newTe.shards[0].id)
require.Equal(t, te.shards[0].id, newTe.shards[1].id) require.Equal(t, te.shards[0].id, newTe.shards[1].id)
require.NoError(t, newTe.ng.Close(context.Background())) require.NoError(t, newTe.ng.Close(context.Background()))
} }
func TestReload(t *testing.T) { func TestReload(t *testing.T) {
@ -299,7 +298,7 @@ func engineWithShards(t *testing.T, path string, num int) (*StorageEngine, []str
blobstor.WithStorages(newStorages(filepath.Join(addPath, strconv.Itoa(id)), errSmallSize))), blobstor.WithStorages(newStorages(filepath.Join(addPath, strconv.Itoa(id)), errSmallSize))),
shard.WithMetaBaseOptions( shard.WithMetaBaseOptions(
meta.WithPath(filepath.Join(addPath, fmt.Sprintf("%d.metabase", id))), meta.WithPath(filepath.Join(addPath, fmt.Sprintf("%d.metabase", id))),
meta.WithPermissions(0700), meta.WithPermissions(0o700),
meta.WithEpochState(epochState{}), meta.WithEpochState(epochState{}),
), ),
} }

View file

@ -143,7 +143,8 @@ func (e *StorageEngine) reportShardError(
sh hashedShard, sh hashedShard,
msg string, msg string,
err error, err error,
fields ...zap.Field) { fields ...zap.Field,
) {
if isLogical(err) { if isLogical(err) {
e.log.Warn(msg, e.log.Warn(msg,
zap.Stringer("shard_id", sh.ID()), zap.Stringer("shard_id", sh.ID()),
@ -162,7 +163,8 @@ func (e *StorageEngine) reportShardErrorWithFlags(
block bool, block bool,
msg string, msg string,
err error, err error,
fields ...zap.Field) { fields ...zap.Field,
) {
sid := sh.ID() sid := sh.ID()
e.log.Warn(msg, append([]zap.Field{ e.log.Warn(msg, append([]zap.Field{
zap.Stringer("shard_id", sid), zap.Stringer("shard_id", sid),

View file

@ -144,7 +144,7 @@ func newStorages(root string, smallSize uint64) []blobstor.SubStorage {
blobovniczatree.WithRootPath(filepath.Join(root, "blobovnicza")), blobovniczatree.WithRootPath(filepath.Join(root, "blobovnicza")),
blobovniczatree.WithBlobovniczaShallowDepth(1), blobovniczatree.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1), blobovniczatree.WithBlobovniczaShallowWidth(1),
blobovniczatree.WithPermissions(0700)), blobovniczatree.WithPermissions(0o700)),
Policy: func(_ *objectSDK.Object, data []byte) bool { Policy: func(_ *objectSDK.Object, data []byte) bool {
return uint64(len(data)) < smallSize return uint64(len(data)) < smallSize
}, },
@ -163,7 +163,7 @@ func newTestStorages(root string, smallSize uint64) ([]blobstor.SubStorage, *tes
blobovniczatree.WithRootPath(filepath.Join(root, "blobovnicza")), blobovniczatree.WithRootPath(filepath.Join(root, "blobovnicza")),
blobovniczatree.WithBlobovniczaShallowDepth(1), blobovniczatree.WithBlobovniczaShallowDepth(1),
blobovniczatree.WithBlobovniczaShallowWidth(1), blobovniczatree.WithBlobovniczaShallowWidth(1),
blobovniczatree.WithPermissions(0700)), blobovniczatree.WithPermissions(0o700)),
)) ))
largeFileStorage := teststore.New( largeFileStorage := teststore.New(
teststore.WithSubstorage(fstree.New( teststore.WithSubstorage(fstree.New(
@ -205,7 +205,8 @@ func testDefaultShardOptions(t testing.TB, id int) []shard.Option {
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))), shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))),
shard.WithMetaBaseOptions( shard.WithMetaBaseOptions(
meta.WithPath(filepath.Join(t.TempDir(), "metabase")), meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
meta.WithPermissions(0700), meta.WithPermissions(0o700),
meta.WithEpochState(epochState{}), meta.WithEpochState(epochState{}),
)} ),
}
} }

View file

@ -59,12 +59,12 @@ func newEngineWithErrorThreshold(t testing.TB, dir string, errThreshold uint32)
shard.WithBlobStorOptions(blobstor.WithStorages(storages)), shard.WithBlobStorOptions(blobstor.WithStorages(storages)),
shard.WithMetaBaseOptions( shard.WithMetaBaseOptions(
meta.WithPath(filepath.Join(dir, fmt.Sprintf("%d.metabase", id))), meta.WithPath(filepath.Join(dir, fmt.Sprintf("%d.metabase", id))),
meta.WithPermissions(0700), meta.WithPermissions(0o700),
meta.WithEpochState(epochState{}), meta.WithEpochState(epochState{}),
), ),
shard.WithPiloramaOptions( shard.WithPiloramaOptions(
pilorama.WithPath(filepath.Join(dir, fmt.Sprintf("%d.pilorama", id))), pilorama.WithPath(filepath.Join(dir, fmt.Sprintf("%d.pilorama", id))),
pilorama.WithPerm(0700)), pilorama.WithPerm(0o700)),
} }
}) })
e := te.engine e := te.engine

View file

@ -163,7 +163,6 @@ func (e *StorageEngine) Evacuate(ctx context.Context, prm EvacuateShardPrm) (*Ev
res := NewEvacuateShardRes() res := NewEvacuateShardRes()
ctx = ctxOrBackground(ctx, prm.async) ctx = ctxOrBackground(ctx, prm.async)
eg, egCtx, err := e.evacuateLimiter.TryStart(ctx, shardIDs, res) eg, egCtx, err := e.evacuateLimiter.TryStart(ctx, shardIDs, res)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -187,7 +186,8 @@ func ctxOrBackground(ctx context.Context, background bool) context.Context {
} }
func (e *StorageEngine) evacuateShards(ctx context.Context, shardIDs []string, prm EvacuateShardPrm, res *EvacuateShardRes, func (e *StorageEngine) evacuateShards(ctx context.Context, shardIDs []string, prm EvacuateShardPrm, res *EvacuateShardRes,
shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard) error { shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard,
) error {
var err error var err error
ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateShards", ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateShards",
trace.WithAttributes( trace.WithAttributes(
@ -246,7 +246,8 @@ func (e *StorageEngine) getTotalObjectsCount(ctx context.Context, shardsToEvacua
} }
func (e *StorageEngine) evacuateShard(ctx context.Context, shardID string, prm EvacuateShardPrm, res *EvacuateShardRes, func (e *StorageEngine) evacuateShard(ctx context.Context, shardID string, prm EvacuateShardPrm, res *EvacuateShardRes,
shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard) error { shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard,
) error {
ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateShard", ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateShard",
trace.WithAttributes( trace.WithAttributes(
attribute.String("shardID", shardID), attribute.String("shardID", shardID),
@ -322,7 +323,8 @@ func (e *StorageEngine) getActualShards(shardIDs []string, handlerDefined bool)
} }
func (e *StorageEngine) evacuateObjects(ctx context.Context, sh *shard.Shard, toEvacuate []object.AddressWithType, prm EvacuateShardPrm, res *EvacuateShardRes, func (e *StorageEngine) evacuateObjects(ctx context.Context, sh *shard.Shard, toEvacuate []object.AddressWithType, prm EvacuateShardPrm, res *EvacuateShardRes,
shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard) error { shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard,
) error {
ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateObjects", ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.evacuateObjects",
trace.WithAttributes( trace.WithAttributes(
attribute.Int("objects_count", len(toEvacuate)), attribute.Int("objects_count", len(toEvacuate)),
@ -378,7 +380,8 @@ func (e *StorageEngine) evacuateObjects(ctx context.Context, sh *shard.Shard, to
} }
func (e *StorageEngine) tryEvacuateObjectLocal(ctx context.Context, addr oid.Address, object *objectSDK.Object, sh *shard.Shard, func (e *StorageEngine) tryEvacuateObjectLocal(ctx context.Context, addr oid.Address, object *objectSDK.Object, sh *shard.Shard,
shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, res *EvacuateShardRes) (bool, error) { shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, res *EvacuateShardRes,
) (bool, error) {
hrw.SortHasherSliceByWeightValue(shards, weights, hrw.StringHash(addr.EncodeToString())) hrw.SortHasherSliceByWeightValue(shards, weights, hrw.StringHash(addr.EncodeToString()))
for j := range shards { for j := range shards {
select { select {

View file

@ -39,7 +39,7 @@ func newEngineEvacuate(t *testing.T, shardNum int, objPerShard int) (*StorageEng
}})), }})),
shard.WithMetaBaseOptions( shard.WithMetaBaseOptions(
meta.WithPath(filepath.Join(dir, fmt.Sprintf("%d.metabase", id))), meta.WithPath(filepath.Join(dir, fmt.Sprintf("%d.metabase", id))),
meta.WithPermissions(0700), meta.WithPermissions(0o700),
meta.WithEpochState(epochState{})), meta.WithEpochState(epochState{})),
} }
}) })
@ -137,7 +137,7 @@ func TestEvacuateShard(t *testing.T) {
func TestEvacuateNetwork(t *testing.T) { func TestEvacuateNetwork(t *testing.T) {
t.Parallel() t.Parallel()
var errReplication = errors.New("handler error") errReplication := errors.New("handler error")
acceptOneOf := func(objects []*objectSDK.Object, max uint64) func(context.Context, oid.Address, *objectSDK.Object) error { acceptOneOf := func(objects []*objectSDK.Object, max uint64) func(context.Context, oid.Address, *objectSDK.Object) error {
var n uint64 var n uint64

View file

@ -72,9 +72,10 @@ func TestListWithCursor(t *testing.T) {
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))), shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))),
shard.WithMetaBaseOptions( shard.WithMetaBaseOptions(
meta.WithPath(filepath.Join(t.TempDir(), "metabase")), meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
meta.WithPermissions(0700), meta.WithPermissions(0o700),
meta.WithEpochState(epochState{}), meta.WithEpochState(epochState{}),
)} ),
}
}).engine }).engine
require.NoError(t, e.Open(context.Background())) require.NoError(t, e.Open(context.Background()))
require.NoError(t, e.Init(context.Background())) require.NoError(t, e.Init(context.Background()))

View file

@ -48,6 +48,7 @@ func TestError(t *testing.T) {
} }
}) })
} }
func TestNilWrap(t *testing.T) { func TestNilWrap(t *testing.T) {
require.NoError(t, Wrap(nil)) require.NoError(t, Wrap(nil))
} }

View file

@ -69,7 +69,6 @@ func (db *DB) GetChildren(ctx context.Context, addresses []oid.Address) (map[oid
} }
return nil return nil
}) })
if err != nil { if err != nil {
return nil, metaerr.Wrap(err) return nil, metaerr.Wrap(err)
} }

View file

@ -10,8 +10,10 @@ import (
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
var objectPhyCounterKey = []byte("phy_counter") var (
var objectLogicCounterKey = []byte("logic_counter") objectPhyCounterKey = []byte("phy_counter")
objectLogicCounterKey = []byte("logic_counter")
)
type objectType uint8 type objectType uint8

View file

@ -45,7 +45,7 @@ func newDB(t testing.TB, opts ...meta.Option) *meta.DB {
bdb := meta.New( bdb := meta.New(
append([]meta.Option{ append([]meta.Option{
meta.WithPath(filepath.Join(t.TempDir(), "metabase")), meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
meta.WithPermissions(0600), meta.WithPermissions(0o600),
meta.WithEpochState(epochState{}), meta.WithEpochState(epochState{}),
}, opts...)..., }, opts...)...,
) )

View file

@ -98,8 +98,8 @@ func (db *DB) Delete(ctx context.Context, prm DeletePrm) (DeleteRes, error) {
var rawRemoved uint64 var rawRemoved uint64
var availableRemoved uint64 var availableRemoved uint64
var err error var err error
var sizes = make([]uint64, len(prm.addrs)) sizes := make([]uint64, len(prm.addrs))
var availableSizes = make([]uint64, len(prm.addrs)) availableSizes := make([]uint64, len(prm.addrs))
err = db.boltDB.Update(func(tx *bbolt.Tx) error { err = db.boltDB.Update(func(tx *bbolt.Tx) error {
// We need to clear slice because tx can try to execute multiple times. // We need to clear slice because tx can try to execute multiple times.

View file

@ -83,7 +83,6 @@ func (db *DB) FilterExpired(ctx context.Context, epoch uint64, addresses []oid.A
} }
return nil return nil
}) })
if err != nil { if err != nil {
return nil, metaerr.Wrap(err) return nil, metaerr.Wrap(err)
} }

View file

@ -115,7 +115,7 @@ func (db *DB) listWithCursor(tx *bbolt.Tx, result []objectcore.AddressWithType,
graveyardBkt := tx.Bucket(graveyardBucketName) graveyardBkt := tx.Bucket(graveyardBucketName)
garbageBkt := tx.Bucket(garbageBucketName) garbageBkt := tx.Bucket(garbageBucketName)
var rawAddr = make([]byte, cidSize, addressKeySize) rawAddr := make([]byte, cidSize, addressKeySize)
loop: loop:
for ; name != nil; name, _ = c.Next() { for ; name != nil; name, _ = c.Next() {

View file

@ -211,7 +211,6 @@ func TestAddObjectDuringListingWithCursor(t *testing.T) {
for _, v := range expected { for _, v := range expected {
require.Equal(t, 1, v) require.Equal(t, 1, v)
} }
} }
func sortAddresses(addrWithType []object.AddressWithType) []object.AddressWithType { func sortAddresses(addrWithType []object.AddressWithType) []object.AddressWithType {

View file

@ -244,7 +244,6 @@ func freePotentialLocks(tx *bbolt.Tx, idCnr cid.ID, locker oid.ID) ([]oid.Addres
return nil return nil
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -101,7 +101,8 @@ func (db *DB) put(tx *bbolt.Tx,
obj *objectSDK.Object, obj *objectSDK.Object,
id []byte, id []byte,
si *objectSDK.SplitInfo, si *objectSDK.SplitInfo,
currEpoch uint64) error { currEpoch uint64,
) error {
cnr, ok := obj.ContainerID() cnr, ok := obj.ContainerID()
if !ok { if !ok {
return errors.New("missing container in object") return errors.New("missing container in object")

View file

@ -23,7 +23,7 @@ func TestVersion(t *testing.T) {
newDB := func(t *testing.T) *DB { newDB := func(t *testing.T) *DB {
return New(WithPath(filepath.Join(dir, t.Name())), return New(WithPath(filepath.Join(dir, t.Name())),
WithPermissions(0600), WithEpochState(epochStateImpl{})) WithPermissions(0o600), WithEpochState(epochStateImpl{}))
} }
check := func(t *testing.T, db *DB) { check := func(t *testing.T, db *DB) {
require.NoError(t, db.boltDB.View(func(tx *bbolt.Tx) error { require.NoError(t, db.boltDB.View(func(tx *bbolt.Tx) error {

View file

@ -28,6 +28,7 @@ func (m *fstreeMetrics) SetParentID(parentID string) {
func (m *fstreeMetrics) SetMode(readOnly bool) { func (m *fstreeMetrics) SetMode(readOnly bool) {
m.m.SetMode(m.shardID, m.path, readOnly) m.m.SetMode(m.shardID, m.path, readOnly)
} }
func (m *fstreeMetrics) Close() { func (m *fstreeMetrics) Close() {
m.m.Close(m.shardID, m.path) m.m.Close(m.shardID, m.path)
} }
@ -35,24 +36,29 @@ func (m *fstreeMetrics) Close() {
func (m *fstreeMetrics) Iterate(d time.Duration, success bool) { func (m *fstreeMetrics) Iterate(d time.Duration, success bool) {
m.m.MethodDuration(m.shardID, m.path, "Iterate", d, success) m.m.MethodDuration(m.shardID, m.path, "Iterate", d, success)
} }
func (m *fstreeMetrics) Delete(d time.Duration, success bool) { func (m *fstreeMetrics) Delete(d time.Duration, success bool) {
m.m.MethodDuration(m.shardID, m.path, "Delete", d, success) m.m.MethodDuration(m.shardID, m.path, "Delete", d, success)
} }
func (m *fstreeMetrics) Exists(d time.Duration, success bool) { func (m *fstreeMetrics) Exists(d time.Duration, success bool) {
m.m.MethodDuration(m.shardID, m.path, "Exists", d, success) m.m.MethodDuration(m.shardID, m.path, "Exists", d, success)
} }
func (m *fstreeMetrics) Put(d time.Duration, size int, success bool) { func (m *fstreeMetrics) Put(d time.Duration, size int, success bool) {
m.m.MethodDuration(m.shardID, m.path, "Put", d, success) m.m.MethodDuration(m.shardID, m.path, "Put", d, success)
if success { if success {
m.m.AddPut(m.shardID, m.path, size) m.m.AddPut(m.shardID, m.path, size)
} }
} }
func (m *fstreeMetrics) Get(d time.Duration, size int, success bool) { func (m *fstreeMetrics) Get(d time.Duration, size int, success bool) {
m.m.MethodDuration(m.shardID, m.path, "Get", d, success) m.m.MethodDuration(m.shardID, m.path, "Get", d, success)
if success { if success {
m.m.AddGet(m.shardID, m.path, size) m.m.AddGet(m.shardID, m.path, size)
} }
} }
func (m *fstreeMetrics) GetRange(d time.Duration, size int, success bool) { func (m *fstreeMetrics) GetRange(d time.Duration, size int, success bool) {
m.m.MethodDuration(m.shardID, m.path, "GetRange", d, success) m.m.MethodDuration(m.shardID, m.path, "GetRange", d, success)
if success { if success {

View file

@ -111,6 +111,7 @@ func (t *boltForest) SetMode(m mode.Mode) error {
t.metrics.SetMode(m) t.metrics.SetMode(m)
return nil return nil
} }
func (t *boltForest) Open(_ context.Context, readOnly bool) error { func (t *boltForest) Open(_ context.Context, readOnly bool) error {
err := util.MkdirAllX(filepath.Dir(t.path), t.perm) err := util.MkdirAllX(filepath.Dir(t.path), t.perm)
if err != nil { if err != nil {
@ -137,6 +138,7 @@ func (t *boltForest) Open(_ context.Context, readOnly bool) error {
t.metrics.SetMode(m) t.metrics.SetMode(m)
return nil return nil
} }
func (t *boltForest) Init() error { func (t *boltForest) Init() error {
if t.mode.NoMetabase() || t.db.IsReadOnly() { if t.mode.NoMetabase() || t.db.IsReadOnly() {
return nil return nil
@ -150,6 +152,7 @@ func (t *boltForest) Init() error {
return err return err
}) })
} }
func (t *boltForest) Close() error { func (t *boltForest) Close() error {
var err error var err error
if t.db != nil { if t.db != nil {

View file

@ -71,7 +71,8 @@ func (f *memoryForest) TreeAddByPath(_ context.Context, d CIDDescriptor, treeID
Parent: node, Parent: node,
Meta: Meta{ Meta: Meta{
Time: s.timestamp(d.Position, d.Size), Time: s.timestamp(d.Position, d.Size),
Items: []KeyValue{{Key: attr, Value: []byte(path[j])}}}, Items: []KeyValue{{Key: attr, Value: []byte(path[j])}},
},
Child: s.findSpareID(), Child: s.findSpareID(),
}) })
lm[j-i] = op.Move lm[j-i] = op.Move
@ -113,9 +114,11 @@ func (f *memoryForest) Init() error {
func (f *memoryForest) Open(context.Context, bool) error { func (f *memoryForest) Open(context.Context, bool) error {
return nil return nil
} }
func (f *memoryForest) SetMode(mode.Mode) error { func (f *memoryForest) SetMode(mode.Mode) error {
return nil return nil
} }
func (f *memoryForest) Close() error { func (f *memoryForest) Close() error {
return nil return nil
} }

View file

@ -36,7 +36,8 @@ var providers = []struct {
f := NewBoltForest( f := NewBoltForest(
append([]Option{ append([]Option{
WithPath(filepath.Join(t.TempDir(), "test.db")), WithPath(filepath.Join(t.TempDir(), "test.db")),
WithMaxBatchSize(1)}, opts...)...) WithMaxBatchSize(1),
}, opts...)...)
require.NoError(t, f.Open(context.Background(), false)) require.NoError(t, f.Open(context.Background(), false))
require.NoError(t, f.Init()) require.NoError(t, f.Init())
t.Cleanup(func() { t.Cleanup(func() {
@ -68,7 +69,8 @@ func testForestTreeMove(t *testing.T, s Forest) {
meta := []KeyValue{ meta := []KeyValue{
{Key: AttributeVersion, Value: []byte("XXX")}, {Key: AttributeVersion, Value: []byte("XXX")},
{Key: AttributeFilename, Value: []byte("file.txt")}} {Key: AttributeFilename, Value: []byte("file.txt")},
}
lm, err := s.TreeAddByPath(context.Background(), d, treeID, AttributeFilename, []string{"path", "to"}, meta) lm, err := s.TreeAddByPath(context.Background(), d, treeID, AttributeFilename, []string{"path", "to"}, meta)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, 3, len(lm)) require.Equal(t, 3, len(lm))
@ -261,7 +263,8 @@ func testForestTreeAdd(t *testing.T, s Forest) {
meta := []KeyValue{ meta := []KeyValue{
{Key: AttributeVersion, Value: []byte("XXX")}, {Key: AttributeVersion, Value: []byte("XXX")},
{Key: AttributeFilename, Value: []byte("file.txt")}} {Key: AttributeFilename, Value: []byte("file.txt")},
}
m := &Move{ m := &Move{
Parent: RootID, Parent: RootID,
Child: RootID, Child: RootID,
@ -306,7 +309,8 @@ func testForestTreeAddByPath(t *testing.T, s Forest) {
meta := []KeyValue{ meta := []KeyValue{
{Key: AttributeVersion, Value: []byte("XXX")}, {Key: AttributeVersion, Value: []byte("XXX")},
{Key: AttributeFilename, Value: []byte("file.txt")}} {Key: AttributeFilename, Value: []byte("file.txt")},
}
t.Run("invalid descriptor", func(t *testing.T) { t.Run("invalid descriptor", func(t *testing.T) {
_, err := s.TreeAddByPath(context.Background(), CIDDescriptor{cid, 0, 0}, treeID, AttributeFilename, []string{"yyy"}, meta) _, err := s.TreeAddByPath(context.Background(), CIDDescriptor{cid, 0, 0}, treeID, AttributeFilename, []string{"yyy"}, meta)
@ -381,7 +385,8 @@ func testForestTreeAddByPath(t *testing.T, s Forest) {
testMeta(t, s, cid, treeID, oldMove.Child, oldMove.Parent, testMeta(t, s, cid, treeID, oldMove.Child, oldMove.Parent,
Meta{Time: oldMove.Time, Items: []KeyValue{ Meta{Time: oldMove.Time, Items: []KeyValue{
{AttributeVersion, []byte("SomeValue")}, {AttributeVersion, []byte("SomeValue")},
{AttributeFilename, []byte("another")}}}) {AttributeFilename, []byte("another")},
}})
t.Run("get by path", func(t *testing.T) { t.Run("get by path", func(t *testing.T) {
nodes, err := s.TreeGetByPath(context.Background(), cid, treeID, AttributeFilename, []string{"path", "another"}, false) nodes, err := s.TreeGetByPath(context.Background(), cid, treeID, AttributeFilename, []string{"path", "another"}, false)
@ -399,7 +404,8 @@ func testForestTreeAddByPath(t *testing.T, s Forest) {
t.Run("empty component", func(t *testing.T) { t.Run("empty component", func(t *testing.T) {
meta := []KeyValue{ meta := []KeyValue{
{Key: AttributeVersion, Value: []byte("XXX")}, {Key: AttributeVersion, Value: []byte("XXX")},
{Key: AttributeFilename, Value: []byte{}}} {Key: AttributeFilename, Value: []byte{}},
}
lm, err := s.TreeAddByPath(context.Background(), d, treeID, AttributeFilename, []string{"path", "to"}, meta) lm, err := s.TreeAddByPath(context.Background(), d, treeID, AttributeFilename, []string{"path", "to"}, meta)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, 1, len(lm)) require.Equal(t, 1, len(lm))

View file

@ -21,7 +21,8 @@ func TestMeta_Bytes(t *testing.T) {
Items: []KeyValue{ Items: []KeyValue{
{"abc", []byte{1, 2, 3}}, {"abc", []byte{1, 2, 3}},
{AttributeFilename, []byte{}}, {AttributeFilename, []byte{}},
}} },
}
data := expected.Bytes() data := expected.Bytes()
@ -35,7 +36,8 @@ func TestMeta_Bytes(t *testing.T) {
Items: []KeyValue{ Items: []KeyValue{
{"abc", []byte{1, 2, 3}}, {"abc", []byte{1, 2, 3}},
{"xyz", []byte{5, 6, 7, 8}}, {"xyz", []byte{5, 6, 7, 8}},
}} },
}
data := expected.Bytes() data := expected.Bytes()

View file

@ -41,7 +41,8 @@ func TestShardReload(t *testing.T) {
metaOpts := []meta.Option{ metaOpts := []meta.Option{
meta.WithPath(filepath.Join(p, "meta")), meta.WithPath(filepath.Join(p, "meta")),
meta.WithEpochState(epochState{})} meta.WithEpochState(epochState{}),
}
opts := []Option{ opts := []Option{
WithID(NewIDFromBytes([]byte{})), WithID(NewIDFromBytes([]byte{})),
@ -49,7 +50,8 @@ func TestShardReload(t *testing.T) {
WithBlobStorOptions(blobOpts...), WithBlobStorOptions(blobOpts...),
WithMetaBaseOptions(metaOpts...), WithMetaBaseOptions(metaOpts...),
WithPiloramaOptions( WithPiloramaOptions(
pilorama.WithPath(filepath.Join(p, "pilorama")))} pilorama.WithPath(filepath.Join(p, "pilorama"))),
}
sh := New(opts...) sh := New(opts...)
require.NoError(t, sh.Open(context.Background())) require.NoError(t, sh.Open(context.Background()))

View file

@ -94,7 +94,8 @@ func newCustomShard(t testing.TB, enableWriteCache bool, o shardOptions) *Shard
WithBlobStorOptions(o.bsOpts...), WithBlobStorOptions(o.bsOpts...),
WithMetaBaseOptions( WithMetaBaseOptions(
append([]meta.Option{ append([]meta.Option{
meta.WithPath(filepath.Join(o.rootPath, "meta")), meta.WithEpochState(epochState{})}, meta.WithPath(filepath.Join(o.rootPath, "meta")), meta.WithEpochState(epochState{}),
},
o.metaOptions...)..., o.metaOptions...)...,
), ),
WithPiloramaOptions(pilorama.WithPath(filepath.Join(o.rootPath, "pilorama"))), WithPiloramaOptions(pilorama.WithPath(filepath.Join(o.rootPath, "pilorama"))),

View file

@ -55,9 +55,7 @@ const (
defaultMaxCacheSize = 1 << 30 // 1 GiB defaultMaxCacheSize = 1 << 30 // 1 GiB
) )
var ( var defaultBucket = []byte{0}
defaultBucket = []byte{0}
)
// New creates new writecache instance. // New creates new writecache instance.
func New(opts ...Option) writecache.Cache { func New(opts ...Option) writecache.Cache {

View file

@ -5,8 +5,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
//TODO
type ReplicatorMetrics interface { type ReplicatorMetrics interface {
IncInFlightRequest() IncInFlightRequest()
DecInFlightRequest() DecInFlightRequest()

View file

@ -55,9 +55,7 @@ const (
defaultWaitInterval = 500 * time.Millisecond defaultWaitInterval = 500 * time.Millisecond
) )
var ( var ErrNoHealthyEndpoint = errors.New("no healthy endpoint")
ErrNoHealthyEndpoint = errors.New("no healthy endpoint")
)
func defaultConfig() *cfg { func defaultConfig() *cfg {
return &cfg{ return &cfg{

View file

@ -42,9 +42,7 @@ const (
putNamedMethod = "putNamed" putNamedMethod = "putNamed"
) )
var ( var errNilArgument = errors.New("empty argument")
errNilArgument = errors.New("empty argument")
)
// NewFromMorph returns the wrapper instance from the raw morph client. // NewFromMorph returns the wrapper instance from the raw morph client.
// //

View file

@ -22,7 +22,7 @@ func (a *AddPeerPrm) SetNodeInfo(nodeInfo netmap.NodeInfo) {
// AddPeer registers peer in FrostFS network through // AddPeer registers peer in FrostFS network through
// Netmap contract call. // Netmap contract call.
func (c *Client) AddPeer(p AddPeerPrm) error { func (c *Client) AddPeer(p AddPeerPrm) error {
var method = addPeerMethod method := addPeerMethod
if c.client.WithNotary() && c.client.IsAlpha() { if c.client.WithNotary() && c.client.IsAlpha() {
// In notary environments Alphabet must calls AddPeerIR method instead of AddPeer. // In notary environments Alphabet must calls AddPeerIR method instead of AddPeer.

View file

@ -16,13 +16,11 @@ func genKey(t *testing.T) *keys.PrivateKey {
} }
func TestParseUpdateInnerRing(t *testing.T) { func TestParseUpdateInnerRing(t *testing.T) {
var ( publicKeys := []*keys.PublicKey{
publicKeys = []*keys.PublicKey{
genKey(t).PublicKey(), genKey(t).PublicKey(),
genKey(t).PublicKey(), genKey(t).PublicKey(),
genKey(t).PublicKey(), genKey(t).PublicKey(),
} }
)
t.Run("wrong number of parameters", func(t *testing.T) { t.Run("wrong number of parameters", func(t *testing.T) {
prms := []stackitem.Item{ prms := []stackitem.Item{

View file

@ -147,7 +147,6 @@ func TestErrorPassing(t *testing.T) {
require.ErrorIs(t, err, bErr, "invalid block error") require.ErrorIs(t, err, bErr, "invalid block error")
}) })
} }
type testSubscriber struct { type testSubscriber struct {
@ -166,6 +165,7 @@ func (s *testSubscriber) UnsubscribeForNotification() {}
func (s *testSubscriber) BlockNotifications() error { func (s *testSubscriber) BlockNotifications() error {
return s.blockErr return s.blockErr
} }
func (s *testSubscriber) SubscribeForNotaryRequests(mainTXSigner util.Uint160) error { func (s *testSubscriber) SubscribeForNotaryRequests(mainTXSigner util.Uint160) error {
return nil return nil
} }

Some files were not shown because too many files have changed in this diff Show more