Skip to content

Commit 96cb656

Browse files
committed
device_write_bps can be int or string with bytes unit
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent e0f9c51 commit 96cb656

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

loader/loader_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,3 +2297,43 @@ services:
22972297
assert.Equal(t, project.Services[0].Name, "extension")
22982298
assert.Equal(t, project.Services[0].Extensions["x-foo"], "bar")
22992299
}
2300+
2301+
func TestDeviceWriteBps(t *testing.T) {
2302+
p, err := loadYAML(`
2303+
name: test
2304+
services:
2305+
foo:
2306+
image: busybox
2307+
blkio_config:
2308+
device_read_bps:
2309+
- path: /dev/test
2310+
rate: 1024k
2311+
device_write_bps:
2312+
- path: /dev/test
2313+
rate: 1024
2314+
`)
2315+
assert.NilError(t, err)
2316+
assert.DeepEqual(t, p.Services, types.Services{
2317+
{
2318+
Name: "foo",
2319+
Image: "busybox",
2320+
Environment: types.MappingWithEquals{},
2321+
Scale: 1,
2322+
BlkioConfig: &types.BlkioConfig{
2323+
DeviceReadBps: []types.ThrottleDevice{
2324+
{
2325+
Path: "/dev/test",
2326+
Rate: types.UnitBytes(1024 * 1024),
2327+
},
2328+
},
2329+
DeviceWriteBps: []types.ThrottleDevice{
2330+
{
2331+
Path: "/dev/test",
2332+
Rate: types.UnitBytes(1024),
2333+
},
2334+
},
2335+
},
2336+
},
2337+
})
2338+
2339+
}

types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ type WeightDevice struct {
340340
// ThrottleDevice is a structure that holds device:rate_per_second pair
341341
type ThrottleDevice struct {
342342
Path string
343-
Rate uint64
343+
Rate UnitBytes
344344

345345
Extensions Extensions `mapstructure:"#extensions" yaml:",inline" json:"-"`
346346
}

0 commit comments

Comments
 (0)