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

Retry when checking ceph pool compression mode. #997

Merged
merged 1 commit into from Feb 21, 2023

Conversation

freyes
Copy link
Member

@freyes freyes commented Feb 20, 2023

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

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
@freyes
Copy link
Member Author

freyes commented Feb 20, 2023

This PR is being exercised by this patch in nova-compute charm - https://review.opendev.org/c/openstack/charm-nova-compute/+/874034

Copy link
Contributor

@ajkavanagh ajkavanagh left a comment

Choose a reason for hiding this comment

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

LGTM

@ajkavanagh ajkavanagh merged commit e6940c6 into openstack-charmers:master Feb 21, 2023
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR: test_configure_compression (zaza.openstack.charm_tests.ceph.tests.BlueStoreCompressionCharmOperation)
2 participants