summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dovetail/container.py45
-rw-r--r--dovetail/test_runner.py7
-rw-r--r--dovetail/utils/dovetail_utils.py17
-rw-r--r--etc/conf/functest_config.yml2
-rw-r--r--etc/testcase/sdnvpn.tc000.yml1
-rw-r--r--etc/testcase/sdnvpn.tc001.yml1
-rw-r--r--etc/testcase/sdnvpn.tc002.yml1
-rw-r--r--etc/testcase/sdnvpn.tc003.yml1
-rw-r--r--etc/testcase/sdnvpn.tc004.yml1
-rw-r--r--etc/testcase/sdnvpn.tc008.yml1
-rw-r--r--etc/testcase/vnf.tc001.yml1
11 files changed, 49 insertions, 29 deletions
diff --git a/dovetail/container.py b/dovetail/container.py
index 4feed802..b77f4919 100644
--- a/dovetail/container.py
+++ b/dovetail/container.py
@@ -17,8 +17,6 @@ from utils.dovetail_config import DovetailConfig as dt_cfg
class Container(object):
container_list = {}
- has_pull_latest_image = {'yardstick': False, 'functest': False,
- 'bottlenecks': False, 'vnftest': False}
logger = None
@@ -37,14 +35,23 @@ class Container(object):
return cls.container_list[type]
@classmethod
- def get_docker_image(cls, type):
- try:
- return '%s:%s' % (dt_cfg.dovetail_config[type]['image_name'],
- dt_cfg.dovetail_config[type]['docker_tag'])
- except KeyError as e:
- cls.logger.exception(
- 'There is no key {} in {} config file.'.format(e, type))
- return None
+ def _get_config(cls, field, project_cfg, testcase_cfg):
+ value = dt_utils.get_value_from_dict(field, testcase_cfg)
+ if not value:
+ value = dt_utils.get_value_from_dict(field, project_cfg)
+ if not value:
+ cls.logger.error("Couldn't find key {}.".format(field))
+ return None
+ return value
+
+ @classmethod
+ def get_docker_image(cls, testcase):
+ project_cfg = dt_cfg.dovetail_config[testcase.validate_type()]
+ testcase_cfg = testcase.testcase['validate']
+
+ name = cls._get_config('image_name', project_cfg, testcase_cfg)
+ tag = cls._get_config('docker_tag', project_cfg, testcase_cfg)
+ return "{}:{}".format(name, tag) if name and tag else None
# get the openrc_volume for creating the container
@classmethod
@@ -132,9 +139,9 @@ class Container(object):
return "%s %s" % (log_vol, key_vol)
@classmethod
- def create(cls, type, testcase_name):
+ def create(cls, type, testcase_name, docker_image):
dovetail_config = dt_cfg.dovetail_config
- docker_image = cls.get_docker_image(type)
+ opts = dovetail_config[type]['opts']
# credentials file openrc.sh is neccessary
openrc = cls.openrc_volume(type)
@@ -255,18 +262,12 @@ class Container(object):
return True
@classmethod
- def pull_image(cls, validate_type):
- docker_image = cls.get_docker_image(validate_type)
+ def pull_image(cls, docker_image):
if not docker_image:
return None
- if cls.has_pull_latest_image[validate_type] is True:
- cls.logger.debug(
- '{} is already the latest one.'.format(docker_image))
- return docker_image
old_image_id = cls.get_image_id(docker_image)
if not cls.pull_image_only(docker_image):
return None
- cls.has_pull_latest_image[validate_type] = True
new_image_id = cls.get_image_id(docker_image)
if not new_image_id:
cls.logger.error(
@@ -282,12 +283,6 @@ class Container(object):
return docker_image
@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 check_container_exist(cls, container_name):
cmd = ('sudo docker ps -aq -f name={}'.format(container_name))
ret, msg = dt_utils.exec_cmd(cmd, cls.logger)
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py
index 26b85a1e..b059047f 100644
--- a/dovetail/test_runner.py
+++ b/dovetail/test_runner.py
@@ -51,14 +51,15 @@ class DockerRunner(object):
return dest_path
def run(self):
+ docker_image = Container.get_docker_image(self.testcase)
if dt_cfg.dovetail_config['offline']:
- exist = Container.check_image_exist(self.testcase.validate_type())
+ exist = Container.get_image_id(docker_image)
if not exist:
self.logger.error("{} image doesn't exist, can't run offline."
.format(self.testcase.validate_type()))
return
else:
- if not Container.pull_image(self.testcase.validate_type()):
+ if not Container.pull_image(docker_image):
self.logger.error("Failed to pull the image.")
return
# for sdnvpn, there is a need to download needed images to config_dir
@@ -71,7 +72,7 @@ class DockerRunner(object):
self.logger.error('Image {} not found.'.format(img_name))
return
container_id = Container.create(self.testcase.validate_type(),
- self.testcase.name())
+ self.testcase.name(), docker_image)
if not container_id:
self.logger.error('Failed to create container.')
return
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index dc7dbafb..4a3d8528 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -408,3 +408,20 @@ def read_plain_file(file_path, logger=None):
logger.exception("Failed to read file {}, exception: {}"
.format(file_path, e))
return None
+
+
+def get_value_from_dict(key_path, input_dict):
+ """
+ Returns the value of a key in input_dict
+ key_path must be given in string format with dots
+ Example: result.dir
+ """
+ if not isinstance(key_path, str):
+ return None
+ for key in key_path.split("."):
+ if not isinstance(input_dict, dict):
+ return None
+ input_dict = input_dict.get(key)
+ if not input_dict:
+ return None
+ return input_dict
diff --git a/etc/conf/functest_config.yml b/etc/conf/functest_config.yml
index e5f21a9c..f76bac4d 100644
--- a/etc/conf/functest_config.yml
+++ b/etc/conf/functest_config.yml
@@ -1,6 +1,6 @@
---
functest:
- image_name: opnfv/functest-restapi
+ image_name: opnfv/functest-smoke
docker_tag: euphrates
opts: '-id --privileged=true'
envs: '-e INSTALLER_TYPE=unknown -e DEPLOY_SCENARIO=unknown -e NODE_NAME=unknown
diff --git a/etc/testcase/sdnvpn.tc000.yml b/etc/testcase/sdnvpn.tc000.yml
index 8a4d6bfa..4b1acf23 100644
--- a/etc/testcase/sdnvpn.tc000.yml
+++ b/etc/testcase/sdnvpn.tc000.yml
@@ -5,6 +5,7 @@ dovetail.sdnvpn.tc000:
validate:
type: functest
testcase: bgpvpn
+ image_name: opnfv/functest-features
pre_condition:
- "sed -i 's/networking_bgpvpn_tempest/networking_bgpvpn_tempest-r networking_bgpvpn_tempest.tests.api.test_bgpvpn.BgpvpnTest*/' /usr/lib/python2.7/site-packages/sdnvpn/test/functest/tempest.py"
- 'cp /home/opnfv/userconfig/pre_config/testcases.yaml /usr/lib/python2.7/site-packages/functest/ci/testcases.yaml'
diff --git a/etc/testcase/sdnvpn.tc001.yml b/etc/testcase/sdnvpn.tc001.yml
index 698b0d2e..a5f9fd00 100644
--- a/etc/testcase/sdnvpn.tc001.yml
+++ b/etc/testcase/sdnvpn.tc001.yml
@@ -5,6 +5,7 @@ dovetail.sdnvpn.tc001:
validate:
type: functest
testcase: bgpvpn
+ image_name: opnfv/functest-features
pre_copy:
exist_src_file: sdnvpn_config_testcase1.yaml
dest_path: /usr/lib/python2.7/site-packages/sdnvpn/test/functest/config.yaml
diff --git a/etc/testcase/sdnvpn.tc002.yml b/etc/testcase/sdnvpn.tc002.yml
index 4823ee55..06f4d65c 100644
--- a/etc/testcase/sdnvpn.tc002.yml
+++ b/etc/testcase/sdnvpn.tc002.yml
@@ -5,6 +5,7 @@ dovetail.sdnvpn.tc002:
validate:
type: functest
testcase: bgpvpn
+ image_name: opnfv/functest-features
pre_copy:
exist_src_file: sdnvpn_config_testcase2.yaml
dest_path: /usr/lib/python2.7/site-packages/sdnvpn/test/functest/config.yaml
diff --git a/etc/testcase/sdnvpn.tc003.yml b/etc/testcase/sdnvpn.tc003.yml
index fbf13ca3..e609390a 100644
--- a/etc/testcase/sdnvpn.tc003.yml
+++ b/etc/testcase/sdnvpn.tc003.yml
@@ -5,6 +5,7 @@ dovetail.sdnvpn.tc003:
validate:
type: functest
testcase: bgpvpn
+ image_name: opnfv/functest-features
pre_copy:
exist_src_file: sdnvpn_config_testcase3.yaml
dest_path: /usr/lib/python2.7/site-packages/sdnvpn/test/functest/config.yaml
diff --git a/etc/testcase/sdnvpn.tc004.yml b/etc/testcase/sdnvpn.tc004.yml
index 5f44f12d..f3628b8a 100644
--- a/etc/testcase/sdnvpn.tc004.yml
+++ b/etc/testcase/sdnvpn.tc004.yml
@@ -5,6 +5,7 @@ dovetail.sdnvpn.tc004:
validate:
type: functest
testcase: bgpvpn
+ image_name: opnfv/functest-features
pre_copy:
exist_src_file: sdnvpn_config_testcase4.yaml
dest_path: /usr/lib/python2.7/site-packages/sdnvpn/test/functest/config.yaml
diff --git a/etc/testcase/sdnvpn.tc008.yml b/etc/testcase/sdnvpn.tc008.yml
index d818bf10..71190223 100644
--- a/etc/testcase/sdnvpn.tc008.yml
+++ b/etc/testcase/sdnvpn.tc008.yml
@@ -5,6 +5,7 @@ dovetail.sdnvpn.tc008:
validate:
type: functest
testcase: bgpvpn
+ image_name: opnfv/functest-features
pre_copy:
exist_src_file: sdnvpn_config_testcase8.yaml
dest_path: /usr/lib/python2.7/site-packages/sdnvpn/test/functest/config.yaml
diff --git a/etc/testcase/vnf.tc001.yml b/etc/testcase/vnf.tc001.yml
index d2a8d70c..5fe02fb3 100644
--- a/etc/testcase/vnf.tc001.yml
+++ b/etc/testcase/vnf.tc001.yml
@@ -5,5 +5,6 @@ dovetail.vnf.tc001:
validate:
type: functest
testcase: cloudify_ims
+ image_name: opnfv/functest-vnf
report:
sub_testcase_list: