diff options
author | MatthewLi <matthew.lijun@huawei.com> | 2017-03-27 08:17:55 -0400 |
---|---|---|
committer | MatthewLi <matthew.lijun@huawei.com> | 2017-03-29 02:05:14 -0400 |
commit | 3ce7ad6a2f98268cd89a32f9fe083529b947bce5 (patch) | |
tree | eeebac16d8bb28f00d4c235f0fb08f94e58c0ddb | |
parent | 223806ad2a5d60c9909f32f35b8cea16bf703a69 (diff) |
dovetail tool: offline support
JIRA: DOVETAIL-164
usage:
dovetail run --testsuite <testsuite> --offline
1,if --offline given, can run offline by using local docker images
(if there is no images, will get an error in log, images can be
pulled from dockerhub or downloaded from artifacts.opnfv.org )
2,if --offline not given, will run online, which means
pull docker image from dockerhub
Change-Id: I87ab35c82e59fb13a7a88c38d233e89285efc4d3
Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
-rw-r--r-- | dovetail/conf/cmd_config.yml | 5 | ||||
-rw-r--r-- | dovetail/container.py | 6 | ||||
-rwxr-xr-x | dovetail/run.py | 5 | ||||
-rw-r--r-- | dovetail/test_runner.py | 12 | ||||
-rw-r--r-- | requirements.txt | 3 | ||||
-rw-r--r-- | setup.py | 2 |
6 files changed, 29 insertions, 4 deletions
diff --git a/dovetail/conf/cmd_config.yml b/dovetail/conf/cmd_config.yml index c0da5113..da8c4732 100644 --- a/dovetail/conf/cmd_config.yml +++ b/dovetail/conf/cmd_config.yml @@ -58,3 +58,8 @@ cli: - '--report' - '-r' help: 'push results to DB (e.g. --report http://192.168.135.2:8000/api/v1)' + offline: + flags: + - '--offline' + is_flag: 'True' + help: 'run in offline method, which means not to update the docker upstream images, functest, yardstick, etc.' diff --git a/dovetail/container.py b/dovetail/container.py index bfdbeb94..878b21cb 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -187,6 +187,12 @@ class Container(object): return 0 @classmethod + def check_image_exist(cls, validate_type): + docker_image = cls.get_docker_image(validate_type) + image_id = cls.get_image_id(docker_image) + return image_id + + @classmethod def clean(cls, container_id): cmd1 = 'sudo docker stop %s' % (container_id) dt_utils.exec_cmd(cmd1, cls.logger) diff --git a/dovetail/run.py b/dovetail/run.py index 17d7edf4..2a2c5677 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -171,6 +171,11 @@ def main(*args, **kwargs): if kwargs['report']: dt_cfg.dovetail_config['report_dest'] = kwargs['report'] + if kwargs['offline']: + dt_cfg.dovetail_config['offline'] = True + else: + dt_cfg.dovetail_config['offline'] = False + testarea = kwargs['testarea'] testsuite_validation = False testarea_validation = False diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py index 537fdec8..ea58768c 100644 --- a/dovetail/test_runner.py +++ b/dovetail/test_runner.py @@ -29,8 +29,16 @@ class DockerRunner(object): cls.logger = dt_logger.Logger(__name__ + '.DockerRunner').getLogger() def run(self): - Container.pull_image(self.testcase.validate_type()) - container_id = Container.create(self.testcase.validate_type()) + if dt_cfg.dovetail_config['offline']: + exist = Container.check_image_exist(self.testcase.validate_type()) + if not exist: + self.logger.error('%s image not exist offline running', + self.testcase.validate_type()) + return + container_id = Container.create(self.testcase.validate_type()) + else: + Container.pull_image(self.testcase.validate_type()) + container_id = Container.create(self.testcase.validate_type()) if not container_id: self.logger.error('failed to create container') return diff --git a/requirements.txt b/requirements.txt index ae643222..e6369598 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ Click Jinja2==2.8 -pbr>=2.0.0 +pbr==2.0.0 PyYAML==3.11 python-openstackclient==3.9.0 requests==2.10.0 six==1.10.0 +stevedore==1.20.0 @@ -10,5 +10,5 @@ import setuptools setuptools.setup( - setup_requires=['pbr>=2.0.0'], + setup_requires=['pbr==2.0.0'], pbr=True) |