Stop using climate python client for testing blazar API
It's better not to use python-client for API testing in gate since if both server side and client side use the wrong schema and so on, gate test can't detect the error. Change-Id: I87b5fccd6354e3725f615fb67b3eea0083a80407
This commit is contained in:
parent
81b85a11af
commit
5ad2ad4824
@ -23,7 +23,11 @@ service_available_group = cfg.OptGroup(name="service_available",
|
||||
ServiceAvailableGroup = [
|
||||
cfg.BoolOpt("climate",
|
||||
default=True,
|
||||
help="Whether or not climate is expected to be available"),
|
||||
help="Whether or not climate is expected to be available. "
|
||||
"This config remains for backward compatibility."),
|
||||
cfg.BoolOpt("blazar",
|
||||
default=True,
|
||||
help="Whether or not blazar is expected to be available"),
|
||||
]
|
||||
|
||||
resource_reservation_group = cfg.OptGroup(name='resource_reservation',
|
||||
|
@ -13,30 +13,48 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import climateclient.client
|
||||
import json
|
||||
|
||||
from oslo_log import log as logging
|
||||
from tempest import clients as manager
|
||||
from tempest import config_resource_reservation as config
|
||||
from tempest.lib.common import rest_client
|
||||
|
||||
CONF = config.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ResourceReservationManager(manager.OfficialClientManager):
|
||||
"""Manager that provides access to the python climate client."""
|
||||
class ResourceReservationV1Client(rest_client.RestClient):
|
||||
"""Client class for accessing the resource reservation API."""
|
||||
CLIMATECLIENT_VERSION = '1'
|
||||
|
||||
def __init__(self, credentials):
|
||||
self.client_type = 'tempest'
|
||||
self.interface = None
|
||||
# super cares for credentials validation
|
||||
super(ResourceReservationManager, self).__init__(credentials)
|
||||
self.resource_reservation_client = (
|
||||
self._get_resource_reservation_client())
|
||||
lease = '/leases'
|
||||
lease_path = '/leases/%s'
|
||||
host = '/os-hosts'
|
||||
host_path = '/os-hosts/%s'
|
||||
|
||||
def _get_resource_reservation_client(self):
|
||||
climate_url = self.identity_client.service_catalog.url_for(
|
||||
service_type='reservation')
|
||||
token = self.identity_client.auth_token
|
||||
return climateclient.client.Client(self.CLIMATECLIENT_VERSION,
|
||||
climate_url, token)
|
||||
def _response_helper(self, resp, body=None):
|
||||
if body:
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_lease(self):
|
||||
resp, body = self.get(self.lease)
|
||||
return self._response_helper(resp, body)
|
||||
|
||||
def get_lease(self, lease):
|
||||
resp, body = self.get(self.lease_path % lease)
|
||||
return self._response_helper(resp, body)
|
||||
|
||||
def create_lease(self, body):
|
||||
body = json.dumps(body)
|
||||
resp, body = self.post(self.lease, body=body)
|
||||
return self._response_helper(resp, body)
|
||||
|
||||
def update_lease(self, lease, body):
|
||||
body = json.dumps(body)
|
||||
resp, body = self.post(self.lease_path % lease, body=body)
|
||||
return self._response_helper(resp, body)
|
||||
|
||||
def delete_lease(self, lease):
|
||||
resp, body = self.delete(self.lease_path % lease)
|
||||
return self._response_helper(resp, body)
|
||||
|
@ -15,10 +15,12 @@
|
||||
|
||||
|
||||
from oslo_log import log
|
||||
from tempest.common import credentials_factory as credentials
|
||||
from tempest import config_resource_reservation as config
|
||||
from tempest import exceptions
|
||||
from tempest import manager as tempestmanager
|
||||
from tempest import resource_reservation_client_manager as clients
|
||||
from tempest.scenario import manager as clientTest
|
||||
from tempest.scenario import manager
|
||||
import tempest.test
|
||||
|
||||
CONF = config.CONF
|
||||
@ -26,7 +28,7 @@ CONF = config.CONF
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class ResourceReservationScenarioTest(clientTest.OfficialClientTest):
|
||||
class ResourceReservationScenarioTest(manager.ScenarioTest):
|
||||
"""Base class for resource reservation scenario tests."""
|
||||
|
||||
@classmethod
|
||||
@ -35,14 +37,18 @@ class ResourceReservationScenarioTest(clientTest.OfficialClientTest):
|
||||
if not CONF.service_available.climate:
|
||||
raise cls.skipException("Resource reservation support is required")
|
||||
|
||||
creds = cls.credentials()
|
||||
cls.manager = clients.ResourceReservationManager(creds)
|
||||
creds = credentials.get_configured_credentials('identity_admin')
|
||||
auth_prov = tempestmanager.get_auth_provider(creds)
|
||||
cls.manager.reservation_client = (
|
||||
clients.ResourceReservationV1Client(auth_prov,
|
||||
'reservation',
|
||||
CONF.identity.region))
|
||||
cls.resource_reservation_client = (
|
||||
cls.manager.resource_reservation_client)
|
||||
|
||||
def get_lease_by_name(self, lease_name):
|
||||
# the same as the climateclient does it: ask for the entire list
|
||||
lease_list = self.resource_reservation_client.lease.list()
|
||||
lease_list = self.resource_reservation_client.list_lease()
|
||||
named_lease = []
|
||||
|
||||
# and then search by lease_name
|
||||
@ -50,20 +56,20 @@ class ResourceReservationScenarioTest(clientTest.OfficialClientTest):
|
||||
filter(lambda lease: lease['name'] == lease_name, lease_list))
|
||||
|
||||
if named_lease:
|
||||
return self.resource_reservation_client.lease.get(
|
||||
return self.resource_reservation_client.get_lease(
|
||||
named_lease[0]['id'])
|
||||
else:
|
||||
message = "Unable to find lease with name '%s'" % lease_name
|
||||
raise exceptions.NotFound(message)
|
||||
|
||||
def delete_lease(self, lease_id):
|
||||
return self.resource_reservation_client.lease.delete(lease_id)
|
||||
return self.resource_reservation_client.delete_lease(lease_id)
|
||||
|
||||
def wait_for_lease_end(self, lease_id):
|
||||
|
||||
def check_lease_end():
|
||||
try:
|
||||
lease = self.resource_reservation_client.lease.get(lease_id)
|
||||
lease = self.resource_reservation_client.get_lease(lease_id)
|
||||
if lease:
|
||||
events = lease['events']
|
||||
return len(filter(lambda evt:
|
||||
@ -93,3 +99,8 @@ class ResourceReservationScenarioTest(clientTest.OfficialClientTest):
|
||||
except Exception as e:
|
||||
LOG.info("Unable to delete %s snapshot. Exception: %s"
|
||||
% (image_name, e.message))
|
||||
|
||||
def is_flavor_enough(self, flavor_id, image_id):
|
||||
image = self.compute_images_client.show_image(image_id)['image']
|
||||
flavor = self.flavors_client.show_flavor(flavor_id)['flavor']
|
||||
return image['minDisk'] <= flavor['disk']
|
||||
|
@ -21,7 +21,6 @@ from oslo_log import log as logging
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.scenario import resource_reservation_scenario as rrs
|
||||
from tempest.scenario import utils
|
||||
from tempest import test
|
||||
|
||||
CONF = config.CONF
|
||||
@ -58,9 +57,7 @@ class TestResourceReservationScenario(rrs.ResourceReservationScenarioTest):
|
||||
self.image_ref = CONF.compute.image_ref
|
||||
if not hasattr(self, 'flavor_ref'):
|
||||
self.flavor_ref = CONF.compute.flavor_ref
|
||||
self.image_utils = utils.ImageUtils()
|
||||
if not self.image_utils.is_flavor_enough(self.flavor_ref,
|
||||
self.image_ref):
|
||||
if not self.is_flavor_enough(self.flavor_ref, self.image_ref):
|
||||
raise self.skipException(
|
||||
'{image} does not fit in {flavor}'.format(
|
||||
image=self.image_ref, flavor=self.flavor_ref
|
||||
|
Loading…
Reference in New Issue
Block a user