summaryrefslogtreecommitdiff
path: root/nova/tests/unit/compute
diff options
context:
space:
mode:
Diffstat (limited to 'nova/tests/unit/compute')
-rw-r--r--nova/tests/unit/compute/test_compute_mgr.py6
-rw-r--r--nova/tests/unit/compute/test_resource_tracker.py17
2 files changed, 21 insertions, 2 deletions
diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py
index 3a8fa207db..282f2ee506 100644
--- a/nova/tests/unit/compute/test_compute_mgr.py
+++ b/nova/tests/unit/compute/test_compute_mgr.py
@@ -373,18 +373,20 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase,
)
# First node in set should have been removed from DB
+ # Last node in set should have been added to DB.
for db_node in db_nodes:
if db_node.hypervisor_hostname == 'node1':
db_node.destroy.assert_called_once_with()
rc_mock.delete_resource_provider.assert_called_once_with(
self.context, db_node, cascade=True)
- mock_rt.remove_node.assert_called_once_with(
- 'node1')
+ mock_rt.remove_node.assert_called_once_with('node1')
mock_log.error.assert_called_once_with(
"Failed to delete compute node resource provider for "
"compute node %s: %s", db_node.uuid, mock.ANY)
else:
self.assertFalse(db_node.destroy.called)
+ self.assertEqual(1, mock_rt.remove_node.call_count)
+ mock_rt.clean_compute_node_cache.assert_called_once_with(db_nodes)
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
'delete_resource_provider')
diff --git a/nova/tests/unit/compute/test_resource_tracker.py b/nova/tests/unit/compute/test_resource_tracker.py
index 947e281b98..147a02bc90 100644
--- a/nova/tests/unit/compute/test_resource_tracker.py
+++ b/nova/tests/unit/compute/test_resource_tracker.py
@@ -4177,3 +4177,20 @@ class ProviderConfigTestCases(BaseTestCase):
mock_log.warning.assert_called_once_with(*expected_log_call)
self.assertIn(uuids.unknown, self.rt.absent_providers)
self.assertEqual(result, [])
+
+
+class TestCleanComputeNodeCache(BaseTestCase):
+
+ def setUp(self):
+ super(TestCleanComputeNodeCache, self).setUp()
+ self._setup_rt()
+ self.context = context.RequestContext(
+ mock.sentinel.user_id, mock.sentinel.project_id)
+
+ @mock.patch.object(resource_tracker.ResourceTracker, "remove_node")
+ def test_clean_compute_node_cache(self, mock_remove):
+ invalid_nodename = "invalid-node"
+ self.rt.compute_nodes[_NODENAME] = self.compute
+ self.rt.compute_nodes[invalid_nodename] = mock.sentinel.compute
+ self.rt.clean_compute_node_cache([self.compute])
+ mock_remove.assert_called_once_with(invalid_nodename)