add cri test case
Signed-off-by: Zhiyu Li <payall4u@qq.com>
This commit is contained in:
parent
9a8bf13158
commit
f8dfbee178
@ -90,6 +90,7 @@ func getCreateContainerTestData() (*runtime.ContainerConfig, *runtime.PodSandbox
|
||||
OomScoreAdj: 500,
|
||||
CpusetCpus: "0-1",
|
||||
CpusetMems: "2-3",
|
||||
Unified: map[string]string{"memory.min": "65536", "memory.swap.max": "1024"},
|
||||
},
|
||||
SecurityContext: &runtime.LinuxContainerSecurityContext{
|
||||
SupplementalGroups: []int64{1111, 2222},
|
||||
@ -136,6 +137,7 @@ func getCreateContainerTestData() (*runtime.ContainerConfig, *runtime.PodSandbox
|
||||
assert.EqualValues(t, *spec.Linux.Resources.CPU.Shares, 300)
|
||||
assert.EqualValues(t, spec.Linux.Resources.CPU.Cpus, "0-1")
|
||||
assert.EqualValues(t, spec.Linux.Resources.CPU.Mems, "2-3")
|
||||
assert.EqualValues(t, spec.Linux.Resources.Unified, map[string]string{"memory.min": "65536", "memory.swap.max": "1024"})
|
||||
assert.EqualValues(t, *spec.Linux.Resources.Memory.Limit, 400)
|
||||
assert.EqualValues(t, *spec.Process.OOMScoreAdj, 500)
|
||||
|
||||
|
@ -48,6 +48,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Cpus: "0-1",
|
||||
Mems: "2-3",
|
||||
},
|
||||
Unified: map[string]string{"memory.min": "65536", "memory.swap.max": "1024"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -59,6 +60,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
OomScoreAdj: 500,
|
||||
CpusetCpus: "4-5",
|
||||
CpusetMems: "6-7",
|
||||
Unified: map[string]string{"memory.min": "1507328", "memory.swap.max": "0"},
|
||||
},
|
||||
expected: &runtimespec.Spec{
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
@ -72,6 +74,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Cpus: "4-5",
|
||||
Mems: "6-7",
|
||||
},
|
||||
Unified: map[string]string{"memory.min": "1507328", "memory.swap.max": "0"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -89,6 +92,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Cpus: "0-1",
|
||||
Mems: "2-3",
|
||||
},
|
||||
Unified: map[string]string{"memory.min": "65536", "memory.swap.max": "1024"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -111,6 +115,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Cpus: "0-1",
|
||||
Mems: "6-7",
|
||||
},
|
||||
Unified: map[string]string{"memory.min": "65536", "memory.swap.max": "1024"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -132,6 +137,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
OomScoreAdj: 500,
|
||||
CpusetCpus: "4-5",
|
||||
CpusetMems: "6-7",
|
||||
Unified: map[string]string{"memory.min": "65536", "memory.swap.max": "1024"},
|
||||
},
|
||||
expected: &runtimespec.Spec{
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
@ -145,6 +151,51 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Cpus: "4-5",
|
||||
Mems: "6-7",
|
||||
},
|
||||
Unified: map[string]string{"memory.min": "65536", "memory.swap.max": "1024"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"should be able to patch the unified map": {
|
||||
spec: &runtimespec.Spec{
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(12345)},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(1111),
|
||||
Quota: proto.Int64(2222),
|
||||
Period: proto.Uint64(3333),
|
||||
Cpus: "0-1",
|
||||
Mems: "2-3",
|
||||
},
|
||||
Unified: map[string]string{"memory.min": "65536", "memory.max": "1507328"},
|
||||
},
|
||||
},
|
||||
},
|
||||
resources: &runtime.LinuxContainerResources{
|
||||
CpuPeriod: 6666,
|
||||
CpuQuota: 5555,
|
||||
CpuShares: 4444,
|
||||
MemoryLimitInBytes: 54321,
|
||||
OomScoreAdj: 500,
|
||||
CpusetCpus: "4-5",
|
||||
CpusetMems: "6-7",
|
||||
Unified: map[string]string{"memory.min": "1507328", "memory.swap.max": "1024"},
|
||||
},
|
||||
expected: &runtimespec.Spec{
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
Period: proto.Uint64(6666),
|
||||
Cpus: "4-5",
|
||||
Mems: "6-7",
|
||||
},
|
||||
Unified: map[string]string{"memory.min": "1507328", "memory.max": "1507328", "memory.swap.max": "1024"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user