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
Retry when checking ceph pool compression mode. #997
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The compression mode after it's set via config-changed might take a while to fully propagate to the whole cluster, hence the hook may be done before the cluster is fully configured with the new compression mode. This is more noticeable in the gate when there are many jobs running in parallel. This patch modes the check to its own method wrapped with a tenacity.retry decorator to make the test more robust. Closes openstack-charmers#946
This PR is being exercised by this patch in nova-compute charm - https://review.opendev.org/c/openstack/charm-nova-compute/+/874034 |
ajkavanagh
approved these changes
Feb 21, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
openstack-mirroring
pushed a commit
to openstack/charm-nova-compute
that referenced
this pull request
Feb 21, 2023
It was found that the modules test_actions_openstack_upgrade and test_actions_package_upgrade were mocking different classes and functions right before importing the modules under test (openstack_upgrade and package_upgrade respectively), although these mocks weren't being reset making tests executions coming after them to get benefitted (or impacted) by the mocks in memory. This patch takes advantage of mock.patch() decorator at the class level and importlib.reload() to make sure the mocks don't outsurvive the module. When the teardown was in place it was found a different set of functions that were relying on that mocking, so they were patched to allow the tests run in the expected (mock'ed) environment. Summary of changes: - Move get_availability_zone() to contexts module, nova_compute_utils depends on nova_compute_context, the latter shouldn't be importing code from the former since it breaks the layering, even when the import is being done within a function's body. - Mock env variable JUJU_UNIT_NAME per test case, the tests defined in the test_nova_compute_utils and test_nova_compute_contexts were relying on the leakage of mocks set by other test modules, this makes them run in an isolated fashion. - Move update_nrpe_config testing to its own class, the main class NovaComputeRelationsTests mocks the function update_nrpe_config() making it difficult to test it in a test method, hence making the test part of its own class it's posible to not mock the function and correctly runs its implementation. - Teardown mocks made at import level. Func-Test-Pr: openstack-charmers/zaza-openstack-tests#997 Change-Id: I4468ef1a0619befc75c6af2bad8df316125a7cf5
openstack-mirroring
pushed a commit
to openstack/openstack
that referenced
this pull request
Feb 21, 2023
* Update charm-nova-compute from branch 'master' to 4a26466235b987a2d4237bbd51819ec7728cd9d0 - Merge "Refactor unit tests to avoid leaks of mocks." - Refactor unit tests to avoid leaks of mocks. It was found that the modules test_actions_openstack_upgrade and test_actions_package_upgrade were mocking different classes and functions right before importing the modules under test (openstack_upgrade and package_upgrade respectively), although these mocks weren't being reset making tests executions coming after them to get benefitted (or impacted) by the mocks in memory. This patch takes advantage of mock.patch() decorator at the class level and importlib.reload() to make sure the mocks don't outsurvive the module. When the teardown was in place it was found a different set of functions that were relying on that mocking, so they were patched to allow the tests run in the expected (mock'ed) environment. Summary of changes: - Move get_availability_zone() to contexts module, nova_compute_utils depends on nova_compute_context, the latter shouldn't be importing code from the former since it breaks the layering, even when the import is being done within a function's body. - Mock env variable JUJU_UNIT_NAME per test case, the tests defined in the test_nova_compute_utils and test_nova_compute_contexts were relying on the leakage of mocks set by other test modules, this makes them run in an isolated fashion. - Move update_nrpe_config testing to its own class, the main class NovaComputeRelationsTests mocks the function update_nrpe_config() making it difficult to test it in a test method, hence making the test part of its own class it's posible to not mock the function and correctly runs its implementation. - Teardown mocks made at import level. Func-Test-Pr: openstack-charmers/zaza-openstack-tests#997 Change-Id: I4468ef1a0619befc75c6af2bad8df316125a7cf5
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The compression mode after it's set via config-changed might take a while to fully propagate to the whole cluster, hence the hook may be done before the cluster is fully configured with the new compression mode. This is more noticeable in the gate when there are many jobs running in parallel.
This patch modes the check to its own method wrapped with a tenacity.retry decorator to make the test more robust.
Closes #946