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
This commit is contained in:
Eric Fried 2019-08-14 14:15:04 -05:00
parent 7bcf8c5a7e
commit 5f412cadbd

View File

@ -30,6 +30,7 @@ import futurist
from keystoneauth1 import adapter as ksa_adap from keystoneauth1 import adapter as ksa_adap
import mock import mock
from neutronclient.common import exceptions as neutron_client_exc from neutronclient.common import exceptions as neutron_client_exc
from openstack import service_description
import os_resource_classes as orc import os_resource_classes as orc
from oslo_concurrency import lockutils from oslo_concurrency import lockutils
from oslo_config import cfg from oslo_config import cfg
@ -2138,5 +2139,16 @@ class OpenStackSDKFixture(fixtures.Fixture):
# https://storyboard.openstack.org/#!/story/2005475 is resolved. # https://storyboard.openstack.org/#!/story/2005475 is resolved.
def setUp(self): def setUp(self):
super(OpenStackSDKFixture, self).setUp() super(OpenStackSDKFixture, self).setUp()
self.useFixture(fixtures.MockPatch( real_make_proxy = service_description.ServiceDescription._make_proxy
'keystoneauth1.adapter.Adapter.get_api_major_version')) _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))