Set a default region for clients
Clients initialized for tests.api.* tests do not have defined values for region [1]. Because of that the clients connect to the first available service endpoint that they find (see this line in tempest [2]). This can cause issues when there are multiple endpoints on a system for barbican (admin, internal, public). This change sets a default value for key_manager.region config option to 'regionOne' and ensures that clients defined on the side of barbican-tempest-plugin are intialised with this value. [1] https://opendev.org/openstack/barbican-tempest-plugin/src/branch/master/barbican_tempest_plugin/tests/api/base.py#L91 [2] https://opendev.org/openstack/tempest/src/branch/master/tempest/lib/auth.py#L586 Change-Id: Ic9ae00c663cca6b83dc961b984cf129d1c33afc4
This commit is contained in:
parent
30e50ef9c8
commit
b18a6bf265
@ -43,7 +43,12 @@ KeyManagerOpts = [
|
|||||||
"min_microversion and max_microversion. "
|
"min_microversion and max_microversion. "
|
||||||
"If both values are not specified, Tempest avoids tests "
|
"If both values are not specified, Tempest avoids tests "
|
||||||
"which require a microversion. Valid values are string "
|
"which require a microversion. Valid values are string "
|
||||||
"with format 'X.Y' or string 'latest'")
|
"with format 'X.Y' or string 'latest'"),
|
||||||
|
cfg.StrOpt('region',
|
||||||
|
default='regionOne',
|
||||||
|
help="The barbican region name to use. If no such region is"
|
||||||
|
"found in the service catalog, the first found one is "
|
||||||
|
"used.")
|
||||||
]
|
]
|
||||||
|
|
||||||
barbican_tempest_group = cfg.OptGroup(
|
barbican_tempest_group = cfg.OptGroup(
|
||||||
|
@ -9,10 +9,13 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
from tempest import config
|
||||||
from tempest.lib.common import rest_client
|
from tempest.lib.common import rest_client
|
||||||
|
|
||||||
|
CONF = config.CONF
|
||||||
|
|
||||||
_DEFAULT_SERVICE_TYPE = 'key-manager'
|
_DEFAULT_SERVICE_TYPE = 'key-manager'
|
||||||
|
_DEFAULT_REGION = CONF.key_manager.region
|
||||||
_MICROVERSION_HEADER = 'OpenStack-API-Version'
|
_MICROVERSION_HEADER = 'OpenStack-API-Version'
|
||||||
|
|
||||||
|
|
||||||
@ -22,6 +25,7 @@ class BarbicanTempestClient(rest_client.RestClient):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs['service'] = _DEFAULT_SERVICE_TYPE
|
kwargs['service'] = _DEFAULT_SERVICE_TYPE
|
||||||
|
kwargs['region'] = _DEFAULT_REGION
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def get_headers(self, accept_type=None, send_type=None):
|
def get_headers(self, accept_type=None, send_type=None):
|
||||||
|
@ -81,22 +81,16 @@ class BaseKeyManagerTest(test.BaseTestCase,
|
|||||||
def setup_clients(cls):
|
def setup_clients(cls):
|
||||||
super(BaseKeyManagerTest, cls).setup_clients()
|
super(BaseKeyManagerTest, cls).setup_clients()
|
||||||
os = getattr(cls, 'os_%s' % cls.credentials[0])
|
os = getattr(cls, 'os_%s' % cls.credentials[0])
|
||||||
cls.consumer_client = os.secret_v1.ConsumerClient(
|
cls.consumer_client = os.secret_v1.ConsumerClient()
|
||||||
service='key-manager'
|
cls.container_client = os.secret_v1.ContainerClient()
|
||||||
)
|
cls.order_client = os.secret_v1.OrderClient()
|
||||||
cls.container_client = os.secret_v1.ContainerClient(
|
cls.secret_client = os.secret_v1.SecretClient()
|
||||||
service='key-manager'
|
|
||||||
)
|
|
||||||
cls.order_client = os.secret_v1.OrderClient(service='key-manager')
|
|
||||||
cls.secret_client = os.secret_v1.SecretClient(service='key-manager')
|
|
||||||
cls.secret_consumer_client = os.secret_v1_1.SecretConsumerClient()
|
cls.secret_consumer_client = os.secret_v1_1.SecretConsumerClient()
|
||||||
cls.secret_metadata_client = os.secret_v1.SecretMetadataClient(
|
cls.secret_metadata_client = os.secret_v1.SecretMetadataClient()
|
||||||
service='key-manager'
|
|
||||||
)
|
|
||||||
cls.version_client = os.secret_v1_1.VersionClient()
|
cls.version_client = os.secret_v1_1.VersionClient()
|
||||||
|
|
||||||
os = getattr(cls, 'os_roles_%s' % cls.credentials[1][0])
|
os = getattr(cls, 'os_roles_%s' % cls.credentials[1][0])
|
||||||
cls.quota_client = os.secret_v1.QuotaClient(service='key-manager')
|
cls.quota_client = os.secret_v1.QuotaClient()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_credentials(cls):
|
def setup_credentials(cls):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user