2016-09-08 13:11:39 -04:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
)
|
|
|
|
|
2016-11-09 04:43:10 -05:00
|
|
|
func TestCalculateBlockIO(t *testing.T) {
|
2016-09-08 13:11:39 -04:00
|
|
|
blkio := types.BlkioStats{
|
2017-05-03 18:14:30 -04:00
|
|
|
IoServiceBytesRecursive: []types.BlkioStatEntry{
|
|
|
|
{Major: 8, Minor: 0, Op: "read", Value: 1234},
|
|
|
|
{Major: 8, Minor: 1, Op: "read", Value: 4567},
|
|
|
|
{Major: 8, Minor: 0, Op: "write", Value: 123},
|
|
|
|
{Major: 8, Minor: 1, Op: "write", Value: 456},
|
|
|
|
},
|
2016-09-08 13:11:39 -04:00
|
|
|
}
|
|
|
|
blkRead, blkWrite := calculateBlockIO(blkio)
|
|
|
|
if blkRead != 5801 {
|
|
|
|
t.Fatalf("blkRead = %d, want 5801", blkRead)
|
|
|
|
}
|
|
|
|
if blkWrite != 579 {
|
|
|
|
t.Fatalf("blkWrite = %d, want 579", blkWrite)
|
|
|
|
}
|
|
|
|
}
|