X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=functest%2Fopnfv_tests%2Fopenstack%2Ftempest%2Ftempest.py;h=a7d608bc3140f6b4942534133dcdcbd5cb5c6695;hb=bf39607ee1128f6a9b46c37c0a8ac1e582d39ea5;hp=3701e485f4be6462d322326c985501a321803ea5;hpb=036cb7d9075f7eee45e7533d8c37a5b89e6c6dd5;p=functest.git diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 3701e485f..a7d608bc3 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -19,6 +19,7 @@ import shutil import subprocess import time +from six.moves import configparser from xtesting.core import testcase import yaml @@ -249,6 +250,16 @@ class TempestCommon(singlevm.VmReady1): subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + def update_rally_regex(self, rally_conf='/etc/rally/rally.conf'): + """Set image name as tempest img_name_regex""" + rconfig = configparser.RawConfigParser() + rconfig.read(rally_conf) + rconfig.add_section('tempest') + rconfig.set('tempest', 'img_name_regex', '^{}$'.format( + self.image.name)) + with open(rally_conf, 'wb') as config_file: + rconfig.write(config_file) + def configure(self, **kwargs): # pylint: disable=unused-argument """ Create all openstack resources for tempest-based testcases and write @@ -276,7 +287,9 @@ class TempestCommon(singlevm.VmReady1): def run(self, **kwargs): self.start_time = time.time() try: - super(TempestCommon, self).run(**kwargs) + assert super(TempestCommon, self).run( + **kwargs) == testcase.TestCase.EX_OK + self.update_rally_regex() self.configure(**kwargs) self.generate_test_list(**kwargs) self.apply_tempest_blacklist() @@ -286,6 +299,7 @@ class TempestCommon(singlevm.VmReady1): res = testcase.TestCase.EX_OK except Exception: # pylint: disable=broad-except LOGGER.exception('Error with run') + self.result = 0 res = testcase.TestCase.EX_RUN_ERROR self.stop_time = time.time() return res @@ -295,5 +309,7 @@ class TempestCommon(singlevm.VmReady1): Cleanup all OpenStack objects. Should be called on completion. """ super(TempestCommon, self).clean() - self.cloud.delete_image(self.image_alt) - self.orig_cloud.delete_flavor(self.flavor_alt.id) + if self.image_alt: + self.cloud.delete_image(self.image_alt) + if self.flavor_alt: + self.orig_cloud.delete_flavor(self.flavor_alt.id)