Fix wrong argument in rally verify

Closes-Bug: #1382428

Change-Id: I58efeda8262f3663e445ace2d499ad0695292675
This commit is contained in:
Andrey Kurilin 2014-10-17 11:54:08 +03:00
parent 0890693dd9
commit df4e8ff813
3 changed files with 42 additions and 32 deletions

View File

@ -36,7 +36,8 @@ class TempestScenario(base.Scenario):
and test_name.split('.')[0] in consts.TEMPEST_TEST_SETS):
test_name = "tempest.api." + test_name
self.context()["verifier"].run(tempest_conf, test_name, log_file)
self.context()["verifier"].run(test_name, log_file=log_file,
tempest_conf=tempest_conf)
@validation.required_openstack(admin=True)
@base.scenario(context={"tempest": {}})
@ -48,7 +49,8 @@ class TempestScenario(base.Scenario):
:param tempest_conf: User specified tempest.conf location
"""
self.context()["verifier"].run(tempest_conf, "", log_file)
self.context()["verifier"].run("", log_file=log_file,
tempest_conf=tempest_conf)
@validation.tempest_set_exists()
@validation.required_openstack(admin=True)
@ -69,7 +71,8 @@ class TempestScenario(base.Scenario):
else:
testr_arg = "tempest.api.%s" % set_name
self._context["verifier"].run(tempest_conf, testr_arg, log_file)
self.context()["verifier"].run(testr_arg, log_file=log_file,
tempest_conf=tempest_conf)
@validation.tempest_tests_exists()
@validation.required_openstack(admin=True)
@ -83,8 +86,8 @@ class TempestScenario(base.Scenario):
:param tempest_conf: User specified tempest.conf location
"""
self._context["verifier"].run(tempest_conf,
" ".join(test_names), log_file)
self.context()["verifier"].run(" ".join(test_names), log_file=log_file,
tempest_conf=tempest_conf)
@validation.required_openstack(admin=True)
@base.scenario(context={"tempest": {}})
@ -96,4 +99,5 @@ class TempestScenario(base.Scenario):
:param tempest_conf: User specified tempest.conf location
"""
self._context["verifier"].run(tempest_conf, regex, log_file)
self.context()["verifier"].run(regex, log_file=log_file,
tempest_conf=tempest_conf)

View File

@ -169,16 +169,17 @@ class Tempest(object):
print("Test set %s has been finished with error. "
"Check log for details" % set_name)
def run(self, tempest_conf=None, testr_arg=None, log_file=None):
def run(self, testr_arg=None, log_file=None, tempest_conf=None):
"""Launch tempest with given arguments
:param tempest_conf: User specified tempest.conf location
:param testr_arg: argument which will be transmitted into testr
:type testr_arg: str
:param log_file: file name for raw subunit results of tests. If not
specified, value from "self.log_file_raw"
will be chosen.
:type testr_arg: str
:type log_file: str
:param tempest_conf: User specified tempest.conf location
:type tempest_conf: str
:raises: :class:`subprocess.CalledProcessError` if tests has been
finished with error.
@ -186,7 +187,6 @@ class Tempest(object):
if tempest_conf and os.path.isfile(tempest_conf):
self.config_file = tempest_conf
self._generate_env()
test_cmd = (
"%(venv)s testr run --parallel --subunit %(arg)s "

View File

@ -81,36 +81,42 @@ class TempestTestCase(test.TestCase):
self.verifier.uninstall()
mock_shutil.rmtree.assert_called_once_with(self.verifier.tempest_path)
@mock.patch(TEMPEST_PATH + '.tempest.Tempest.env')
@mock.patch(TEMPEST_PATH + '.tempest.subprocess')
def test_run(self, mock_sp, mock_env):
self.verifier.run(testr_arg='tempest.api.image')
fake_call = (
'%(venv)s testr run --parallel --subunit tempest.api.image '
'| tee %(tempest_path)s/subunit.stream '
'| %(venv)s subunit-2to1 '
'| %(venv)s %(tempest_path)s/tools/colorizer.py' % {
'venv': self.verifier.venv_wrapper,
'tempest_path': self.verifier.tempest_path})
mock_sp.check_call.assert_called_once_with(
fake_call, env=mock_env, cwd=self.verifier.tempest_path,
shell=True)
@mock.patch(TEMPEST_PATH + '.tempest.os.remove')
@mock.patch(TEMPEST_PATH + '.tempest.Tempest.discover_tests')
@mock.patch(TEMPEST_PATH + '.tempest.Tempest._initialize_testr')
@mock.patch(TEMPEST_PATH + '.tempest.Tempest.run')
@mock.patch(TEMPEST_PATH + '.config.TempestConf')
@mock.patch('rally.db.deployment_get')
@mock.patch('rally.osclients.Clients')
@mock.patch('rally.objects.endpoint.Endpoint')
def test_verify(self, mock_endpoint, mock_osclients,
mock_get, mock_conf, mock_run, mock_testr_init,
mock_discover, mock_os):
def test_verify(self, mock_conf, mock_run, mock_testr_init, mock_os):
self.verifier.verify("smoke", None)
mock_conf().generate.assert_called_once_with(self.verifier.config_file)
mock_run.assert_called_once_with("smoke")
@mock.patch(TEMPEST_PATH + '.tempest.Tempest.env')
@mock.patch(TEMPEST_PATH + '.tempest.subprocess')
@mock.patch(TEMPEST_PATH + '.config.TempestConf')
@mock.patch(TEMPEST_PATH + '.tempest.Tempest.is_configured',
return_value=False)
def test_verify_complex(self, mock_is_configured, mock_conf,
mock_sp, mock_env):
set_name = "compute"
fake_call = (
"%(venv)s testr run --parallel --subunit tempest.api.%(testr_arg)s"
" | tee %(tempest_path)s/subunit.stream"
" | %(venv)s subunit-2to1"
" | %(venv)s %(tempest_path)s/tools/colorizer.py" % {
"venv": self.verifier.venv_wrapper,
"testr_arg": set_name,
"tempest_path": self.verifier.tempest_path})
self.verifier.verify(set_name, None)
mock_conf.assert_called_once_with(self.verifier.deploy_id)
mock_conf().generate.assert_called_once_with(self.verifier.config_file)
self.verifier.verification.start_verifying.assert_called_once_with(
set_name)
mock_sp.check_call.assert_called_once_with(
fake_call, env=mock_env, cwd=self.verifier.tempest_path,
shell=True)
@mock.patch('os.environ')
def test__generate_env(self, mock_env):
expected_env = {'PATH': '/some/path'}