Merge "Use tempest-plugin service client registration"

This commit is contained in:
Jenkins 2017-08-03 13:42:22 +00:00 committed by Gerrit Code Review
commit ca3fbef37b
13 changed files with 145 additions and 50 deletions

View File

@ -0,0 +1,32 @@
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
from tempest import config
from tempest.lib.services import clients
CONF = config.CONF
class Clients(clients.ServiceClients):
"""Tempest stable service clients and loaded plugins service clients"""
def __init__(self, credentials, service=None):
"""Emulate the interface of Tempest's clients.Manager"""
# Identity settings
if CONF.identity.auth_version == 'v2':
identity_uri = CONF.identity.uri
else:
identity_uri = CONF.identity.uri_v3
super(Clients, self).__init__(credentials, identity_uri)

View File

@ -16,6 +16,7 @@
import os
from tempest import config
from tempest.test_discover import plugins
from manila_tempest_tests import config as config_share
@ -54,3 +55,21 @@ class ManilaTempestPlugin(plugins.TempestPlugin):
def get_opt_lists(self):
return [(config_share.share_group.name, config_share.ShareGroup),
('service_available', [config_share.service_option])]
def get_service_clients(self):
shares_config = config.service_client_config('share')
v1_params = {
'name': 'share_v1',
'service_version': 'share.v1',
'module_path': 'manila_tempest_tests.services.share.json',
'client_names': ['SharesClient'],
}
v2_params = {
'name': 'share_v2',
'service_version': 'share.v2',
'module_path': 'manila_tempest_tests.services.share.v2',
'client_names': ['SharesV2Client'],
}
v1_params.update(shares_config)
v2_params.update(shares_config)
return [v1_params, v2_params]

View File

@ -0,0 +1,18 @@
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
from manila_tempest_tests.services.share import json as v1
from manila_tempest_tests.services.share.v2 import json as v2
__all__ = ['v1', 'v2']

View File

@ -0,0 +1,17 @@
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
from manila_tempest_tests.services.share.json.shares_client import SharesClient
__all__ = ['SharesClient']

View File

