@mock.patch('oslo_messaging.RPCClient.can_send_version',
return_value=True)
- def test_retype(self, can_send_version):
+ @mock.patch('cinder.quota.DbQuotaDriver.rollback')
+ def test_retype(self, rollback, can_send_version):
class FakeHost(object):
def __init__(self):
self.host = 'host'
reservations=self.fake_reservations,
old_reservations=self.fake_reservations,
version='1.37')
+ rollback.assert_not_called()
can_send_version.assert_called_once_with('1.37')
- def test_retype_version_134(self):
+ @mock.patch('cinder.quota.DbQuotaDriver.rollback')
+ def test_retype_version_134(self, rollback):
class FakeHost(object):
def __init__(self):
self.host = 'host'
reservations=self.fake_reservations,
old_reservations=self.fake_reservations,
version='1.34')
+ self.assertTrue(rollback.called)
can_send_version.assert_any_call('1.37')
can_send_version.assert_any_call('1.34')
- def test_retype_version_112(self):
+ @mock.patch('cinder.quota.DbQuotaDriver.rollback')
+ def test_retype_version_112(self, rollback):
class FakeHost(object):
def __init__(self):
self.host = 'host'
reservations=self.fake_reservations,
old_reservations=self.fake_reservations,
version='1.12')
+ self.assertTrue(rollback.called)
can_send_version.assert_any_call('1.37')
can_send_version.assert_any_call('1.34')
from oslo_config import cfg
from oslo_serialization import jsonutils
+from cinder import quota
from cinder import rpc
from cinder.volume import utils
CONF = cfg.CONF
+QUOTAS = quota.QUOTAS
class VolumeAPI(rpc.RPCAPI):
version = '1.37'
msg_args.update(volume=volume, old_reservations=old_reservations)
else:
+ if old_reservations is not None:
+ QUOTAS.rollback(ctxt, old_reservations)
if self.client.can_send_version('1.34'):
version = '1.34'
msg_args['volume'] = volume