summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2018-02-03 05:02:51 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-02-03 05:02:51 +0000
commit613d6b44998016ad84d87228cde53109fef0cc5f (patch)
tree30397a7d9253eb2385e308712c3e8e09e765f31d
parent768601416d408f8596f6d86f9abadbe13cf19c72 (diff)
parent0925daced02fd7555d43cd96e5b944d0f8edb748 (diff)
Merge "Do not use shell to execute commands in tempest"
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py27
-rw-r--r--functest/tests/unit/openstack/tempest/test_tempest.py7
2 files changed, 15 insertions, 19 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 29fcb48e2..87b0b664b 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -47,7 +47,7 @@ class TempestCommon(testcase.TestCase):
super(TempestCommon, self).__init__(**kwargs)
self.resources = TempestResourcesManager(**kwargs)
self.MODE = ""
- self.OPTION = ""
+ self.OPTION = []
self.VERIFIER_ID = conf_utils.get_verifier_id()
self.VERIFIER_REPO_DIR = conf_utils.get_verifier_repo_dir(
self.VERIFIER_ID)
@@ -123,11 +123,10 @@ class TempestCommon(testcase.TestCase):
result_file.close()
def run_verifier_tests(self):
- self.OPTION += (" --load-list {} --detailed"
- .format(conf_utils.TEMPEST_LIST))
-
- cmd_line = "rally verify start " + self.OPTION
- logger.info("Starting Tempest test suite: '%s'." % cmd_line)
+ cmd = ["rally", "verify", "start", "--load-list",
+ conf_utils.TEMPEST_LIST]
+ cmd.extend(self.OPTION)
+ logger.info("Starting Tempest test suite: '%s'." % cmd)
header = ("Tempest environment:\n"
" SUT: %s\n Scenario: %s\n Node: %s\n Date: %s\n" %
@@ -146,7 +145,7 @@ class TempestCommon(testcase.TestCase):
f_env.write(header)
p = subprocess.Popen(
- cmd_line, shell=True,
+ cmd,
stdout=subprocess.PIPE,
stderr=f_stderr,
bufsize=1)
@@ -172,10 +171,9 @@ class TempestCommon(testcase.TestCase):
if self.VERIFICATION_ID is None:
raise Exception('Verification UUID not found')
- cmd_line = "rally verify show --uuid {}".format(self.VERIFICATION_ID)
- logger.info("Showing result for a verification: '%s'." % cmd_line)
- p = subprocess.Popen(cmd_line,
- shell=True,
+ cmd = ["rally", "verify", "show", "--uuid", self.VERIFICATION_ID]
+ logger.info("Showing result for a verification: '%s'." % cmd)
+ p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
for line in p.stdout:
@@ -266,7 +264,7 @@ class TempestSmokeSerial(TempestCommon):
kwargs["case_name"] = 'tempest_smoke_serial'
TempestCommon.__init__(self, **kwargs)
self.MODE = "smoke"
- self.OPTION = "--concurrency 1"
+ self.OPTION = ["--concurrency", "1"]
class TempestSmokeParallel(TempestCommon):
@@ -276,7 +274,6 @@ class TempestSmokeParallel(TempestCommon):
kwargs["case_name"] = 'tempest_smoke_parallel'
TempestCommon.__init__(self, **kwargs)
self.MODE = "smoke"
- self.OPTION = ""
class TempestFullParallel(TempestCommon):
@@ -295,7 +292,7 @@ class TempestCustom(TempestCommon):
kwargs["case_name"] = 'tempest_custom'
TempestCommon.__init__(self, **kwargs)
self.MODE = "custom"
- self.OPTION = "--concurrency 1"
+ self.OPTION = ["--concurrency", "1"]
class TempestDefcore(TempestCommon):
@@ -305,7 +302,7 @@ class TempestDefcore(TempestCommon):
kwargs["case_name"] = 'tempest_defcore'
TempestCommon.__init__(self, **kwargs)
self.MODE = "defcore"
- self.OPTION = "--concurrency 1"
+ self.OPTION = ["--concurrency", "1"]
class TempestResourcesManager(object):
diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py
index 292eb75bb..37b61f3ba 100644
--- a/functest/tests/unit/openstack/tempest/test_tempest.py
+++ b/functest/tests/unit/openstack/tempest/test_tempest.py
@@ -145,12 +145,11 @@ class OSTempestTesting(unittest.TestCase):
mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'subprocess.Popen'):
conf_utils.TEMPEST_LIST = 'test_tempest_list'
- cmd_line = ("rally verify start --load-list "
- "test_tempest_list --detailed")
+ cmd = ["rally", "verify", "start", "--load-list",
+ conf_utils.TEMPEST_LIST]
self.tempestcommon.run_verifier_tests()
mock_logger_info. \
- assert_any_call("Starting Tempest test suite: '%s'."
- % cmd_line)
+ assert_any_call("Starting Tempest test suite: '%s'." % cmd)
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'os.path.exists', return_value=False)