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"
|
2021-10-11 10:04:25 +01:00
|
|
|
"storj.io/storj/multinode"
|
2019-02-26 18:35:16 +00:00
|
|
|
"storj.io/storj/satellite"
|
2021-05-13 09:14:18 +01:00
|
|
|
"storj.io/storj/satellite/metabase"
|
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)
|
2021-05-13 09:14:18 +01:00
|
|
|
SatelliteMetabaseDB func(log *zap.Logger, index int, db *metabase.DB) (*metabase.DB, error)
|
2020-10-29 16:54:35 +00:00
|
|
|
Satellite func(log *zap.Logger, index int, config *satellite.Config)
|
2020-03-27 16:18:19 +00:00
|
|
|
|
2021-08-02 18:48:55 +01: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
|
2021-10-11 10:04:25 +01:00
|
|
|
|
|
|
|
MultinodeDB func(index int, db multinode.DB, log *zap.Logger) (multinode.DB, error)
|
|
|
|
Multinode func(index int, config *multinode.Config)
|
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
|
|
|
|
2022-03-03 00:23:11 +00:00
|
|
|
// RepairExcludedCountryCodes returns function to change satellite repair excluded country codes.
|
|
|
|
var RepairExcludedCountryCodes = func(repairExcludedCountryCodes []string) func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
return func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Overlay.RepairExcludedCountryCodes = repairExcludedCountryCodes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// UploadExcludedCountryCodes returns function to change satellite upload excluded country codes.
|
|
|
|
var UploadExcludedCountryCodes = func(uploadExcludedCountryCodes []string) func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
return func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Overlay.Node.UploadExcludedCountryCodes = uploadExcludedCountryCodes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-07-29 13:08:19 +01:00
|
|
|
// MaxObjectKeyLength returns function to change satellite max object key length value.
|
|
|
|
var MaxObjectKeyLength = func(maxObjectKeyLength int) func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
return func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Metainfo.MaxEncryptedObjectKeyLength = maxObjectKeyLength
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
},
|
|
|
|
}
|