[Kimchi-devel] [PATCH] [Kimchi 2/2] Fix storage volume test to run without nginx

Lucio Correia luciojhc at linux.vnet.ibm.com
Fri Feb 24 20:56:52 UTC 2017


Now that test requests are made directly to cherrypy,
which aborts connection in case of an HTTP 413 error,
the test case needs to be changed to expect for that
exception instead.

Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
---
 tests/test_model_storagevolume.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tests/test_model_storagevolume.py b/tests/test_model_storagevolume.py
index 638751a..36be961 100644
--- a/tests/test_model_storagevolume.py
+++ b/tests/test_model_storagevolume.py
@@ -26,6 +26,7 @@ import requests
 import tempfile
 import unittest
 from functools import partial
+from requests.exceptions import ConnectionError
 
 from tests.utils import fake_auth_header, HOST
 from tests.utils import patch_auth, PORT, request
@@ -174,7 +175,10 @@ def _do_volume_test(self, model, pool_name):
             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
+            # Max body size is set to 4M so the upload should fail with 413.
+            # Since nginx is not being used for testing anymore, and cherrypy
+            # aborts connection instead of returning a 413 like nginx does,
+            # test case expects for exception raised by cherrypy.
             newfile = '/tmp/5m-file'
             with open(newfile, 'wb') as fd:
                 fd.seek(5*1024*1024-1)
@@ -187,11 +191,12 @@ def _do_volume_test(self, model, pool_name):
                     tmp_fd.write(data)
 
                 with open(newfile + '.tmp', 'rb') as tmp_fd:
-                    r = requests.put(url, data={'chunk_size': len(data)},
+                    error_msg = "Connection aborted"
+                    with self.assertRaisesRegexp(ConnectionError, error_msg):
+                        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
-- 
2.7.4



More information about the Kimchi-devel mailing list