[Kimchi-devel] [PATCH] [Kimchi 2/2] Remove test for HTTP error 413

Lucio Correia posted 2 patches 7 years, 11 months ago
There is a newer version of this series
[Kimchi-devel] [PATCH] [Kimchi 2/2] Remove test for HTTP error 413
Posted by Lucio Correia 7 years, 11 months ago
Python requests httplib is not prepared to handle 413 errors
as required by Cherrypy like nginx is, thus it will not return
error 413 when HTTP request data is bigger than max_body_size.

Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com>
---
 tests/test_model_storagevolume.py | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/tests/test_model_storagevolume.py b/tests/test_model_storagevolume.py
index 638751a..b1d03dd 100644
--- a/tests/test_model_storagevolume.py
+++ b/tests/test_model_storagevolume.py
@@ -173,26 +173,6 @@ def _do_volume_test(self, model, pool_name):
             # Upload volume content
             url = 'http://%s:%s' % (HOST, PORT) + uri + '/' + filename
 
-            # Create a file with 5M to upload
-            # Max body size is set to 4M so the upload will fail with 413
-            newfile = '/tmp/5m-file'
-            with open(newfile, 'wb') as fd:
-                fd.seek(5*1024*1024-1)
-                fd.write("\0")
-            rollback.prependDefer(os.remove, newfile)
-
-            with open(newfile, 'rb') as fd:
-                with open(newfile + '.tmp', 'wb') as tmp_fd:
-                    data = fd.read()
-                    tmp_fd.write(data)
-
-                with open(newfile + '.tmp', 'rb') as tmp_fd:
-                    r = requests.put(url, data={'chunk_size': len(data)},
-                                     files={'chunk': tmp_fd},
-                                     verify=False,
-                                     headers=fake_auth_header())
-                    self.assertEquals(r.status_code, 413)
-
             # Do upload
             index = 0
             chunk_size = 2 * 1024
-- 
2.7.4

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
Re: [Kimchi-devel] [PATCH] [Kimchi 2/2] Remove test for HTTP error 413
Posted by Aline Manera 7 years, 10 months ago

On 02/09/2017 03:05 PM, Lucio Correia wrote:
> Python requests httplib is not prepared to handle 413 errors
> as required by Cherrypy like nginx is, thus it will not return
> error 413 when HTTP request data is bigger than max_body_size.

I understand the problem but the solution is not remove the test case IMO.
We should fix the test case according to httplib limitation and keep 
validating max body size is proper set.

> Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com>
> ---
>   tests/test_model_storagevolume.py | 20 --------------------
>   1 file changed, 20 deletions(-)
>
> diff --git a/tests/test_model_storagevolume.py b/tests/test_model_storagevolume.py
> index 638751a..b1d03dd 100644
> --- a/tests/test_model_storagevolume.py
> +++ b/tests/test_model_storagevolume.py
> @@ -173,26 +173,6 @@ def _do_volume_test(self, model, pool_name):
>               # Upload volume content
>               url = 'http://%s:%s' % (HOST, PORT) + uri + '/' + filename
>
> -            # Create a file with 5M to upload
> -            # Max body size is set to 4M so the upload will fail with 413
> -            newfile = '/tmp/5m-file'
> -            with open(newfile, 'wb') as fd:
> -                fd.seek(5*1024*1024-1)
> -                fd.write("\0")
> -            rollback.prependDefer(os.remove, newfile)
> -
> -            with open(newfile, 'rb') as fd:
> -                with open(newfile + '.tmp', 'wb') as tmp_fd:
> -                    data = fd.read()
> -                    tmp_fd.write(data)
> -
> -                with open(newfile + '.tmp', 'rb') as tmp_fd:
> -                    r = requests.put(url, data={'chunk_size': len(data)},
> -                                     files={'chunk': tmp_fd},
> -                                     verify=False,
> -                                     headers=fake_auth_header())
> -                    self.assertEquals(r.status_code, 413)
> -
>               # Do upload
>               index = 0
>               chunk_size = 2 * 1024

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel