summaryrefslogtreecommitdiffhomepage
path: root/runsc/test/root
diff options
context:
space:
mode:
Diffstat (limited to 'runsc/test/root')
-rw-r--r--runsc/test/root/cgroup_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/runsc/test/root/cgroup_test.go b/runsc/test/root/cgroup_test.go
index fdb94ff64..0eabf9561 100644
--- a/runsc/test/root/cgroup_test.go
+++ b/runsc/test/root/cgroup_test.go
@@ -18,6 +18,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strconv"
"strings"
"testing"
@@ -123,6 +124,8 @@ func TestCgroup(t *testing.T) {
t.Fatalf("Docker.ID() failed: %v", err)
}
t.Logf("cgroup ID: %s", gid)
+
+ // Check list of attributes defined above.
for _, attr := range attrs {
path := filepath.Join("/sys/fs/cgroup", attr.ctrl, "docker", gid, attr.file)
out, err := ioutil.ReadFile(path)
@@ -137,4 +140,33 @@ func TestCgroup(t *testing.T) {
t.Errorf("arg: %q, cgroup attribute %s/%s, got: %q, want: %q", attr.arg, attr.ctrl, attr.file, got, attr.want)
}
}
+
+ // Check that sandbox is inside cgroup.
+ controllers := []string{
+ "blkio",
+ "cpu",
+ "cpuset",
+ "memory",
+ "net_cls",
+ "net_prio",
+ "devices",
+ "freezer",
+ "perf_event",
+ "pids",
+ "systemd",
+ }
+ pid, err := d.SandboxPid()
+ if err != nil {
+ t.Fatalf("SandboxPid: %v", err)
+ }
+ for _, ctrl := range controllers {
+ path := filepath.Join("/sys/fs/cgroup", ctrl, "docker", gid, "cgroup.procs")
+ out, err := ioutil.ReadFile(path)
+ if err != nil {
+ t.Fatalf("failed to read %q: %v", path, err)
+ }
+ if got := string(out); !strings.Contains(got, strconv.Itoa(pid)) {
+ t.Errorf("cgroup control %s processes, got: %q, want: %q", ctrl, got, pid)
+ }
+ }
}