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"
|
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:40:48 +01:00
|
|
|
"storj.io/storj/versioncontrol"
|
2019-02-26 18:35:16 +00:00
|
|
|
)
|
|
|
|
|
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-10-29 16:54:35 +00:00
|
|
|
SatelliteDB func(log *zap.Logger, index int, db satellite.DB) (satellite.DB, error)
|
|
|
|
SatelliteMetabaseDB func(log *zap.Logger, index int, db metainfo.MetabaseDB) (metainfo.MetabaseDB, error)
|
|
|
|
Satellite func(log *zap.Logger, index int, config *satellite.Config)
|
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
|
|
|
|
2020-07-16 15:40:48 +01:00
|
|
|
VersionControl func(config *versioncontrol.Config)
|
|
|
|
|
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) {
|
2020-11-10 11:56:30 +00:00
|
|
|
config.Metainfo.RS.Min = minThreshold
|
|
|
|
config.Metainfo.RS.Repair = repairThreshold
|
|
|
|
config.Metainfo.RS.Success = successThreshold
|
|
|
|
config.Metainfo.RS.Total = totalThreshold
|
2020-01-21 10:38:41 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
}
|
2021-01-28 23:25:10 +00:00
|
|
|
|
|
|
|
// DisableTCP prevents both satellite and storagenode being able to accept new
|
|
|
|
// tcp connections.
|
|
|
|
var DisableTCP = Reconfigure{
|
|
|
|
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Server.DisableTCPTLS = true
|
|
|
|
},
|
|
|
|
StorageNode: func(index int, config *storagenode.Config) {
|
|
|
|
config.Server.DisableTCPTLS = true
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// DisableQUIC prevents both satellite and storagenode being able to accept new
|
|
|
|
// quic connections.
|
|
|
|
var DisableQUIC = Reconfigure{
|
|
|
|
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Server.DisableQUIC = true
|
|
|
|
},
|
|
|
|
StorageNode: func(index int, config *storagenode.Config) {
|
|
|
|
config.Server.DisableQUIC = true
|
|
|
|
},
|
|
|
|
}
|