Skip to content

Commit

Permalink
- fix channel_codename for auxiliary apps
Browse files Browse the repository at this point in the history
- include auxiliary app on unit test for min_os_release_apps
  • Loading branch information
gabrielcocenza committed Apr 11, 2024
1 parent a2f8357 commit 0cfb929
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 12 deletions.
8 changes: 2 additions & 6 deletions cou/apps/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
5 changes: 2 additions & 3 deletions cou/apps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
74 changes: 71 additions & 3 deletions tests/unit/steps/test_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="",
Expand All @@ -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="",
Expand Down Expand Up @@ -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):
Expand All @@ -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="",
Expand Down Expand Up @@ -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"
)

0 comments on commit 0cfb929

Please sign in to comment.