Fix zaqar-bench not working

Currently zaqar-bench do not work with up-to-date Zaqar and
python-zaqarclient.
This happened because Zaqar server moved to version 1.1 and
python-zaqarclient did not.
And also because python-zaqarclient has changed it's default
authentication backend to "keystone".

This patch makes zaqar-bench instantiate each python-zaqarclient's
Client object with Zaqar API version, "X-PROJECT-ID" and 'noauth'
backend specified.

Also to avoid huge code duplication it adds "helpers.py" file which
provides a convenient method to get a new Client object.

Change-Id: If0d905d3d373d145d5c46738d33685c47fe6d425
Closes-Bug: 1518815
This commit is contained in:
Eva Balycheva 2015-11-28 07:42:09 +03:00
parent 5b07797959
commit ac98e6cb12
5 changed files with 39 additions and 9 deletions

View File

@ -17,10 +17,9 @@ from __future__ import print_function
import json
import multiprocessing as mp
from zaqarclient.queues import client
from zaqar.bench import config
from zaqar.bench import consumer
from zaqar.bench import helpers
from zaqar.bench import observer
from zaqar.bench import producer
@ -39,7 +38,7 @@ def _print_verbose_stats(name, stats):
def _reset_queues():
cli = client.Client(CONF.server_url, 1.1)
cli = helpers.get_new_client()
for i in range(CONF.num_queues):
# TODO(kgriffs): DRY up name generation so it is done

View File

@ -24,10 +24,10 @@ from gevent import monkey as curious_george
curious_george.patch_all(thread=False, select=False)
import gevent
import marktime
from zaqarclient.queues import client
from zaqarclient.transport import errors
from zaqar.bench import config
from zaqar.bench import helpers
CONF = config.conf
@ -95,7 +95,7 @@ def claim_delete(queues, stats, test_duration, ttl, grace, limit):
def load_generator(stats, num_workers, num_queues,
test_duration, url, ttl, grace, limit):
cli = client.Client(CONF.server_url)
cli = helpers.get_new_client()
queues = [cli.queue(CONF.queue_prefix + '-' + str(i))
for i in range(num_queues)]

31
zaqar/bench/helpers.py Normal file
View File

@ -0,0 +1,31 @@
# 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 zaqarclient.queues import client
from zaqar.bench import config
CONF = config.conf
client_conf = {
'auth_opts': {
'backend': 'noauth',
'options': {
'os_project_id': 'my-lovely-benchmark',
},
},
}
def get_new_client():
return client.Client(CONF.server_url, 1.1, conf=client_conf)

View File

@ -25,10 +25,10 @@ curious_george.patch_all(thread=False, select=False)
import gevent
import marktime
from six.moves import urllib
from zaqarclient.queues import client
from zaqarclient.transport import errors
from zaqar.bench import config
from zaqar.bench import helpers
CONF = config.conf
@ -99,7 +99,7 @@ def observer(queues, stats, test_duration, limit):
def load_generator(stats, num_workers, num_queues,
test_duration, limit):
cli = client.Client(CONF.server_url)
cli = helpers.get_new_client()
queues = [cli.queue(CONF.queue_prefix + '-' + str(i))
for i in range(num_queues)]

View File

@ -25,10 +25,10 @@ from gevent import monkey as curious_george
curious_george.patch_all(thread=False, select=False)
import gevent
import marktime
from zaqarclient.queues import client
from zaqarclient.transport import errors
from zaqar.bench import config
from zaqar.bench import helpers
CONF = config.conf
@ -104,7 +104,7 @@ def producer(queues, message_pool, stats, test_duration):
# weight them, so can have some busy queues, some not.)
def load_generator(stats, num_workers, num_queues, test_duration):
cli = client.Client(CONF.server_url)
cli = helpers.get_new_client()
queues = [cli.queue(CONF.queue_prefix + '-' + str(i))
for i in range(num_queues)]