Make LIVE Tests configurable with ENV

To enable ldap live test, set the environmental variable
``ENABLE_LDAP_LIVE_TESTS`` to a non-false value.

To enable tls ldap live test, set the environmental variable
``ENABLE_TLS_LDAP_LIVE_TESTS`` to a non-false value.

To enable mysql sql live test, set the environmental variable
``ENABLE_LIVE_MYSQL_TESTS`` to a non-false value.

To enable postgres sql live test, set the environmental variable
``ENABLE_LIVE_POSTGRES_TESTS`` to a non-false value.

To enable db2 sql live test, set the environmental variable
``ENABLE_LIVE_DB2_TESTS`` to a non-false value.

This allows for running all tests in a standard run by simply setting
the appropriate environmental variables.

This moves the live tests to be skips if the specific live-test
environmental variables are not set.

Change-Id: I8c09a8dcfca3f9691306c5f416f688205171bda3
Closes-Bug: 1243392
This commit is contained in:
Morgan Fainberg 2014-03-13 15:01:38 -07:00
parent be9d13fb67
commit c726163357
5 changed files with 41 additions and 3 deletions

View File

@ -304,10 +304,14 @@ and set environment variables ``KEYSTONE_IDENTITY_BACKEND=ldap`` and
``KEYSTONE_CLEAR_LDAP=yes`` in your ``localrc`` file. ``KEYSTONE_CLEAR_LDAP=yes`` in your ``localrc`` file.
The unit tests can be run against a live server with The unit tests can be run against a live server with
``keystone/tests/_ldap_livetest.py``. The default password is ``test`` but if you have ``keystone/tests/test_ldap_livetest.py``. The default password is ``test`` but if you have
installed devstack with a different LDAP password, modify the file installed devstack with a different LDAP password, modify the file
``keystone/tests/backend_liveldap.conf`` to reflect your password. ``keystone/tests/backend_liveldap.conf`` to reflect your password.
.. NOTE::
To run the live tests you need to set the environment variable ``ENABLE_LDAP_LIVE_TEST``
to a non-negative value.
Generating Updated Sample Config File Generating Updated Sample Config File
------------------------------------- -------------------------------------

View File

@ -685,6 +685,10 @@ class TestCase(BaseTestCase):
if not self.ipv6_enabled: if not self.ipv6_enabled:
raise self.skipTest("IPv6 is not enabled in the system") raise self.skipTest("IPv6 is not enabled in the system")
def skip_if_env_not_set(self, env_var):
if not os.environ.get(env_var):
self.skipTest('Env variable %s is not set.' % env_var)
def assertSetEqual(self, set1, set2, msg=None): def assertSetEqual(self, set1, set2, msg=None):
# TODO(morganfainberg): Remove this and self._assertSetEqual once # TODO(morganfainberg): Remove this and self._assertSetEqual once
# support for python 2.6 is no longer needed. # support for python 2.6 is no longer needed.

View File

