Stop libvirt test from deleting instances dir

* fixes bug 974293

Change-Id: Id41ab20193a70246ad2e3e1cc18edf47059d312d
This commit is contained in:
Vishvananda Ishaya 2012-04-05 17:00:25 -07:00
parent 7a51a3f962
commit 0d03119e20

View File

@ -2275,25 +2275,8 @@ class LibvirtConnectionTestCase(test.TestCase):
"""Test for nova.virt.libvirt.connection.LibvirtConnection."""
def setUp(self):
super(LibvirtConnectionTestCase, self).setUp()
self.libvirtconnection = connection.LibvirtConnection(read_only=True)
self.temp_path = os.path.join(flags.FLAGS.instances_path,
'instance-00000001/', '')
try:
os.makedirs(self.temp_path)
except Exception:
print 'testcase init error'
pass
def tearDown(self):
super(LibvirtConnectionTestCase, self).tearDown()
try:
shutil.rmtree(flags.FLAGS.instances_path)
except Exception:
pass
def _create_instance(self, params=None):
"""Create a test instance"""
if not params:
@ -2501,14 +2484,18 @@ class LibvirtConnectionTestCase(test.TestCase):
self.stubs.Set(self.libvirtconnection, '_create_new_domain',
fake_create_new_domain)
ins_ref = self._create_instance()
libvirt_xml_path = os.path.join(flags.FLAGS.instances_path,
ins_ref['name'], 'libvirt.xml')
f = open(libvirt_xml_path, 'w')
f.close()
with utils.tempdir() as tmpdir:
self.flags(instances_path=tmpdir)
ins_ref = self._create_instance()
os.mkdir(os.path.join(tmpdir, ins_ref['name']))
libvirt_xml_path = os.path.join(tmpdir,
ins_ref['name'],
'libvirt.xml')
f = open(libvirt_xml_path, 'w')
f.close()
ref = self.libvirtconnection.finish_revert_migration(ins_ref, None)
self.assertTrue(isinstance(ref, eventlet.event.Event))
ref = self.libvirtconnection.finish_revert_migration(ins_ref, None)
self.assertTrue(isinstance(ref, eventlet.event.Event))
class LibvirtNonblockingTestCase(test.TestCase):