@@ -48,6 +48,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
4848 Cpus : "0-1" ,
4949 Mems : "2-3" ,
5050 },
51+ Unified : map [string ]string {"memory.min" : "65536" , "memory.swap.max" : "1024" },
5152 },
5253 },
5354 },
@@ -59,6 +60,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
5960 OomScoreAdj : 500 ,
6061 CpusetCpus : "4-5" ,
6162 CpusetMems : "6-7" ,
63+ Unified : map [string ]string {"memory.min" : "1507328" , "memory.swap.max" : "0" },
6264 },
6365 expected : & runtimespec.Spec {
6466 Process : & runtimespec.Process {OOMScoreAdj : oomscoreadj },
@@ -72,6 +74,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
7274 Cpus : "4-5" ,
7375 Mems : "6-7" ,
7476 },
77+ Unified : map [string ]string {"memory.min" : "1507328" , "memory.swap.max" : "0" },
7578 },
7679 },
7780 },
@@ -89,6 +92,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
8992 Cpus : "0-1" ,
9093 Mems : "2-3" ,
9194 },
95+ Unified : map [string ]string {"memory.min" : "65536" , "memory.swap.max" : "1024" },
9296 },
9397 },
9498 },
@@ -111,6 +115,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
111115 Cpus : "0-1" ,
112116 Mems : "6-7" ,
113117 },
118+ Unified : map [string ]string {"memory.min" : "65536" , "memory.swap.max" : "1024" },
114119 },
115120 },
116121 },
@@ -132,6 +137,7 @@ func TestUpdateOCILinuxResource(t *testing.T) {
132137 OomScoreAdj : 500 ,
133138 CpusetCpus : "4-5" ,
134139 CpusetMems : "6-7" ,
140+ Unified : map [string ]string {"memory.min" : "65536" , "memory.swap.max" : "1024" },
135141 },
136142 expected : & runtimespec.Spec {
137143 Process : & runtimespec.Process {OOMScoreAdj : oomscoreadj },
@@ -145,6 +151,51 @@ func TestUpdateOCILinuxResource(t *testing.T) {
145151 Cpus : "4-5" ,
146152 Mems : "6-7" ,
147153 },
154+ Unified : map [string ]string {"memory.min" : "65536" , "memory.swap.max" : "1024" },
155+ },
156+ },
157+ },
158+ },
159+ "should be able to patch the unified map" : {
160+ spec : & runtimespec.Spec {
161+ Process : & runtimespec.Process {OOMScoreAdj : oomscoreadj },
162+ Linux : & runtimespec.Linux {
163+ Resources : & runtimespec.LinuxResources {
164+ Memory : & runtimespec.LinuxMemory {Limit : proto .Int64 (12345 )},
165+ CPU : & runtimespec.LinuxCPU {
166+ Shares : proto .Uint64 (1111 ),
167+ Quota : proto .Int64 (2222 ),
168+ Period : proto .Uint64 (3333 ),
169+ Cpus : "0-1" ,
170+ Mems : "2-3" ,
171+ },
172+ Unified : map [string ]string {"memory.min" : "65536" , "memory.max" : "1507328" },
173+ },
174+ },
175+ },
176+ resources : & runtime.LinuxContainerResources {
177+ CpuPeriod : 6666 ,
178+ CpuQuota : 5555 ,
179+ CpuShares : 4444 ,
180+ MemoryLimitInBytes : 54321 ,
181+ OomScoreAdj : 500 ,
182+ CpusetCpus : "4-5" ,
183+ CpusetMems : "6-7" ,
184+ Unified : map [string ]string {"memory.min" : "1507328" , "memory.swap.max" : "1024" },
185+ },
186+ expected : & runtimespec.Spec {
187+ Process : & runtimespec.Process {OOMScoreAdj : oomscoreadj },
188+ Linux : & runtimespec.Linux {
189+ Resources : & runtimespec.LinuxResources {
190+ Memory : & runtimespec.LinuxMemory {Limit : proto .Int64 (54321 )},
191+ CPU : & runtimespec.LinuxCPU {
192+ Shares : proto .Uint64 (4444 ),
193+ Quota : proto .Int64 (5555 ),
194+ Period : proto .Uint64 (6666 ),
195+ Cpus : "4-5" ,
196+ Mems : "6-7" ,
197+ },
198+ Unified : map [string ]string {"memory.min" : "1507328" , "memory.max" : "1507328" , "memory.swap.max" : "1024" },
148199 },
149200 },
150201 },
0 commit comments