diff --git a/setup.cfg b/setup.cfg index cc37b198..35e8071d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,7 +22,8 @@ classifier = [files] packages = - storlets + storlet_middleware + storlet_gateway [build_sphinx] source-dir = doc/source diff --git a/storlet_gateway b/storlet_gateway new file mode 120000 index 00000000..99fc227e --- /dev/null +++ b/storlet_gateway @@ -0,0 +1 @@ +Engine/swift/storlet_gateway \ No newline at end of file diff --git a/storlet_middleware b/storlet_middleware new file mode 120000 index 00000000..f5fc3b2d --- /dev/null +++ b/storlet_middleware @@ -0,0 +1 @@ +Engine/swift/storlet_middleware \ No newline at end of file diff --git a/tests/unit/test_storlet_middleware.py b/tests/unit/test_storlet_middleware.py new file mode 100644 index 00000000..30cc4e16 --- /dev/null +++ b/tests/unit/test_storlet_middleware.py @@ -0,0 +1,74 @@ +# Copyright (c) 2010-2015 OpenStack Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from os.path import join +from storlet_middleware import storlet_handler +from swift.common.swob import Request +from swift.common.swob import Response +import unittest + + +DEFAULT_CONFIG = { + 'storlet_container': 'storlet', + 'storlet_dependency': 'dependency', + 'storlet_timeout': '40', + 'storlet_gateway_module': + 'storlet_gateway.storlet_stub_gateway:StorletStubBase', + 'storlet_gateway_conf': '/etc/swift/storlet_stub_gateway.conf', + 'execution_server': 'proxy'} + + +class FakeApp(object): + def __call__(self, env, start_response): + req = Request(env) + return Response(request=req, body='FAKE APP')( + env, start_response) + + +class TestStorletsMiddleware(unittest.TestCase): + def setUp(self): + self.got_statuses = [] + + def tearDown(self): + pass + + def get_app(self, app, global_conf, **local_conf): + factory = storlet_handler.filter_factory(global_conf, **local_conf) + return factory(app) + + def start_response(self, status, headers): + self.got_statuses.append(status) + + def test_load_app(self): + try: + self.get_app(FakeApp(), DEFAULT_CONFIG) + except Exception: + self.fail('Application loading got an error') + + def test_GET_without_storlets(self): + def basic_get(path): + req = Request.blank(path, environ={'REQUEST_METHOD': 'GET'}) + app = self.get_app(FakeApp(), DEFAULT_CONFIG) + resp = app(req.environ, self.start_response) + self.assertEqual('200 OK', self.got_statuses[-1]) + self.assertEqual(resp, ['FAKE APP']) + + for target in ('AUTH_a', 'AUTH_a/c', 'AUTH_a/c/o'): + path = join('/', 'v1', target) + basic_get(path) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/unit/unit_test.py b/tests/unit/unit_test.py deleted file mode 100644 index 707be3fe..00000000 --- a/tests/unit/unit_test.py +++ /dev/null @@ -1,27 +0,0 @@ -'''------------------------------------------------------------------------- -Copyright IBM Corp. 2015, 2015 All Rights Reserved -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -Limitations under the License. --------------------------------------------------------------------------''' - -''' -@author: cdoron -''' -import subprocess - - -def main(): - subprocess.call(["pwd"]) - -'''------------------------------------------------------------------------''' -if __name__ == "__main__": - main() diff --git a/tox.ini b/tox.ini index 1a23e30e..919cbc19 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,10 @@ usedevelop = True install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} -deps = -r{toxinidir}/test-requirements.txt +deps = + -r{toxinidir}/test-requirements.txt + PyECLib==1.0.7 + https://launchpad.net/swift/kilo/2.3.0/+download/swift-2.3.0.tar.gz #commands = python setup.py test --slowest --testr-args='{posargs}' commands = ./.unittests