Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ pytestdebug.log
.vscode/
deb_dist
*.tar.gz
.idea/
3 changes: 2 additions & 1 deletion juju/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,8 @@ async def _watcher(stop_event):
try:
results = await utils.run_with_interrupt(
watcher.Next(),
stop_event)
stop_event,
log=log)
except JujuAPIError as e:
if 'watcher was stopped' not in str(e):
raise
Expand Down
3 changes: 2 additions & 1 deletion juju/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,8 @@ async def _all_watcher():
try:
results = await utils.run_with_interrupt(
allwatcher.Next(),
self._watch_stopping)
self._watch_stopping,
log=log)
except JujuAPIError as e:
if 'watcher was stopped' not in str(e):
raise
Expand Down
36 changes: 18 additions & 18 deletions tests/integration/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@base.bootstrapped
@pytest.mark.asyncio
async def test_action(event_loop):
async def test_action():
async with base.CleanModel() as model:
ubuntu_app = await model.deploy(
'percona-cluster',
Expand Down Expand Up @@ -57,7 +57,7 @@ async def test_action(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_get_set_config(event_loop):
async def test_get_set_config():
async with base.CleanModel() as model:
ubuntu_app = await model.deploy(
'percona-cluster',
Expand All @@ -82,7 +82,7 @@ async def test_get_set_config(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_status_is_not_unset(event_loop):
async def test_status_is_not_unset():
async with base.CleanModel() as model:
app = await model.deploy(
'ubuntu',
Expand All @@ -96,7 +96,7 @@ async def test_status_is_not_unset(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_status(event_loop):
async def test_status():
async with base.CleanModel() as model:
app = await model.deploy('cs:~juju-qa/blocked-0')

Expand All @@ -111,7 +111,7 @@ def app_ready():

@base.bootstrapped
@pytest.mark.asyncio
async def test_add_units(event_loop):
async def test_add_units():
from juju.unit import Unit

async with base.CleanModel() as model:
Expand All @@ -130,7 +130,7 @@ async def test_add_units(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_deploy_charmhub_charm(event_loop):
async def test_deploy_charmhub_charm():
async with base.CleanModel() as model:
app = await model.deploy('ch:hello-juju')
await model.block_until(lambda: (len(app.units) > 0 and
Expand All @@ -140,7 +140,7 @@ async def test_deploy_charmhub_charm(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_upgrade_charm_switch_channel(event_loop):
async def test_upgrade_charm_switch_channel():
# Note for future:
# This test requires a charm that has different
# revisions for different channels/risks.
Expand Down Expand Up @@ -184,7 +184,7 @@ async def test_upgrade_charm_switch_channel(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_upgrade_local_charm(event_loop):
async def test_upgrade_local_charm():
# Skip temporarily due to a known problem:
pytest.skip('cannot upgrade application "ubuntu" to charm "local:focal/ubuntu-0": required storage "files" removed')
async with base.CleanModel() as model:
Expand All @@ -201,7 +201,7 @@ async def test_upgrade_local_charm(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_upgrade_switch_charmstore_to_charmhub(event_loop):
async def test_upgrade_switch_charmstore_to_charmhub():
async with base.CleanModel() as model:
app = await model.deploy('cs:ubuntu', series='focal')
await model.wait_for_idle(status="active")
Expand All @@ -213,7 +213,7 @@ async def test_upgrade_switch_charmstore_to_charmhub(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_upgrade_charm_resource(event_loop):
async def test_upgrade_charm_resource():
async with base.CleanModel() as model:
app = await model.deploy('cs:~juju-qa/bionic/upgrade-charm-resource-test-0')

Expand All @@ -233,7 +233,7 @@ async def test_upgrade_charm_resource(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_refresh_with_resource_argument(event_loop):
async def test_refresh_with_resource_argument():
async with base.CleanModel() as model:
app = await model.deploy('juju-qa-test', resources={'foo-file': 2})
res2 = await app.get_resources()
Expand All @@ -245,7 +245,7 @@ async def test_refresh_with_resource_argument(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_upgrade_charm_resource_same_rev_no_update(event_loop):
async def test_upgrade_charm_resource_same_rev_no_update():
async with base.CleanModel() as model:
app = await model.deploy('keystone', channel='victoria/stable')
ress = await app.get_resources()
Expand All @@ -256,7 +256,7 @@ async def test_upgrade_charm_resource_same_rev_no_update(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_refresh_charmhub_to_local(event_loop):
async def test_refresh_charmhub_to_local():
charm_path = INTEGRATION_TEST_DIR / 'charm'
async with base.CleanModel() as model:
app = await model.deploy('ubuntu', application_name='ubu-path')
Expand All @@ -270,7 +270,7 @@ async def test_refresh_charmhub_to_local(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_local_refresh(event_loop):
async def test_local_refresh():
charm_path = INTEGRATION_TEST_DIR / 'charm'
async with base.CleanModel() as model:
app = await model.deploy('ubuntu')
Expand All @@ -286,7 +286,7 @@ async def test_local_refresh(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_upgrade_local_charm_with_resource(event_loop):
async def test_upgrade_local_charm_with_resource():
charm_path = INTEGRATION_TEST_DIR / 'file-resource-charm'
async with base.CleanModel() as model:
app = await model.deploy(str(charm_path))
Expand All @@ -308,7 +308,7 @@ async def test_upgrade_local_charm_with_resource(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_trusted(event_loop):
async def test_trusted():
async with base.CleanModel() as model:
await model.deploy('ubuntu', trust=True)

Expand All @@ -323,7 +323,7 @@ async def test_trusted(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_app_remove_wait_flag(event_loop):
async def test_app_remove_wait_flag():
async with base.CleanModel() as model:
app = await model.deploy('ubuntu')
a_name = app.name
Expand All @@ -335,7 +335,7 @@ async def test_app_remove_wait_flag(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_app_charm_name(event_loop):
async def test_app_charm_name():
async with base.CleanModel() as model:
app = await model.deploy('ubuntu')
await model.wait_for_idle(status="active")
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/test_charmhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@base.bootstrapped
@pytest.mark.asyncio
async def test_info(event_loop):
async def test_info():
async with base.CleanModel() as model:
result = await model.charmhub.info("hello-juju")

Expand All @@ -19,7 +19,7 @@ async def test_info(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_info_with_channel(event_loop):
async def test_info_with_channel():
async with base.CleanModel() as model:
result = await model.charmhub.info("hello-juju", "latest/stable")

Expand All @@ -29,7 +29,7 @@ async def test_info_with_channel(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_info_not_found(event_loop):
async def test_info_not_found():
async with base.CleanModel() as model:
try:
await model.charmhub.info("badnameforapp")
Expand All @@ -41,7 +41,7 @@ async def test_info_not_found(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_find(event_loop):
async def test_find():
async with base.CleanModel() as model:
result = await model.charmhub.find("kube")

Expand All @@ -53,7 +53,7 @@ async def test_find(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_find_bundles(event_loop):
async def test_find_bundles():
async with base.CleanModel() as model:
result = await model.charmhub.find("kube", charm_type="bundle")

Expand All @@ -65,7 +65,7 @@ async def test_find_bundles(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_find_all(event_loop):
async def test_find_all():
async with base.CleanModel() as model:
result = await model.charmhub.find("")

Expand All @@ -77,7 +77,7 @@ async def test_find_all(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_subordinate_charm_zero_units(event_loop):
async def test_subordinate_charm_zero_units():
# normally in pylibjuju deploy num_units defaults to 1, we switch
# that to 0 behind the scenes if we see that the charmhub charm
# we're deploying is a subordinate charm
Expand All @@ -104,7 +104,7 @@ async def test_subordinate_charm_zero_units(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_list_resources(event_loop):
async def test_list_resources():
async with base.CleanModel() as model:
resources = await model.charmhub.list_resources('hello-kubecon')
assert isinstance(resources, list) and len(resources) > 0
2 changes: 1 addition & 1 deletion tests/integration/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@base.bootstrapped
@pytest.mark.asyncio
async def test_user_info(event_loop):
async def test_user_info():
async with base.CleanModel() as model:
controller_conn = await model.connection().controller()

Expand Down
14 changes: 7 additions & 7 deletions tests/integration/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@base.bootstrapped
@pytest.mark.asyncio
async def test_connection_happy_path(event_loop):
async def test_connection_happy_path():
async with base.CleanController() as contr:
conn = contr.connection()
new_cont = Controller()
Expand All @@ -40,7 +40,7 @@ async def test_connection_happy_path(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_monitor(event_loop):
async def test_monitor():
async with base.CleanModel() as model:
conn = model.connection()
assert conn.monitor.status == 'connected'
Expand All @@ -51,7 +51,7 @@ async def test_monitor(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_monitor_catches_error(event_loop):
async def test_monitor_catches_error():

async with base.CleanModel() as model:
conn = model.connection()
Expand All @@ -72,7 +72,7 @@ async def test_monitor_catches_error(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_full_status(event_loop):
async def test_full_status():
async with base.CleanModel() as model:
await model.deploy(
'ubuntu',
Expand All @@ -88,7 +88,7 @@ async def test_full_status(event_loop):

@base.bootstrapped
@pytest.mark.asyncio
async def test_reconnect(event_loop):
async def test_reconnect():
async with base.CleanModel() as model:
kwargs = model.connection().connect_params()
conn = await Connection.connect(**kwargs)
Expand All @@ -105,7 +105,7 @@ async def test_reconnect(event_loop):
@base.bootstrapped
@pytest.mark.asyncio
@pytest.mark.skip('tests the websocket protocol, not pylibjuju, needs to be revised')
async def test_redirect(event_loop):
async def test_redirect():
controller = Controller()
await controller.connect()
kwargs = controller.connection().connect_params()
Expand Down Expand Up @@ -258,7 +258,7 @@ def _find_free_port(self):

@base.bootstrapped
@pytest.mark.asyncio
async def test_verify_controller_cert(event_loop):
async def test_verify_controller_cert():
jujudata = FileJujuData()
controller_name = jujudata.current_controller()
endpoint = jujudata.controllers()[controller_name]['api-endpoints'][0]
Expand Down
Loading