summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Kosonen <juha.kosonen@nokia.com>2018-02-02 13:27:33 +0200
committerJuha Kosonen <juha.kosonen@nokia.com>2018-02-02 13:27:33 +0200
commit0925daced02fd7555d43cd96e5b944d0f8edb748 (patch)
tree48f3632038e0b6cd98348c513a2753ec004f4c29
parent2db621767d66b632fab4e2594e4524348484ad56 (diff)
Do not use shell to execute commands in tempest
Change-Id: I4d699481fdc63058c12ca9cfe18138e87025e9b3 Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com>
-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 29fcb48e..87b0b664 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 292eb75b..37b61f3b 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)