MCPcopy
hub / github.com/opencontainers/runc / testCgroupResourcesUnified

Function testCgroupResourcesUnified

libcontainer/integration/exec_test.go:615–705  ·  view source on GitHub ↗
(t *testing.T, systemd bool)

Source from the content-addressed store, hash-verified

613}
614
615func testCgroupResourcesUnified(t *testing.T, systemd bool) {
616 if testing.Short() {
617 return
618 }
619 if !cgroups.IsCgroup2UnifiedMode() {
620 t.Skip("requires cgroup v2")
621 }
622
623 config := newTemplateConfig(t, &tParam{systemd: systemd})
624 config.Cgroups.Resources.Memory = 536870912 // 512M
625 config.Cgroups.Resources.MemorySwap = 536870912 // 512M, i.e. no swap
626 config.Namespaces.Add(configs.NEWCGROUP, "")
627
628 testCases := []struct {
629 name string
630 cfg map[string]string
631 expError string
632 cmd []string
633 exp string
634 }{
635 {
636 name: "dummy",
637 cmd: []string{"true"},
638 exp: "",
639 },
640 {
641 name: "set memory.min",
642 cfg: map[string]string{"memory.min": "131072"},
643 cmd: []string{"cat", "/sys/fs/cgroup/memory.min"},
644 exp: "131072\n",
645 },
646 {
647 name: "check memory.max",
648 cmd: []string{"cat", "/sys/fs/cgroup/memory.max"},
649 exp: strconv.Itoa(int(config.Cgroups.Resources.Memory)) + "\n",
650 },
651
652 {
653 name: "overwrite memory.max",
654 cfg: map[string]string{"memory.max": "268435456"},
655 cmd: []string{"cat", "/sys/fs/cgroup/memory.max"},
656 exp: "268435456\n",
657 },
658 {
659 name: "no such controller error",
660 cfg: map[string]string{"privet.vsem": "vam"},
661 expError: "controller \"privet\" not available",
662 },
663 {
664 name: "slash in key error",
665 cfg: map[string]string{"bad/key": "val"},
666 expError: "must be a file name (no slashes)",
667 },
668 {
669 name: "no dot in key error",
670 cfg: map[string]string{"badkey": "val"},
671 expError: "must be in the form CONTROLLER.PARAMETER",
672 },

Callers 2

Calls 6

newTemplateConfigFunction · 0.85
runContainerFunction · 0.85
AddMethod · 0.80
ContainsMethod · 0.80
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…