From 0cc6a4d93738a974b0e330aab57cee9807021d69 Mon Sep 17 00:00:00 2001 From: tianshapjq Date: Thu, 30 Nov 2017 14:14:59 +0800 Subject: [PATCH] new testcase to cgroup_manager_linux.go --- pkg/kubelet/cm/cgroup_manager_linux_test.go | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkg/kubelet/cm/cgroup_manager_linux_test.go b/pkg/kubelet/cm/cgroup_manager_linux_test.go index ed60c4d50e..36c5a7c30c 100644 --- a/pkg/kubelet/cm/cgroup_manager_linux_test.go +++ b/pkg/kubelet/cm/cgroup_manager_linux_test.go @@ -99,3 +99,35 @@ func TestLibcontainerAdapterAdaptToSystemdAsCgroupFs(t *testing.T) { } } } + +func TestLibcontainerAdapterNotAdaptToSystemd(t *testing.T) { + cgroupfs := newLibcontainerAdapter(libcontainerCgroupfs) + otherAdatper := newLibcontainerAdapter(libcontainerCgroupManagerType("test")) + + testCases := []struct { + input string + expected string + }{ + { + input: "/", + expected: "/", + }, + { + input: "/Burstable", + expected: "/Burstable", + }, + { + input: "", + expected: "", + }, + } + for _, testCase := range testCases { + if actual := cgroupfs.adaptName(CgroupName(testCase.input), true); actual != testCase.expected { + t.Errorf("Unexpected result, input: %v, expected: %v, actual: %v", testCase.input, testCase.expected, actual) + } + + if actual := otherAdatper.adaptName(CgroupName(testCase.input), true); actual != testCase.expected { + t.Errorf("Unexpected result, input: %v, expected: %v, actual: %v", testCase.input, testCase.expected, actual) + } + } +}