Skip to content

Test suite logging fixes#101

Merged
bmr-cymru merged 7 commits intomainfrom
bmr-test-logging-fixes
Jan 23, 2025
Merged

Test suite logging fixes#101
bmr-cymru merged 7 commits intomainfrom
bmr-test-logging-fixes

Conversation

@bmr-cymru
Copy link
Copy Markdown
Contributor

No description provided.

@bmr-cymru
Copy link
Copy Markdown
Contributor Author

Jenkins, test this please.

@packit-as-a-service
Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/snapshotmanager-snapm-101
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

snapm.command.main() calls setup_logging() after parsing arguments, and
shutdown_logging() before returning. The setup call adds the console
handler and configures the level and formatter according to the command
line arguments. The call to logging.shutdown() flushes each handler but
does _not_ close or remove them.

In situations where the main() function is called repeatedly (for e.g.
from the test suite) this leads to the installation of a duplicate log
handler each time main() calls setup_logging(). The more times main() is
called the more handlers are added leading to nonsense like:

  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch
  ERROR - Unrecognised field: nosuch

Fix this by checking whether our console handler is already present in
snapm_log.handlers at setup and if it is just apply any log level
changes according to the current command line.
Log test output to the console as well as to the test.log file.
@bmr-cymru bmr-cymru force-pushed the bmr-test-logging-fixes branch 2 times, most recently from b90610a to 387ab08 Compare January 21, 2025 18:17
2025-01-21 16:04:34,567 DEBUG root Preparing test_activate_deactivate_snapsets
2025-01-21 16:04:53,181 DEBUG root Cleaning up Stratis (test_activate_deactivate_snapsets)
2025-01-21 16:04:55,735 DEBUG root Cleaning up LVM (test_activate_deactivate_snapsets)
@bmr-cymru bmr-cymru force-pushed the bmr-test-logging-fixes branch from 387ab08 to f2c3799 Compare January 21, 2025 20:13
@bmr-cymru
Copy link
Copy Markdown
Contributor Author

Jenkins, test this please.

@bmr-cymru bmr-cymru changed the title tests: fix duplicate log handlers in test suite Test suite logging fixes Jan 21, 2025
@bmr-cymru bmr-cymru merged commit f2c3799 into main Jan 23, 2025
bmr-cymru added a commit that referenced this pull request Jan 23, 2025
Commit 29e6c92 incorrectly drops the call to set the log level for the
"snapm" logger, breaking verbose command line output via -v.

Fixes: #101
@bmr-cymru bmr-cymru deleted the bmr-test-logging-fixes branch May 30, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant