io_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package cgroup
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "path"
  5. "testing"
  6. )
  7. func TestCgroup_IOStat(t *testing.T) {
  8. cgRoot = "fixtures/cgroup"
  9. cg, _ := NewFromProcessCgroupFile(path.Join("fixtures/proc/200/cgroup"))
  10. stat, err := cg.IOStat()
  11. assert.Nil(t, err)
  12. assert.Equal(t,
  13. map[string]IOStat{
  14. "8:0": {ReadOps: 0, WriteOps: 281, ReadBytes: 0, WrittenBytes: 4603904},
  15. "8:16": {ReadOps: 0, WriteOps: 39, ReadBytes: 0, WrittenBytes: 655360},
  16. "8:32": {ReadOps: 23043666, WriteOps: 28906992, ReadBytes: 998632854016, WrittenBytes: 884175858688},
  17. "8:48": {ReadOps: 20689345, WriteOps: 27906791, ReadBytes: 875529547776, WrittenBytes: 753046432768},
  18. "9:1": {ReadOps: 633949, WriteOps: 4, ReadBytes: 10238894080, WrittenBytes: 49152},
  19. },
  20. stat)
  21. cg, _ = NewFromProcessCgroupFile(path.Join("fixtures/proc/400/cgroup"))
  22. stat, err = cg.IOStat()
  23. assert.Nil(t, err)
  24. assert.Equal(t,
  25. map[string]IOStat{
  26. "252:0": {ReadOps: 22, WriteOps: 57111, ReadBytes: 11, WrittenBytes: 630538240},
  27. "253:0": {ReadOps: 44, WriteOps: 57056, ReadBytes: 33, WrittenBytes: 630538241},
  28. },
  29. stat)
  30. }