Skip to content

Commit

Permalink
chore: exact and at least units are exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaqq committed Oct 15, 2024
1 parent a7a613e commit ec9233b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion juju/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ async def _check_idle(

ready_units.append(unit)

if len(ready_units) < _wait_for_units:
if wait_for_exact_units is None and len(ready_units) < _wait_for_units:
logging.info("Waiting for app %r units %s/%s",
app_name, len(ready_units), _wait_for_units)
return False
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_wait_for_idle.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ async def test_wrong_exact_count(full_status_response: dict, kwargs: dict, wrong
assert not idle and not legacy


async def test_exact_count_precedence(full_status_response: dict, kwargs: dict):
app = full_status_response["response"]["applications"]["hexanator"]
app["units"]["hexanator/1"] = copy.deepcopy(app["units"]["hexanator/0"])

kwargs["apps"] = ["hexanator"]
kwargs["wait_for_exact_units"] = 2
kwargs["wait_for_at_least_units"] = 9
kwargs["_wait_for_units"] = 9

idle, legacy = await model_fake(full_status_response).check_both(**kwargs)
assert idle and legacy


async def test_ready_unit_count(full_status_response: dict, kwargs: dict):
app = full_status_response["response"]["applications"]["hexanator"]
app["units"]["hexanator/1"] = copy.deepcopy(app["units"]["hexanator/0"])
Expand Down

0 comments on commit ec9233b

Please sign in to comment.