libvirt-volume: improve unit test time

A number of tests would invoke code that would sleep. This
patch adds a mocked function for the sleep.

Change-Id: I804a86e3b8b750919cf7a9547ef514f833a5fd49
Related-bug: #1279820
This commit is contained in:
Gary Kotton 2014-02-15 08:54:45 -08:00
parent 41a720ae55
commit e16b2a8822
1 changed files with 3 additions and 0 deletions

View File

@ -15,6 +15,7 @@
import fixtures
import os
import time
from oslo.config import cfg
@ -555,6 +556,7 @@ class LibvirtVolumeTestCase(test.NoDBTestCase):
def test_libvirt_kvm_iser_volume_with_multipath(self):
self.flags(iser_use_multipath=True, group='libvirt')
self.stubs.Set(os.path, 'exists', lambda x: True)
self.stubs.Set(time, 'sleep', lambda x: None)
devs = ['/dev/mapper/sda', '/dev/mapper/sdb']
self.stubs.Set(self.fake_conn, 'get_all_block_devices', lambda: devs)
libvirt_driver = volume.LibvirtISERVolumeDriver(self.fake_conn)
@ -583,6 +585,7 @@ class LibvirtVolumeTestCase(test.NoDBTestCase):
def test_libvirt_kvm_iser_volume_with_multipath_getmpdev(self):
self.flags(iser_use_multipath=True, group='libvirt')
self.stubs.Set(os.path, 'exists', lambda x: True)
self.stubs.Set(time, 'sleep', lambda x: None)
libvirt_driver = volume.LibvirtISERVolumeDriver(self.fake_conn)
name0 = 'volume-00000000'
location0 = '10.0.2.15:3260'