diff --git a/debian/control b/debian/control index af997da..4fb1d3f 100644 --- a/debian/control +++ b/debian/control @@ -1,32 +1,32 @@ Source: swh-objstorage Maintainer: Software Heritage developers Section: python Priority: optional Build-Depends: debhelper (>= 9), dh-python (>= 2), python3-aiohttp (>= 2.1.0), python3-all, python3-flask, python3-nose, python3-setuptools, - python3-swh.core (>= 0.0.28~), + python3-swh.core (>= 0.0.37~), python3-swh.model (>= 0.0.14~), python3-click, python3-libcloud, python3-azure-storage, python3-vcversioner Standards-Version: 3.9.6 Homepage: https://forge.softwareheritage.org/diffusion/DOBJS/ Package: python3-swh.objstorage Architecture: all -Depends: python3-swh.core (>= 0.0.28~), ${misc:Depends}, ${python3:Depends}, python3-aiohttp (>= 2.1.0) +Depends: python3-swh.core (>= 0.0.37~), ${misc:Depends}, ${python3:Depends}, python3-aiohttp (>= 2.1.0) Description: Software Heritage Object Storage Package: python3-swh.objstorage.cloud Architecture: all Depends: python3-swh.objstorage (= ${binary:Version}), python3-libcloud, python3-azure-storage, ${misc:Depends}, ${python3:Depends} Breaks: python3-swh.objstorage (<= 0.0.7~) Description: Software Heritage Cloud Object Storage diff --git a/requirements-swh.txt b/requirements-swh.txt index 464723a..c193587 100644 --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,2 +1,2 @@ -swh.core >= 0.0.28 +swh.core >= 0.0.37 swh.model >= 0.0.14 diff --git a/swh/objstorage/tests/server_testing.py b/swh/objstorage/tests/server_testing.py deleted file mode 100644 index 02cc94e..0000000 --- a/swh/objstorage/tests/server_testing.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (C) 2015 The Software Heritage developers -# See the AUTHORS file at the top-level directory of this distribution -# License: GNU General Public License version 3, or any later version -# See top-level LICENSE file for more information - -import aiohttp.web -import multiprocessing -import socket -import time - -from urllib.request import urlopen - - -class ServerTestFixture(): - """ Base class for http client/server testing. - - Mix this in a test class in order to have access to an http flask - server running in background. - - Note that the subclass should define a dictionary in self.config - that contains the flask server config. - And a flask application in self.app that corresponds to the type of - server the tested client needs. - - To ensure test isolation, each test will run in a different server - and a different repertory. - - In order to correctly work, the subclass must call the parents class's - setUp() and tearDown() methods. - """ - - def setUp(self): - super().setUp() - self.start_server() - - def tearDown(self): - self.stop_server() - super().tearDown() - - def url(self): - return 'http://127.0.0.1:%d/' % self.port - - def start_server(self): - """ Spawn the API server using multiprocessing. - """ - self.process = None - - # WSGI app configuration - for key, value in self.config.items(): - self.app[key] = value - # Get an available port number - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.bind(('127.0.0.1', 0)) - self.port = sock.getsockname()[1] - sock.close() - - # Worker function for multiprocessing - def worker(app, port): - return aiohttp.web.run_app(app, port=port, print=lambda *_: None) - - self.process = multiprocessing.Process( - target=worker, args=(self.app, self.port) - ) - self.process.start() - - # Wait max 5 seconds for server to spawn - i = 0 - while i < 100: - try: - urlopen(self.url()) - except Exception: - i += 1 - time.sleep(0.1) - else: - return - - def stop_server(self): - """ Terminate the API server's process. - """ - if self.process: - self.process.terminate() diff --git a/swh/objstorage/tests/test_objstorage_api.py b/swh/objstorage/tests/test_objstorage_api.py index 7946075..c482a8e 100644 --- a/swh/objstorage/tests/test_objstorage_api.py +++ b/swh/objstorage/tests/test_objstorage_api.py @@ -1,35 +1,35 @@ -# Copyright (C) 2015 The Software Heritage developers +# Copyright (C) 2015-2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import tempfile import unittest +from swh.core.tests.server_testing import ServerTestFixtureAsync from swh.objstorage import get_objstorage from swh.objstorage.tests.objstorage_testing import ObjStorageTestFixture -from swh.objstorage.tests.server_testing import ServerTestFixture from swh.objstorage.api.server import make_app -class TestRemoteObjStorage(ServerTestFixture, ObjStorageTestFixture, +class TestRemoteObjStorage(ServerTestFixtureAsync, ObjStorageTestFixture, unittest.TestCase): """ Test the remote archive API. """ def setUp(self): self.config = { 'cls': 'pathslicing', 'args': { 'root': tempfile.mkdtemp(), 'slicing': '0:1/0:5', 'allow_delete': True, }, 'client_max_size': 8 * 1024 * 1024, } self.app = make_app(self.config) super().setUp() self.storage = get_objstorage('remote', { 'url': self.url() })