@ -38,6 +38,13 @@ def create_object(dn, attrs):
class LiveLDAPIdentity(test_backend_ldap.LDAPIdentity): class LiveLDAPIdentity(test_backend_ldap.LDAPIdentity):
def setUp(self):
self._ldap_skip_live()
super(LiveLDAPIdentity, self).setUp()
def _ldap_skip_live(self):
self.skip_if_env_not_set('ENABLE_LDAP_LIVE_TEST')
def clear_database(self): def clear_database(self):
devnull = open('/dev/null', 'w') devnull = open('/dev/null', 'w')
subprocess.call(['ldapdelete', subprocess.call(['ldapdelete',

View File

@ -20,7 +20,7 @@ from keystone import config
from keystone import exception from keystone import exception
from keystone import identity from keystone import identity
from keystone import tests from keystone import tests
from keystone.tests import _ldap_livetest from keystone.tests import test_ldap_livetest
CONF = config.CONF CONF = config.CONF
@ -34,7 +34,10 @@ def create_object(dn, attrs):
conn.unbind_s() conn.unbind_s()
class LiveTLSLDAPIdentity(_ldap_livetest.LiveLDAPIdentity): class LiveTLSLDAPIdentity(test_ldap_livetest.LiveLDAPIdentity):
def _ldap_skip_live(self):
self.skip_if_env_not_set('ENABLE_TLS_LDAP_LIVE_TEST')
def config_files(self): def config_files(self):
config_files = super(LiveTLSLDAPIdentity, self).config_files() config_files = super(LiveTLSLDAPIdentity, self).config_files()

View File

@ -22,6 +22,10 @@ CONF = config.CONF
class PostgresqlMigrateTests(test_sql_upgrade.SqlUpgradeTests): class PostgresqlMigrateTests(test_sql_upgrade.SqlUpgradeTests):
def setUp(self):
self.skip_if_env_not_set('ENABLE_LIVE_POSTGRES_TEST')
super(PostgresqlMigrateTests, self).setUp()
def config_files(self): def config_files(self):
files = (test_sql_upgrade.SqlUpgradeTests. files = (test_sql_upgrade.SqlUpgradeTests.
_config_file_list[:]) _config_file_list[:])
@ -30,6 +34,10 @@ class PostgresqlMigrateTests(test_sql_upgrade.SqlUpgradeTests):
class MysqlMigrateTests(test_sql_upgrade.SqlUpgradeTests): class MysqlMigrateTests(test_sql_upgrade.SqlUpgradeTests):
def setUp(self):
self.skip_if_env_not_set('ENABLE_LIVE_MYSQL_TEST')
super(MysqlMigrateTests, self).setUp()
def config_files(self): def config_files(self):
files = (test_sql_upgrade.SqlUpgradeTests. files = (test_sql_upgrade.SqlUpgradeTests.
_config_file_list[:]) _config_file_list[:])
@ -39,6 +47,10 @@ class MysqlMigrateTests(test_sql_upgrade.SqlUpgradeTests):
class PostgresqlRevokeExtensionsTests( class PostgresqlRevokeExtensionsTests(
test_sql_migrate_extensions.RevokeExtension): test_sql_migrate_extensions.RevokeExtension):
def setUp(self):
self.skip_if_env_not_set('ENABLE_LIVE_POSTGRES_TEST')
super(PostgresqlRevokeExtensionsTests, self).setUp()
def config_files(self): def config_files(self):
files = (test_sql_upgrade.SqlUpgradeTests. files = (test_sql_upgrade.SqlUpgradeTests.
_config_file_list[:]) _config_file_list[:])
@ -47,6 +59,10 @@ class PostgresqlRevokeExtensionsTests(
class MysqlRevokeExtensionsTests(test_sql_migrate_extensions.RevokeExtension): class MysqlRevokeExtensionsTests(test_sql_migrate_extensions.RevokeExtension):
def setUp(self):
self.skip_if_env_not_set('ENABLE_LIVE_MYSQL_TEST')
super(MysqlRevokeExtensionsTests, self).setUp()
def config_files(self): def config_files(self):
files = (test_sql_upgrade.SqlUpgradeTests. files = (test_sql_upgrade.SqlUpgradeTests.
_config_file_list[:]) _config_file_list[:])
@ -55,6 +71,10 @@ class MysqlRevokeExtensionsTests(test_sql_migrate_extensions.RevokeExtension):
class Db2MigrateTests(test_sql_upgrade.SqlUpgradeTests): class Db2MigrateTests(test_sql_upgrade.SqlUpgradeTests):
def setUp(self):
self.skip_if_env_not_set('ENABLE_LIVE_DB2_TEST')
super(Db2MigrateTests, self).setUp()
def config_files(self): def config_files(self):
files = (test_sql_upgrade.SqlUpgradeTests. files = (test_sql_upgrade.SqlUpgradeTests.
_config_file_list[:]) _config_file_list[:])