mirror of
https://github.com/pgsty/minio.git
synced 2026-07-20 20:50:22 +03:00
xl PutObject: Split object into parts (#3651)
For faster time-to-first-byte when we try to download a big object
This commit is contained in:
committed by
Harshavardhana
parent
46743c7918
commit
e9394dc22d
@@ -22,6 +22,8 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
)
|
||||
|
||||
// Tests caclculating disk count.
|
||||
@@ -325,3 +327,35 @@ func TestGetXLMetaV1GJson10(t *testing.T) {
|
||||
}
|
||||
compareXLMetaV1(t, unMarshalXLMeta, gjsonXLMeta)
|
||||
}
|
||||
|
||||
// Test the predicted part size from the part index
|
||||
func TestGetPartSizeFromIdx(t *testing.T) {
|
||||
// Create test cases
|
||||
testCases := []struct {
|
||||
totalSize int64
|
||||
partSize int64
|
||||
partIndex int
|
||||
expectedSize int64
|
||||
}{
|
||||
// Total size is - 1
|
||||
{-1, 10, 1, -1},
|
||||
// Total size is zero
|
||||
{0, 10, 1, 0},
|
||||
// part size 2MiB, total size 4MiB
|
||||
{4 * humanize.MiByte, 2 * humanize.MiByte, 1, 2 * humanize.MiByte},
|
||||
{4 * humanize.MiByte, 2 * humanize.MiByte, 2, 2 * humanize.MiByte},
|
||||
{4 * humanize.MiByte, 2 * humanize.MiByte, 3, 0},
|
||||
// part size 2MiB, total size 5MiB
|
||||
{5 * humanize.MiByte, 2 * humanize.MiByte, 1, 2 * humanize.MiByte},
|
||||
{5 * humanize.MiByte, 2 * humanize.MiByte, 2, 2 * humanize.MiByte},
|
||||
{5 * humanize.MiByte, 2 * humanize.MiByte, 3, 1 * humanize.MiByte},
|
||||
{5 * humanize.MiByte, 2 * humanize.MiByte, 4, 0},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
s := getPartSizeFromIdx(testCase.totalSize, testCase.partSize, testCase.partIndex)
|
||||
if s != testCase.expectedSize {
|
||||
t.Errorf("Test %d: The calculated part size is incorrect: expected = %d, found = %d\n", i+1, testCase.expectedSize, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user