class TestCase(testtools.TestCase):
"""Test case base class for all unit tests."""
+ def _get_joined_notifier(self, *args, **kwargs):
+ # We create a new fake notifier but we join the notifications with
+ # the default notifier
+ notifier = fake_notifier.get_fake_notifier(*args, **kwargs)
+ notifier.notifications = self.notifier.notifications
+ return notifier
+
def setUp(self):
"""Run before each test method to initialize test environment."""
super(TestCase, self).setUp()
+ # Create default notifier
+ self.notifier = fake_notifier.get_fake_notifier()
+
+ # Mock rpc get notifier with fake notifier method that joins all
+ # notifications with the default notifier
+ p = mock.patch('cinder.rpc.get_notifier',
+ side_effect=self._get_joined_notifier)
+ p.start()
+
# Import cinder objects for test cases
objects.register_all()
from cinder import exception
from cinder import test
from cinder.tests.unit.api import fakes
-from cinder.tests.unit import fake_notifier
import cinder.wsgi
self.controller = types_extra_specs.VolumeTypeExtraSpecsController()
"""to reset notifier drivers left over from other api/contrib tests"""
- fake_notifier.reset()
- self.addCleanup(fake_notifier.reset)
def test_index(self):
self.stubs.Set(cinder.db, 'volume_type_extra_specs_get',
self.stubs.Set(cinder.db, 'volume_type_extra_specs_delete',
delete_volume_type_extra_specs)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
req = fakes.HTTPRequest.blank(self.api_path + '/key5')
self.controller.delete(req, 1, 'key5')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
+ self.assertEqual(len(self.notifier.notifications), 1)
def test_delete_not_found(self):
self.stubs.Set(cinder.db, 'volume_type_extra_specs_delete',
return_create_volume_type_extra_specs)
body = {"extra_specs": {"key1": "value1"}}
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
req = fakes.HTTPRequest.blank(self.api_path)
res_dict = self.controller.create(req, 1, body)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
+ self.assertEqual(len(self.notifier.notifications), 1)
self.assertEqual('value1', res_dict['extra_specs']['key1'])
body = {"extra_specs": {"other_alphanum.-_:": "value1"}}
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
req = fakes.HTTPRequest.blank(self.api_path)
res_dict = self.controller.create(req, 1, body)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
+ self.assertEqual(len(self.notifier.notifications), 1)
self.assertEqual('value1',
res_dict['extra_specs']['other_alphanum.-_:'])
"other2_alphanum.-_:": "value2",
"other3_alphanum.-_:": "value3"}}
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
req = fakes.HTTPRequest.blank(self.api_path)
res_dict = self.controller.create(req, 1, body)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
+ self.assertEqual(len(self.notifier.notifications), 1)
self.assertEqual('value1',
res_dict['extra_specs']['other_alphanum.-_:'])
self.assertEqual('value2',
return_create_volume_type_extra_specs)
body = {"key1": "value1"}
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
req = fakes.HTTPRequest.blank(self.api_path + '/key1')
res_dict = self.controller.update(req, 1, 'key1', body)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
+ self.assertEqual(len(self.notifier.notifications), 1)
self.assertEqual('value1', res_dict['key1'])
from cinder import exception
from cinder import test
from cinder.tests.unit.api import fakes
-from cinder.tests.unit import fake_notifier
from cinder.volume import volume_types
self.flags(host='fake')
self.controller = types_manage.VolumeTypesManageController()
"""to reset notifier drivers left over from other api/contrib tests"""
- fake_notifier.reset()
- self.addCleanup(fake_notifier.reset)
def tearDown(self):
super(VolumeTypesManageApiTest, self).tearDown()
return_volume_types_destroy)
req = fakes.HTTPRequest.blank('/v2/fake/types/1')
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
self.controller._delete(req, 1)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
def test_volume_types_delete_not_found(self):
self.stubs.Set(volume_types, 'get_volume_type',
self.stubs.Set(volume_types, 'destroy',
return_volume_types_destroy)
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
req = fakes.HTTPRequest.blank('/v2/fake/types/777')
self.assertRaises(webob.exc.HTTPNotFound, self.controller._delete,
req, '777')
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
def test_volume_types_with_volumes_destroy(self):
self.stubs.Set(volume_types, 'get_volume_type',
self.stubs.Set(volume_types, 'destroy',
return_volume_types_with_volumes_destroy)
req = fakes.HTTPRequest.blank('/v2/fake/types/1')
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
self.controller._delete(req, 1)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
def test_create(self):
self.stubs.Set(volume_types, 'create',
"extra_specs": {"key1": "value1"}}}
req = fakes.HTTPRequest.blank('/v2/fake/types')
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
res_dict = self.controller._create(req, body)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
self._check_test_results(res_dict, {
'expected_name': 'vol_type_1', 'expected_desc': 'vol_type_desc_1'})
req = fakes.HTTPRequest.blank('/v2/fake/types/1')
req.method = 'PUT'
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
res_dict = self.controller._update(req, '1', body)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
self._check_test_results(res_dict,
{'expected_desc': 'vol_type_desc_1_1',
'expected_name': 'vol_type_1_1'})
req = fakes.HTTPRequest.blank('/v2/fake/types/777')
req.method = 'PUT'
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
self.assertRaises(webob.exc.HTTPNotFound,
self.controller._update, req, '777', body)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
def test_update_db_fail(self):
self.stubs.Set(volume_types, 'update',
req = fakes.HTTPRequest.blank('/v2/fake/types/1')
req.method = 'PUT'
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
self.assertRaises(webob.exc.HTTPInternalServerError,
self.controller._update, req, '1', body)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
def test_update_no_name_no_description(self):
body = {"volume_type": {}}
req = fakes.HTTPRequest.blank('/v2/fake/types/999')
req.method = 'PUT'
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
res_dict = self.controller._update(req, '999', body)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
self._check_test_results(res_dict,
{'expected_name': 'vol_type_999_999',
'expected_desc': 'vol_type_desc_999'})
req = fakes.HTTPRequest.blank('/v2/fake/types/888')
req.method = 'PUT'
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
res_dict = self.controller._update(req, '888', body)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
self._check_test_results(res_dict,
{'expected_name': 'vol_type_888',
'expected_desc': 'vol_type_desc_888_888'})
req = fakes.HTTPRequest.blank('/v2/fake/types/666')
req.method = 'PUT'
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
self.assertRaises(webob.exc.HTTPConflict,
self.controller._update, req, '666', body)
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
# delete
- fake_notifier.reset()
+ self.notifier.reset()
self.stubs.Set(volume_types, 'destroy',
return_volume_types_destroy)
req = fakes.HTTPRequest.blank('/v2/fake/types/1')
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.notifications))
self.controller._delete(req, '1')
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
# update again
self.stubs.Set(volume_types, 'update',
req = fakes.HTTPRequest.blank('/v2/fake/types/666')
req.method = 'PUT'
- fake_notifier.reset()
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
+ self.notifier.reset()
+ self.assertEqual(0, len(self.notifier.notifications))
res_dict = self.controller._update(req, '666', body)
self._check_test_results(res_dict,
{'expected_name': 'vol_type_666',
'expected_desc': 'vol_type_desc_666'})
- self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.notifications))
def _check_test_results(self, results, expected_results):
self.assertEqual(1, len(results))
from cinder import db
from cinder import test
from cinder.tests.unit.api import fakes
-from cinder.tests.unit import fake_notifier
def return_volume_type_encryption(context, volume_type_id):
self.flags(host='fake')
self.api_path = '/v2/fake/os-volume-types/1/encryption'
"""to reset notifier drivers left over from other api/contrib tests"""
- fake_notifier.reset()
- self.addCleanup(fake_notifier.reset)
def _get_response(self, volume_type, admin=True,
url='/v2/fake/types/%s/encryption',
'provider': provider,
'volume_type_id': volume_type['id']}}
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
res = self._get_response(volume_type)
res_dict = json.loads(res.body)
self.assertEqual(200, res.status_code)
req_headers='application/json')
res_dict = json.loads(res.body)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
+ self.assertEqual(len(self.notifier.notifications), 1)
# check response
self.assertIn('encryption', res_dict)
req_headers='application/json')
res_dict = json.loads(res.body)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
self.assertEqual(404, res.status_code)
expected = {
class VolumeApiTest(test.TestCase):
def setUp(self):
super(VolumeApiTest, self).setUp()
- self.addCleanup(fake_notifier.reset)
self.ext_mgr = extensions.ExtensionManager()
self.ext_mgr.extensions = {}
fake_image.stub_out_image_service(self.stubs)
}
body = {"volume": updates}
req = fakes.HTTPRequest.blank('/v1/volumes/1')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
res_dict = self.controller.update(req, '1', body)
expected = {'volume': {
'status': 'fakestatus',
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1),
'size': 1}}
self.assertEqual(res_dict, expected)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2)
+ self.assertEqual(len(self.notifier.notifications), 2)
def test_volume_update_metadata(self):
self.stubs.Set(db, 'volume_get', stubs.stub_volume_get_db)
}
body = {"volume": updates}
req = fakes.HTTPRequest.blank('/v1/volumes/1')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
res_dict = self.controller.update(req, '1', body)
expected = {'volume': {
'status': 'fakestatus',
'size': 1
}}
self.assertEqual(res_dict, expected)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2)
+ self.assertEqual(len(self.notifier.notifications), 2)
def test_volume_update_with_admin_metadata(self):
self.stubs.Set(volume_api.API, "update", stubs.stub_volume_update)
}
body = {"volume": updates}
req = fakes.HTTPRequest.blank('/v1/volumes/1')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
admin_ctx = context.RequestContext('admin', 'fakeproject', True)
req.environ['cinder.context'] = admin_ctx
res_dict = self.controller.update(req, '1', body)
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1),
'size': 1}}
self.assertEqual(res_dict, expected)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2)
+ self.assertEqual(len(self.notifier.notifications), 2)
def test_update_empty_body(self):
body = {}
class VolumeApiTest(test.TestCase):
def setUp(self):
super(VolumeApiTest, self).setUp()
- self.addCleanup(fake_notifier.reset)
self.ext_mgr = extensions.ExtensionManager()
self.ext_mgr.extensions = {}
fake_image.stub_out_image_service(self.stubs)
}
body = {"volume": updates}
req = fakes.HTTPRequest.blank('/v2/volumes/1')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
res_dict = self.controller.update(req, '1', body)
expected = {
'volume': {
}
}
self.assertEqual(res_dict, expected)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2)
+ self.assertEqual(len(self.notifier.notifications), 2)
def test_volume_update_deprecation(self):
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_get)
}
body = {"volume": updates}
req = fakes.HTTPRequest.blank('/v2/volumes/1')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
res_dict = self.controller.update(req, '1', body)
expected = {
'volume': {
}
}
self.assertEqual(res_dict, expected)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2)
+ self.assertEqual(len(self.notifier.notifications), 2)
def test_volume_update_deprecation_key_priority(self):
"""Test current update keys have priority over deprecated keys."""
}
body = {"volume": updates}
req = fakes.HTTPRequest.blank('/v2/volumes/1')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
res_dict = self.controller.update(req, '1', body)
expected = {
'volume': {
}
}
self.assertEqual(res_dict, expected)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2)
+ self.assertEqual(len(self.notifier.notifications), 2)
def test_volume_update_metadata(self):
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_get)
}
body = {"volume": updates}
req = fakes.HTTPRequest.blank('/v2/volumes/1')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
res_dict = self.controller.update(req, '1', body)
expected = {'volume': {
'status': 'fakestatus',
],
}}
self.assertEqual(res_dict, expected)
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2)
+ self.assertEqual(len(self.notifier.notifications), 2)
def test_volume_update_with_admin_metadata(self):
self.stubs.Set(volume_api.API, "update", stubs.stub_volume_update)
}
body = {"volume": updates}
req = fakes.HTTPRequest.blank('/v2/volumes/1')
- self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
+ self.assertEqual(len(self.notifier.notifications), 0)
admin_ctx = context.RequestContext('admin', 'fake', True)
req.environ['cinder.context'] = admin_ctx
res_dict = self.controller.update(req, '1', body)
],
}}
self.assertEqual(expected, res_dict)
- self.assertEqual(2, len(fake_notifier.NOTIFICATIONS))
+ self.assertEqual(2, len(self.notifier.notifications))
def test_update_empty_body(self):
body = {}
from cinder import rpc
-NOTIFICATIONS = []
-
-
-def reset():
- del NOTIFICATIONS[:]
-
FakeMessage = collections.namedtuple('Message',
['publisher_id', 'priority',
priority=priority,
event_type=event_type,
payload=payload)
- NOTIFICATIONS.append(msg)
self.notifications.append(msg)
+ def reset(self):
+ del self.notifications[:]
+
def stub_notifier(stubs):
stubs.Set(messaging, 'Notifier', FakeNotifier)
from cinder.tests.unit.brick import fake_lvm
from cinder.tests.unit import conf_fixture
from cinder.tests.unit import fake_driver
-from cinder.tests.unit import fake_notifier
from cinder.tests.unit.image import fake as fake_image
from cinder.tests.unit.keymgr import fake as fake_keymgr
from cinder.tests.unit import utils as tests_utils
self.called = []
def _cleanup(self):
- fake_notifier.reset()
try:
shutil.rmtree(CONF.volumes_dir)
except OSError:
volume_id = volume['id']
self.assertIsNone(volume['encryption_key_id'])
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(0, len(self.notifier.notifications),
+ self.notifier.notifications)
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_volume,
self.context, volume_id)
volume_id = volume['id']
self.assertIsNone(volume['encryption_key_id'])
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(0, len(self.notifier.notifications),
+ self.notifier.notifications)
self.assertRaises(exception.DriverNotInitialized,
self.volume.delete_volume,
self.context, volume_id)
**self.volume_params)
volume_id = volume['id']
self.assertIsNone(volume['encryption_key_id'])
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(0, len(self.notifier.notifications),
+ self.notifier.notifications)
self.volume.create_volume(self.context, volume_id)
- self.assertEqual(2, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
- msg = fake_notifier.NOTIFICATIONS[0]
+ self.assertEqual(2, len(self.notifier.notifications),
+ self.notifier.notifications)
+ msg = self.notifier.notifications[0]
self.assertEqual('volume.create.start', msg['event_type'])
expected = {
'status': 'creating',
'metadata': [],
}
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[1]
+ msg = self.notifier.notifications[1]
self.assertEqual('volume.create.end', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
vol = db.volume_get(context.get_admin_context(read_deleted='yes'),
volume_id)
self.assertEqual('deleted', vol['status'])
- self.assertEqual(4, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
- msg = fake_notifier.NOTIFICATIONS[2]
+ self.assertEqual(4, len(self.notifier.notifications),
+ self.notifier.notifications)
+ msg = self.notifier.notifications[2]
self.assertEqual('volume.delete.start', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[3]
+ msg = self.notifier.notifications[3]
self.assertEqual('volume.delete.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
self.assertRaises(exception.NotFound,
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(0, len(self.notifier.notifications),
+ self.notifier.notifications)
self.volume.create_volume(self.context, volume['id'])
- msg = fake_notifier.NOTIFICATIONS[0]
+ msg = self.notifier.notifications[0]
self.assertEqual('volume.create.start', msg['event_type'])
self.assertEqual('creating', msg['payload']['status'])
self.assertEqual('INFO', msg['priority'])
- msg = fake_notifier.NOTIFICATIONS[1]
+ msg = self.notifier.notifications[1]
self.assertEqual('volume.create.end', msg['event_type'])
self.assertEqual('available', msg['payload']['status'])
self.assertEqual('INFO', msg['priority'])
- if len(fake_notifier.NOTIFICATIONS) > 2:
+ if len(self.notifier.notifications) > 2:
# Cause an assert to print the unexpected item
- self.assertFalse(fake_notifier.NOTIFICATIONS[2])
- self.assertEqual(2, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertFalse(self.notifier.notifications[2])
+ self.assertEqual(2, len(self.notifier.notifications),
+ self.notifier.notifications)
snapshot_id = self._create_snapshot(volume['id'],
size=volume['size'])['id']
self.assertEqual(snapshot_id,
db.snapshot_get(context.get_admin_context(),
snapshot_id).id)
- msg = fake_notifier.NOTIFICATIONS[2]
+ msg = self.notifier.notifications[2]
self.assertEqual('snapshot.create.start', msg['event_type'])
expected = {
'created_at': 'DONTCARE',
'metadata': '',
}
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[3]
+ msg = self.notifier.notifications[3]
self.assertEqual('snapshot.create.end', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
- if len(fake_notifier.NOTIFICATIONS) > 4:
+ if len(self.notifier.notifications) > 4:
# Cause an assert to print the unexpected item
- self.assertFalse(fake_notifier.NOTIFICATIONS[4])
+ self.assertFalse(self.notifier.notifications[4])
- self.assertEqual(4, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(4, len(self.notifier.notifications),
+ self.notifier.notifications)
self.volume.delete_snapshot(self.context, snapshot_obj)
- msg = fake_notifier.NOTIFICATIONS[4]
+ msg = self.notifier.notifications[4]
self.assertEqual('snapshot.delete.start', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[5]
+ msg = self.notifier.notifications[5]
self.assertEqual('snapshot.delete.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
- if len(fake_notifier.NOTIFICATIONS) > 6:
+ if len(self.notifier.notifications) > 6:
# Cause an assert to print the unexpected item
- self.assertFalse(fake_notifier.NOTIFICATIONS[6])
+ self.assertFalse(self.notifier.notifications[6])
- self.assertEqual(6, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(6, len(self.notifier.notifications),
+ self.notifier.notifications)
snap = db.snapshot_get(context.get_admin_context(read_deleted='yes'),
snapshot_id)
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2')
group_id = group['id']
- self.assertEqual(0, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(0, len(self.notifier.notifications),
+ self.notifier.notifications)
self.volume.create_consistencygroup(self.context, group_id)
- self.assertEqual(2, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
- msg = fake_notifier.NOTIFICATIONS[0]
+ self.assertEqual(2, len(self.notifier.notifications),
+ self.notifier.notifications)
+ msg = self.notifier.notifications[0]
self.assertEqual('consistencygroup.create.start', msg['event_type'])
expected = {
'status': 'available',
'consistencygroup_id': group_id
}
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[1]
+ msg = self.notifier.notifications[1]
self.assertEqual(msg['event_type'], 'consistencygroup.create.end')
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
context.get_admin_context(read_deleted='yes'),
group_id)
self.assertEqual('deleted', cg['status'])
- self.assertEqual(4, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
- msg = fake_notifier.NOTIFICATIONS[2]
+ self.assertEqual(4, len(self.notifier.notifications),
+ self.notifier.notifications)
+ msg = self.notifier.notifications[2]
self.assertEqual('consistencygroup.delete.start', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[3]
+ msg = self.notifier.notifications[3]
self.assertEqual('consistencygroup.delete.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
self.assertRaises(exception.NotFound,
'consistencygroup_id': group_id
}
self.assertEqual('available', cg['status'])
- self.assertEqual(10, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
- msg = fake_notifier.NOTIFICATIONS[6]
+ self.assertEqual(10, len(self.notifier.notifications),
+ self.notifier.notifications)
+ msg = self.notifier.notifications[6]
self.assertEqual('consistencygroup.update.start', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[8]
+ msg = self.notifier.notifications[8]
self.assertEqual('consistencygroup.update.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
cgvolumes = db.volume_get_all_by_group(self.context, group_id)
}
self.assertEqual('available', cg2['status'])
- msg = fake_notifier.NOTIFICATIONS[2]
+ msg = self.notifier.notifications[2]
self.assertEqual('consistencygroup.create.start', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[4]
+ msg = self.notifier.notifications[4]
self.assertEqual('consistencygroup.create.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
- if len(fake_notifier.NOTIFICATIONS) > 6:
- self.assertFalse(fake_notifier.NOTIFICATIONS[6])
- self.assertEqual(6, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ if len(self.notifier.notifications) > 6:
+ self.assertFalse(self.notifier.notifications[6])
+ self.assertEqual(6, len(self.notifier.notifications),
+ self.notifier.notifications)
self.volume.delete_consistencygroup(self.context, group2_id)
- if len(fake_notifier.NOTIFICATIONS) > 10:
- self.assertFalse(fake_notifier.NOTIFICATIONS[10])
- self.assertEqual(10, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ if len(self.notifier.notifications) > 10:
+ self.assertFalse(self.notifier.notifications[10])
+ self.assertEqual(10, len(self.notifier.notifications),
+ self.notifier.notifications)
- msg = fake_notifier.NOTIFICATIONS[6]
+ msg = self.notifier.notifications[6]
self.assertEqual('consistencygroup.delete.start', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[8]
+ msg = self.notifier.notifications[8]
self.assertEqual('consistencygroup.delete.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
consistencygroup_id=group_id)
cgsnapshot_id = cgsnapshot['id']
- if len(fake_notifier.NOTIFICATIONS) > 2:
- self.assertFalse(fake_notifier.NOTIFICATIONS[2])
- self.assertEqual(2, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ if len(self.notifier.notifications) > 2:
+ self.assertFalse(self.notifier.notifications[2])
+ self.assertEqual(2, len(self.notifier.notifications),
+ self.notifier.notifications)
cgsnapshot_returns = self._create_cgsnapshot(group_id, volume_id)
cgsnapshot_id = cgsnapshot_returns[0]['id']
db.cgsnapshot_get(context.get_admin_context(),
cgsnapshot_id).id)
- if len(fake_notifier.NOTIFICATIONS) > 6:
- self.assertFalse(fake_notifier.NOTIFICATIONS[6])
+ if len(self.notifier.notifications) > 6:
+ self.assertFalse(self.notifier.notifications[6])
- msg = fake_notifier.NOTIFICATIONS[2]
+ msg = self.notifier.notifications[2]
self.assertEqual('cgsnapshot.create.start', msg['event_type'])
expected = {
'created_at': 'DONTCARE',
'consistencygroup_id': group_id
}
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[3]
+ msg = self.notifier.notifications[3]
self.assertEqual('snapshot.create.start', msg['event_type'])
- msg = fake_notifier.NOTIFICATIONS[4]
+ msg = self.notifier.notifications[4]
self.assertEqual('cgsnapshot.create.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[5]
+ msg = self.notifier.notifications[5]
self.assertEqual('snapshot.create.end', msg['event_type'])
- self.assertEqual(6, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(6, len(self.notifier.notifications),
+ self.notifier.notifications)
self.volume.delete_cgsnapshot(self.context, cgsnapshot_id)
- if len(fake_notifier.NOTIFICATIONS) > 10:
- self.assertFalse(fake_notifier.NOTIFICATIONS[10])
+ if len(self.notifier.notifications) > 10:
+ self.assertFalse(self.notifier.notifications[10])
- msg = fake_notifier.NOTIFICATIONS[6]
+ msg = self.notifier.notifications[6]
self.assertEqual('cgsnapshot.delete.start', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
- msg = fake_notifier.NOTIFICATIONS[8]
+ msg = self.notifier.notifications[8]
self.assertEqual('cgsnapshot.delete.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
- self.assertEqual(10, len(fake_notifier.NOTIFICATIONS),
- fake_notifier.NOTIFICATIONS)
+ self.assertEqual(10, len(self.notifier.notifications),
+ self.notifier.notifications)
cgsnap = db.cgsnapshot_get(
context.get_admin_context(read_deleted='yes'),