]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import argparse |
2 | import contextlib | |
3 | import logging | |
4 | ||
5 | from teuthology import misc as teuthology | |
11fdf7f2 TL |
6 | from teuthology.orchestra import run |
7 | ||
8 | log = logging.getLogger(__name__) | |
9 | ||
10 | ||
11 | def get_toxvenv_dir(ctx): | |
12 | return '{tdir}/tox-venv'.format(tdir=teuthology.get_testdir(ctx)) | |
13 | ||
14 | @contextlib.contextmanager | |
15 | def task(ctx, config): | |
16 | """ | |
17 | Deploy tox from pip. It's a dependency for both Keystone and Tempest. | |
18 | """ | |
19 | assert config is None or isinstance(config, list) \ | |
20 | or isinstance(config, dict), \ | |
21 | "task tox only supports a list or dictionary for configuration" | |
22 | all_clients = ['client.{id}'.format(id=id_) | |
23 | for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')] | |
24 | if config is None: | |
25 | config = all_clients | |
26 | if isinstance(config, list): | |
27 | config = dict.fromkeys(config) | |
28 | ||
29 | log.info('Deploying tox from pip...') | |
30 | for (client, _) in config.items(): | |
31 | # yup, we have to deploy tox first. The packaged one, available | |
32 | # on Sepia's Ubuntu machines, is outdated for Keystone/Tempest. | |
33 | tvdir = get_toxvenv_dir(ctx) | |
e306af50 | 34 | ctx.cluster.only(client).run(args=[ 'virtualenv', '-p', 'python3', tvdir ]) |
11fdf7f2 TL |
35 | ctx.cluster.only(client).run(args= |
36 | [ 'source', '{tvdir}/bin/activate'.format(tvdir=tvdir), | |
37 | run.Raw('&&'), | |
e306af50 | 38 | 'pip', 'install', 'tox==3.15.0' |
11fdf7f2 TL |
39 | ]) |
40 | ||
41 | # export the path Keystone and Tempest | |
42 | ctx.tox = argparse.Namespace() | |
43 | ctx.tox.venv_path = get_toxvenv_dir(ctx) | |
44 | ||
45 | try: | |
46 | yield | |
47 | finally: | |
48 | for (client, _) in config.items(): | |
49 | ctx.cluster.only(client).run( | |
50 | args=[ 'rm', '-rf', get_toxvenv_dir(ctx) ]) |