Adds the Zaqar client
The Zaqar client is required for benchmarking the messaging and notifications service. Change-Id: I763cea5a415185f6571d7a74681d27f63a7357a1
This commit is contained in:
parent
ff21cd43c3
commit
785072d26c
@ -29,6 +29,7 @@ from neutronclient.neutron import client as neutron
|
||||
from novaclient import client as nova
|
||||
from oslo.config import cfg
|
||||
from saharaclient import client as sahara
|
||||
from zaqarclient.queues import client as zaqar
|
||||
|
||||
from rally import consts
|
||||
from rally import exceptions
|
||||
@ -51,6 +52,7 @@ nova._adapter_pool = lambda x: nova.adapters.HTTPAdapter()
|
||||
|
||||
def cached(func):
|
||||
"""Cache client handles."""
|
||||
|
||||
def wrapper(self, *args, **kwargs):
|
||||
key = '{0}{1}{2}'.format(func.__name__,
|
||||
str(args) if args else '',
|
||||
@ -60,6 +62,7 @@ def cached(func):
|
||||
return self.cache[key]
|
||||
self.cache[key] = func(self, *args, **kwargs)
|
||||
return self.cache[key]
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@ -251,6 +254,25 @@ class Clients(object):
|
||||
|
||||
return client
|
||||
|
||||
@cached
|
||||
def zaqar(self):
|
||||
"""Return Zaqar client."""
|
||||
kc = self.keystone()
|
||||
messaging_api_url = kc.service_catalog.url_for(
|
||||
service_type='messaging', endpoint_type='public',
|
||||
region_name=self.endpoint.region_name)
|
||||
conf = {'auth_opts': {'backend': 'keystone', 'options': {
|
||||
'os_username': self.endpoint.username,
|
||||
'os_password': self.endpoint.password,
|
||||
'os_project_name': self.endpoint.tenant_name,
|
||||
'os_auth_url': self.endpoint.auth_url,
|
||||
'insecure': CONF.https_insecure,
|
||||
}}}
|
||||
client = zaqar.Client(url=messaging_api_url,
|
||||
version='1.1',
|
||||
conf=conf)
|
||||
return client
|
||||
|
||||
@cached
|
||||
def designate(self):
|
||||
"""Return designate client."""
|
||||
|
@ -24,6 +24,7 @@ python-heatclient>=0.2.9
|
||||
python-ceilometerclient>=1.0.6
|
||||
python-ironicclient>=0.2.1
|
||||
python-saharaclient>=0.7.3
|
||||
python-zaqarclient>=0.0.3
|
||||
python-subunit>=0.0.18
|
||||
requests>=1.2.1,!=2.4.0
|
||||
SQLAlchemy>=0.8.4,<=0.8.99,>=0.9.7,<=0.9.99
|
||||
|
@ -1042,6 +1042,12 @@ class FakeSaharaClient(object):
|
||||
self.node_group_templates.list.side_effect = [[mock_with_id], []]
|
||||
|
||||
|
||||
class FakeZaqarClient(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
class FakeClients(object):
|
||||
|
||||
def __init__(self, endpoint_=None):
|
||||
@ -1054,6 +1060,7 @@ class FakeClients(object):
|
||||
self._heat = None
|
||||
self._designate = None
|
||||
self._ceilometer = None
|
||||
self._zaqar = None
|
||||
self._endpoint = endpoint_ or endpoint.Endpoint(
|
||||
"http://fake.example.org:5000/v2.0/",
|
||||
"fake_username",
|
||||
@ -1108,6 +1115,11 @@ class FakeClients(object):
|
||||
self._ceilometer = FakeCeilometerClient()
|
||||
return self._ceilometer
|
||||
|
||||
def zaqar(self):
|
||||
if not self._zaqar:
|
||||
self._zaqar = FakeZaqarClient()
|
||||
return self._zaqar
|
||||
|
||||
|
||||
class FakeRunner(object):
|
||||
|
||||
|
@ -210,6 +210,29 @@ class OSClientsTestCase(test.TestCase):
|
||||
mock_sahara.Client.assert_called_once_with("1.1", **kw)
|
||||
self.assertEqual(self.clients.cache["sahara"], fake_sahara)
|
||||
|
||||
@mock.patch("rally.osclients.zaqar")
|
||||
def test_zaqar(self, mock_zaqar):
|
||||
fake_zaqar = fakes.FakeZaqarClient()
|
||||
mock_zaqar.Client = mock.MagicMock(return_value=fake_zaqar)
|
||||
self.assertTrue("zaqar" not in self.clients.cache)
|
||||
client = self.clients.zaqar()
|
||||
self.assertEqual(client, fake_zaqar)
|
||||
self.service_catalog.url_for.assert_called_once_with(
|
||||
service_type='messaging', endpoint_type='public',
|
||||
region_name=self.endpoint.region_name)
|
||||
fake_zaqar_url = self.service_catalog.url_for.return_value
|
||||
conf = {'auth_opts': {'backend': 'keystone', 'options': {
|
||||
'os_username': self.endpoint.username,
|
||||
'os_password': self.endpoint.password,
|
||||
'os_project_name': self.endpoint.tenant_name,
|
||||
'os_auth_url': self.endpoint.auth_url,
|
||||
'insecure': cfg.CONF.https_insecure,
|
||||
}}}
|
||||
mock_zaqar.Client.assert_called_once_with(url=fake_zaqar_url,
|
||||
version="1.1",
|
||||
conf=conf)
|
||||
self.assertEqual(self.clients.cache["zaqar"], fake_zaqar)
|
||||
|
||||
@mock.patch("rally.osclients.Clients.keystone")
|
||||
def test_services(self, mock_keystone):
|
||||
available_services = {consts.ServiceType.IDENTITY: {},
|
||||
|
Loading…
x
Reference in New Issue
Block a user