@ -35,18 +35,12 @@ class SharesClient(rest_client.RestClient):
It handles shares and access to it in OpenStack.
"""
def __init__(self, auth_provider):
super(SharesClient, self).__init__(
auth_provider,
CONF.share.catalog_type,
CONF.share.region or CONF.identity.region,
endpoint_type=CONF.share.endpoint_type)
def __init__(self, auth_provider, **kwargs):
super(SharesClient, self).__init__(auth_provider, **kwargs)
self.share_protocol = None
if CONF.share.enable_protocols:
self.share_protocol = CONF.share.enable_protocols[0]
self.share_network_id = CONF.share.share_network_id
self.build_interval = CONF.share.build_interval
self.build_timeout = CONF.share.build_timeout
self.share_size = CONF.share.share_size
def create_share(self, share_protocol=None, size=None,

View File

@ -0,0 +1,18 @@
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
from manila_tempest_tests.services.share.v2.json.shares_client import \
SharesV2Client
__all__ = ['SharesV2Client']

View File

@ -39,8 +39,8 @@ class SharesV2Client(shares_client.SharesClient):
"""
api_version = 'v2'
def __init__(self, auth_provider):
super(SharesV2Client, self).__init__(auth_provider)
def __init__(self, auth_provider, **kwargs):
super(SharesV2Client, self).__init__(auth_provider, **kwargs)
self.API_MICROVERSIONS_HEADER = 'x-openstack-manila-api-version'
def inject_microversion_header(self, headers, version,

View File

@ -430,7 +430,7 @@ class MigrationOppositeDriverModesNFSTest(MigrationBase):
# then we need it for DHSS=True
new_share_network_id = self.provide_share_network(
self.shares_v2_client,
self.os_admin.networks_client,
self.networks_client,
isolated_creds_client=None,
ignore_multitenancy_config=True,
)

View File

@ -21,7 +21,6 @@ import traceback
from oslo_concurrency import lockutils
from oslo_log import log
import six
from tempest import clients
from tempest.common import credentials_factory as common_creds
from tempest import config
@ -30,10 +29,8 @@ from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions
from tempest import test
from manila_tempest_tests import clients
from manila_tempest_tests.common import constants
from manila_tempest_tests.services.share.json import shares_client
from manila_tempest_tests.services.share.v2.json import (
shares_client as shares_v2_client)
from manila_tempest_tests import share_exceptions
from manila_tempest_tests import utils
@ -138,6 +135,10 @@ class BaseSharesTest(test.BaseTestCase):
# Will be cleaned up in tearDown method
method_isolated_creds = []
# NOTE(andreaf) Override the client manager class to be used, so that
# a stable class is used, which includes plugin registered services as well
client_manager = clients.Clients
def skip_if_microversion_not_supported(self, microversion):
if not utils.is_microversion_supported(microversion):
raise self.skipException(
@ -212,11 +213,11 @@ class BaseSharesTest(test.BaseTestCase):
ic.type_of_creds = type_of_creds
# create client with isolated creds
os = clients.Manager(credentials=creds)
os = clients.Clients(creds)
if client_version == '1':
client = shares_client.SharesClient(os.auth_provider)
client = os.share_v1.SharesClient()
elif client_version == '2':
client = shares_v2_client.SharesV2Client(os.auth_provider)
client = os.share_v2.SharesV2Client()
# Set place where will be deleted isolated creds
ic_res = {
@ -233,7 +234,7 @@ class BaseSharesTest(test.BaseTestCase):
if (not CONF.service_available.neutron and
CONF.share.create_networks_when_multitenancy_enabled):
raise cls.skipException("Neutron support is required")
nc = os.networks_client
nc = os.network.NetworksClient()
share_network_id = cls.provide_share_network(client, nc, ic)
client.share_network_id = share_network_id
resource = {
@ -263,7 +264,16 @@ class BaseSharesTest(test.BaseTestCase):
def setup_clients(cls):
super(BaseSharesTest, cls).setup_clients()
os = getattr(cls, 'os_%s' % cls.credentials[0])
os.shares_client = shares_client.SharesClient(os.auth_provider)
# Initialise share clients for test credentials
cls.shares_client = os.share_v1.SharesClient()
cls.shares_v2_client = os.share_v2.SharesV2Client()
# Initialise network clients for test credentials
if CONF.service_available.neutron:
cls.networks_client = os.network.NetworksClient()
cls.subnets_client = os.network.SubnetsClient()
else:
cls.networks_client = None
cls.subnets_client = None
if CONF.identity.auth_version == 'v3':
project_id = os.auth_provider.auth_data[1]['project']['id']
@ -272,16 +282,12 @@ class BaseSharesTest(test.BaseTestCase):
cls.tenant_id = project_id
cls.user_id = os.auth_provider.auth_data[1]['user']['id']
cls.shares_client = os.shares_client
os.shares_v2_client = shares_v2_client.SharesV2Client(
os.auth_provider)
cls.shares_v2_client = os.shares_v2_client
if CONF.share.multitenancy_enabled:
if (not CONF.service_available.neutron and
CONF.share.create_networks_when_multitenancy_enabled):
raise cls.skipException("Neutron support is required")
share_network_id = cls.provide_share_network(
cls.shares_v2_client, os.networks_client)
cls.shares_v2_client, cls.networks_client)
cls.shares_client.share_network_id = share_network_id
cls.shares_v2_client.share_network_id = share_network_id
@ -1046,14 +1052,14 @@ class BaseSharesMixedTest(BaseSharesTest):
@classmethod
def setup_clients(cls):
super(BaseSharesMixedTest, cls).setup_clients()
cls.admin_shares_client = shares_client.SharesClient(
cls.os_admin.auth_provider)
cls.admin_shares_v2_client = shares_v2_client.SharesV2Client(
cls.os_admin.auth_provider)
cls.alt_shares_client = shares_client.SharesClient(
cls.os_alt.auth_provider)
cls.alt_shares_v2_client = shares_v2_client.SharesV2Client(
cls.os_alt.auth_provider)
# Initialise share clients
cls.admin_shares_client = cls.os_admin.share_v1.SharesClient()
cls.admin_shares_v2_client = cls.os_admin.share_v2.SharesV2Client()
cls.alt_shares_client = cls.os_alt.share_v1.SharesClient()
cls.alt_shares_v2_client = cls.os_alt.share_v2.SharesV2Client()
# Initialise network clients
cls.os_admin.networks_client = cls.os_admin.network.NetworksClient()
cls.os_alt.networks_client = cls.os_alt.network.NetworksClient()
if CONF.share.multitenancy_enabled:
admin_share_network_id = cls.provide_share_network(

View File

@ -95,7 +95,7 @@ class SecServicesMappingNegativeTest(base.BaseSharesTest):
not CONF.share.multitenancy_enabled, "Only for multitenancy.")
def test_delete_ss_from_sn_used_by_share_server(self):
sn = self.shares_client.get_share_network(
self.os_primary.shares_client.share_network_id)
self.shares_client.share_network_id)
fresh_sn = self.create_share_network(
neutron_net_id=sn["neutron_net_id"],
neutron_subnet_id=sn["neutron_subnet_id"])

View File

@ -81,7 +81,7 @@ class SecurityServicesNegativeTest(base.BaseSharesTest):
ss = self.create_security_service(**ss_data)
sn = self.shares_client.get_share_network(
self.os_primary.shares_client.share_network_id)
self.shares_client.share_network_id)
fresh_sn = self.create_share_network(
neutron_net_id=sn["neutron_net_id"],
neutron_subnet_id=sn["neutron_subnet_id"])

View File

@ -247,8 +247,7 @@ class ShareNetworksTest(base.BaseSharesTest, ShareNetworkListMixin):
@base.skip_if_microversion_lt("2.18")
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
def test_gateway_with_neutron(self):
os = getattr(self, 'os_%s' % self.credentials[0])
subnet_client = os.subnets_client
subnet_client = self.subnets_client
self.create_share(cleanup_in_class=False)
share_net_details = self.shares_v2_client.get_share_network(
@ -267,8 +266,7 @@ class ShareNetworksTest(base.BaseSharesTest, ShareNetworkListMixin):
@base.skip_if_microversion_lt("2.20")
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
def test_mtu_with_neutron(self):
os = getattr(self, 'os_%s' % self.credentials[0])
network_client = os.networks_client
network_client = self.networks_client
self.create_share(cleanup_in_class=False)
share_net_details = self.shares_v2_client.get_share_network(

View File

@ -21,9 +21,6 @@ from tempest.lib.common.utils import data_utils
from manila_tempest_tests.common import constants
from manila_tempest_tests.common import remote_client
from manila_tempest_tests.services.share.json import shares_client
from manila_tempest_tests.services.share.v2.json import (
shares_client as shares_v2_client)
from manila_tempest_tests.tests.scenario import manager
CONF = config.CONF
@ -41,14 +38,10 @@ class ShareScenarioTest(manager.NetworkScenarioTest):
super(ShareScenarioTest, cls).resource_setup()
# Manila clients
cls.shares_client = shares_client.SharesClient(
cls.os_primary.auth_provider)
cls.shares_v2_client = shares_v2_client.SharesV2Client(
cls.os_primary.auth_provider)
cls.shares_admin_client = shares_client.SharesClient(
cls.os_admin.auth_provider)
cls.shares_admin_v2_client = shares_v2_client.SharesV2Client(
cls.os_admin.auth_provider)
cls.shares_client = cls.os_primary.share_v1.SharesClient()
cls.shares_v2_client = cls.os_primary.share_v2.SharesV2Client()
cls.shares_admin_client = cls.os_admin.share_v1.SharesClient()
cls.shares_admin_v2_client = cls.os_admin.share_v2.SharesV2Client()
@classmethod
def skip_checks(cls):