Skip to content

Commit

Permalink
validation: test linux_cgroups_memory with different values
Browse files Browse the repository at this point in the history
Test memory cgroups with different values for memory limit
as well as swappiness.

Signed-off-by: Dongsu Park <dongsu@kinvolk.io>
  • Loading branch information
Dongsu Park committed Jun 6, 2018
1 parent 279a194 commit 871f0eb
Showing 1 changed file with 36 additions and 17 deletions.
53 changes: 36 additions & 17 deletions validation/linux_cgroups_memory.go
@@ -1,33 +1,52 @@
package main

import (
"fmt"
"runtime"

"github.com/mndrix/tap-go"
"github.com/opencontainers/runtime-tools/cgroups"
"github.com/opencontainers/runtime-tools/validation/util"
)

func main() {
var limit int64 = 50593792
var swappiness uint64 = 50
if "linux" != runtime.GOOS {
util.Fatal(fmt.Errorf("linux-specific cgroup test"))
}

t := tap.New()
t.Header(0)
defer t.AutoPlan()

g, err := util.GetDefaultGenerator()
if err != nil {
util.Fatal(err)
cases := []struct {
limit int64
swappiness uint64
}{
{50593792, 10},
{50593792, 50},
{50593792, 100},
{151781376, 10},
{151781376, 50},
{151781376, 100},
}
g.SetLinuxCgroupsPath(cgroups.AbsCgroupPath)
g.SetLinuxResourcesMemoryLimit(limit)
g.SetLinuxResourcesMemoryReservation(limit)
g.SetLinuxResourcesMemorySwap(limit)
g.SetLinuxResourcesMemoryKernel(limit)
g.SetLinuxResourcesMemoryKernelTCP(limit)
g.SetLinuxResourcesMemorySwappiness(swappiness)
g.SetLinuxResourcesMemoryDisableOOMKiller(true)
err = util.RuntimeOutsideValidate(g, t, util.ValidateLinuxResourcesMemory)
if err != nil {
util.Fatal(err)

for _, c := range cases {
g, err := util.GetDefaultGenerator()
if err != nil {
util.Fatal(err)
}
g.SetLinuxCgroupsPath(cgroups.AbsCgroupPath)
g.SetLinuxResourcesMemoryLimit(c.limit)
g.SetLinuxResourcesMemoryReservation(c.limit)
g.SetLinuxResourcesMemorySwap(c.limit)
g.SetLinuxResourcesMemoryKernel(c.limit)
g.SetLinuxResourcesMemoryKernelTCP(c.limit)
g.SetLinuxResourcesMemorySwappiness(c.swappiness)
g.SetLinuxResourcesMemoryDisableOOMKiller(true)
err = util.RuntimeOutsideValidate(g, t, util.ValidateLinuxResourcesMemory)
if err != nil {
t.Fail(err.Error())
}
}

t.AutoPlan()
}

0 comments on commit 871f0eb

Please sign in to comment.