Merge "Fake out sleeps in unit tests"

This commit is contained in:
Jenkins 2015-05-03 22:46:49 +00:00 committed by Gerrit Code Review
commit 51ae2ebccd
4 changed files with 17 additions and 5 deletions

View File

@ -16,11 +16,13 @@ import os
import os.path import os.path
import string import string
import mock
from oslo_log import log as logging from oslo_log import log as logging
from cinder.brick import exception from cinder.brick import exception
from cinder.brick.initiator import linuxscsi from cinder.brick.initiator import linuxscsi
from cinder import test from cinder import test
from cinder.tests.unit import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -68,6 +70,8 @@ class LinuxSCSITestCase(test.TestCase):
('tee -a /sys/block/sdc/device/delete')] ('tee -a /sys/block/sdc/device/delete')]
self.assertEqual(expected_commands, self.cmds) self.assertEqual(expected_commands, self.cmds)
@mock.patch('cinder.openstack.common.loopingcall.FixedIntervalLoopingCall',
new=utils.ZeroIntervalLoopingCall)
def test_wait_for_volume_removal(self): def test_wait_for_volume_removal(self):
fake_path = '/dev/disk/by-path/fake-iscsi-iqn-lun-0' fake_path = '/dev/disk/by-path/fake-iscsi-iqn-lun-0'
self.stubs.Set(os.path, "exists", lambda x: True) self.stubs.Set(os.path, "exists", lambda x: True)

View File

@ -37,5 +37,4 @@ class ExtensionsTest(integrated_helpers._IntegratedTestBase):
"""Simple check that fox-n-socks works.""" """Simple check that fox-n-socks works."""
response = self.api.api_request('/foxnsocks') response = self.api.api_request('/foxnsocks')
foxnsocks = response.text foxnsocks = response.text
LOG.debug("foxnsocks: %s" % foxnsocks)
self.assertEqual('Try to say this Mr. Knox, sir...', foxnsocks) self.assertEqual('Try to say this Mr. Knox, sir...', foxnsocks)

View File

@ -24,6 +24,7 @@ import shutil
import socket import socket
import sys import sys
import tempfile import tempfile
import time
import eventlet import eventlet
import mock import mock
@ -39,7 +40,7 @@ from taskflow.engines.action_engine import engine
from cinder.backup import driver as backup_driver from cinder.backup import driver as backup_driver
from cinder.brick.local_dev import lvm as brick_lvm from cinder.brick.local_dev import lvm as brick_lvm
from cinder import compute from cinder.compute import nova
from cinder import context from cinder import context
from cinder import db from cinder import db
from cinder import exception from cinder import exception
@ -2632,6 +2633,8 @@ class VolumeTestCase(BaseVolumeTestCase):
self.assertNotIn(iscsi_target, targets) self.assertNotIn(iscsi_target, targets)
targets.append(iscsi_target) targets.append(iscsi_target)
# FIXME(jdg): What is this actually testing?
# We never call the internal _check method?
for _index in xrange(100): for _index in xrange(100):
tests_utils.create_volume(self.context, **self.volume_params) tests_utils.create_volume(self.context, **self.volume_params)
for volume_id in volume_ids: for volume_id in volume_ids:
@ -3818,7 +3821,7 @@ class VolumeTestCase(BaseVolumeTestCase):
self.assertIsNone(volume['migration_status']) self.assertIsNone(volume['migration_status'])
self.assertEqual('available', volume['status']) self.assertEqual('available', volume['status'])
@mock.patch.object(compute.nova.API, 'update_server_volume') @mock.patch.object(nova.API, 'update_server_volume')
@mock.patch('cinder.volume.manager.VolumeManager.' @mock.patch('cinder.volume.manager.VolumeManager.'
'migrate_volume_completion') 'migrate_volume_completion')
@mock.patch('cinder.db.volume_get') @mock.patch('cinder.db.volume_get')
@ -3843,7 +3846,7 @@ class VolumeTestCase(BaseVolumeTestCase):
fake_new_volume['id'], fake_new_volume['id'],
error=False) error=False)
@mock.patch.object(compute.nova.API, 'update_server_volume') @mock.patch.object(nova.API, 'update_server_volume')
@mock.patch('cinder.volume.manager.VolumeManager.' @mock.patch('cinder.volume.manager.VolumeManager.'
'migrate_volume_completion') 'migrate_volume_completion')
@mock.patch('cinder.db.volume_get') @mock.patch('cinder.db.volume_get')
@ -4020,7 +4023,8 @@ class VolumeTestCase(BaseVolumeTestCase):
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume') as \ mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume') as \
mock_create_volume, \ mock_create_volume, \
mock.patch.object(self.volume, '_clean_temporary_volume') as \ mock.patch.object(self.volume, '_clean_temporary_volume') as \
clean_temporary_volume: clean_temporary_volume, \
mock.patch.object(time, 'sleep'):
# Exception case at the timeout of the volume creation # Exception case at the timeout of the volume creation
mock_create_volume.side_effect = fake_create_volume mock_create_volume.side_effect = fake_create_volume

View File

@ -19,6 +19,7 @@ from oslo_log import log as logging
from cinder import context from cinder import context
from cinder import exception from cinder import exception
from cinder import test from cinder import test
from cinder.tests.unit import utils
from cinder.volume.drivers import xio from cinder.volume.drivers import xio
from cinder.volume import qos_specs from cinder.volume import qos_specs
from cinder.volume import volume_types from cinder.volume import volume_types
@ -1194,6 +1195,8 @@ class XIOISEDriverTestCase(object):
self.setup_driver() self.setup_driver()
self.driver.create_snapshot(SNAPSHOT1) self.driver.create_snapshot(SNAPSHOT1)
@mock.patch('cinder.openstack.common.loopingcall.FixedIntervalLoopingCall',
new=utils.ZeroIntervalLoopingCall)
def test_negative_create_snapshot_invalid_state_recover(self, mock_req): def test_negative_create_snapshot_invalid_state_recover(self, mock_req):
ctxt = context.get_admin_context() ctxt = context.get_admin_context()
extra_specs = {"Feature:Pool": "1", extra_specs = {"Feature:Pool": "1",
@ -1218,6 +1221,8 @@ class XIOISEDriverTestCase(object):
self.setup_driver() self.setup_driver()
self.driver.create_snapshot(SNAPSHOT1) self.driver.create_snapshot(SNAPSHOT1)
@mock.patch('cinder.openstack.common.loopingcall.FixedIntervalLoopingCall',
new=utils.ZeroIntervalLoopingCall)
def test_negative_create_snapshot_invalid_state_norecover(self, mock_req): def test_negative_create_snapshot_invalid_state_norecover(self, mock_req):
ctxt = context.get_admin_context() ctxt = context.get_admin_context()
extra_specs = {"Feature:Pool": "1", extra_specs = {"Feature:Pool": "1",