Skip to content

Commit 64e8cb6

Browse files
committed
Add test for subordinate charm num-unit auto adjustment
1 parent a69f8fb commit 64e8cb6

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

tests/integration/test_charmhub.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33
from .. import base
4-
from juju.errors import JujuAPIError
4+
from juju.errors import JujuAPIError, JujuError
55

66

77
@base.bootstrapped
@@ -69,3 +69,26 @@ async def test_find_all(event_loop):
6969
for resp in result.result:
7070
assert resp.name != ""
7171
assert resp.type_ in ["charm", "bundle"]
72+
73+
74+
@base.bootstrapped
75+
@pytest.mark.asyncio
76+
async def test_subordinate_charm_zero_units(event_loop):
77+
# normally in pylibjuju deploy num_units defaults to 1, we switch
78+
# that to 0 behind the scenes if we see that the charmhub charm
79+
# we're deploying is a subordinate charm
80+
async with base.CleanModel() as model:
81+
82+
# rsyslog-forwarder-ha is a subordinate charm
83+
app = await model.deploy('rsyslog-forwarder-ha')
84+
assert len(app.units) == 0
85+
await app.destroy()
86+
87+
# note that it'll error if the user tries to use num_units
88+
with pytest.raises(JujuError):
89+
await model.deploy('rsyslog-forwarder-ha', num_units=175)
90+
91+
# (full disclosure: it'll quitely switch to 0 if user enters
92+
# num_units=1)
93+
app2 = await model.deploy('rsyslog-forwarder-ha', num_units=1)
94+
assert len(app2.units) == 0

0 commit comments

Comments
 (0)