From: Casey Bodley Date: Thu, 5 Sep 2019 15:09:26 +0000 (-0400) Subject: qa/keystone: use bindep to discover keystone's dependencies X-Git-Tag: v15.1.0~1525^2~8 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=86930f3e0f7aa7cd8b847bf01a156437e64be0b4;p=ceph-ci.git qa/keystone: use bindep to discover keystone's dependencies downloads the keystone repository first, because we need keystone/bindep.txt to discover the binary dependencies Signed-off-by: Casey Bodley --- diff --git a/qa/tasks/keystone.py b/qa/tasks/keystone.py index 08905216cb4..116a20bf21f 100644 --- a/qa/tasks/keystone.py +++ b/qa/tasks/keystone.py @@ -4,6 +4,7 @@ Deploy and configure Keystone for Teuthology import argparse import contextlib import logging +from cStringIO import StringIO from teuthology import misc as teuthology from teuthology import contextutil @@ -16,42 +17,13 @@ from teuthology.exceptions import ConfigError log = logging.getLogger(__name__) -@contextlib.contextmanager -def install_packages(ctx, config): - """ - Download the packaged dependencies of Keystone. - Remove install packages upon exit. - - The context passed in should be identical to the context - passed in to the main task. - """ - assert isinstance(config, dict) - log.info('Installing packages for Keystone...') - - deps = { - 'deb': [ 'libffi-dev', 'libssl-dev', 'libldap2-dev', 'libsasl2-dev' ], - 'rpm': [ 'libffi-devel', 'openssl-devel' ], - } - for (client, _) in config.items(): - (remote,) = ctx.cluster.only(client).remotes.iterkeys() - for dep in deps[remote.os.package_type]: - install_package(dep, remote) - try: - yield - finally: - log.info('Removing packaged dependencies of Keystone...') - - for (client, _) in config.items(): - (remote,) = ctx.cluster.only(client).remotes.iterkeys() - for dep in deps[remote.os.package_type]: - remove_package(dep, remote) - def get_keystone_dir(ctx): return '{tdir}/keystone'.format(tdir=teuthology.get_testdir(ctx)) -def run_in_keystone_dir(ctx, client, args): - ctx.cluster.only(client).run( +def run_in_keystone_dir(ctx, client, args, **kwargs): + return ctx.cluster.only(client).run( args=[ 'cd', get_keystone_dir(ctx), run.Raw('&&'), ] + args, + **kwargs ) def run_in_keystone_venv(ctx, client, args): @@ -114,6 +86,36 @@ def download(ctx, config): args=[ 'rm', '-rf', keystonedir ], ) +@contextlib.contextmanager +def install_packages(ctx, config): + """ + Download the packaged dependencies of Keystone. + Remove install packages upon exit. + + The context passed in should be identical to the context + passed in to the main task. + """ + assert isinstance(config, dict) + log.info('Installing packages for Keystone...') + + packages = {} + for (client, _) in config.items(): + # use bindep to read which dependencies we need from keystone/bindep.txt + r = run_in_keystone_dir(ctx, client, ['bindep', '-c'], stdout=StringIO()) + packages[client] = r.stdout.getvalue().splitlines() + (remote,) = ctx.cluster.only(client).remotes.iterkeys() + for dep in packages[client]: + install_package(dep, remote) + try: + yield + finally: + log.info('Removing packaged dependencies of Keystone...') + + for (client, _) in config.items(): + (remote,) = ctx.cluster.only(client).remotes.iterkeys() + for dep in packages[client]: + remove_package(dep, remote) + @contextlib.contextmanager def setup_venv(ctx, config): """ @@ -387,8 +389,8 @@ def task(ctx, config): ctx.keystone.admin_endpoints = assign_ports(ctx, config, 35357) with contextutil.nested( - lambda: install_packages(ctx=ctx, config=config), lambda: download(ctx=ctx, config=config), + lambda: install_packages(ctx=ctx, config=config), lambda: setup_venv(ctx=ctx, config=config), lambda: configure_instance(ctx=ctx, config=config), lambda: run_keystone(ctx=ctx, config=config),