Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validation: test linux_cgroups_memory with different values
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |