Avoid timeout from service update api unit tests

Since If32bca070185937ef83f689b7163d965a89ec10a some of the service
update api tests are slow because setting a compute enabled or
disabled makes an RPC call to the given compute service. These tests
does not have the proper RPC setup so that call times out. The compute
api only logs an error for the timeout so the tests wasn't failing.

This patch stubs the RPC call as that is not necessary for the
api testing and therefore speeds up the tests.

Change-Id: If0960de896a67fd6bfca230b8915a45cb7af99b7
This commit is contained in:
Balazs Gibizer 2019-08-16 14:23:33 +02:00
parent c7a32709b9
commit 588c513f3d
1 changed files with 6 additions and 0 deletions

View File

@ -195,6 +195,12 @@ class ServicesTestV21(test.TestCase):
self.stub_out('nova.db.api.service_update',
fake_db_service_update(fake_services_list))
# NOTE(gibi): enable / disable a compute service tries to call
# the compute service via RPC to update placement. However in these
# tests the compute services are faked. So stub out the RPC call to
# avoid waiting for the RPC timeout.
self.stub_out("nova.compute.rpcapi.ComputeAPI.set_host_enabled",
lambda *args, **kwargs: None)
self.req = fakes.HTTPRequest.blank('')
self.useFixture(fixtures.SingleCellSimple())