pkg/kubelet: adapt to new libcontainer API
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@@ -60,7 +60,11 @@ func fakeContainerMgrMountInt() mount.Interface {
|
||||
func TestCgroupMountValidationSuccess(t *testing.T) {
|
||||
f, err := validateSystemRequirements(fakeContainerMgrMountInt())
|
||||
assert.Nil(t, err)
|
||||
assert.False(t, f.cpuHardcapping, "cpu hardcapping is expected to be disabled")
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
assert.True(t, f.cpuHardcapping, "cpu hardcapping is expected to be enabled")
|
||||
} else {
|
||||
assert.False(t, f.cpuHardcapping, "cpu hardcapping is expected to be disabled")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCgroupMountValidationMemoryMissing(t *testing.T) {
|
||||
@@ -115,6 +119,19 @@ func TestCgroupMountValidationMultipleSubsystem(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestGetCpuWeight(t *testing.T) {
|
||||
assert.Equal(t, uint64(0), getCpuWeight(nil))
|
||||
|
||||
v := uint64(2)
|
||||
assert.Equal(t, uint64(1), getCpuWeight(&v))
|
||||
|
||||
v = uint64(262144)
|
||||
assert.Equal(t, uint64(10000), getCpuWeight(&v))
|
||||
|
||||
v = uint64(1000000000)
|
||||
assert.Equal(t, uint64(10000), getCpuWeight(&v))
|
||||
}
|
||||
|
||||
func TestSoftRequirementsValidationSuccess(t *testing.T) {
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
t.Skip("skipping cgroup v1 test on a cgroup v2 system")
|
||||
@@ -148,28 +165,3 @@ func TestSoftRequirementsValidationSuccess(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, f.cpuHardcapping, "cpu hardcapping is expected to be enabled")
|
||||
}
|
||||
|
||||
func TestGetCpuWeight(t *testing.T) {
|
||||
assert.Equal(t, uint64(0), getCpuWeight(nil))
|
||||
|
||||
v := uint64(2)
|
||||
assert.Equal(t, uint64(1), getCpuWeight(&v))
|
||||
|
||||
v = uint64(262144)
|
||||
assert.Equal(t, uint64(10000), getCpuWeight(&v))
|
||||
|
||||
v = uint64(1000000000)
|
||||
assert.Equal(t, uint64(10000), getCpuWeight(&v))
|
||||
}
|
||||
|
||||
func TestGetCpuMax(t *testing.T) {
|
||||
assert.Equal(t, getCpuMax(nil, nil), "max 100000")
|
||||
|
||||
quota := int64(50000)
|
||||
period := uint64(200000)
|
||||
assert.Equal(t, "50000 200000", getCpuMax("a, &period))
|
||||
|
||||
assert.Equal(t, "max 200000", getCpuMax(nil, &period))
|
||||
|
||||
assert.Equal(t, "50000 100000", getCpuMax("a, nil))
|
||||
}
|
||||
|
Reference in New Issue
Block a user