check / check (push) Waiting to run
s3.part_size was loaded and defaulted but never reached the S3 client, whose uploader used a fixed 10MiB part. The client now takes the part size from the config, for storage_url and for the s3.* fields, and config load rejects a value below 5MiB or above 5GiB, an explicit 0 included. A blob too large for S3's limit of 10,000 parts at that size is uploaded in larger parts, since the uploader cannot learn the size of the reader it is given. The docs gave the default as 5MB, which the config file reads as 5,000,000 bytes, below the minimum; they now say 5MiB. Judgement call: the 5GiB maximum is enforced along with the 5MiB minimum the issue names. Model: opus-5-5
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package s3
|
|
|
|
import "testing"
|
|
|
|
// TestUploadPartSize checks that an upload too large for 10,000 parts of the
|
|
// configured size gets parts just large enough to fit in 10,000.
|
|
func TestUploadPartSize(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
const mib = 1024 * 1024
|
|
|
|
tests := []struct {
|
|
name string
|
|
configured int64
|
|
size int64
|
|
want int64
|
|
}{
|
|
{
|
|
name: "an upload that fits keeps the configured size",
|
|
configured: 5 * mib,
|
|
size: 10 * 1024 * mib,
|
|
want: 5 * mib,
|
|
},
|
|
{
|
|
name: "exactly 10,000 parts keeps the configured size",
|
|
configured: 6 * mib,
|
|
size: 10_000 * 6 * mib,
|
|
want: 6 * mib,
|
|
},
|
|
{
|
|
name: "one byte more than 10,000 parts adds a byte to each",
|
|
configured: 6 * mib,
|
|
size: 10_000*6*mib + 1,
|
|
want: 6*mib + 1,
|
|
},
|
|
{
|
|
name: "zero means the SDK default of 5MiB",
|
|
configured: 0,
|
|
size: 1,
|
|
want: 5 * mib,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
got := uploadPartSize(tt.configured, tt.size)
|
|
if got != tt.want {
|
|
t.Errorf("uploadPartSize(%d, %d) = %d, want %d",
|
|
tt.configured, tt.size, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|