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

Fix zha test by tweaking the log level #115368

Merged
merged 8 commits into from
Apr 10, 2024
Merged

Fix zha test by tweaking the log level #115368

merged 8 commits into from
Apr 10, 2024

Conversation

jbouwh
Copy link
Contributor

@jbouwh jbouwh commented Apr 10, 2024

Proposed change

test_probe_failure_exception_handling failed multiple times:
https://github.com/home-assistant/core/actions/runs/8633392085/job/23671932070?pr=110950

Possible the asserting on debug log is an issue because the test used to lean on the debug level being set to DEBUG by another test. This PR set the log level to debug temporary to ensure the test passes.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @dmulcahey, @Adminiuga, @puddly, @TheJulianJES, mind taking a look at this pull request as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zha can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign zha Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@jbouwh jbouwh changed the title Add typing to test_probe_failure_exception_handling Assert on mock call instead of logs Apr 10, 2024
Copy link
Contributor

@puddly puddly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fundamentally changes what the test is testing, however, no? Could the Home Assistant log handling be in a separate thread and thus caplog.text may take an event loop step (or two) to populate?

@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 10, 2024

This fundamentally changes what the test is testing, however, no? Could the Home Assistant log handling be in a separate thread and thus caplog.text may take an event loop step (or two) to populate?

For now it is just a test to see if the CI passes. If debug logging is filtered out some how, this could be the cause the logging it self fails.

@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 10, 2024

@puddly May be you can have a look at the linked failed CI test. As all is mocked out I cannot find a reason how this test could fail (I mean the original one), but somehow it does.

@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 10, 2024

Previous test passed.
Now I have re added the log assertion, so lets see what happens

@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 10, 2024

Well, the test with the log assertion also passes. No Idea what the root cause is of the CI failure linked in the PR description.

@jbouwh jbouwh marked this pull request as ready for review April 10, 2024 17:48
@jbouwh jbouwh changed the title Assert on mock call instead of logs Assert zha test on mock and logs Apr 10, 2024
@jbouwh jbouwh added the bugfix label Apr 10, 2024
@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 10, 2024

@puddly may be the log processing is not finished yet, so an extra await asyncio.sleep(0) is added. Hopefully this fixes the issue.

@puddly
Copy link
Contributor

puddly commented Apr 10, 2024

That was my original thought as well. Looks like the tests pass this run.

@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 10, 2024

@bdraco found out we updated pytest-xdist (#111266). This might have changed the order of the tests. He believes some patch or mutable object might cause the failure.

@jbouwh jbouwh added the ci-full-run Marks a PR to trigger a full CI run (instead of partial) label Apr 10, 2024
@jbouwh jbouwh marked this pull request as draft April 10, 2024 20:34
@jbouwh jbouwh changed the title Assert zha test on mock and logs Assert zha test on mock and logs and tweak log level Apr 10, 2024
@jbouwh jbouwh marked this pull request as ready for review April 10, 2024 22:59
@jbouwh jbouwh changed the title Assert zha test on mock and logs and tweak log level Fix zha test by tweaking the log level Apr 10, 2024
@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 10, 2024

Thnx!

@bdraco bdraco merged commit be8adf9 into dev Apr 10, 2024
33 of 34 checks passed
@bdraco bdraco deleted the zha-ci-test branch April 10, 2024 23:10
@bdraco
Copy link
Member

bdraco commented Apr 10, 2024

It would be nice if we can find the source of the not so isolated logger level change is happening, but this is fine for now as that may take a long time to uncover

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bugfix ci-full-run Marks a PR to trigger a full CI run (instead of partial) cla-signed has-tests integration: zha Quality Scale: No score small-pr PRs with less than 30 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants