From 0cfb929f597bb465d3c6aeade8375bfff5643461 Mon Sep 17 00:00:00 2001 From: Gabriel Cocenza Date: Thu, 11 Apr 2024 16:08:24 -0300 Subject: [PATCH] - fix channel_codename for auxiliary apps - include auxiliary app on unit test for min_os_release_apps --- cou/apps/auxiliary.py | 8 +--- cou/apps/base.py | 5 +-- tests/unit/steps/test_analyze.py | 74 ++++++++++++++++++++++++++++++-- 3 files changed, 75 insertions(+), 12 deletions(-) diff --git a/cou/apps/auxiliary.py b/cou/apps/auxiliary.py index c17dbdc0..1e177fad 100644 --- a/cou/apps/auxiliary.py +++ b/cou/apps/auxiliary.py @@ -112,13 +112,9 @@ def channel_codename(self) -> OpenStackRelease: :raises ApplicationError: When cannot identify suitable OpenStack release codename based on the track of the charm channel. """ - if self.is_from_charm_store: + if not self.using_release_channel: logger.debug( - ( - "'Application %s' installed from charm store; assuming Ussuri as the " - "underlying version." - ), - self.name, + "%s cannot determine OpenStack release by channel. Assuming as Ussuri", self.name ) return OpenStackRelease("ussuri") diff --git a/cou/apps/base.py b/cou/apps/base.py index e7aaf4ac..2ffdea78 100644 --- a/cou/apps/base.py +++ b/cou/apps/base.py @@ -180,11 +180,10 @@ def channel_codename(self) -> OpenStackRelease: """ if not self.using_release_channel: logger.debug( - "'%s' cannot determine OpenStack release by the channel and " - "will be considered as Ussuri.", - self.name, + "%s cannot determine OpenStack release by channel. Assuming as Ussuri", self.name ) return OpenStackRelease("ussuri") + # get the OpenStack release from the channel track of the application. return OpenStackRelease(self._get_track_from_channel(self.channel)) diff --git a/tests/unit/steps/test_analyze.py b/tests/unit/steps/test_analyze.py index 8ed01153..979113c6 100644 --- a/tests/unit/steps/test_analyze.py +++ b/tests/unit/steps/test_analyze.py @@ -542,6 +542,7 @@ def test_split_apps(exp_control_plane, exp_data_plane): def test_min_os_release_apps_release_channel(model): """Test to evaluate the Openstack release using release channels on apps.""" machines = {f"{i}": generate_cou_machine(f"{i}") for i in range(3)} + keystone = Keystone( name="keystone", can_upgrade_to="", @@ -563,6 +564,27 @@ def test_min_os_release_apps_release_channel(model): workload_version="19.1.0", ) + rmq = RabbitMQServer( + name="rabbitmq-server", + can_upgrade_to="", + charm="rabbitmq-server", + channel="3.8/stable", + config={"source": {"value": "cloud:focal-wallaby"}}, + machines={"2": machines["2"]}, + model=model, + origin="ch", + series="focal", + subordinate_to=[], + units={ + "rabbitmq-server/0": Unit( + name="rabbitmq-server/0", + workload_version="3.8", + machine=machines["2"], + ) + }, + workload_version="3.8", + ) + ch_subordinate_using_release = SubordinateApplication( name="keystone-ldap", can_upgrade_to="", @@ -600,19 +622,29 @@ def test_min_os_release_apps_release_channel(model): ) assert keystone.current_os_release == "wallaby" + assert keystone.channel_codename == "wallaby" + + assert rmq.current_os_release == "yoga" + assert rmq.channel_codename == "yoga" + assert ch_subordinate_using_release.current_os_release == "victoria" + assert ch_subordinate_using_release.channel_codename == "victoria" + assert channel_app_using_release.current_os_release == "ussuri" + assert channel_app_using_release.channel_codename == "ussuri" # channel_app_using_release and ch_subordinate_using_release are considered because are # using release channel assert ( Analysis.min_os_release_apps( - [keystone, channel_app_using_release, ch_subordinate_using_release] + [keystone, rmq, channel_app_using_release, ch_subordinate_using_release] ) == "ussuri" ) - assert Analysis.min_os_release_apps([keystone, ch_subordinate_using_release]) == "victoria" + assert ( + Analysis.min_os_release_apps([keystone, rmq, ch_subordinate_using_release]) == "victoria" + ) def test_min_os_release_apps_not_release_channel(model): @@ -639,6 +671,27 @@ def test_min_os_release_apps_not_release_channel(model): workload_version="19.1.0", ) + rmq_latest_stable = RabbitMQServer( + name="rabbitmq-server", + can_upgrade_to="", + charm="rabbitmq-server", + channel="latest/stable", + config={"source": {"value": "distro"}}, + machines={"0": machines["0"]}, + model=model, + origin="ch", + series="focal", + subordinate_to=[], + units={ + "rabbitmq-server/0": Unit( + name="rabbitmq-server/0", + workload_version="3.8", + machine=machines["0"], + ) + }, + workload_version="3.8", + ) + cs_subordinate = SubordinateApplication( name="keystone-ldap", can_upgrade_to="", @@ -676,14 +729,29 @@ def test_min_os_release_apps_not_release_channel(model): ) assert keystone_latest_stable.current_os_release == "wallaby" + assert keystone_latest_stable.channel_codename == "ussuri" + + assert rmq_latest_stable.current_os_release == "yoga" + assert rmq_latest_stable.channel_codename == "ussuri" + assert cs_subordinate.current_os_release == "ussuri" + assert cs_subordinate.channel_codename == "ussuri" + assert channel_app_latest_stable.current_os_release == "ussuri" + assert channel_app_latest_stable.channel_codename == "ussuri" # channel_app_latest_stable is skipped because is using latest/stable # cs_subordinate is disconsidered because is from charmstore assert ( Analysis.min_os_release_apps( - [keystone_latest_stable, channel_app_latest_stable, cs_subordinate] + [keystone_latest_stable, rmq_latest_stable, channel_app_latest_stable, cs_subordinate] ) == "wallaby" ) + + assert ( + Analysis.min_os_release_apps( + [rmq_latest_stable, channel_app_latest_stable, cs_subordinate] + ) + == "yoga" + )