from cinder import utils
from cinder import service
from cinder import tests
+from cinder.tests import fake_flags
test_opts = [
def setUp(self):
"""Run before each test method to initialize test environment."""
super(TestCase, self).setUp()
+
+ fake_flags.set_defaults(FLAGS)
+
# NOTE(vish): We need a better method for creating fixtures for tests
# now that we have some required db setup for the system
# to work properly.
self.stubs = stubout.StubOutForTesting()
self.injected = []
self._services = []
- self._overridden_opts = []
def tearDown(self):
"""Runs after each test method to tear down test environment."""
super(TestCase, self).tearDown()
finally:
# Reset any overridden flags
- self.reset_flags()
+ FLAGS.reset()
# Stop any timers
for x in self.injected:
"""Override flag variables for a test."""
for k, v in kw.iteritems():
FLAGS.set_override(k, v)
- self._overridden_opts.append(k)
-
- def reset_flags(self):
- """Resets all flag variables for the test.
-
- Runs after each test.
-
- """
- for k in self._overridden_opts:
- FLAGS.set_override(k, None)
- self._overridden_opts = []
def start_service(self, name, host=None, **kwargs):
host = host and host or uuid.uuid4().hex
from cinder.db import migration
from cinder.tests import fake_flags
+ fake_flags.set_defaults(FLAGS)
if FLAGS.sql_connection == "sqlite://":
if migration.db_version() > 1:
FLAGS = flags.FLAGS
-flags.DECLARE('volume_driver', 'cinder.volume.manager')
-FLAGS.set_default('volume_driver', 'cinder.volume.driver.FakeISCSIDriver')
-FLAGS.set_default('connection_type', 'fake')
-FLAGS.set_default('fake_rabbit', True)
-FLAGS.set_default('rpc_backend', 'cinder.rpc.impl_fake')
flags.DECLARE('iscsi_num_targets', 'cinder.volume.driver')
-FLAGS.set_default('iscsi_num_targets', 8)
-FLAGS.set_default('verbose', True)
-FLAGS.set_default('sql_connection', "sqlite://")
-FLAGS.set_default('sqlite_synchronous', False)
flags.DECLARE('policy_file', 'cinder.policy')
-FLAGS.set_default('policy_file', 'cinder/tests/policy.json')
+flags.DECLARE('volume_driver', 'cinder.volume.manager')
+
+
+def set_defaults(conf):
+ conf.set_default('volume_driver', 'cinder.volume.driver.FakeISCSIDriver')
+ conf.set_default('connection_type', 'fake')
+ conf.set_default('fake_rabbit', True)
+ conf.set_default('rpc_backend', 'cinder.rpc.impl_fake')
+ conf.set_default('iscsi_num_targets', 8)
+ conf.set_default('verbose', True)
+ conf.set_default('sql_connection', "sqlite://")
+ conf.set_default('sqlite_synchronous', False)
+ conf.set_default('policy_file', 'cinder/tests/policy.json')
self.assertEqual(FLAGS.flags_unittest, 'foo')
self.flags(flags_unittest='bar')
self.assertEqual(FLAGS.flags_unittest, 'bar')
- self.reset_flags()
+ FLAGS.reset()
self.assertEqual(FLAGS.flags_unittest, 'foo')
def test_defaults(self):