diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-01-16 02:42:14 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-02-23 03:26:18 +0000 |
commit | 5d7eda52596537ccdce783cf7ba910b834ecdfd1 (patch) | |
tree | 81922707038272f974a4a6ae1e67ff79fa8fe0d5 | |
parent | dc8a65358cea4df851f34f92e25d3313194d13bb (diff) |
Record test case names when run a task using API
JIRA: YARDSTICK-509
Currently we use influxdb as database and will not record test case name
when run a test suite. So if we must offer test case name if we want to
get result from API.
I will record test case name when run a test suite. So we needn't
offer test case any more when call for get result API.
Change-Id: I87ea4770422cbc46aa6671bfcc53bd4498825eef
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
-rw-r--r-- | api/resources/testsuites_action.py | 25 | ||||
-rw-r--r-- | yardstick/common/constants.py | 2 |
2 files changed, 23 insertions, 4 deletions
diff --git a/api/resources/testsuites_action.py b/api/resources/testsuites_action.py index f833dc22f..a385290d9 100644 --- a/api/resources/testsuites_action.py +++ b/api/resources/testsuites_action.py @@ -13,9 +13,11 @@ from __future__ import absolute_import import uuid import os import logging +import yaml -from api import conf from api.utils import common as common_utils +from yardstick.common import constants as consts +from yardstick.common.task_template import TaskTemplate logger = logging.getLogger(__name__) @@ -30,8 +32,7 @@ def runTestSuite(args): if 'suite' not in opts: opts['suite'] = 'true' - testsuite = os.path.join(conf.TEST_SUITE_PATH, - conf.TEST_SUITE_PRE + testsuite + '.yaml') + testsuite = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(testsuite)) task_id = str(uuid.uuid4()) @@ -40,6 +41,22 @@ def runTestSuite(args): logger.debug('The command_list is: %s', command_list) logger.debug('Start to execute command list') - common_utils.exec_command_task(command_list, task_id) + task_dic = { + 'task_id': task_id, + 'details': _get_cases_from_suite_file(testsuite) + } + common_utils.exec_command_task(command_list, task_dic) return common_utils.result_handler('success', task_id) + + +def _get_cases_from_suite_file(testsuite): + def get_name(full_name): + return os.path.splitext(full_name)[0] + + with open(testsuite) as f: + contents = TaskTemplate.render(f.read()) + + suite_dic = yaml.safe_load(contents) + testcases = (get_name(c['file_name']) for c in suite_dic['test_cases']) + return ','.join(testcases) diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py index e068c0b98..54ddf33dc 100644 --- a/yardstick/common/constants.py +++ b/yardstick/common/constants.py @@ -33,6 +33,8 @@ YARDSTICK_ROOT_PATH = dirname(dirname(dirname(abspath(__file__)))) + sep TESTCASE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_cases/') +TESTSUITE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_suites/') + YARDSTICK_REPOS_DIR = '/home/opnfv/repos/yardstick' YARDSTICK_LOG_DIR = '/tmp/yardstick/' |