From 5f412cadbddb4a985c41372c55161a9f9ca3e4ce Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Wed, 14 Aug 2019 14:15:04 -0500 Subject: [PATCH] Enhance SDK fixture for 0.34.0 As we work out the kinks in openstacksdk to smooth the road for nova's usage thereof, and until openstacksdk can provide opaque fixtures that it can keep up to date as its internals change, we've been needing to stub things out incrementally. This commit more aggressively mocks the piece of openstacksdk that keeps changing under us. It effectively does what [1] does, but without the get_endpoint() sanity check, which blows up in unit/functional test because it tries to do real ksa auth. [1] https://review.opendev.org/#/c/675135/ Change-Id: I1ef2ca51da2dc25026a2fbdcfb1ed5199aaa518b --- nova/tests/fixtures.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 3cee121d2a..80f801cb77 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -30,6 +30,7 @@ import futurist from keystoneauth1 import adapter as ksa_adap import mock from neutronclient.common import exceptions as neutron_client_exc +from openstack import service_description import os_resource_classes as orc from oslo_concurrency import lockutils from oslo_config import cfg @@ -2138,5 +2139,16 @@ class OpenStackSDKFixture(fixtures.Fixture): # https://storyboard.openstack.org/#!/story/2005475 is resolved. def setUp(self): super(OpenStackSDKFixture, self).setUp() - self.useFixture(fixtures.MockPatch( - 'keystoneauth1.adapter.Adapter.get_api_major_version')) + real_make_proxy = service_description.ServiceDescription._make_proxy + _stub_service_types = {'placement'} + + def fake_make_proxy(self, instance): + if self.service_type in _stub_service_types: + return instance.config.get_session_client( + self.service_type, + allow_version_hack=True, + ) + return real_make_proxy(self, instance) + self.useFixture(fixtures.MockPatchObject( + service_description.ServiceDescription, '_make_proxy', + fake_make_proxy))