add cinder v2 api tests for volume_services
Partially implements: blueprint cinder-v2-api-tests Change-Id: I1df5ae89f6493c42d00fcf5c1092a1e5c0671b99
This commit is contained in:
parent
bcb3a82148
commit
9f12382b04
@ -17,7 +17,7 @@ from tempest.api.volume import base
|
||||
from tempest import test
|
||||
|
||||
|
||||
class VolumesServicesTestJSON(base.BaseVolumeV1AdminTest):
|
||||
class VolumesServicesV2TestJSON(base.BaseVolumeAdminTest):
|
||||
"""
|
||||
Tests Volume Services API.
|
||||
volume service list requires admin privileges.
|
||||
@ -26,21 +26,20 @@ class VolumesServicesTestJSON(base.BaseVolumeV1AdminTest):
|
||||
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(VolumesServicesTestJSON, cls).resource_setup()
|
||||
cls.client = cls.os_adm.volume_services_client
|
||||
_, cls.services = cls.client.list_services()
|
||||
super(VolumesServicesV2TestJSON, cls).resource_setup()
|
||||
_, cls.services = cls.admin_volume_services_client.list_services()
|
||||
cls.host_name = cls.services[0]['host']
|
||||
cls.binary_name = cls.services[0]['binary']
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_list_services(self):
|
||||
_, services = self.client.list_services()
|
||||
_, services = self.admin_volume_services_client.list_services()
|
||||
self.assertNotEqual(0, len(services))
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_get_service_by_service_binary_name(self):
|
||||
params = {'binary': self.binary_name}
|
||||
_, services = self.client.list_services(params)
|
||||
_, services = self.admin_volume_services_client.list_services(params)
|
||||
self.assertNotEqual(0, len(services))
|
||||
for service in services:
|
||||
self.assertEqual(self.binary_name, service['binary'])
|
||||
@ -51,7 +50,7 @@ class VolumesServicesTestJSON(base.BaseVolumeV1AdminTest):
|
||||
service['host'] == self.host_name]
|
||||
params = {'host': self.host_name}
|
||||
|
||||
_, services = self.client.list_services(params)
|
||||
_, services = self.admin_volume_services_client.list_services(params)
|
||||
|
||||
# we could have a periodic job checkin between the 2 service
|
||||
# lookups, so only compare binary lists.
|
||||
@ -65,7 +64,11 @@ class VolumesServicesTestJSON(base.BaseVolumeV1AdminTest):
|
||||
def test_get_service_by_service_and_host_name(self):
|
||||
params = {'host': self.host_name, 'binary': self.binary_name}
|
||||
|
||||
_, services = self.client.list_services(params)
|
||||
_, services = self.admin_volume_services_client.list_services(params)
|
||||
self.assertEqual(1, len(services))
|
||||
self.assertEqual(self.host_name, services[0]['host'])
|
||||
self.assertEqual(self.binary_name, services[0]['binary'])
|
||||
|
||||
|
||||
class VolumesServicesV1TestJSON(VolumesServicesV2TestJSON):
|
||||
_api_version = 1
|
||||
|
@ -170,6 +170,8 @@ class BaseVolumeAdminTest(BaseVolumeTest):
|
||||
msg = "Volume API v1 is disabled"
|
||||
raise cls.skipException(msg)
|
||||
cls.volume_qos_client = cls.os_adm.volume_qos_client
|
||||
cls.admin_volume_services_client = \
|
||||
cls.os_adm.volume_services_client
|
||||
cls.volume_types_client = cls.os_adm.volume_types_client
|
||||
cls.admin_volume_client = cls.os_adm.volumes_client
|
||||
cls.hosts_client = cls.os_adm.volume_hosts_client
|
||||
@ -181,6 +183,8 @@ class BaseVolumeAdminTest(BaseVolumeTest):
|
||||
msg = "Volume API v2 is disabled"
|
||||
raise cls.skipException(msg)
|
||||
cls.volume_qos_client = cls.os_adm.volume_qos_v2_client
|
||||
cls.admin_volume_services_client = \
|
||||
cls.os_adm.volume_services_v2_client
|
||||
cls.volume_types_client = cls.os_adm.volume_types_v2_client
|
||||
cls.admin_volume_client = cls.os_adm.volumes_v2_client
|
||||
cls.hosts_client = cls.os_adm.volume_hosts_v2_client
|
||||
|
@ -140,6 +140,8 @@ from tempest.services.volume.v2.json.admin.volume_hosts_client import \
|
||||
VolumeHostsV2ClientJSON
|
||||
from tempest.services.volume.v2.json.admin.volume_quotas_client import \
|
||||
VolumeQuotasV2Client
|
||||
from tempest.services.volume.v2.json.admin.volume_services_client import \
|
||||
VolumesServicesV2ClientJSON
|
||||
from tempest.services.volume.v2.json.admin.volume_types_client import \
|
||||
VolumeTypesV2ClientJSON
|
||||
from tempest.services.volume.v2.json.availability_zone_client import \
|
||||
@ -289,6 +291,8 @@ class Manager(manager.Manager):
|
||||
self.volume_qos_client = QosSpecsClientJSON(self.auth_provider)
|
||||
self.volume_qos_v2_client = QosSpecsV2ClientJSON(
|
||||
self.auth_provider)
|
||||
self.volume_services_v2_client = VolumesServicesV2ClientJSON(
|
||||
self.auth_provider)
|
||||
|
||||
def _set_volume_json_clients(self):
|
||||
self.backups_client = BackupsClientJSON(self.auth_provider)
|
||||
|
@ -22,10 +22,10 @@ from tempest import config
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class VolumesServicesClientJSON(rest_client.RestClient):
|
||||
class BaseVolumesServicesClientJSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(VolumesServicesClientJSON, self).__init__(auth_provider)
|
||||
super(BaseVolumesServicesClientJSON, self).__init__(auth_provider)
|
||||
self.service = CONF.volume.catalog_type
|
||||
|
||||
def list_services(self, params=None):
|
||||
@ -37,3 +37,7 @@ class VolumesServicesClientJSON(rest_client.RestClient):
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return resp, body['services']
|
||||
|
||||
|
||||
class VolumesServicesClientJSON(BaseVolumesServicesClientJSON):
|
||||
"""Volume V1 volume services client"""
|
||||
|
@ -0,0 +1,26 @@
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.services.volume.json.admin import volume_services_client as vs_cli
|
||||
|
||||
|
||||
class VolumesServicesV2ClientJSON(vs_cli.BaseVolumesServicesClientJSON):
|
||||
"""
|
||||
Client class to send CRUD Volume V2 API requests to a Cinder endpoint
|
||||
"""
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(VolumesServicesV2ClientJSON, self).__init__(auth_provider)
|
||||
self.api_version = "v2"
|
Loading…
Reference in New Issue
Block a user