Create unique volumes_dir for testing.
Updates test_volume.py so that we create a uniq volumes_dir for testing. This avoids polluting the source tree with fake volume UUID's when running tests. Change-Id: I3c37083915effec0eff7c8d9bfffb9f7674fe6f5
This commit is contained in:
@@ -24,6 +24,8 @@ import cStringIO
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import mox
|
import mox
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
@@ -45,11 +47,17 @@ class VolumeTestCase(test.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(VolumeTestCase, self).setUp()
|
super(VolumeTestCase, self).setUp()
|
||||||
self.flags(connection_type='fake')
|
vol_tmpdir = tempfile.mkdtemp()
|
||||||
|
self.flags(connection_type='fake',
|
||||||
|
volumes_dir=vol_tmpdir)
|
||||||
self.volume = importutils.import_object(FLAGS.volume_manager)
|
self.volume = importutils.import_object(FLAGS.volume_manager)
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(FLAGS.volumes_dir)
|
||||||
|
except OSError, e:
|
||||||
|
pass
|
||||||
super(VolumeTestCase, self).tearDown()
|
super(VolumeTestCase, self).tearDown()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -360,7 +368,9 @@ class DriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DriverTestCase, self).setUp()
|
super(DriverTestCase, self).setUp()
|
||||||
|
vol_tmpdir = tempfile.mkdtemp()
|
||||||
self.flags(volume_driver=self.driver_name,
|
self.flags(volume_driver=self.driver_name,
|
||||||
|
volumes_dir=vol_tmpdir,
|
||||||
logging_default_format_string="%(message)s")
|
logging_default_format_string="%(message)s")
|
||||||
self.volume = importutils.import_object(FLAGS.volume_manager)
|
self.volume = importutils.import_object(FLAGS.volume_manager)
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
@@ -375,6 +385,13 @@ class DriverTestCase(test.TestCase):
|
|||||||
self.stream = cStringIO.StringIO()
|
self.stream = cStringIO.StringIO()
|
||||||
log.addHandler(logging.StreamHandler(self.stream))
|
log.addHandler(logging.StreamHandler(self.stream))
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(FLAGS.volumes_dir)
|
||||||
|
except OSError, e:
|
||||||
|
pass
|
||||||
|
super(DriverTestCase, self).tearDown()
|
||||||
|
|
||||||
def _attach_volume(self):
|
def _attach_volume(self):
|
||||||
"""Attach volumes to an instance. This function also sets
|
"""Attach volumes to an instance. This function also sets
|
||||||
a fake log message."""
|
a fake log message."""
|
||||||
|
|||||||
Reference in New Issue
Block a user