summaryrefslogtreecommitdiff
path: root/nova/tests/unit/test_context.py
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2017-02-24 06:19:13 -0800
committerDan Smith <dansmith@redhat.com>2017-03-10 07:00:32 -0800
commit159062882ec1a004cc62fffc9c426c5a5e533e15 (patch)
treebf8f1a7d077baa4cc13f20275fea65218586044b /nova/tests/unit/test_context.py
parent4cd8ab5bdc6914aaa53c094b5582403dbc511be8 (diff)
downloadnova-159062882ec1a004cc62fffc9c426c5a5e533e15.tar.gz
Change MQ targeting to honor only what is in the context
Previously we had aimed to make things like compute RPC automatically look up the InstanceMapping or HostMapping for the call being performed to target appropriately. However, we cannot do that within the cell, and even trying incurs some overhead. For now, just deprecate the by_instance() and by_host() methods and honor what is in the context (if set) and otherwise fall back to the default client. Make the context target routines create and store the RPC transport and remove the caching logic from the ClientRouter since we're removing its ability to do that. Related to blueprint cells-aware-api Change-Id: I10f374adca672576058c4dbab708c040d166df47
Diffstat (limited to 'nova/tests/unit/test_context.py')
-rw-r--r--nova/tests/unit/test_context.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/nova/tests/unit/test_context.py b/nova/tests/unit/test_context.py
index 33d72f7d7c..f1f2544194 100644
--- a/nova/tests/unit/test_context.py
+++ b/nova/tests/unit/test_context.py
@@ -290,18 +290,24 @@ class ContextTestCase(test.NoDBTestCase):
mock_authorize.assert_called_once_with(ctxt, mock.sentinel.rule,
mock.sentinel.target)
+ @mock.patch('nova.rpc.create_transport')
@mock.patch('nova.db.create_context_manager')
- def test_target_cell(self, mock_create_ctxt_mgr):
- mock_create_ctxt_mgr.return_value = mock.sentinel.cm
+ def test_target_cell(self, mock_create_ctxt_mgr, mock_rpc):
+ mock_create_ctxt_mgr.return_value = mock.sentinel.cdb
+ mock_rpc.return_value = mock.sentinel.cmq
ctxt = context.RequestContext('111',
'222',
roles=['admin', 'weasel'])
# Verify the existing db_connection, if any, is restored
ctxt.db_connection = mock.sentinel.db_conn
- mapping = objects.CellMapping(database_connection='fake://')
+ ctxt.mq_connection = mock.sentinel.mq_conn
+ mapping = objects.CellMapping(database_connection='fake://',
+ transport_url='fake://')
with context.target_cell(ctxt, mapping):
- self.assertEqual(ctxt.db_connection, mock.sentinel.cm)
+ self.assertEqual(ctxt.db_connection, mock.sentinel.cdb)
+ self.assertEqual(ctxt.mq_connection, mock.sentinel.cmq)
self.assertEqual(mock.sentinel.db_conn, ctxt.db_connection)
+ self.assertEqual(mock.sentinel.mq_conn, ctxt.mq_connection)
def test_get_context(self):
ctxt = context.get_context()