Skip to content

Commit

Permalink
Merge "Use FakeLoopingCall instead of the real one"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 20, 2013
2 parents 64cad73 + ecddac5 commit fc705de
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cinder/tests/brick/test_brick_connector.py
Expand Up @@ -26,6 +26,7 @@
from cinder.brick.initiator import linuxfc
from cinder.brick.initiator import linuxscsi
from cinder.openstack.common import log as logging
from cinder.openstack.common import loopingcall
from cinder.openstack.common import processutils as putils
from cinder import test

Expand Down Expand Up @@ -330,6 +331,30 @@ def test_connect_volume(self):
connection_info['data'])


class FakeFixedIntervalLoopingCall(object):
def __init__(self, f=None, *args, **kw):
self.args = args
self.kw = kw
self.f = f
self._stop = False

def stop(self):
self._stop = True

def wait(self):
return self

def start(self, interval, initial_delay=None):
while not self._stop:
try:
self.f(*self.args, **self.kw)
except loopingcall.LoopingCallDone:
return self
except Exception:
LOG.exception(_('in fixed duration looping call'))
raise


class AoEConnectorTestCase(ConnectorTestCase):
"""Test cases for AoE initiator class."""
def setUp(self):
Expand All @@ -338,6 +363,9 @@ def setUp(self):
self.connector = connector.AoEConnector('sudo')
self.connection_properties = {'target_shelf': 'fake_shelf',
'target_lun': 'fake_lun'}
self.stubs.Set(loopingcall,
'FixedIntervalLoopingCall',
FakeFixedIntervalLoopingCall)

def tearDown(self):
self.mox.VerifyAll()
Expand Down

0 comments on commit fc705de

Please sign in to comment.