2019-02-26 18:35:16 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package testplanet
|
|
|
|
|
|
|
|
import (
|
2019-07-10 03:36:09 +01:00
|
|
|
"time"
|
|
|
|
|
2019-02-26 18:35:16 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/identity/testidentity"
|
2020-05-26 09:05:43 +01:00
|
|
|
"storj.io/common/memory"
|
2020-05-06 15:30:22 +01:00
|
|
|
"storj.io/common/pb"
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/storj"
|
2019-02-26 18:35:16 +00:00
|
|
|
"storj.io/storj/satellite"
|
2019-10-10 19:06:26 +01:00
|
|
|
"storj.io/storj/satellite/metainfo"
|
2019-02-26 18:35:16 +00:00
|
|
|
"storj.io/storj/storagenode"
|
|
|
|
)
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// Reconfigure allows to change node configurations.
|
2019-02-26 18:35:16 +00:00
|
|
|
type Reconfigure struct {
|
2020-03-27 16:18:19 +00:00
|
|
|
SatelliteDB func(log *zap.Logger, index int, db satellite.DB) (satellite.DB, error)
|
|
|
|
SatellitePointerDB func(log *zap.Logger, index int, db metainfo.PointerDB) (metainfo.PointerDB, error)
|
|
|
|
Satellite func(log *zap.Logger, index int, config *satellite.Config)
|
|
|
|
|
2020-05-06 15:30:22 +01:00
|
|
|
ReferralManagerServer func(log *zap.Logger) pb.DRPCReferralManagerServer
|
2019-02-26 18:35:16 +00:00
|
|
|
|
2020-03-27 16:18:19 +00:00
|
|
|
StorageNodeDB func(index int, db storagenode.DB, log *zap.Logger) (storagenode.DB, error)
|
|
|
|
StorageNode func(index int, config *storagenode.Config)
|
|
|
|
UniqueIPCount int
|
2019-12-10 16:32:54 +00:00
|
|
|
|
|
|
|
Identities func(log *zap.Logger, version storj.IDVersion) *testidentity.Identities
|
2019-02-26 18:35:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DisablePeerCAWhitelist returns a `Reconfigure` that sets `UsePeerCAWhitelist` for
|
|
|
|
// all node types that use kademlia.
|
|
|
|
var DisablePeerCAWhitelist = Reconfigure{
|
|
|
|
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Server.UsePeerCAWhitelist = false
|
|
|
|
},
|
|
|
|
StorageNode: func(index int, config *storagenode.Config) {
|
|
|
|
config.Server.UsePeerCAWhitelist = false
|
|
|
|
},
|
|
|
|
}
|
2019-07-10 03:36:09 +01:00
|
|
|
|
|
|
|
// ShortenOnlineWindow returns a `Reconfigure` that sets the NodeSelection
|
2020-07-16 15:18:02 +01:00
|
|
|
// OnlineWindow to 1 second, meaning a connection failure leads to marking the nodes as offline.
|
2019-07-10 03:36:09 +01:00
|
|
|
var ShortenOnlineWindow = Reconfigure{
|
|
|
|
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Overlay.Node.OnlineWindow = 1 * time.Second
|
|
|
|
},
|
|
|
|
}
|
2020-01-21 10:38:41 +00:00
|
|
|
|
2020-05-26 09:05:43 +01:00
|
|
|
// Combine combines satellite reconfigure functions.
|
|
|
|
var Combine = func(elements ...func(log *zap.Logger, index int, config *satellite.Config)) func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
return func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
for _, f := range elements {
|
|
|
|
f(log, index, config)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// ReconfigureRS returns function to change satellite redundancy scheme values.
|
2020-01-21 10:38:41 +00:00
|
|
|
var ReconfigureRS = func(minThreshold, repairThreshold, successThreshold, totalThreshold int) func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
return func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Metainfo.RS.MinThreshold = minThreshold
|
|
|
|
config.Metainfo.RS.RepairThreshold = repairThreshold
|
|
|
|
config.Metainfo.RS.SuccessThreshold = successThreshold
|
|
|
|
config.Metainfo.RS.TotalThreshold = totalThreshold
|
|
|
|
}
|
|
|
|
}
|
2020-05-26 09:05:43 +01:00
|
|
|
|
|
|
|
// MaxSegmentSize returns function to change satellite max segment size value.
|
|
|
|
var MaxSegmentSize = func(maxSegmentSize memory.Size) func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
return func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Metainfo.MaxSegmentSize = maxSegmentSize
|
|
|
|
}
|
|
|
|
}
|
2020-06-01 21:07:31 +01:00
|
|
|
|
|
|
|
// MaxMetadataSize returns function to change satellite max metadata size value.
|
|
|
|
var MaxMetadataSize = func(maxMetadataSize memory.Size) func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
return func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Metainfo.MaxMetadataSize = maxMetadataSize
|
|
|
|
}
|
|
|
|
}
|