summaryrefslogtreecommitdiffstats
path: root/dovetail/test_runner.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-03-09 03:27:14 -0500
committerGeorg Kunz <georg.kunz@ericsson.com>2018-03-14 16:01:41 +0000
commit66d20467c423505559bba2efa5aae2619903d647 (patch)
tree10d796efb2e5c7e679150d7a63ecc5842fd5ccd5 /dovetail/test_runner.py
parent189f27b7a90b6ddc74f1c3ede806e87d7548c539 (diff)
Add process info to pod.yaml to specify the info of a special process
1. Many HA test cases try to kill special processes with their name. 2. Then they check corresponding openstack services and the status of processes' recovery. 3. For different SUTs, the names of the processes and the hosts' names may be different. 4. So there is a requirement for Dovetail tool to provide one way to allow users to specify all the infos about process name and its host name. 5. All process infos can be added into file DOVETAIL_HOME/user_config/pod.yaml 6. The infos include 'attack_process' and 'attack_host' for each HA test cases. 7. If not given in this file, will use Yardtsick default values. JIRA: DOVETAIL-627 Change-Id: I83cee991f72a8685080ed562597c70d73002623a Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/test_runner.py')
-rw-r--r--dovetail/test_runner.py56
1 files changed, 52 insertions, 4 deletions
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py
index d2697f6d..934efb74 100644
--- a/dovetail/test_runner.py
+++ b/dovetail/test_runner.py
@@ -7,13 +7,18 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
-import os
import json
-import utils.dovetail_utils as dt_utils
-import utils.dovetail_logger as dt_logger
-from utils.dovetail_config import DovetailConfig as dt_cfg
+import os
+
+import jinja2
+import jinja2.meta
+import yaml
from container import Container
+from dovetail import constants
+from utils.dovetail_config import DovetailConfig as dt_cfg
+import utils.dovetail_utils as dt_utils
+import utils.dovetail_logger as dt_logger
class DockerRunner(object):
@@ -143,9 +148,52 @@ class FunctestRunner(DockerRunner):
class YardstickRunner(DockerRunner):
+ config_file_name = 'yardstick_config.yml'
+
def __init__(self, testcase):
self.type = 'yardstick'
super(YardstickRunner, self).__init__(testcase)
+ self._update_yardstick_config(testcase)
+
+ @staticmethod
+ def _render(task_template, **kwargs):
+ return jinja2.Template(task_template).render(**kwargs)
+
+ @staticmethod
+ def _add_testcase_info(testcase, config_item=None):
+ if not config_item:
+ config_item = {}
+ config_item['validate_testcase'] = testcase.validate_testcase()
+ config_item['testcase'] = testcase.name()
+ return config_item
+
+ def _update_yardstick_config(self, testcase):
+ config_item = None
+ pod_file = os.path.join(dt_cfg.dovetail_config['config_dir'],
+ dt_cfg.dovetail_config['pod_file'])
+ config_file = os.path.join(constants.CONF_PATH, self.config_file_name)
+ pod_info = dt_utils.read_yaml_file(pod_file, self.logger)
+ task_template = dt_utils.read_plain_file(config_file, self.logger)
+ if not (pod_info and task_template):
+ return None
+ try:
+ process_info = pod_info['process_info']
+ except KeyError as e:
+ process_info = None
+ if process_info:
+ for item in process_info:
+ try:
+ if item['testcase_name'] == testcase.name():
+ config_item = self._add_testcase_info(testcase, item)
+ break
+ except KeyError as e:
+ self.logger.error('Need key {} in {}'.format(e, item))
+ if not config_item:
+ config_item = self._add_testcase_info(testcase)
+ full_task = self._render(task_template, **config_item)
+ full_task_yaml = yaml.load(full_task)
+ dt_cfg.dovetail_config.update(full_task_yaml)
+ return dt_cfg.dovetail_config
class BottlenecksRunner(DockerRunner):