From 35deeef79839d68f57a492fe5522c106309ce332 Mon Sep 17 00:00:00 2001 From: Fei Long Wang Date: Thu, 28 Jul 2016 11:40:46 +1200 Subject: [PATCH] Fix SSL and verbose issue of zaqar bench Currently, Zaqar bench doesn't pass insecure or cert when build Zaqar client which cause it doesn't work with SSL. This patch fix it and also deprecates the 'verbose' option which is replaced with 'debug'. Closes-Bug: #1607124 Change-Id: I7411b9a310abb5e51f91bac0766a6fe7d684741c --- bench-requirements.txt | 4 ++-- zaqar/bench/conductor.py | 8 ++++---- zaqar/bench/config.py | 3 +++ zaqar/bench/consumer.py | 2 +- zaqar/bench/helpers.py | 23 +++++++++++------------ zaqar/bench/observer.py | 2 +- zaqar/bench/producer.py | 2 +- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/bench-requirements.txt b/bench-requirements.txt index 5cc80afd4..2026a02f2 100644 --- a/bench-requirements.txt +++ b/bench-requirements.txt @@ -1,4 +1,4 @@ gevent>=1.0.1 marktime>=0.2.0 -python-zaqarclient>=0.0.2 -os-client-config!=1.6.2,>=1.4.0 \ No newline at end of file +python-zaqarclient>=1.1.0 +os-client-config>=1.13.1 # Apache-2.0 \ No newline at end of file diff --git a/zaqar/bench/conductor.py b/zaqar/bench/conductor.py index 6feeb2277..fd1b84dc5 100644 --- a/zaqar/bench/conductor.py +++ b/zaqar/bench/conductor.py @@ -30,7 +30,7 @@ from zaqar.bench import producer CONF = config.conf -def _print_verbose_stats(name, stats): +def _print_debug_stats(name, stats): print(name.capitalize()) print('=' * len(name)) @@ -55,7 +55,7 @@ def main(): # clean them up after the performance test, in case # the user wants to examine the state of the system. if not CONF.skip_queue_reset: - if CONF.verbose: + if CONF.debug: print('Resetting queues...') _reset_queues() @@ -74,7 +74,7 @@ def main(): for each_proc in procs: stats.update(downstream_queue.get_nowait()) - if CONF.verbose: + if CONF.debug: print() for name in ('producer', 'observer', 'consumer'): @@ -84,7 +84,7 @@ def main(): if not stats_group['duration_sec']: continue - _print_verbose_stats(name, stats_group) + _print_debug_stats(name, stats_group) else: stats['params'] = { diff --git a/zaqar/bench/config.py b/zaqar/bench/config.py index 49cc28d2a..5d4959d23 100644 --- a/zaqar/bench/config.py +++ b/zaqar/bench/config.py @@ -49,6 +49,9 @@ _CLI_OPTIONS = ( default=5, help='Number of Observer Workers'), + cfg.BoolOpt('debug', default=True, + help=('Tag to indicate if print the details of running.')), + cfg.FloatOpt('api_version', short='api', default='2', help='Zaqar API version to use'), diff --git a/zaqar/bench/consumer.py b/zaqar/bench/consumer.py index 06f7dcdde..9479d1355 100644 --- a/zaqar/bench/consumer.py +++ b/zaqar/bench/consumer.py @@ -152,7 +152,7 @@ def run(upstream_queue): procs = [mp.Process(target=load_generator, args=args) for _ in range(num_procs)] - if CONF.verbose: + if CONF.debug: print('\nStarting consumers (cp={0}, cw={1})...'.format( num_procs, num_workers)) diff --git a/zaqar/bench/helpers.py b/zaqar/bench/helpers.py index 3e1868259..2117008e4 100644 --- a/zaqar/bench/helpers.py +++ b/zaqar/bench/helpers.py @@ -17,7 +17,6 @@ import os import sys import os_client_config -from six.moves import urllib_parse from zaqarclient.queues import client from zaqar.bench import config @@ -46,6 +45,10 @@ def _get_credential_args(): cloud = os_cfg.get_one_cloud() cred_args = cloud.get_auth_args() + cred_args['insecure'] = cloud.auth.get('insecure') + cred_args['cacert'] = cloud.auth.get('cacert') + cred_args['token'] = cloud.auth.get('token') + required_options = ['username', 'password', 'auth_url', 'project_name'] if not all(arg in cred_args for arg in required_options): try: @@ -68,24 +71,20 @@ def _get_credential_args(): def _generate_client_conf(): auth_strategy = os.environ.get('OS_AUTH_STRATEGY', 'noauth') + if auth_strategy == 'keystone': args = _get_credential_args() - # FIXME(flwang): Now we're hardcode the keystone auth version, since - # there is a 'bug' with the osc-config which is returning the auth_url - # without version. This should be fixed as long as the bug is fixed. - parsed_url = urllib_parse.urlparse(args['auth_url']) - auth_url = args['auth_url'] - if not parsed_url.path or parsed_url.path == '/': - auth_url = urllib_parse.urljoin(args['auth_url'], 'v2.0') conf = { 'auth_opts': { 'backend': 'keystone', 'options': { - 'os_username': args['username'], - 'os_password': args['password'], + 'os_username': args.get('username'), + 'os_password': args.get('password'), 'os_project_name': args['project_name'], - 'os_auth_url': auth_url, - 'insecure': '', + 'os_auth_url': args['auth_url'], + 'insecure': args.get('insecure'), + 'cacert': args.get('cacert'), + 'auth_token': args.get('token') }, }, } diff --git a/zaqar/bench/observer.py b/zaqar/bench/observer.py index db8752e72..861eacde4 100644 --- a/zaqar/bench/observer.py +++ b/zaqar/bench/observer.py @@ -148,7 +148,7 @@ def run(upstream_queue): procs = [mp.Process(target=load_generator, args=args) for _ in range(num_procs)] - if CONF.verbose: + if CONF.debug: print('\nStarting observer (op={0}, ow={1})...'.format( num_procs, num_workers)) diff --git a/zaqar/bench/producer.py b/zaqar/bench/producer.py index 248ee52fd..62c5998f7 100644 --- a/zaqar/bench/producer.py +++ b/zaqar/bench/producer.py @@ -158,7 +158,7 @@ def run(upstream_queue): for _ in range(num_procs) ] - if CONF.verbose: + if CONF.debug: print('\nStarting producer (pp={0}, pw={1})...'.format( num_procs, num_workers))