mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-01 01:10:30 +02:00
Merge #11789: [tests] [travis-ci] Combine logs on failure
ff8a9b0[tests] Add combinedlogslen argument to test_runner.py (John Newbery)dba94ea[tests] [travis-ci] Move Travis functional test log post processing to test_runner (John Newbery)bba1c54[tests] Improve logging shutdown and add hint for combine_logs (John Newbery) Pull request description: Replaces #11779 . Notes from that PR: > Currently, when a functional test fails, the debug logs are printed sequentially to the travis log. This makes debugging race conditions based on the travis log hard. Instead, all logs events should be combined and sorted by their timestamp, then appended to the travis log. @MarcoFalke Tree-SHA512: 56c80067d6a2c92f7e6a35e3ae5160637a0de052d9da593c7be6e02233544a93c66d62456f903f85e2edc09e31ab4bdafd1aed1d9897ae48c634f82631f856f7
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Base class for RPC testing."""
|
||||
|
||||
from collections import deque
|
||||
from enum import Enum
|
||||
import logging
|
||||
import optparse
|
||||
@@ -149,32 +148,19 @@ class BitcoinTestFramework():
|
||||
shutil.rmtree(self.options.tmpdir)
|
||||
else:
|
||||
self.log.warning("Not cleaning up dir %s" % self.options.tmpdir)
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
# Dump the end of the debug logs, to aid in debugging rare
|
||||
# travis failures.
|
||||
import glob
|
||||
filenames = [self.options.tmpdir + "/test_framework.log"]
|
||||
filenames += glob.glob(self.options.tmpdir + "/node*/regtest/debug.log")
|
||||
MAX_LINES_TO_PRINT = 1000
|
||||
for fn in filenames:
|
||||
try:
|
||||
with open(fn, 'r') as f:
|
||||
print("From", fn, ":")
|
||||
print("".join(deque(f, MAX_LINES_TO_PRINT)))
|
||||
except OSError:
|
||||
print("Opening file %s failed." % fn)
|
||||
traceback.print_exc()
|
||||
|
||||
if success == TestStatus.PASSED:
|
||||
self.log.info("Tests successful")
|
||||
sys.exit(TEST_EXIT_PASSED)
|
||||
exit_code = TEST_EXIT_PASSED
|
||||
elif success == TestStatus.SKIPPED:
|
||||
self.log.info("Test skipped")
|
||||
sys.exit(TEST_EXIT_SKIPPED)
|
||||
exit_code = TEST_EXIT_SKIPPED
|
||||
else:
|
||||
self.log.error("Test failed. Test logging available at %s/test_framework.log", self.options.tmpdir)
|
||||
logging.shutdown()
|
||||
sys.exit(TEST_EXIT_FAILED)
|
||||
self.log.error("Hint: Call {} '{}' to consolidate all logs".format(os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../combine_logs.py"), self.options.tmpdir))
|
||||
exit_code = TEST_EXIT_FAILED
|
||||
logging.shutdown()
|
||||
sys.exit(exit_code)
|
||||
|
||||
# Methods to override in subclass test scripts.
|
||||
def set_test_params(self):
|
||||
|
||||
Reference in New Issue
Block a user