diff options
author | Stephen Finucane <stephenfin@redhat.com> | 2021-04-01 17:49:02 +0100 |
---|---|---|
committer | Stephen Finucane <stephenfin@redhat.com> | 2021-08-09 15:34:40 +0100 |
commit | 100b9dc62c0ec9f7b38739837c06646122c818d5 (patch) | |
tree | 461ffc78155a8ff058796c522b983a47a946717e /nova/tests/unit/compute/test_host_api.py | |
parent | 84b61790763f91e12eebb96d955e2f83abc00d56 (diff) | |
download | nova-100b9dc62c0ec9f7b38739837c06646122c818d5.tar.gz |
db: Unify 'nova.db.api', 'nova.db.sqlalchemy.api'
Merge these, removing an unnecessary layer of abstraction, and place
them in the new 'nova.db.main' directory. The resulting change is huge,
but it's mainly the result of 's/sqlalchemy import api/main import api/'
and 's/nova.db.api/nova.db.main.api/' with some necessary cleanup. We
also need to rework how we do the blocking of API calls since we no
longer have a 'DBAPI' object that we can monkey patch as we were doing
before. This is now done via a global variable that is set by the 'main'
function of 'nova.cmd.compute'.
The main impact of this change is that it's no longer possible to set
'[database] use_db_reconnect' and have all APIs automatically wrapped in
a DB retry. Seeing as this behavior is experimental, isn't applied to
any of the API DB methods (which don't use oslo.db's 'DBAPI' helper),
and is used explicitly in what would appear to be the critical cases
(via the explicit 'oslo_db.api.wrap_db_retry' decorator), this doesn't
seem like a huge loss.
Change-Id: Iad2e4da4546b80a016e477577d23accb2606a6e4
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Diffstat (limited to 'nova/tests/unit/compute/test_host_api.py')
-rw-r--r-- | nova/tests/unit/compute/test_host_api.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/nova/tests/unit/compute/test_host_api.py b/nova/tests/unit/compute/test_host_api.py index 96b41dab1c..e4c310deb0 100644 --- a/nova/tests/unit/compute/test_host_api.py +++ b/nova/tests/unit/compute/test_host_api.py @@ -102,7 +102,7 @@ class ComputeHostAPITestCase(test.TestCase): _do_test() - @mock.patch('nova.db.api.service_get_by_compute_host') + @mock.patch('nova.db.main.api.service_get_by_compute_host') def test_get_host_uptime_service_down( self, mock_get_service_get_by_compute_host, ): @@ -229,7 +229,7 @@ class ComputeHostAPITestCase(test.TestCase): None, set_zones=False) mock_get_hm.assert_called_once_with(self.ctxt, cells[1].id) - @mock.patch('nova.db.api.service_get_all') + @mock.patch('nova.db.main.api.service_get_all') def test_service_get_all_no_zones(self, mock_service_get_all): services = [dict(test_service.fake_service, id=1, topic='compute', host='host1'), @@ -258,7 +258,7 @@ class ComputeHostAPITestCase(test.TestCase): disabled=None) self._compare_objs(result, [services[1]]) - @mock.patch('nova.db.api.service_get_all') + @mock.patch('nova.db.main.api.service_get_all') def test_service_get_all(self, mock_service_get_all): services = [dict(test_service.fake_service, topic='compute', host='host1'), @@ -305,7 +305,7 @@ class ComputeHostAPITestCase(test.TestCase): self._compare_objs(result, exp_services) @mock.patch( - 'nova.db.api.service_get_by_compute_host', + 'nova.db.main.api.service_get_by_compute_host', return_value=test_service.fake_service) def test_service_get_by_compute_host( self, mock_service_get_by_compute_host, @@ -314,8 +314,8 @@ class ComputeHostAPITestCase(test.TestCase): self.ctxt, 'fake-host') self.assertEqual(test_service.fake_service['id'], result.id) - @mock.patch('nova.db.api.service_get_by_host_and_binary') - @mock.patch('nova.db.api.service_update') + @mock.patch('nova.db.main.api.service_get_by_host_and_binary') + @mock.patch('nova.db.main.api.service_update') def test_service_update_by_host_and_binary( self, mock_service_update, mock_service_get_by_host_and_binary, ): @@ -397,7 +397,8 @@ class ComputeHostAPITestCase(test.TestCase): 'fake-host') self.assertEqual(['fake-responses'], result) - @mock.patch('nova.db.api.task_log_get_all', return_value='fake-response') + @mock.patch( + 'nova.db.main.api.task_log_get_all', return_value='fake-response') def test_task_log_get_all(self, mock_task_log_get_all): result = self.host_api.task_log_get_all(self.ctxt, 'fake-name', 'fake-begin', 'fake-end', @@ -487,7 +488,7 @@ class ComputeHostAPITestCase(test.TestCase): mock_remove_host.assert_called_once_with( mock.ANY, aggregate.uuid, 'fake-compute-host') - @mock.patch('nova.db.api.compute_node_statistics') + @mock.patch('nova.db.main.api.compute_node_statistics') def test_compute_node_statistics(self, mock_cns): # Note this should only be called twice mock_cns.side_effect = [ |