From 5d2f91d9d6f195edceb07cb721f8e82247ac2a63 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 24 May 2020 23:06:08 +0800 Subject: [PATCH] qa/tasks/tempest.py: install python3 for tempest test install python3 for tempest's tox based test otherwise the test would fail if python3.6 or python3.8 is not found. this change is not cherry-picked from master, as our python bindings are now built with python3.6, so python3.6 is always used. it's supported by tempest's test. Signed-off-by: Kefu Chai --- qa/tasks/tempest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/qa/tasks/tempest.py b/qa/tasks/tempest.py index 13189fd54b5e1..2fe49a7ee4611 100644 --- a/qa/tasks/tempest.py +++ b/qa/tasks/tempest.py @@ -8,6 +8,7 @@ from six.moves import configparser from teuthology import misc as teuthology from teuthology import contextutil +from teuthology import packaging from teuthology.exceptions import ConfigError from teuthology.orchestra import run @@ -72,6 +73,26 @@ def download(ctx, config): def get_toxvenv_dir(ctx): return ctx.tox.venv_path +@contextlib.contextmanager +def install_python3(ctx, config): + assert isinstance(config, dict) + log.info('Installing Python3 for Tempest') + installed = [] + for (client, _) in config.items(): + (remote,) = ctx.cluster.only(client).remotes.keys() + try: + packaging.get_package_version(remote, 'python3') + except: + packaging.install_package('python3', remote) + installed.append(client) + try: + yield + finally: + log.info('Removing Python3 required by Tempest...') + for client in installed: + (remote,) = ctx.cluster.only(client).remotes.keys() + packaging.remove_package('python3', remote) + @contextlib.contextmanager def setup_venv(ctx, config): """ @@ -255,6 +276,7 @@ def task(ctx, config): with contextutil.nested( lambda: download(ctx=ctx, config=config), + lambda: install_python3(ctx=ctx, config=config), lambda: setup_venv(ctx=ctx, config=config), lambda: configure_instance(ctx=ctx, config=config), lambda: run_tempest(ctx=ctx, config=config), -- 2.39.5