aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests')
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py44
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_utils.py10
2 files changed, 30 insertions, 24 deletions
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index 0117e69c..0c657688 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -346,27 +346,24 @@ class RallyBase(testcase.TestCase):
LOGGER.info('No tests for scenario "%s"', test_name)
return
- cmd_line = ("rally task start --abort-on-sla-failure "
- "--task {0} "
- "--task-args \"{1}\""
- .format(task_file, self._build_task_args(test_name)))
- LOGGER.debug('running command line: %s', cmd_line)
-
- proc = subprocess.Popen(cmd_line, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT, shell=True)
+ cmd = (["rally", "task", "start", "--abort-on-sla-failure", "--task",
+ task_file, "--task-args",
+ str(self._build_task_args(test_name))])
+ LOGGER.debug('running command: %s', cmd)
+
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
output = self._get_output(proc, test_name)
task_id = self.get_task_id(output)
LOGGER.debug('task_id : %s', task_id)
if task_id is None:
LOGGER.error('Failed to retrieve task_id, validating task...')
- cmd_line = ("rally task validate "
- "--task {0} "
- "--task-args \"{1}\""
- .format(task_file, self._build_task_args(test_name)))
- LOGGER.debug('running command line: %s', cmd_line)
- proc = subprocess.Popen(cmd_line, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT, shell=True)
+ cmd = (["rally", "task", "validate", "--task", task_file,
+ "--task-args", str(self._build_task_args(test_name))])
+ LOGGER.debug('running command: %s', cmd)
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
output = self.get_cmd_output(proc)
LOGGER.error("Task validation result:" + "\n" + output)
return
@@ -380,17 +377,18 @@ class RallyBase(testcase.TestCase):
# write html report file
report_html_name = 'opnfv-{}.html'.format(test_name)
report_html_dir = os.path.join(self.RESULTS_DIR, report_html_name)
- cmd_line = "rally task report {} --out {}".format(task_id,
- report_html_dir)
+ cmd = (["rally", "task", "report", task_id, "--out", report_html_dir])
- LOGGER.debug('running command line: %s', cmd_line)
- os.popen(cmd_line)
+ LOGGER.debug('running command: %s', cmd)
+ subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
# get and save rally operation JSON result
- cmd_line = "rally task results %s" % task_id
- LOGGER.debug('running command line: %s', cmd_line)
- cmd = os.popen(cmd_line)
- json_results = cmd.read()
+ cmd = (["rally", "task", "results", task_id])
+ LOGGER.debug('running command: %s', cmd)
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ json_results = self.get_cmd_output(proc)
report_json_name = 'opnfv-{}.json'.format(test_name)
report_json_dir = os.path.join(self.RESULTS_DIR, report_json_name)
with open(report_json_dir, 'w') as r_file:
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
index c3cd6245..284e88b5 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
@@ -5,17 +5,25 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+from functest.utils.constants import CONST
+
from snaps.openstack.utils import neutron_utils, nova_utils
def get_ext_net_name(os_creds):
"""
- Returns the first external network name
+ Returns the configured external network name or
+ the first retrieved external network name
:param: os_creds: an instance of snaps OSCreds object
:return:
"""
neutron = neutron_utils.neutron_client(os_creds)
ext_nets = neutron_utils.get_external_networks(neutron)
+ if (hasattr(CONST, 'EXTERNAL_NETWORK')):
+ extnet_config = CONST.__getattribute__('EXTERNAL_NETWORK')
+ for ext_net in ext_nets:
+ if ext_net.name == extnet_config:
+ return extnet_config
return ext_nets[0].name if ext_nets else ""