Merge "enforce running multi-input on the proxy"

This commit is contained in:
Jenkins
2017-01-28 08:30:36 +00:00
committed by Gerrit Code Review
3 changed files with 28 additions and 5 deletions

View File

@@ -307,7 +307,8 @@ class StorletBaseHandler(object):
r = self.request.headers['X-Storlet-Range']
return len(Range(r).ranges) > 1
def _has_run_on_proxy_header(self):
@property
def has_run_on_proxy_header(self):
"""
Check whether there is a header mandating storlet execution on proxy
@@ -320,9 +321,23 @@ class StorletBaseHandler(object):
return True
return False
@property
def has_extra_resources_header(self):
"""
Check whether the client specifies multi input storlet execution.
If the request contains 'X-Storlet-Extra-Resources' header,
Storlets gathers multiple object data into the place, which
currently should happen in proxy-server.
:return: Whether the request contains X-Storlet-Extra-Resources header
"""
return 'X-Storlet-Extra-Resources' in self.request.headers
@property
def execute_on_proxy(self):
return (self._has_run_on_proxy_header() or
return (self.has_run_on_proxy_header or
self.has_extra_resources_header or
self.storlet_execute_on_proxy)
@property

View File

@@ -19,9 +19,10 @@ import unittest
from hashlib import md5
class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
class TestMultiInputStorlet(StorletJavaFunctionalTest):
def setUp(self):
super(TestMultiInputStorletOnProxy, self).setUp(
self.additional_headers = {}
super(TestMultiInputStorlet, self).setUp(
storlet_dir='MultiInputStorlet',
storlet_name='multiinputstorlet-1.0.jar',
storlet_main='org.openstack.storlet.multiinput.MultiInputStorlet',
@@ -45,6 +46,7 @@ class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
'/%s/%s' % (self.container, obj2),
'X-Storlet-Run-On-Proxy': ''
}
headers.update(self.additional_headers)
resp_headers, resp_content = c.get_object(
self.url, self.token, self.container, obj,
@@ -72,6 +74,7 @@ class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
'X-Storlet-Extra-Resources':
'/%s/%s' % (self.container, obj2),
}
headers.update(self.additional_headers)
expected_string = '0123456789abcdefghijklmnopqr'
etag = c.put_object(
@@ -90,5 +93,11 @@ class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
self.assertEqual('value2', resp_headers['x-object-meta-key2'])
class TestMultiInputStorletOnProxy(TestMultiInputStorlet):
def setUp(self):
super(TestMultiInputStorletOnProxy, self).setUp()
self.additional_headers = {'X-Storlet-Run-On-Proxy': ''}
if __name__ == '__main__':
unittest.main()

View File

@@ -182,7 +182,6 @@ class TestStorletMiddlewareProxy(BaseTestStorletMiddleware):
with storlet_enabled():
headers = {'X-Run-Storlet': 'Storlet-1.0.jar',
'X-Storlet-Run-On-Proxy': '',
'X-Storlet-Extra-Resources': '/c2/o2'}
resp = self.get_request_response(target, 'GET', headers=headers)
self.assertEqual('200 OK', resp.status)