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:
JT Olio 2023-03-06 11:20:44 -05:00 committed by JT Olio
parent 41efebeebd
commit ade808375c

View File

@ -85,13 +85,29 @@ func TestUploadAndPartialDownload(t *testing.T) {
// check rough limits for the upload and download // check rough limits for the upload and download
totalUpload := int64(len(expectedData)) totalUpload := int64(len(expectedData))
t.Log(totalUpload, totalBandwidthUsage.Put, int64(len(planet.StorageNodes))*totalUpload) totalUploadOrderMax := calcUploadOrderMax(totalUpload)
assert.True(t, totalUpload < totalBandwidthUsage.Put && totalBandwidthUsage.Put < int64(len(planet.StorageNodes))*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) t.Log(totalDownload, totalBandwidthUsage.Get, int64(len(planet.StorageNodes))*totalDownload)
assert.True(t, 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) { func TestUpload(t *testing.T) {
testplanet.Run(t, testplanet.Config{ testplanet.Run(t, testplanet.Config{
SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 1, SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 1,