diff options
author | xudan <xudan16@huawei.com> | 2018-04-07 23:42:50 -0400 |
---|---|---|
committer | Georg Kunz <georg.kunz@ericsson.com> | 2018-04-10 10:21:21 +0000 |
commit | d596c9988d82cb6876b0acd12e79a89319bdbd0b (patch) | |
tree | 8cb05f39c1e447dddb383d272d2a83af944127af | |
parent | 8b0d80d556dfd7935b6464ec76b49c9c0e6249e0 (diff) |
Decoupling Yardstick Docker config items from source code
There are some special Docker setting items when creating
Yardstick Docker Containers.
1. Remove the extra settings which are required by Yardstick Danube.
2. Remove the settings for pushing results to DB because Dovetail
plan to disable this function.
3. Move the other special Functest settings to config files.
JIRA: DOVETAIL-640
Change-Id: Ic2d90393e227d7886b14d805eaa307b7aef56e4a
Signed-off-by: xudan <xudan16@huawei.com>
-rw-r--r-- | dovetail/container.py | 67 | ||||
-rw-r--r-- | dovetail/test_runner.py | 3 | ||||
-rw-r--r-- | dovetail/utils/dovetail_config.py | 12 | ||||
-rw-r--r-- | etc/conf/yardstick_config.yml | 20 | ||||
-rw-r--r-- | etc/testcase/ha.tc011.yml | 3 |
5 files changed, 34 insertions, 71 deletions
diff --git a/dovetail/container.py b/dovetail/container.py index b77f4919..833f1ec9 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -68,42 +68,6 @@ class Container(object): "File {} doesn't exist.".format(dovetail_config['openrc'])) return None - # set yardstick external network name and log volume for its container. - # external network is necessary for yardstick. - @classmethod - def set_yardstick_config(cls): - dovetail_config = dt_cfg.dovetail_config - ext_net = dt_utils.get_ext_net_name(dovetail_config['openrc'], - cls.logger) - if ext_net: - envs = "%s%s" % (" -e EXTERNAL_NETWORK=", ext_net) - else: - cls.logger.error("Can't find any external network.") - return None - insecure = os.getenv("OS_INSECURE") - if insecure and insecure.lower() == 'true': - envs = envs + " -e OS_CACERT=False " - - log_vol = '-v %s:%s ' % (dovetail_config['result_dir'], - dovetail_config["yardstick"]['result']['log']) - - # for yardstick, support pod.yaml configuration - pod_file = os.path.join(dovetail_config['config_dir'], - dovetail_config['pod_file']) - if not os.path.isfile(pod_file): - cls.logger.error("File {} doesn't exist.".format(pod_file)) - return None - key_file = os.path.join(dovetail_config['config_dir'], - dovetail_config['pri_key']) - key_container_path = dovetail_config["yardstick"]['result']['key_path'] - if not os.path.isfile(key_file): - cls.logger.debug("Key file {} is not found, must use password in " - "{} to do HA test.".format(key_file, pod_file)) - key_vol = '' - else: - key_vol = '-v %s:%s ' % (key_file, key_container_path) - return "%s %s %s" % (envs, log_vol, key_vol) - @classmethod def set_bottlenecks_config(cls, testcase_name): dovetail_config = dt_cfg.dovetail_config @@ -168,8 +132,6 @@ class Container(object): # set_yardstick_config # set_bottlenecks_config config = " " - if type.lower() == "yardstick": - config = cls.set_yardstick_config() if type.lower() == "bottlenecks": config = cls.set_bottlenecks_config(testcase_name) if type.lower() == "vnftest": @@ -216,9 +178,7 @@ class Container(object): " | awk '{print $1}' | head -1", cls.logger) cls.container_list[type] = container_id - if type.lower() == 'yardstick': - cls.set_yardstick_conf_file(container_id) - elif type.lower() == 'vnftest': + if type.lower() == 'vnftest': cls.set_vnftest_conf_file(container_id) return container_id @@ -309,8 +269,8 @@ class Container(object): return dt_utils.exec_cmd(cmd, cls.logger, exit_on_error) @classmethod - def pre_copy(cls, container_id, src_path, dest_path, - exit_on_error=False): + def copy_file(cls, container_id, src_path, dest_path, + exit_on_error=False): if not src_path or not dest_path: return (1, 'src_path or dest_path is empty') cmd = 'cp %s %s' % (src_path, dest_path) @@ -324,19 +284,14 @@ class Container(object): return dt_utils.exec_cmd(cmd, cls.logger) @classmethod - def set_yardstick_conf_file(cls, container_id): - valid_type = 'yardstick' - src = dt_cfg.dovetail_config[valid_type]['yard_conf']['src_file'] - dest = dt_cfg.dovetail_config[valid_type]['yard_conf']['dest_file'] - cls.pre_copy(container_id, src, dest) - url = dt_cfg.dovetail_config['report_dest'] - if url.startswith("http"): - cmd = ("sed -i '17s#http://127.0.0.1:8000/results#{}#g' {}" - .format(url, dest)) - cls.exec_cmd(container_id, cmd) - if url.lower() == 'file': - cmd = ("sed -i '13s/http/file/g' {}".format(dest)) - cls.exec_cmd(container_id, cmd) + def copy_files_in_container(cls, valid_type, container_id): + project_config = dt_cfg.dovetail_config[valid_type] + if 'copy_file_in_container' not in project_config.keys(): + return + if not project_config['copy_file_in_container']: + return + for item in project_config['copy_file_in_container']: + cls.copy_file(container_id, item['src_file'], item['dest_file']) @classmethod def set_vnftest_conf_file(cls, container_id): diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py index b059047f..fbc33b6f 100644 --- a/dovetail/test_runner.py +++ b/dovetail/test_runner.py @@ -47,7 +47,7 @@ class DockerRunner(object): file_path = dt_cfg.dovetail_config[self.type]['config']['dir'] src_path = os.path.join(file_path, 'pre_config', exist_file) - Container.pre_copy(container_id, src_path, dest_path) + Container.copy_file(container_id, src_path, dest_path) return dest_path def run(self): @@ -166,6 +166,7 @@ class YardstickRunner(DockerRunner): config_item = {} config_item['validate_testcase'] = testcase.validate_testcase() config_item['testcase'] = testcase.name() + config_item['os_insecure'] = os.getenv("OS_INSECURE") return config_item def _update_yardstick_config(self, testcase): diff --git a/dovetail/utils/dovetail_config.py b/dovetail/utils/dovetail_config.py index 316be312..37a20dbe 100644 --- a/dovetail/utils/dovetail_config.py +++ b/dovetail/utils/dovetail_config.py @@ -67,12 +67,16 @@ class DovetailConfig(object): @classmethod def get_opts(cls, valid_type): - if 'opts' in cls.dovetail_config[valid_type].keys(): - return cls.dovetail_config[valid_type]['opts'] + project_config = cls.dovetail_config[valid_type] + if 'opts' in project_config.keys(): + if project_config['opts']: + return project_config['opts'] return "" @classmethod def get_envs(cls, valid_type): - if 'envs' in cls.dovetail_config[valid_type].keys(): - return cls.dovetail_config[valid_type]['envs'] + project_config = cls.dovetail_config[valid_type] + if 'envs' in project_config.keys(): + if project_config['envs']: + return project_config['envs'] return "" diff --git a/etc/conf/yardstick_config.yml b/etc/conf/yardstick_config.yml index 1b924d85..6e09c271 100644 --- a/etc/conf/yardstick_config.yml +++ b/etc/conf/yardstick_config.yml @@ -4,31 +4,35 @@ {% set attack_process = attack_process or '' %} {% set validate_testcase = validate_testcase or '' %} {% set testcase = testcase or '' %} +{% set os_insecure = os_insecure or 'False' %} +{% set os_cacert = '' %} +{% if os_insecure == 'True' %} + {% set os_cacert = ' -e OS_CACERT=False ' %} +{% endif %} yardstick: image_name: opnfv/yardstick docker_tag: opnfv-5.1.0 opts: '-id --privileged=true' + envs: {{os_cacert}} config: dir: '/home/opnfv/userconfig' pre_condition: - 'echo this is pre_condition' cmds: - - 'mkdir -p /home/opnfv/yardstick/results/' - "cd /home/opnfv/repos/yardstick && source /etc/yardstick/openstack.creds && yardstick task start tests/opnfv/test_cases/{{validate_testcase}}.yaml - --output-file /home/opnfv/yardstick/results/{{testcase}}.out + --output-file /tmp/yardstick/{{testcase}}.out --task-args '{'file': '/home/opnfv/userconfig/pre_config/pod.yaml', 'attack_host': {{attack_host}}, 'attack_process': {{attack_process}}}'" post_condition: - 'echo this is post_condition' result: - dir: '/home/opnfv/yardstick/results' - log: '/tmp/yardstick' + dir: '/tmp/yardstick' file_path: 'yardstick.log' - key_path: '/root/.ssh/id_rsa' openrc: '/etc/yardstick/openstack.creds' - yard_conf: - src_file: '/home/opnfv/repos/yardstick/etc/yardstick/yardstick.conf.sample' - dest_file: '/etc/yardstick/yardstick.conf' + copy_file_in_container: + - + src_file: 'pre_config/id_rsa' + dest_file: '/root/.ssh/id_rsa' diff --git a/etc/testcase/ha.tc011.yml b/etc/testcase/ha.tc011.yml index e7e67e75..7f5a7d4b 100644 --- a/etc/testcase/ha.tc011.yml +++ b/etc/testcase/ha.tc011.yml @@ -10,10 +10,9 @@ dovetail.ha.tc011: --disk-format qcow2 --container-format bare --public --file /home/opnfv/userconfig/images/cirros-0.3.5-x86_64-disk.img' cmds: - - 'mkdir -p /home/opnfv/yardstick/results/' - "cd /home/opnfv/repos/yardstick && source /etc/yardstick/openstack.creds && yardstick task start tests/opnfv/test_cases/{{validate_testcase}}.yaml - --output-file /home/opnfv/yardstick/results/{{testcase}}.out + --output-file /tmp/yardstick/{{testcase}}.out --task-args '{'file': '/home/opnfv/userconfig/pre_config/pod.yaml', 'image': 'cirros-ha-11', 'flavor': 'm1.tiny'}'" post_condition: |