summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-02-23 16:18:38 +0000
committerGerrit Code Review <review@openstack.org>2013-02-23 16:18:38 +0000
commitd2123eebf99092e3cc36a7ebc46b6a632e2742cd (patch)
tree4af606c64c691a636c67d74cff5485ce02612d57 /nova/tests
parenta7078ae7b30490a4c46bc213784f46ae5134fedb (diff)
parentfaf8dceb639c1c70ef2b3277cfb0a2e370706f45 (diff)
Merge "Adding ability to specify the libvirt cache mode for disk devices"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_libvirt.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index c9b47437c..cad556851 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -270,6 +270,17 @@ class FakeVolumeDriver(object):
return ""
+class FakeConfigGuestDisk(object):
+ def __init__(self, *args, **kwargs):
+ self.source_type = None
+ self.driver_cache = None
+
+
+class FakeConfigGuest(object):
+ def __init__(self, *args, **kwargs):
+ self.driver_cache = None
+
+
class LibvirtConnTestCase(test.TestCase):
def setUp(self):
@@ -3571,6 +3582,33 @@ class LibvirtConnTestCase(test.TestCase):
self.assertEqual(got_events[0].transition,
virtevent.EVENT_LIFECYCLE_STOPPED)
+ def test_set_cache_mode(self):
+ self.flags(disk_cachemodes=['file=directsync'])
+ conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
+ fake_conf = FakeConfigGuestDisk()
+
+ fake_conf.source_type = 'file'
+ conn.set_cache_mode(fake_conf)
+ self.assertEqual(fake_conf.driver_cache, 'directsync')
+
+ def test_set_cache_mode_invalid_mode(self):
+ self.flags(disk_cachemodes=['file=FAKE'])
+ conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
+ fake_conf = FakeConfigGuestDisk()
+
+ fake_conf.source_type = 'file'
+ conn.set_cache_mode(fake_conf)
+ self.assertEqual(fake_conf.driver_cache, None)
+
+ def test_set_cache_mode_invalid_object(self):
+ self.flags(disk_cachemodes=['file=directsync'])
+ conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
+ fake_conf = FakeConfigGuest()
+
+ fake_conf.driver_cache = 'fake'
+ conn.set_cache_mode(fake_conf)
+ self.assertEqual(fake_conf.driver_cache, 'fake')
+
class HostStateTestCase(test.TestCase):