From ce0a9456eb1d5a67754d8bbb70a1b339e98da92d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 16 Dec 2015 16:46:04 +0100 Subject: [PATCH] Use extras for dependency installation This allows to only install precisely what's required. Change-Id: I2e9f19b03aca8452ae8fa83f50f7dbfc8e69b56f --- aodh/tests/functional/db.py | 2 +- .../functional/storage/test_impl_mongodb.py | 9 ++++- devstack/plugin.sh | 2 +- doc/source/testing.rst | 2 +- requirements.txt | 2 - setup.cfg | 38 +++++++++++++++++++ test-requirements.txt | 27 ------------- tox.ini | 16 +++++++- 8 files changed, 63 insertions(+), 35 deletions(-) delete mode 100644 test-requirements.txt diff --git a/aodh/tests/functional/db.py b/aodh/tests/functional/db.py index f8745545..9f6118d3 100644 --- a/aodh/tests/functional/db.py +++ b/aodh/tests/functional/db.py @@ -25,7 +25,6 @@ from oslo_config import fixture as fixture_config from oslotest import mockpatch import six from six.moves.urllib import parse as urlparse -import sqlalchemy from testtools import testcase from aodh import service @@ -50,6 +49,7 @@ class SQLManager(fixtures.Fixture): def __init__(self, conf): self.conf = conf db_name = 'aodh_%s' % uuid.uuid4().hex + import sqlalchemy self._engine = sqlalchemy.create_engine( conf.database.connection.replace(self.url_dbname_placeholder, self.url_dbname_createstring)) diff --git a/aodh/tests/functional/storage/test_impl_mongodb.py b/aodh/tests/functional/storage/test_impl_mongodb.py index c26680d0..75f923c2 100644 --- a/aodh/tests/functional/storage/test_impl_mongodb.py +++ b/aodh/tests/functional/storage/test_impl_mongodb.py @@ -20,12 +20,17 @@ server before running the tests. """ +import unittest -from aodh.storage import impl_mongodb +try: + from aodh.storage import impl_mongodb +except ImportError: + impl_mongodb = None from aodh.tests import base as test_base from aodh.tests.functional import db as tests_db +@unittest.skipUnless(impl_mongodb, "pymongo not available") @tests_db.run_with('mongodb') class MongoDBConnection(tests_db.TestBase): def test_connection_pooling(self): @@ -39,6 +44,7 @@ class MongoDBConnection(tests_db.TestBase): self.assertTrue(conn.conn) +@unittest.skipUnless(impl_mongodb, "pymongo not available") @tests_db.run_with('mongodb') class IndexTest(tests_db.TestBase): def _test_ttl_index_absent(self, conn, coll_name, ttl_opt): @@ -78,6 +84,7 @@ class IndexTest(tests_db.TestBase): class CapabilitiesTest(test_base.BaseTestCase): + @unittest.skipUnless(impl_mongodb, "pymongo not available") def test_alarm_capabilities(self): expected_capabilities = { 'alarms': {'query': {'simple': True, diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 7b7f7f5c..bc4beef9 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -241,7 +241,7 @@ function install_aodh { _aodh_prepare_coordination _aodh_prepare_storage_backend install_aodhclient - setup_develop $AODH_DIR + sudo -H pip install -e "$AODH_DIR"[test,$AODH_BACKEND] sudo install -d -o $STACK_USER -m 755 $AODH_CONF_DIR $AODH_API_LOG_DIR } diff --git a/doc/source/testing.rst b/doc/source/testing.rst index de7ccf0b..e3096f84 100644 --- a/doc/source/testing.rst +++ b/doc/source/testing.rst @@ -37,7 +37,7 @@ run through tox_. 3. Install the test dependencies:: - $ sudo pip install -r /opt/stack/aodh/test-requirements.txt + $ sudo pip install -e /opt/stack/aodh[test] 4. Run the unit and code-style tests:: diff --git a/requirements.txt b/requirements.txt index e141c36a..77cab6e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -alembic>=0.7.2 retrying!=1.3.0,>=1.2.3 # Apache-2.0 croniter>=0.3.4 # MIT License jsonschema!=2.5.0,<3.0.0,>=2.0.0 @@ -27,7 +26,6 @@ python-keystoneclient>=1.6.0 pytz>=2013.6 requests>=2.5.2 six>=1.9.0 -SQLAlchemy<1.1.0,>=0.9.7 stevedore>=1.5.0 # Apache-2.0 tooz>=0.16.0 # Apache-2.0 Werkzeug>=0.7 # BSD License diff --git a/setup.cfg b/setup.cfg index d768f763..aeccad37 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,6 +25,44 @@ setup-hooks = packages = aodh +[extras] +mysql = + SQLAlchemy<1.1.0,>=0.9.7 + alembic>=0.7.2 + PyMySQL>=0.6.2 # MIT License + +postgresql = + SQLAlchemy<1.1.0,>=0.9.7 + alembic>=0.7.2 + psycopg2 + +mongodb = + pymongo>=3.0.2 + +hbase = + happybase!=0.7,>=0.5:python_version=='2.7' + # Required for bson + pymongo>=3.0.2 + +doc = + oslosphinx>=2.5.0 # Apache-2.0 + reno>=0.1.1 # Apache2 + sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 + sphinxcontrib-httpdomain + sphinxcontrib-pecanwsme>=0.8 + +test = + oslotest>=1.5.1 # Apache-2.0 + coverage>=3.6 + fixtures>=1.3.1 + mock>=1.0 + testrepository>=0.0.18 + testtools>=1.4.0 + gabbi>=0.12.0 # Apache-2.0 + # Provides subunit-trace + tempest-lib>=0.6.1 + python-subunit>=0.0.18 + [entry_points] aodh.storage = log = aodh.storage.impl_log:Connection diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 6b4f7f9d..00000000 --- a/test-requirements.txt +++ /dev/null @@ -1,27 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. - -# Hacking already pins down pep8, pyflakes and flake8 -hacking<0.11,>=0.10.0 -Babel>=1.3 -coverage>=3.6 -fixtures>=1.3.1 -happybase!=0.7,>=0.5;python_version=='2.7' -mock>=1.0 -PyMySQL>=0.6.2 # MIT License -# Docs Requirements -oslosphinx>=2.5.0 # Apache-2.0 -reno>=0.1.1 # Apache2 -oslotest>=1.5.1 # Apache-2.0 -psycopg2 -pymongo>=3.0.2 -python-subunit>=0.0.18 -sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 -sphinxcontrib-httpdomain -sphinxcontrib-pecanwsme>=0.8 -testrepository>=0.0.18 -testtools>=1.4.0 -gabbi>=0.12.0 # Apache-2.0 -# Provides subunit-trace -tempest-lib>=0.6.1 diff --git a/tox.ini b/tox.ini index a262b076..8d550143 100644 --- a/tox.ini +++ b/tox.ini @@ -4,8 +4,7 @@ skipsdist = True envlist = py34,py27,pep8 [testenv] -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +deps = .[test] install_command = pip install -U {opts} {packages} usedevelop = True setenv = VIRTUAL_ENV={envdir} @@ -21,25 +20,30 @@ whitelist_externals = bash # in "py-" jobs [testenv:py27-hbase] +deps = .[hbase,test] setenv = OS_TEST_PATH=aodh/tests/functional/ AODH_TEST_STORAGE_URL=hbase://__test__ [testenv:py27-mongodb] +deps = .[mongodb,test] setenv = OS_TEST_PATH=aodh/tests/functional/ commands = bash -x {toxinidir}/setup-test-env-mongodb.sh python setup.py testr --slowest --testr-args="{posargs}" [testenv:py27-mysql] +deps = .[mysql,test] setenv = OS_TEST_PATH=aodh/tests/functional/ commands = bash -x {toxinidir}/setup-test-env-mysql.sh python setup.py testr --slowest --testr-args="{posargs}" [testenv:py27-pgsql] +deps = .[postgresql,test] setenv = OS_TEST_PATH=aodh/tests/functional/ commands = bash -x {toxinidir}/setup-test-env-postgresql.sh python setup.py testr --slowest --testr-args="{posargs}" [testenv:functional] +deps = .[mysql,postgresql,mongodb,test] setenv = VIRTUAL_ENV={envdir} OS_TEST_PATH=aodh/tests/functional/ GABBI_LIVE_FAIL_IF_NO_TEST=1 @@ -52,6 +56,7 @@ commands = # gabbi tests without needing to discovery across the entire body of # tests. [testenv:gabbi] +deps = .[mongodb,test] setenv = OS_TEST_PATH=aodh/tests/functional/gabbi commands = bash -x {toxinidir}/setup-test-env-mongodb.sh \ @@ -61,22 +66,26 @@ commands = commands = bash -x {toxinidir}/setup-test-env-mongodb.sh python setup.py testr --slowest --coverage --testr-args="{posargs}" [testenv:pep8] +deps = hacking<0.11,>=0.10.0 commands = flake8 # Check that .po and .pot files are valid: bash -c "find aodh -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null" [testenv:releasenotes] +deps = .[doc] commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html [testenv:genconfig] commands = oslo-config-generator --config-file=etc/aodh/aodh-config-generator.conf [testenv:docs] +deps = .[doc] commands = python setup.py build_sphinx setenv = PYTHONHASHSEED=0 [testenv:venv] +deps = .[doc] commands = {posargs} setenv = PYTHONHASHSEED=0 @@ -84,14 +93,17 @@ setenv = PYTHONHASHSEED=0 commands = bash -x oslo_debug_helper {posargs} [testenv:debug-mongodb] +deps = .[mongodb,test] setenv = OS_TEST_PATH=aodh/tests/functional/ commands = bash -x {toxinidir}/setup-test-env-mongodb.sh oslo_debug_helper {posargs} [testenv:debug-mysql] +deps = .[mysql,test] setenv = OS_TEST_PATH=aodh/tests/functional/ commands = bash -x {toxinidir}/setup-test-env-mysql.sh oslo_debug_helper {posargs} [testenv:debug-pgsql] +deps = .[postgresql,test] setenv = OS_TEST_PATH=aodh/tests/functional/ commands = bash -x {toxinidir}/setup-test-env-postgresql.sh oslo_debug_helper {posargs}