10 async def test_action(event_loop
):
11 async with base
.CleanModel() as model
:
12 ubuntu_app
= await model
.deploy(
14 application_name
='mysql',
18 'tuning-level': 'safest',
25 # update and check app config
26 await ubuntu_app
.set_config({'tuning-level': 'fast'})
27 config
= await ubuntu_app
.get_config()
28 assert config
['tuning-level']['value'] == 'fast'
30 # update and check app constraints
31 await ubuntu_app
.set_constraints({'mem': 512 * MB
})
32 constraints
= await ubuntu_app
.get_constraints()
33 assert constraints
['mem'] == 512 * MB
38 async def test_add_units(event_loop
):
39 from juju
.unit
import Unit
41 async with base
.CleanModel() as model
:
42 app
= await model
.deploy(
44 application_name
='ubuntu',
48 units
= await app
.add_units(count
=2)
50 assert len(units
) == 2
52 assert isinstance(unit
, Unit
)
57 async def test_upgrade_charm(event_loop
):
58 async with base
.CleanModel() as model
:
59 app
= await model
.deploy('ubuntu-0')
60 assert app
.data
['charm-url'] == 'cs:ubuntu-0'
61 await app
.upgrade_charm()
62 assert app
.data
['charm-url'].startswith('cs:ubuntu-')
63 assert app
.data
['charm-url'] != 'cs:ubuntu-0'
68 async def test_upgrade_charm_channel(event_loop
):
69 async with base
.CleanModel() as model
:
70 app
= await model
.deploy('ubuntu-0')
71 assert app
.data
['charm-url'] == 'cs:ubuntu-0'
72 await app
.upgrade_charm(channel
='stable')
73 assert app
.data
['charm-url'].startswith('cs:ubuntu-')
74 assert app
.data
['charm-url'] != 'cs:ubuntu-0'
79 async def test_upgrade_charm_revision(event_loop
):
80 async with base
.CleanModel() as model
:
81 app
= await model
.deploy('ubuntu-0')
82 assert app
.data
['charm-url'] == 'cs:ubuntu-0'
83 await app
.upgrade_charm(revision
=8)
84 assert app
.data
['charm-url'] == 'cs:ubuntu-8'
89 async def test_upgrade_charm_switch(event_loop
):
90 async with base
.CleanModel() as model
:
91 app
= await model
.deploy('ubuntu-0')
92 assert app
.data
['charm-url'] == 'cs:ubuntu-0'
93 await app
.upgrade_charm(switch
='ubuntu-8')
94 assert app
.data
['charm-url'] == 'cs:ubuntu-8'