]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/tempest.py: install python3 for tempest test
authorKefu Chai <kchai@redhat.com>
Sun, 24 May 2020 15:06:08 +0000 (23:06 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 3 Jun 2020 11:57:01 +0000 (19:57 +0800)
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 <kchai@redhat.com>
qa/tasks/tempest.py

index 13189fd54b5e1269ed211b1ad450c72e7a9d4cec..2fe49a7ee4611cfe0d56e07e2fe8b2f674978b76 100644 (file)
@@ -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),