Skip to content

Commit

Permalink
CA-390127: Fix adding even the last log() messages to the output arch…
Browse files Browse the repository at this point in the history
…ive (#93)

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
  • Loading branch information
bernhardkaindl committed Mar 21, 2024
1 parent 8187429 commit 60c73a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 3 additions & 8 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,9 @@ def assert_bugtool_logfile_data(logfile):
# caught and logged, the log file should contain the backtrace from the
# raised exception:
#
# FIXME: This is not working in Python 2.7 yet (in this specific case): CA-390127
# CA-390127 affects Python3 in principle too, but it does not make this test fail
# Fixing CA-390127 is a prerequisite for enabling this check for Python 2.7:
#
if sys.version_info.major > 2: # pragma: no cover
assert len(lines) == 9
for backtrace_string in MOCK_EXCEPTION_STRINGS:
assert backtrace_string in log
assert len(lines) == 9
for backtrace_string in MOCK_EXCEPTION_STRINGS:
assert backtrace_string in log


def assert_valid_inventory(bugtool, args, cap, tmp_path, base_path, filetype):
Expand Down
8 changes: 6 additions & 2 deletions xen-bugtool
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,6 @@ exclude those logs from the archive.
cmd_output(CAP_YUM, [RPM, '-qa'])
tree_output(CAP_YUM, SIGNING_KEY_INFO_DIR)

file_output(CAP_XEN_BUGTOOL, [XEN_BUGTOOL_LOG])

# permit the user to filter out data
for k in sorted(data.keys()):
if not ANSWER_YES_TO_ALL and not yes("Include '%s'? [Y/n]: " % k):
Expand Down Expand Up @@ -1312,6 +1310,12 @@ exclude those logs from the archive.
output_ts('Running commands to collect data')
collect_data(subdir, archive)

# after all is done, include all log() entries from the XEN_BUGTOOL_LOG file
if CAP_XEN_BUGTOOL in entries:
archive.addRealFile(
construct_filename(subdir, XEN_BUGTOOL_LOG, {}), XEN_BUGTOOL_LOG
)

# include inventory
include_inventory(archive, subdir)

Expand Down

0 comments on commit 60c73a5

Please sign in to comment.