summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TESTING.rst88
-rw-r--r--openstack/common/db/sqlalchemy/session.py17
-rw-r--r--openstack/common/network_utils.py5
-rw-r--r--openstack/common/strutils.py18
-rw-r--r--requirements.txt2
-rw-r--r--tests/unit/db/sqlalchemy/test_sqlalchemy.py24
6 files changed, 140 insertions, 14 deletions
diff --git a/TESTING.rst b/TESTING.rst
new file mode 100644
index 0000000..4191b1b
--- /dev/null
+++ b/TESTING.rst
@@ -0,0 +1,88 @@
+===========================
+Testing Your OpenStack Code
+===========================
+------------
+A Quickstart
+------------
+
+This is designed to be enough information for you to run your first tests.
+Detailed information on testing can be found here: https://wiki.openstack.org/wiki/Testing
+
+*Install pip*::
+
+ [apt-get | yum] install python-pip
+More information on pip here: http://www.pip-installer.org/en/latest/
+
+*Use pip to install tox*::
+
+ pip install tox
+
+Run The Tests
+-------------
+
+*Navigate to the project's root directory and execute*::
+
+ tox
+Note: completing this command may take a long time (depends on system resources)
+also, you might not see any output until tox is complete.
+
+Information about tox can be found here: http://testrun.org/tox/latest/
+
+
+Run The Tests in One Environment
+--------------------------------
+
+Tox will run your entire test suite in the environments specified in the project tox.ini::
+
+ [tox]
+
+ envlist = <list of available environments>
+
+To run the test suite in just one of the environments in envlist execute::
+
+ tox -e <env>
+so for example, *run the test suite in py26*::
+
+ tox -e py26
+
+Run One Test
+------------
+
+To run individual tests with tox:
+
+if testr is in tox.ini, for example::
+
+ [testenv]
+
+ includes "python setup.py testr --slowest --testr-args='{posargs}'"
+
+run individual tests with the following syntax::
+
+ tox -e <env> -- path.to.module:Class.test
+so for example, *run the cpu_limited test in Nova*::
+
+ tox -e py27 -- nova.tests.test_claims:ClaimTestCase.test_cpu_unlimited
+
+if nose is in tox.ini, for example::
+
+ [testenv]
+
+ includes "nosetests {posargs}"
+
+run individual tests with the following syntax::
+
+ tox -e <env> -- --tests path.to.module:Class.test
+so for example, *run the list test in Glance*::
+
+ tox -e py27 -- --tests glance.tests.unit.test_auth.py:TestImageRepoProxy.test_list
+
+Need More Info?
+---------------
+
+More information about testr: https://wiki.openstack.org/wiki/Testr
+
+More information about nose: https://nose.readthedocs.org/en/latest/
+
+
+More information about testing OpenStack code can be found here:
+https://wiki.openstack.org/wiki/Testing
diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py
index b5e10f1..0951ee6 100644
--- a/openstack/common/db/sqlalchemy/session.py
+++ b/openstack/common/db/sqlalchemy/session.py
@@ -280,6 +280,8 @@ database_opts = [
'database',
deprecated_name='sql_connection',
deprecated_group=DEFAULT,
+ deprecated_opts=[cfg.DeprecatedOpt('sql_connection',
+ group='DATABASE')],
secret=True),
cfg.StrOpt('slave_connection',
default='',
@@ -290,34 +292,46 @@ database_opts = [
default=3600,
deprecated_name='sql_idle_timeout',
deprecated_group=DEFAULT,
+ deprecated_opts=[cfg.DeprecatedOpt('sql_idle_timeout',
+ group='DATABASE')],
help='timeout before idle sql connections are reaped'),
cfg.IntOpt('min_pool_size',
default=1,
deprecated_name='sql_min_pool_size',
deprecated_group=DEFAULT,
+ deprecated_opts=[cfg.DeprecatedOpt('sql_min_pool_size',
+ group='DATABASE')],
help='Minimum number of SQL connections to keep open in a '
'pool'),
cfg.IntOpt('max_pool_size',
default=None,
deprecated_name='sql_max_pool_size',
deprecated_group=DEFAULT,
+ deprecated_opts=[cfg.DeprecatedOpt('sql_max_pool_size',
+ group='DATABASE')],
help='Maximum number of SQL connections to keep open in a '
'pool'),
cfg.IntOpt('max_retries',
default=10,
deprecated_name='sql_max_retries',
deprecated_group=DEFAULT,
+ deprecated_opts=[cfg.DeprecatedOpt('sql_max_retries',
+ group='DATABASE')],
help='maximum db connection retries during startup. '
'(setting -1 implies an infinite retry count)'),
cfg.IntOpt('retry_interval',
default=10,
deprecated_name='sql_retry_interval',
deprecated_group=DEFAULT,
+ deprecated_opts=[cfg.DeprecatedOpt('reconnect_interval',
+ group='DATABASE')],
help='interval between retries of opening a sql connection'),
cfg.IntOpt('max_overflow',
default=None,
deprecated_name='sql_max_overflow',
deprecated_group=DEFAULT,
+ deprecated_opts=[cfg.DeprecatedOpt('sqlalchemy_max_overflow',
+ group='DATABASE')],
help='If set, use this value for max_overflow with sqlalchemy'),
cfg.IntOpt('connection_debug',
default=0,
@@ -332,12 +346,15 @@ database_opts = [
help='Add python stack traces to SQL as comment strings'),
cfg.IntOpt('pool_timeout',
default=None,
+ deprecated_name='sqlalchemy_pool_timeout',
+ deprecated_group='DATABASE',
help='If set, use this value for pool_timeout with sqlalchemy'),
]
CONF = cfg.CONF
CONF.register_opts(sqlite_db_opts)
CONF.register_opts(database_opts, 'database')
+
LOG = logging.getLogger(__name__)
_ENGINE = None
diff --git a/openstack/common/network_utils.py b/openstack/common/network_utils.py
index 0527ab9..0fbf171 100644
--- a/openstack/common/network_utils.py
+++ b/openstack/common/network_utils.py
@@ -19,11 +19,6 @@
Network-related utilities and helper functions.
"""
-from openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
def parse_host_port(address, default_port=None):
"""Interpret a string as a host:port pair.
diff --git a/openstack/common/strutils.py b/openstack/common/strutils.py
index a3fb53a..0ba9b44 100644
--- a/openstack/common/strutils.py
+++ b/openstack/common/strutils.py
@@ -23,6 +23,8 @@ import re
import sys
import unicodedata
+import six
+
from openstack.common.gettextutils import _
@@ -71,7 +73,7 @@ def bool_from_string(subject, strict=False):
ValueError which is useful when parsing values passed in from an API call.
Strings yielding False are 'f', 'false', 'off', 'n', 'no', or '0'.
"""
- if not isinstance(subject, basestring):
+ if not isinstance(subject, six.string_types):
subject = str(subject)
lowered = subject.strip().lower()
@@ -99,12 +101,12 @@ def safe_decode(text, incoming=None, errors='strict'):
values http://docs.python.org/2/library/codecs.html
:returns: text or a unicode `incoming` encoded
representation of it.
- :raises TypeError: If text is not an isntance of basestring
+ :raises TypeError: If text is not an isntance of str
"""
- if not isinstance(text, basestring):
+ if not isinstance(text, six.string_types):
raise TypeError("%s can't be decoded" % type(text))
- if isinstance(text, unicode):
+ if isinstance(text, six.text_type):
return text
if not incoming:
@@ -142,16 +144,16 @@ def safe_encode(text, incoming=None,
values http://docs.python.org/2/library/codecs.html
:returns: text or a bytestring `encoding` encoded
representation of it.
- :raises TypeError: If text is not an isntance of basestring
+ :raises TypeError: If text is not an isntance of str
"""
- if not isinstance(text, basestring):
+ if not isinstance(text, six.string_types):
raise TypeError("%s can't be encoded" % type(text))
if not incoming:
incoming = (sys.stdin.encoding or
sys.getdefaultencoding())
- if isinstance(text, unicode):
+ if isinstance(text, six.text_type):
return text.encode(encoding, errors)
elif text and encoding != incoming:
# Decode text before encoding it with `encoding`
@@ -204,7 +206,7 @@ def to_slug(value, incoming=None, errors="strict"):
:param errors: Errors handling policy. See here for valid
values http://docs.python.org/2/library/codecs.html
:returns: slugified unicode representation of `value`
- :raises TypeError: If text is not an instance of basestring
+ :raises TypeError: If text is not an instance of str
"""
value = safe_decode(value, incoming, errors)
# NOTE(aababilov): no need to use safe_(encode|decode) here:
diff --git a/requirements.txt b/requirements.txt
index 835c252..ec6dbdd 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -12,6 +12,6 @@ kombu>2.4.7
argparse
stevedore
SQLAlchemy>=0.7.8,<=0.7.9
-oslo.config>=1.1.0
+http://tarballs.openstack.org/oslo.config/oslo.config-1.2.0a2.tar.gz#egg=oslo.config-1.2.0a2
qpid-python
six
diff --git a/tests/unit/db/sqlalchemy/test_sqlalchemy.py b/tests/unit/db/sqlalchemy/test_sqlalchemy.py
index ac178b8..46a0cb2 100644
--- a/tests/unit/db/sqlalchemy/test_sqlalchemy.py
+++ b/tests/unit/db/sqlalchemy/test_sqlalchemy.py
@@ -85,6 +85,30 @@ pool_timeout=7
self.assertEquals(test_utils.CONF.database.connection_trace, True)
self.assertEquals(test_utils.CONF.database.pool_timeout, 7)
+ def test_dbapi_database_deprecated_parameters(self):
+ paths = self.create_tempfiles([('test',
+ '[DATABASE]\n'
+ 'sql_connection=fake_connection\n'
+ 'sql_idle_timeout=100\n'
+ 'sql_min_pool_size=99\n'
+ 'sql_max_pool_size=199\n'
+ 'sql_max_retries=22\n'
+ 'reconnect_interval=17\n'
+ 'sqlalchemy_max_overflow=101\n'
+ 'sqlalchemy_pool_timeout=5\n'
+ )])
+
+ test_utils.CONF(['--config-file', paths[0]])
+ self.assertEquals(test_utils.CONF.database.connection,
+ 'fake_connection')
+ self.assertEquals(test_utils.CONF.database.idle_timeout, 100)
+ self.assertEquals(test_utils.CONF.database.min_pool_size, 99)
+ self.assertEquals(test_utils.CONF.database.max_pool_size, 199)
+ self.assertEquals(test_utils.CONF.database.max_retries, 22)
+ self.assertEquals(test_utils.CONF.database.retry_interval, 17)
+ self.assertEquals(test_utils.CONF.database.max_overflow, 101)
+ self.assertEquals(test_utils.CONF.database.pool_timeout, 5)
+
class SessionErrorWrapperTestCase(test_base.DbTestCase):
def setUp(self):