Skip to content

Commit 84e4a2c

Browse files
authored
Merge pull request #742 from cderici/revise-local-refresh
#742 #### Description This change revises the `local_refresh()` (i.e. `application.upgrade_charm()` with a local charm) to use the `app_facade.GetCharmURLOrigin()` to get the origin of the currently running application charm, instead of trying to pass `channel` to the `SetCharm` like before. We already implemented this when revising `upgrade_charm` in #729, but the upgrade local was missed (we talked about it but I forgot to include it). This should fix the `tests/integration/test_application.py::test_upgrade_local_charm` that's currently failing in the CI runs. #### QA Steps The integration test mentioned above is revised a little bit, so it should pass. QA with different types and shapes of local charms would be appreciated. ``` tox -e integration -- tests/integration/test_application.py::test_upgrade_local_charm ```
2 parents 4d18b7d + f41e893 commit 84e4a2c

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

juju/application.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,6 @@ async def refresh(
633633
:param str switch: Crossgrade charm url
634634
635635
"""
636-
if path is not None:
637-
await self.local_refresh(channel, force, force_series, force_units,
638-
path, resources)
639-
return
640636
if resources is not None:
641637
raise NotImplementedError("resources option is not implemented")
642638

@@ -659,6 +655,11 @@ async def refresh(
659655
charm_url = switch or charm_url_origin_result.url
660656
origin = charm_url_origin_result.charm_origin
661657

658+
if path is not None:
659+
await self.local_refresh(origin, force, force_series,
660+
force_units, path, resources)
661+
return
662+
662663
parsed_url = URL.parse(charm_url)
663664
charm_name = parsed_url.name
664665

@@ -788,7 +789,8 @@ async def refresh(
788789
upgrade_charm = refresh
789790

790791
async def local_refresh(
791-
self, channel=None, force=False, force_series=False, force_units=False,
792+
self, charm_origin=None, force=False, force_series=False,
793+
force_units=False,
792794
path=None, resources=None):
793795
"""Refresh the charm for this application with a local charm.
794796
@@ -831,7 +833,7 @@ async def local_refresh(
831833
# Update application
832834
await app_facade.SetCharm(
833835
application=self.entity_id,
834-
channel=channel,
836+
charm_origin=charm_origin,
835837
charm_url=charm_url,
836838
config_settings=None,
837839
config_settings_yaml=None,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: simple
22
summary: A simple example charm with the new operator framework
3+
series: ["focal"]
34
description: |
45
Simple is an example charm

tests/integration/test_application.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ async def test_upgrade_local_charm(event_loop):
247247
async with base.CleanModel() as model:
248248
tests_dir = Path(__file__).absolute().parent
249249
charm_path = tests_dir / 'upgrade-charm'
250-
app = await model.deploy('cs:ubuntu', series='focal')
250+
app = await model.deploy('ch:ubuntu', series='focal')
251251
await model.wait_for_idle(status="active")
252-
assert app.data['charm-url'].startswith('cs:ubuntu')
252+
assert app.data['charm-url'].startswith('ch:') and 'ubuntu' in \
253+
app.data['charm-url']
253254
await app.upgrade_charm(path=charm_path)
254255
await model.wait_for_idle(status="waiting")
255256
assert app.data['charm-url'] == 'local:focal/ubuntu-0'

0 commit comments

Comments
 (0)