Merge "Pause resource cleanup"
This commit is contained in:
commit
215e82b894
9
releasenotes/notes/pause_teardown-45c9d60ffa889f7f.yaml
Normal file
9
releasenotes/notes/pause_teardown-45c9d60ffa889f7f.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Pause teardown
|
||||||
|
When pause_teardown flag in tempest.conf is set to True a pdb breakpoint
|
||||||
|
is added to tearDown and tearDownClass methods in test.py.
|
||||||
|
This allows to pause cleaning resources process, so that used resources
|
||||||
|
can be examined. Closer examination of used resources may lead to faster
|
||||||
|
debugging.
|
@ -1070,6 +1070,15 @@ DefaultGroup = [
|
|||||||
"prefix to ideintify resources which are "
|
"prefix to ideintify resources which are "
|
||||||
"created by Tempest and no projects set "
|
"created by Tempest and no projects set "
|
||||||
"this option on OpenStack dev community."),
|
"this option on OpenStack dev community."),
|
||||||
|
cfg.BoolOpt('pause_teardown',
|
||||||
|
default=False,
|
||||||
|
help="""Whether to pause a test in global teardown.
|
||||||
|
|
||||||
|
The best use case is investigating used resources of one test.
|
||||||
|
A test can be run as follows:
|
||||||
|
$ ostestr --pdb TEST_ID
|
||||||
|
or
|
||||||
|
$ python -m testtools.run TEST_ID"""),
|
||||||
]
|
]
|
||||||
|
|
||||||
_opts = [
|
_opts = [
|
||||||
|
@ -247,6 +247,9 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
|
# insert pdb breakpoint when pause_teardown is enabled
|
||||||
|
if CONF.pause_teardown:
|
||||||
|
cls.insert_pdb_breakpoint()
|
||||||
at_exit_set.discard(cls)
|
at_exit_set.discard(cls)
|
||||||
# It should never be overridden by descendants
|
# It should never be overridden by descendants
|
||||||
if hasattr(super(BaseTestCase, cls), 'tearDownClass'):
|
if hasattr(super(BaseTestCase, cls), 'tearDownClass'):
|
||||||
@ -283,6 +286,22 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
|||||||
finally:
|
finally:
|
||||||
del trace # to avoid circular refs
|
del trace # to avoid circular refs
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(BaseTestCase, self).tearDown()
|
||||||
|
# insert pdb breakpoint when pause_teardown is enabled
|
||||||
|
if CONF.pause_teardown:
|
||||||
|
BaseTestCase.insert_pdb_breakpoint()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def insert_pdb_breakpoint(cls):
|
||||||
|
"""Add pdb breakpoint.
|
||||||
|
|
||||||
|
This can help in debugging process, cleaning of resources is
|
||||||
|
paused, so they can be examined.
|
||||||
|
"""
|
||||||
|
import pdb
|
||||||
|
pdb.set_trace()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def skip_checks(cls):
|
def skip_checks(cls):
|
||||||
"""Class level skip checks.
|
"""Class level skip checks.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user