Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify which logger to update. #14058

Merged

Conversation

jhtimmins
Copy link
Contributor

This fixes the test test_should_load_plugins_from_property, which is currently quarantined as a "Heisentest".

Current behavior:
The test currently fails because the records that it expects to find in the logger are not present.

Cause:
While the test sets the logger as "DEBUG", it doesn't specify which logger to update. Python loggers are namespaced (typically based on the current file's path), but this has to be defined explicitly. In the absence of a specified logger, any attempts to lookup will return the BaseLogger instance.

The test is therefore updating the log level for the base logger, but when the test runs, the plugins_manager.py file defines a namespaced logger log = logging.getLogger(__name__) used throughout the file. Since a different logger is used, the original log level, in this case INFO, is used. INFO is a higher level than DEBUG, so the calls to log.debug() get filtered out, and when the test looks for log records it finds an empty list.

Fix:
Just specify which logger to update when modifying the log level in the test.

@jhtimmins
Copy link
Contributor Author

@ashb

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Feb 4, 2021
@github-actions
Copy link

github-actions bot commented Feb 4, 2021

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@ashb ashb merged commit e80ad5a into apache:master Feb 4, 2021
@ashb ashb deleted the fix-failing-test_plugins_manager-test branch February 4, 2021 10:09
kaxil pushed a commit that referenced this pull request Feb 4, 2021
This fixes the test test_should_load_plugins_from_property, which is currently quarantined as a "Heisentest".

Current behavior:
The test currently fails because the records that it expects to find in the logger are not present.

Cause:
While the test sets the logger as "DEBUG", it doesn't specify which logger to update. Python loggers are namespaced (typically based on the current file's path), but this has to be defined explicitly. In the absence of a specified logger, any attempts to lookup will return the BaseLogger instance.

The test is therefore updating the log level for the base logger, but when the test runs, the plugins_manager.py file defines a namespaced logger log = logging.getLogger(__name__) used throughout the file. Since a different logger is used, the original log level, in this case INFO, is used. INFO is a higher level than DEBUG, so the calls to log.debug() get filtered out, and when the test looks for log records it finds an empty list.

Fix:
Just specify which logger to update when modifying the log level in the test.

(cherry picked from commit e80ad5a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:plugins full tests needed We need to run full set of tests for this PR to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants