diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-04-06 19:42:29 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-04-06 19:42:29 +0000 |
| commit | 27acf7b0667d06ab786101d82ef8b502e467046f (patch) | |
| tree | 5307ce4bb486233594d2d428024e97ec15dff5a9 | |
| parent | b573276e00f486120b35d84b892df2c0fa617acc (diff) | |
| parent | 0d03119e2059e50105b3045eb019940c860489c1 (diff) | |
Merge "Stop libvirt test from deleting instances dir"
| -rw-r--r-- | nova/tests/test_libvirt.py | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 87b3073ed..472013618 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -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() - - ref = self.libvirtconnection.finish_revert_migration(ins_ref, None) - self.assertTrue(isinstance(ref, eventlet.event.Event)) + 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)) class LibvirtNonblockingTestCase(test.TestCase): |
