2021-11-12 11:19:16 +00:00
|
|
|
package netmaptest
|
2021-10-27 10:00:35 +00:00
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
import (
|
2022-09-17 10:07:56 +00:00
|
|
|
"math/rand"
|
|
|
|
|
2023-03-07 11:20:03 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
|
|
|
subnetidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/subnet/id/test"
|
2022-06-07 08:25:34 +00:00
|
|
|
)
|
2021-11-08 12:25:13 +00:00
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
func filter(withInner bool) (x netmap.Filter) {
|
2021-11-08 12:25:13 +00:00
|
|
|
x.SetName("name")
|
|
|
|
if withInner {
|
2022-06-07 08:25:34 +00:00
|
|
|
x.LogicalOR(filter(false), filter(false))
|
|
|
|
} else {
|
|
|
|
x.NumericGE("epoch", 13)
|
2021-11-08 12:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filter returns random netmap.Filter.
|
2022-06-07 08:25:34 +00:00
|
|
|
func Filter() netmap.Filter {
|
2021-11-08 12:25:13 +00:00
|
|
|
return filter(true)
|
|
|
|
}
|
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
// Replica returns random netmap.ReplicaDescriptor.
|
|
|
|
func Replica() (x netmap.ReplicaDescriptor) {
|
2022-06-14 14:27:51 +00:00
|
|
|
x.SetNumberOfObjects(666)
|
2022-06-07 08:25:34 +00:00
|
|
|
x.SetSelectorName("selector")
|
2021-11-08 12:25:13 +00:00
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
return
|
2021-11-08 12:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Selector returns random netmap.Selector.
|
2022-06-07 08:25:34 +00:00
|
|
|
func Selector() (x netmap.Selector) {
|
2022-06-14 14:27:51 +00:00
|
|
|
x.SetNumberOfNodes(11)
|
2021-11-08 12:25:13 +00:00
|
|
|
x.SetName("name")
|
2022-06-07 08:25:34 +00:00
|
|
|
x.SetFilterName("filter")
|
|
|
|
x.SelectByBucketAttribute("attribute")
|
|
|
|
x.SelectDistinct()
|
2021-11-08 12:25:13 +00:00
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
return
|
2021-11-08 12:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PlacementPolicy returns random netmap.PlacementPolicy.
|
2022-06-07 08:25:34 +00:00
|
|
|
func PlacementPolicy() (p netmap.PlacementPolicy) {
|
|
|
|
p.SetContainerBackupFactor(9)
|
|
|
|
p.AddFilters(Filter(), Filter())
|
|
|
|
p.AddReplicas(Replica(), Replica())
|
|
|
|
p.AddSelectors(Selector(), Selector())
|
|
|
|
p.RestrictSubnet(subnetidtest.ID())
|
|
|
|
|
|
|
|
return
|
2021-10-27 10:00:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkInfo returns random netmap.NetworkInfo.
|
2022-06-07 08:25:34 +00:00
|
|
|
func NetworkInfo() (x netmap.NetworkInfo) {
|
2021-10-27 10:00:35 +00:00
|
|
|
x.SetCurrentEpoch(21)
|
|
|
|
x.SetMagicNumber(32)
|
|
|
|
x.SetMsPerBlock(43)
|
2022-06-07 08:25:34 +00:00
|
|
|
x.SetAuditFee(1)
|
|
|
|
x.SetStoragePrice(2)
|
|
|
|
x.SetContainerFee(3)
|
|
|
|
x.SetEigenTrustAlpha(0.4)
|
2022-06-14 14:27:51 +00:00
|
|
|
x.SetNumberOfEigenTrustIterations(5)
|
2022-06-07 08:25:34 +00:00
|
|
|
x.SetEpochDuration(6)
|
|
|
|
x.SetIRCandidateFee(7)
|
|
|
|
x.SetMaxObjectSize(8)
|
|
|
|
x.SetWithdrawalFee(9)
|
|
|
|
|
|
|
|
return
|
2021-10-27 10:00:35 +00:00
|
|
|
}
|
2022-09-17 10:07:56 +00:00
|
|
|
|
|
|
|
// NodeInfo returns random netmap.NodeInfo.
|
|
|
|
func NodeInfo() (x netmap.NodeInfo) {
|
|
|
|
key := make([]byte, 33)
|
|
|
|
rand.Read(key)
|
|
|
|
|
|
|
|
x.SetPublicKey(key)
|
|
|
|
x.SetNetworkEndpoints("1", "2", "3")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|