Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix replication bandwidth unit conversion #4922

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions cmd/admin-bucket-remote-add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func TestGetBandwidthInBytes(t *testing.T) {
type args struct {
bandwidthStr string
}
f1 := 999.123457 * 1024 * 1024 / 8
f2 := 10.123456790 * 1024 * 1024 * 1024 / 8
f3 := 10000.123456790 * 1024 * 1024 * 1024 / 8
f4 := (0.001*1024*1024*1024 + 1) / 8 // round up
f1 := 999.1234567 * 1024 * 1024
f2 := 10.123456789 * 1024 * 1024 * 1024
f3 := 10000.123456789 * 1024 * 1024 * 1024
f4 := 0.001 * 1024 * 1024 * 1024
tests := []struct {
name string
args args
Expand All @@ -39,66 +39,66 @@ func TestGetBandwidthInBytes(t *testing.T) {
args: args{
bandwidthStr: "1Mi",
},
want: 1024 * 1024 / 8,
want: 1024 * 1024,
},
{
name: "1MegaBit",
args: args{
bandwidthStr: "1M",
},
want: 1000000 / 8,
want: 1000000,
},
{
name: "1GigaBit",
name: "1GigaByte",
args: args{
bandwidthStr: "1G",
},
want: 1000000000 / 8,
want: 1000000000,
},
{
name: "1GigaByte",
name: "1GibiByte",
args: args{
bandwidthStr: "1Gi",
},
want: 1024 * 1024 * 1024 / 8,
want: 1024 * 1024 * 1024,
},
{
name: "FractionalMegaBits",
name: "FractionalMegaBytes",
args: args{
bandwidthStr: "999.123456789123456789M",
},
want: 999123457 / 8,
want: 999123456,
},
{
name: "FractionalGigaBits",
name: "FractionalGigaBytes",
args: args{
bandwidthStr: "10.123456789123456789123456G",
},
want: 10123456789 / 8,
want: 10123456789,
},
{
name: "FractionalBigGigaBits",
name: "FractionalBigGigaBytes",
args: args{
bandwidthStr: "10000.123456789123456789123456G",
},
want: 10000123456789 / 8,
want: 10000123456789,
},
{
name: "FractionalMegaBytes",
name: "FractionalMebiBytes",
args: args{
bandwidthStr: "999.123456789123456789Mi",
},
want: uint64(f1),
},
{
name: "FractionalGigaBytes",
name: "FractionalGibiBytes",
args: args{
bandwidthStr: "10.123456789123456789123456Gi",
},
want: uint64(f2),
},
{
name: "FractionalBigGigaBytes",
name: "FractionalBigGibiBytes",
args: args{
bandwidthStr: "10000.123456789123456789123456Gi",
},
Expand All @@ -116,7 +116,7 @@ func TestGetBandwidthInBytes(t *testing.T) {
args: args{
bandwidthStr: "1024Ki",
},
want: 1024 * 1024 / 8,
want: 1024 * 1024,
},
}
t.Parallel()
Expand Down
1 change: 0 additions & 1 deletion cmd/replicate-add.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ func getBandwidthInBytes(bandwidthStr string) (bandwidth uint64, err error) {
if err != nil {
return
}
bandwidth = bandwidth / 8
}
return
}
Expand Down
Loading