From 764d22a4dba16a8a73822c9caa988e3bf1500317 Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Sun, 9 Mar 2014 19:15:45 -0500 Subject: [PATCH] Configurable temporary directory for tests The temporary directory used for testing was always keystone/tests/tmp. This change makes it so that the temporary directory can be configured by setting the KEYSTONE_TEST_TEMP_DIR environment variable. For example: $ mkdir ~/keystone_test_temp $ sudo mount -t tmpfs -o size=16M tmpfs ~/keystone_test_temp && sudo chown $USER: ~/keystone_test_temp $ KEYSTONE_TEST_TEMP_DIR=$HOME/keystone_test_temp tox -e py27 Change-Id: I41f86a23882a382ab19747e008720c0da5fd56e6 --- keystone/tests/backend_sql_disk.conf | 2 -- keystone/tests/core.py | 11 ++++++++++- keystone/tests/test_auth_plugin.py | 7 +++++-- keystone/tests/test_v3.py | 8 ++++++-- 4 files changed, 21 insertions(+), 7 deletions(-) delete mode 100644 keystone/tests/backend_sql_disk.conf diff --git a/keystone/tests/backend_sql_disk.conf b/keystone/tests/backend_sql_disk.conf deleted file mode 100644 index 31ce195f51..0000000000 --- a/keystone/tests/backend_sql_disk.conf +++ /dev/null @@ -1,2 +0,0 @@ -[database] -connection = sqlite:///keystone/tests/tmp/test.db diff --git a/keystone/tests/core.py b/keystone/tests/core.py index 56a8ddcd95..5a6472cedb 100644 --- a/keystone/tests/core.py +++ b/keystone/tests/core.py @@ -81,7 +81,16 @@ TESTSDIR = os.path.dirname(os.path.abspath(__file__)) ROOTDIR = os.path.normpath(os.path.join(TESTSDIR, '..', '..')) VENDOR = os.path.join(ROOTDIR, 'vendor') ETCDIR = os.path.join(ROOTDIR, 'etc') -TMPDIR = os.path.join(TESTSDIR, 'tmp') + + +def _calc_tmpdir(): + env_val = os.environ.get('KEYSTONE_TEST_TEMP_DIR') + if env_val: + return env_val + return os.path.join(TESTSDIR, 'tmp') + + +TMPDIR = _calc_tmpdir() CONF = config.CONF diff --git a/keystone/tests/test_auth_plugin.py b/keystone/tests/test_auth_plugin.py index 0053f52836..f1e3f11f1a 100644 --- a/keystone/tests/test_auth_plugin.py +++ b/keystone/tests/test_auth_plugin.py @@ -70,9 +70,13 @@ class TestAuthPlugin(tests.TestCase): return [tests.dirs.etc('keystone.conf.sample'), tests.dirs.tests('test_overrides.conf'), tests.dirs.tests('backend_sql.conf'), - tests.dirs.tests('backend_sql_disk.conf'), tests.dirs.tests('test_auth_plugin.conf')] + def config(self, config_files): + super(TestAuthPlugin, self).config(config_files) + db_conn = 'sqlite:///%s' % tests.dirs.tmp('test.db') + self.config_fixture.config(group='database', connection=db_conn) + def test_unsupported_auth_method(self): method_name = uuid.uuid4().hex auth_data = {'methods': [method_name]} @@ -127,7 +131,6 @@ class TestByClassNameAuthMethodRegistration(TestAuthPlugin): return [tests.dirs.etc('keystone.conf.sample'), tests.dirs.tests('test_overrides.conf'), tests.dirs.tests('backend_sql.conf'), - tests.dirs.tests('backend_sql_disk.conf'), tests.dirs.tests('test_auth_plugin_by_class_name.conf')] diff --git a/keystone/tests/test_v3.py b/keystone/tests/test_v3.py index d6c7e77fea..010bef3cf0 100644 --- a/keystone/tests/test_v3.py +++ b/keystone/tests/test_v3.py @@ -40,8 +40,7 @@ TIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ' class RestfulTestCase(rest.RestfulTestCase): _config_file_list = [tests.dirs.etc('keystone.conf.sample'), tests.dirs.tests('test_overrides.conf'), - tests.dirs.tests('backend_sql.conf'), - tests.dirs.tests('backend_sql_disk.conf')] + tests.dirs.tests('backend_sql.conf')] #Subclasses can override this to specify the complete list of configuration #files. The base version makes a copy of the original values, otherwise @@ -90,6 +89,11 @@ class RestfulTestCase(rest.RestfulTestCase): self.addCleanup(self.teardown_database) + def config(self, config_files): + super(RestfulTestCase, self).config(config_files) + db_conn = 'sqlite:///%s' % tests.dirs.tmp('test.db') + self.config_fixture.config(group='database', connection=db_conn) + def load_backends(self): self.config(self.config_files())