Skip to content

Commit

Permalink
Add (async_)block_until_charm_channel support
Browse files Browse the repository at this point in the history
This adds async_block_until_charm_channel and
block_until_charm_channel which will initially be
used for charm upgrade testing.
  • Loading branch information
Corey Bryant committed Oct 17, 2023
1 parent 44333de commit d6c927f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions zaza/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,34 @@ async def _check_charm_url():
block_until_charm_url = sync_wrapper(async_block_until_charm_url)


async def async_block_until_charm_channel(application, target_channel,
model_name=None, timeout=2700):
"""Block until the charm channel matches target_channel.
An example accessing this function via its sync wrapper::
block_until_charm_channel('cinder', 'yoga/stable')
:param application_name: Name of application
:type application_name: str
:param target_channel: Target charm channel
:type target_channel: str
:param model_name: Name of model to interact with.
:type model_name: str
:param timeout: Time to wait for status to be achieved
:type timeout: float
"""
async def _check_charm_channel():
model_status = await async_get_status(model_name)
charm_channel = model_status.applications[application].charm_channel
return charm_channel == target_channel

Check warning on line 1861 in zaza/model.py

View check run for this annotation

Codecov / codecov/patch

zaza/model.py#L1858-L1861

Added lines #L1858 - L1861 were not covered by tests

await async_block_until(_check_charm_channel, timeout=timeout)

Check warning on line 1863 in zaza/model.py

View check run for this annotation

Codecov / codecov/patch

zaza/model.py#L1863

Added line #L1863 was not covered by tests


block_until_charm_channel = sync_wrapper(async_block_until_charm_channel)


async def async_block_until_service_status(unit_name, services, target_status,
model_name=None, timeout=2700,
pgrep_full=False):
Expand Down

0 comments on commit d6c927f

Please sign in to comment.