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},
|
2019-03-10 22:01:22 -04:00
|
|
|
{Major: 8, Minor: 0, Op: "Read", Value: 6},
|
|
|
|
{Major: 8, Minor: 1, Op: "Read", Value: 8},
|
2017-05-03 18:14:30 -04:00
|
|
|
{Major: 8, Minor: 0, Op: "write", Value: 123},
|
|
|
|
{Major: 8, Minor: 1, Op: "write", Value: 456},
|
2019-03-10 22:01:22 -04:00
|
|
|
{Major: 8, Minor: 0, Op: "Write", Value: 6},
|
|
|
|
{Major: 8, Minor: 1, Op: "Write", Value: 8},
|
|
|
|
{Major: 8, Minor: 1, Op: "", Value: 456},
|
2017-05-03 18:14:30 -04:00
|
|
|
},
|
2016-09-08 13:11:39 -04:00
|
|
|
}
|
|
|
|
blkRead, blkWrite := calculateBlockIO(blkio)
|
2019-03-10 22:01:22 -04:00
|
|
|
if blkRead != 5815 {
|
|
|
|
t.Fatalf("blkRead = %d, want 5815", blkRead)
|
2016-09-08 13:11:39 -04:00
|
|
|
}
|
2019-03-10 22:01:22 -04:00
|
|
|
if blkWrite != 593 {
|
|
|
|
t.Fatalf("blkWrite = %d, want 593", blkWrite)
|
2016-09-08 13:11:39 -04:00
|
|
|
}
|
|
|
|
}
|