summaryrefslogtreecommitdiffstats
path: root/api/resources
diff options
context:
space:
mode:
Diffstat (limited to 'api/resources')
-rw-r--r--api/resources/env_action.py16
-rw-r--r--api/resources/testsuites_action.py25
2 files changed, 32 insertions, 9 deletions
diff --git a/api/resources/env_action.py b/api/resources/env_action.py
index ea94bc123..9d1686a1d 100644
--- a/api/resources/env_action.py
+++ b/api/resources/env_action.py
@@ -195,6 +195,13 @@ def prepareYardstickEnv(args):
return result_handler('success', {'task_id': task_id})
+def _already_source_openrc():
+ """Check if openrc is sourced already"""
+ return all(os.environ.get(k) for k in ['OS_AUTH_URL', 'OS_USERNAME',
+ 'OS_PASSWORD', 'OS_TENANT_NAME',
+ 'EXTERNAL_NETWORK'])
+
+
def _prepare_env_daemon(task_id):
_create_task(task_id)
@@ -208,11 +215,10 @@ def _prepare_env_daemon(task_id):
rc_file = config.OPENSTACK_RC_FILE
- _get_remote_rc_file(rc_file, installer_ip, installer_type)
-
- _source_file(rc_file)
-
- _append_external_network(rc_file)
+ if not _already_source_openrc():
+ _get_remote_rc_file(rc_file, installer_ip, installer_type)
+ _source_file(rc_file)
+ _append_external_network(rc_file)
# update the external_network
_source_file(rc_file)
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)