storagenode/piecestore: be more flexible with bandwidth usage max
this is to prepare for https://review.dev.storj.io/c/storj/uplink/+/9814 Change-Id: Ib74fd63a352a0ae4cc1f8b66fb70df649844c33a
This commit is contained in:
parent
41efebeebd
commit
ade808375c
@ -85,13 +85,29 @@ func TestUploadAndPartialDownload(t *testing.T) {
|
||||
|
||||
// check rough limits for the upload and download
|
||||
totalUpload := int64(len(expectedData))
|
||||
t.Log(totalUpload, totalBandwidthUsage.Put, int64(len(planet.StorageNodes))*totalUpload)
|
||||
assert.True(t, totalUpload < totalBandwidthUsage.Put && totalBandwidthUsage.Put < int64(len(planet.StorageNodes))*totalUpload)
|
||||
totalUploadOrderMax := calcUploadOrderMax(totalUpload)
|
||||
t.Log(totalUpload, totalBandwidthUsage.Put, totalUploadOrderMax, int64(len(planet.StorageNodes))*totalUploadOrderMax)
|
||||
assert.True(t, totalUpload < totalBandwidthUsage.Put && totalBandwidthUsage.Put < int64(len(planet.StorageNodes))*totalUploadOrderMax)
|
||||
t.Log(totalDownload, totalBandwidthUsage.Get, int64(len(planet.StorageNodes))*totalDownload)
|
||||
assert.True(t, totalBandwidthUsage.Get < int64(len(planet.StorageNodes))*totalDownload)
|
||||
})
|
||||
}
|
||||
|
||||
func calcUploadOrderMax(size int64) (ordered int64) {
|
||||
initialStep := 64 * memory.KiB.Int64()
|
||||
maxStep := 256 * memory.KiB.Int64()
|
||||
currentStep := initialStep
|
||||
ordered = 0
|
||||
for ordered < size {
|
||||
ordered += currentStep
|
||||
currentStep = currentStep * 3 / 2
|
||||
if currentStep > maxStep {
|
||||
currentStep = maxStep
|
||||
}
|
||||
}
|
||||
return ordered
|
||||
}
|
||||
|
||||
func TestUpload(t *testing.T) {
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 1,
|
||||
|
Loading…
Reference in New Issue
Block a user