Make hard test timeouts more gentle

When we're hitting hard test timeouts we never have logs from the test
case that caused it because the whole test runner is killed by a
signal. Instead of a direct hard kill use a gentle timeout and give
the test case some time to exit cleanly until we hit a hard test
timeout. This should make debugging such things a lot easier.

Change-Id: Ia06bd66c24041a7e08639812a8fc4788bc2b9683
This commit is contained in:
Tobias Henkel 2019-03-23 07:59:06 +01:00
parent 947aae0d99
commit 25572fff82
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
1 changed files with 4 additions and 1 deletions

View File

@ -2290,7 +2290,10 @@ class BaseTestCase(testtools.TestCase):
# If timeout value is invalid do not set a timeout.
test_timeout = 0
if test_timeout > 0:
self.useFixture(fixtures.Timeout(test_timeout, gentle=False))
# Try a gentle timeout first and as a safety net a hard timeout
# later.
self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
self.useFixture(fixtures.Timeout(test_timeout + 20, gentle=False))
if not self.shouldNeverCapture():
if (os.environ.get('OS_STDOUT_CAPTURE') == 'True' or