@@ -171,6 +171,13 @@ def test_request_limit_memory(self, mock_requests):
171171 body = {'memory' : json .dumps (mem )}
172172 response = self .client .post (url , body )
173173 self .assertEqual (response .status_code , 400 , response .data )
174+ # out of range
175+ body = {'memory' : json .dumps ({'web' : '64M' })}
176+ response = self .client .post (url , body )
177+ self .assertEqual (response .status_code , 400 , response .data )
178+ body = {'memory' : json .dumps ({'web' : '1024G' })}
179+ response = self .client .post (url , body )
180+ self .assertEqual (response .status_code , 400 , response .data )
174181
175182 mem = {'w3&b' : '1G' }
176183 body = {'memory' : json .dumps (mem )}
@@ -202,7 +209,7 @@ def test_request_limit_cpu(self, mock_requests):
202209 self .assertNotIn ('"' , response .data ['cpu' ])
203210
204211 # set an initial limit
205- body = {'cpu' : json .dumps ({'web' : '1024 ' })}
212+ body = {'cpu' : json .dumps ({'web' : '1000m ' })}
206213 response = self .client .post (url , body )
207214 self .assertEqual (response .status_code , 201 , response .data )
208215 limit1 = response .data
@@ -213,19 +220,19 @@ def test_request_limit_cpu(self, mock_requests):
213220 self .assertIn ('cpu' , response .data )
214221 cpu = response .data ['cpu' ]
215222 self .assertIn ('web' , cpu )
216- self .assertEqual (cpu ['web' ], '1024 ' )
223+ self .assertEqual (cpu ['web' ], '1000m ' )
217224
218225 # set an additional value
219- body = {'cpu' : json .dumps ({'worker' : '512m ' })}
226+ body = {'cpu' : json .dumps ({'worker' : '2000m ' })}
220227 response = self .client .post (url , body )
221228 self .assertEqual (response .status_code , 201 , response .data )
222229 limit2 = response .data
223230 self .assertNotEqual (limit1 ['uuid' ], limit2 ['uuid' ])
224231 cpu = response .data ['cpu' ]
225232 self .assertIn ('worker' , cpu )
226- self .assertEqual (cpu ['worker' ], '512m ' )
233+ self .assertEqual (cpu ['worker' ], '2000m ' )
227234 self .assertIn ('web' , cpu )
228- self .assertEqual (cpu ['web' ], '1024 ' )
235+ self .assertEqual (cpu ['web' ], '1000m ' )
229236
230237 # read the limit again
231238 response = self .client .get (url )
@@ -234,9 +241,9 @@ def test_request_limit_cpu(self, mock_requests):
234241 self .assertEqual (limit2 , limit3 )
235242 cpu = response .data ['cpu' ]
236243 self .assertIn ('worker' , cpu )
237- self .assertEqual (cpu ['worker' ], '512m ' )
244+ self .assertEqual (cpu ['worker' ], '2000m ' )
238245 self .assertIn ('web' , cpu )
239- self .assertEqual (cpu ['web' ], '1024 ' )
246+ self .assertEqual (cpu ['web' ], '1000m ' )
240247
241248 # add with requests/limits
242249 body = {'cpu' : json .dumps ({'db' : '1' })}
@@ -248,14 +255,14 @@ def test_request_limit_cpu(self, mock_requests):
248255 self .assertEqual (response .status_code , 200 , response .data )
249256 cpu = response .data ['cpu' ]
250257 self .assertIn ('worker' , cpu )
251- self .assertEqual (cpu ['worker' ], '512m ' )
258+ self .assertEqual (cpu ['worker' ], '2000m ' )
252259 self .assertIn ('web' , cpu )
253- self .assertEqual (cpu ['web' ], '1024 ' )
260+ self .assertEqual (cpu ['web' ], '1000m ' )
254261 self .assertIn ('db' , cpu )
255262 self .assertEqual (cpu ['db' ], '1' )
256263
257264 # replace one with requests/limits
258- body = {'cpu' : json .dumps ({'web' : '300m ' })}
265+ body = {'cpu' : json .dumps ({'web' : '3000m ' })}
259266 response = self .client .post (url , body )
260267 self .assertEqual (response .status_code , 201 , response .data )
261268
@@ -264,9 +271,9 @@ def test_request_limit_cpu(self, mock_requests):
264271 self .assertEqual (response .status_code , 200 , response .data )
265272 cpu = response .data ['cpu' ]
266273 self .assertIn ('worker' , cpu )
267- self .assertEqual (cpu ['worker' ], '512m ' )
274+ self .assertEqual (cpu ['worker' ], '2000m ' )
268275 self .assertIn ('web' , cpu )
269- self .assertEqual (cpu ['web' ], '300m ' )
276+ self .assertEqual (cpu ['web' ], '3000m ' )
270277 self .assertIn ('db' , cpu )
271278 self .assertEqual (cpu ['db' ], '1' )
272279
@@ -283,6 +290,13 @@ def test_request_limit_cpu(self, mock_requests):
283290 body = {'cpu' : json .dumps (mem )}
284291 response = self .client .post (url , body )
285292 self .assertEqual (response .status_code , 400 , response .data )
293+ # out of range
294+ body = {'cpu' : json .dumps ({'web' : '1000' })}
295+ response = self .client .post (url , body )
296+ self .assertEqual (response .status_code , 400 , response .data )
297+ body = {'cpu' : json .dumps ({'web' : '100m' })}
298+ response = self .client .post (url , body )
299+ self .assertEqual (response .status_code , 400 , response .data )
286300
287301 mem = {'w3&b' : '1G' }
288302 body = {'cpu' : json .dumps (mem )}
0 commit comments