From 185f5acfe8e8e2f8868f6549c05abaf7563d737d Mon Sep 17 00:00:00 2001 From: Ponomaryov Valeriy Date: Tue, 23 Dec 2014 15:04:37 +0200 Subject: [PATCH] Add possibility to suppress errors in Tempest plugin cleanup Now if something can not be cleaned up we get error and in case of CI job it is 'fail' of job. We should be able to suppress such errors. Added config option 'suppress_errors_in_cleanup' that allows us to raise errors when it is 'False' and log errors when it is 'True'. Disable it by default. Enable it for CI Tempest jobs. Implements blueprint tempest-clean-up-suppress-errors Change-Id: I03a39cc020f52d54211369c8f5cbfc2e14651a21 --- contrib/ci/post_test_hook.sh | 3 +++ contrib/tempest/tempest/api/share/base.py | 8 ++++++++ contrib/tempest/tempest/config_share.py | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/contrib/ci/post_test_hook.sh b/contrib/ci/post_test_hook.sh index 7d5526f9ac..62d4c059fc 100755 --- a/contrib/ci/post_test_hook.sh +++ b/contrib/ci/post_test_hook.sh @@ -25,6 +25,9 @@ if [[ "$1" =~ "multibackend" ]]; then # backend names are defined in pre_test_hook iniset $BASE/new/tempest/etc/tempest.conf share backend_names "LONDON,PARIS" + + # Suppress errors in cleanup of resources + iniset $BASE/new/tempest/etc/tempest.conf share suppress_errors_in_cleanup True fi # let us control if we die or not diff --git a/contrib/tempest/tempest/api/share/base.py b/contrib/tempest/tempest/api/share/base.py index 907855cb2f..409adc942b 100644 --- a/contrib/tempest/tempest/api/share/base.py +++ b/contrib/tempest/tempest/api/share/base.py @@ -21,9 +21,11 @@ from tempest.common.utils import data_utils from tempest import config_share as config from tempest import exceptions from tempest.openstack.common import lockutils +from tempest.openstack.common import log as logging from tempest import test CONF = config.CONF +LOG = logging.getLogger(__name__) class BaseSharesTest(test.BaseTestCase): @@ -378,6 +380,12 @@ class BaseSharesTest(test.BaseTestCase): pass except exceptions.Unauthorized: pass + except Exception as e: + # Catch all other exceptions + if not CONF.share.suppress_errors_in_cleanup: + raise e + else: + LOG.error("Suppressed cleanup error: %s" % e) res["deleted"] = True @classmethod diff --git a/contrib/tempest/tempest/config_share.py b/contrib/tempest/tempest/config_share.py index a6a1a411ac..4af9730038 100644 --- a/contrib/tempest/tempest/config_share.py +++ b/contrib/tempest/tempest/config_share.py @@ -89,6 +89,11 @@ ShareGroup = [ default=500, help="Timeout in seconds to wait for a share to become" "available."), + cfg.BoolOpt("suppress_errors_in_cleanup", + default=False, + help="Whether to suppress errors with clean up operation " + "or not. There are cases when we may want to skip " + "such errors and catch only test errors."), ]