Add unit test for DisableCgroup, RestrictOOMScoreAdj.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-01-03 10:47:34 -08:00
parent 0fa8668aa4
commit b1ad4ee9b6
3 changed files with 47 additions and 0 deletions

View File

@@ -1021,3 +1021,18 @@ func TestHostname(t *testing.T) {
assert.Contains(t, spec.Process.Env, test.expectedEnv)
}
}
func TestDisableCgroup(t *testing.T) {
config, sandboxConfig, imageConfig, _ := getCreateContainerTestData()
c := newTestCRIService()
c.config.DisableCgroup = true
spec, err := c.generateContainerSpec("test-id", "sandbox-id", 1234, config, sandboxConfig, imageConfig, nil)
require.NoError(t, err)
t.Log("resource limit should not be set")
assert.Nil(t, spec.Linux.Resources.Memory)
assert.Nil(t, spec.Linux.Resources.CPU)
t.Log("cgroup path should be empty")
assert.Empty(t, spec.Linux.CgroupsPath)
}