glance/glance/tests/unit/common
Matthew Treinish bf7887a102
Replace body_file with class to call uwsgi.chunked_read()
Since the WebOb 1.7 release webob doesn't natively support receiving
chunked transfer encoding bodies. [1] When glance is run under the
eventlet wsgi server this was fine, because eventlet will dechunk the
input on read() (or readline()) calls, so from the webob perspective
it's just a file object. However, the effort to remove the dependence
on using eventlet as the web server and deploy glance as a traditional
wsgi script we lose this mechanism. The wsgi spec doesn't provide a
consistent mechanism

When we run glance under uwsgi the uwsgi server provides an api to read
chunked data. [2] However, we need to explicitly call that api when to
dechunk the data and pass it to glance code which expects a file object.
This commit solves this issue by creating a fake file class that will
call the chunked_read() api from uwsgi on read() calls. This object is
then used if we're running the api code under uwsgi and the body has a
chunked transfer-encoding.

In conjuction with devstack change
Iab2e2848877fa1497008d18c05b0154892941589 this closes glance bug 1703856

[1] https://docs.pylonsproject.org/projects/webob/en/stable/whatsnew-1.7.html#backwards-incompatibility
[2] http://uwsgi-docs.readthedocs.io/en/latest/Chunked.html

Partial-bug 1703856

Co-Authored-By: Chris Dent <cdent@anticdent.org>

Change-Id: Idf6b4b891ba31cccbeb53d373b40fce5380cea64
2017-10-18 17:25:22 -04:00
..
scripts Remove references of s3 store driver 2016-08-11 12:32:48 -04:00
__init__.py Improve unit tests for glance.common package 2013-05-20 17:31:22 +03:00
test_client.py Port rpc and wsgi to Python 3 2015-10-13 12:27:50 +02:00
test_config.py Fix Python 3 issues in glance.tests.unit.common 2015-08-16 11:39:41 +02:00
test_exception.py Enable python3.5 testing. 2016-12-21 05:55:37 +00:00
test_location_strategy.py Merge "Fix tests when CONF.set_override with enforce_type=True" 2017-04-28 12:45:17 +00:00
test_property_utils.py Tests: Remove the redundant methods 2017-06-20 15:55:01 +08:00
test_rpc.py Merge "Extracted HTTP response codes to constants in tests" 2016-10-21 08:54:28 +00:00
test_scripts.py Introduces eventlet executor for Glance Tasks 2014-09-02 11:45:58 -04:00
test_swift_store_utils.py Tests: Remove the redundant methods 2017-06-20 15:55:01 +08:00
test_timeutils.py Use more specific asserts in unit tests 2016-08-04 21:17:52 +02:00
test_utils.py Use more specific asserts in unit tests 2016-08-04 21:17:52 +02:00
test_wsgi.py Replace body_file with class to call uwsgi.chunked_read() 2017-10-18 17:25:22 -04:00