Skip to content

Commit

Permalink
Aligning name of applications (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgildein committed Mar 4, 2024
1 parent 62c2d2f commit 3ddc771
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 93 deletions.
14 changes: 7 additions & 7 deletions cou/apps/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


@AppFactory.register_application(["vault", "ceph-fs", "ceph-radosgw"])
class OpenStackAuxiliaryApplication(OpenStackApplication):
class AuxiliaryApplication(OpenStackApplication):
"""Application for charms that can have multiple OpenStack releases for a workload."""

def is_valid_track(self, charm_channel: str) -> bool:
Expand Down Expand Up @@ -123,7 +123,7 @@ def channel_codename(self) -> OpenStackRelease:


@AppFactory.register_application(["rabbitmq-server"])
class RabbitMQServer(OpenStackAuxiliaryApplication):
class RabbitMQServer(AuxiliaryApplication):
"""RabbitMQ application.
RabbitMQ must wait for the entire model to be idle before declaring the upgrade complete.
Expand All @@ -134,7 +134,7 @@ class RabbitMQServer(OpenStackAuxiliaryApplication):


@AppFactory.register_application(["ceph-mon"])
class CephMonApplication(OpenStackAuxiliaryApplication):
class CephMon(AuxiliaryApplication):
"""Application for Ceph Monitor charm."""

wait_timeout = 30 * 60 # 30 min
Expand Down Expand Up @@ -173,7 +173,7 @@ def _get_change_require_osd_release_step(self) -> PreUpgradeStep:


@AppFactory.register_application(["ovn-central", "ovn-dedicated-chassis"])
class OvnPrincipalApplication(OpenStackAuxiliaryApplication):
class OvnPrincipal(AuxiliaryApplication):
"""Ovn principal application class."""

def pre_upgrade_steps(
Expand All @@ -194,7 +194,7 @@ def pre_upgrade_steps(


@AppFactory.register_application(["mysql-innodb-cluster"])
class MysqlInnodbClusterApplication(OpenStackAuxiliaryApplication):
class MysqlInnodbCluster(AuxiliaryApplication):
"""Application for mysql-innodb-cluster charm."""

# NOTE(agileshaw): holding 'mysql-server-core-8.0' package prevents undesired
Expand All @@ -205,8 +205,8 @@ class MysqlInnodbClusterApplication(OpenStackAuxiliaryApplication):

# NOTE (gabrielcocenza): Although CephOSD class is empty now, it will be
# necessary to add post upgrade plan to set require-osd-release. Registering on
# OpenStackAuxiliaryApplication can be easily forgot and ceph-osd can't be instantiated
# AuxiliaryApplication can be easily forgot and ceph-osd can't be instantiated
# as a normal OpenStackApplication.
@AppFactory.register_application(["ceph-osd"])
class CephOSD(OpenStackAuxiliaryApplication):
class CephOSD(AuxiliaryApplication):
"""Application for ceph-osd."""
10 changes: 4 additions & 6 deletions cou/apps/auxiliary_subordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@
"""Auxiliary subordinate application class."""
from typing import Optional

from cou.apps.auxiliary import OpenStackAuxiliaryApplication
from cou.apps.auxiliary import AuxiliaryApplication
from cou.apps.factory import AppFactory
from cou.apps.subordinate import SubordinateBaseClass
from cou.apps.subordinate import SubordinateBase
from cou.steps import PreUpgradeStep
from cou.utils.app_utils import validate_ovn_support
from cou.utils.juju_utils import COUUnit
from cou.utils.openstack import AUXILIARY_SUBORDINATES, OpenStackRelease


@AppFactory.register_application(AUXILIARY_SUBORDINATES)
class OpenStackAuxiliarySubordinateApplication(
SubordinateBaseClass, OpenStackAuxiliaryApplication
):
class AuxiliarySubordinateApplication(SubordinateBase, AuxiliaryApplication):
"""Auxiliary subordinate application class."""

@property
Expand All @@ -42,7 +40,7 @@ def current_os_release(self) -> OpenStackRelease:


@AppFactory.register_application(["ovn-chassis"])
class OvnSubordinateApplication(OpenStackAuxiliarySubordinateApplication):
class OvnSubordinate(AuxiliarySubordinateApplication):
"""Ovn subordinate application class."""

def pre_upgrade_steps(
Expand Down
2 changes: 1 addition & 1 deletion cou/apps/channel_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


@AppFactory.register_application(CHANNEL_BASED_CHARMS)
class OpenStackChannelBasedApplication(OpenStackApplication):
class ChannelBasedApplication(OpenStackApplication):
"""Application for charms that are channel based."""

def _get_latest_os_version(self, unit: COUUnit) -> OpenStackRelease:
Expand Down
4 changes: 2 additions & 2 deletions cou/apps/subordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
logger = logging.getLogger(__name__)


class SubordinateBaseClass(OpenStackApplication):
class SubordinateBase(OpenStackApplication):
"""Subordinate base class."""

def pre_upgrade_steps(
Expand Down Expand Up @@ -73,7 +73,7 @@ def post_upgrade_steps(


@AppFactory.register_application(SUBORDINATES)
class OpenStackSubordinateApplication(SubordinateBaseClass):
class SubordinateApplication(SubordinateBase):
"""Subordinate application class."""

@property
Expand Down
21 changes: 9 additions & 12 deletions cou/steps/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,19 @@
# decorator
# pylint: disable=unused-import
from cou.apps.auxiliary import ( # noqa: F401
CephMonApplication,
OpenStackAuxiliaryApplication,
OvnPrincipalApplication,
AuxiliaryApplication,
CephMon,
OvnPrincipal,
RabbitMQServer,
)
from cou.apps.auxiliary_subordinate import ( # noqa: F401
OpenStackAuxiliarySubordinateApplication,
OvnSubordinateApplication,
AuxiliarySubordinateApplication,
OvnSubordinate,
)
from cou.apps.base import OpenStackApplication
from cou.apps.channel_based import OpenStackChannelBasedApplication # noqa: F401
from cou.apps.channel_based import ChannelBasedApplication # noqa: F401
from cou.apps.core import Keystone, Octavia # noqa: F401
from cou.apps.subordinate import ( # noqa: F401
OpenStackSubordinateApplication,
SubordinateBaseClass,
)
from cou.apps.subordinate import SubordinateApplication, SubordinateBase # noqa: F401
from cou.commands import CLIargs
from cou.exceptions import (
DataPlaneCannotUpgrade,
Expand Down Expand Up @@ -318,15 +315,15 @@ def _generate_control_plane_plan(
description="Control Plane principal(s) upgrade plan",
target=target,
force=force,
filter_function=lambda app: not isinstance(app, SubordinateBaseClass),
filter_function=lambda app: not isinstance(app, SubordinateBase),
)

subordinate_upgrade_plan = create_upgrade_group(
apps=apps,
description="Control Plane subordinate(s) upgrade plan",
target=target,
force=force,
filter_function=lambda app: isinstance(app, SubordinateBaseClass),
filter_function=lambda app: isinstance(app, SubordinateBase),
)

logger.debug("Generation of the control plane upgrade plan complete")
Expand Down
35 changes: 15 additions & 20 deletions tests/unit/apps/test_auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@

import pytest

from cou.apps.auxiliary import (
CephMonApplication,
MysqlInnodbClusterApplication,
OvnPrincipalApplication,
RabbitMQServer,
)
from cou.apps.auxiliary import CephMon, MysqlInnodbCluster, OvnPrincipal, RabbitMQServer
from cou.exceptions import ApplicationError, HaltUpgradePlanGeneration
from cou.steps import (
ApplicationUpgradePlan,
Expand Down Expand Up @@ -560,10 +555,10 @@ def test_auxiliary_no_suitable_channel(model):


def test_ceph_mon_app(model):
"""Test the correctness of instantiating CephMonApplication."""
"""Test the correctness of instantiating CephMon."""
charm = "ceph-mon"
machines = {"0": MagicMock(spec_set=COUMachine)}
app = CephMonApplication(
app = CephMon(
name=charm,
can_upgrade_to="",
charm=charm,
Expand Down Expand Up @@ -597,7 +592,7 @@ def test_ceph_mon_upgrade_plan_xena_to_yoga(model):
target = OpenStackRelease("yoga")
charm = "ceph-mon"
machines = {"0": MagicMock(spec_set=COUMachine)}
app = CephMonApplication(
app = CephMon(
name=charm,
can_upgrade_to="quincy/stable",
charm=charm,
Expand Down Expand Up @@ -686,7 +681,7 @@ def test_ceph_mon_upgrade_plan_ussuri_to_victoria(model):
target = OpenStackRelease("victoria")
charm = "ceph-mon"
machines = {"0": MagicMock(spec_set=COUMachine)}
app = CephMonApplication(
app = CephMon(
name=charm,
can_upgrade_to="quincy/stable",
charm=charm,
Expand Down Expand Up @@ -766,10 +761,10 @@ def test_ceph_mon_upgrade_plan_ussuri_to_victoria(model):


def test_ovn_principal(model):
"""Test the correctness of instantiating OvnPrincipalApplication."""
"""Test the correctness of instantiating OvnPrincipal."""
charm = "ovn-central"
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OvnPrincipalApplication(
app = OvnPrincipal(
name=charm,
can_upgrade_to="22.06/stable",
charm=charm,
Expand Down Expand Up @@ -798,7 +793,7 @@ def test_ovn_principal(model):


def test_ovn_workload_ver_lower_than_22_principal(model):
"""Test the OvnPrincipalApplication with lower version than 22."""
"""Test the OvnPrincipal with lower version than 22."""
target = OpenStackRelease("victoria")
charm = "ovn-central"
exp_msg = (
Expand All @@ -808,7 +803,7 @@ def test_ovn_workload_ver_lower_than_22_principal(model):
"ovn-upgrade-2203.html"
)
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OvnPrincipalApplication(
app = OvnPrincipal(
name=charm,
can_upgrade_to="22.03/stable",
charm=charm,
Expand All @@ -835,7 +830,7 @@ def test_ovn_workload_ver_lower_than_22_principal(model):

@pytest.mark.parametrize("channel", ["55.7", "19.03"])
def test_ovn_no_compatible_os_release(channel, model):
"""Test the OvnPrincipalApplication with not compatible os release."""
"""Test the OvnPrincipal with not compatible os release."""
charm = "ovn-central"
machines = {"0": MagicMock(spec_set=COUMachine)}
exp_msg = (
Expand All @@ -846,7 +841,7 @@ def test_ovn_no_compatible_os_release(channel, model):
)

with pytest.raises(ApplicationError, match=exp_msg):
OvnPrincipalApplication(
OvnPrincipal(
name=charm,
can_upgrade_to="quincy/stable",
charm=charm,
Expand All @@ -869,11 +864,11 @@ def test_ovn_no_compatible_os_release(channel, model):


def test_ovn_principal_upgrade_plan(model):
"""Test generating plan for OvnPrincipalApplication."""
"""Test generating plan for OvnPrincipal."""
target = OpenStackRelease("victoria")
charm = "ovn-central"
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OvnPrincipalApplication(
app = OvnPrincipal(
name=charm,
can_upgrade_to="22.06/stable",
charm=charm,
Expand Down Expand Up @@ -949,11 +944,11 @@ def test_ovn_principal_upgrade_plan(model):


def test_mysql_innodb_cluster_upgrade(model):
"""Test generating plan for MysqlInnodbClusterApplication."""
"""Test generating plan for MysqlInnodbCluster."""
target = OpenStackRelease("victoria")
charm = "mysql-innodb-cluster"
machines = {"0": MagicMock(spec_set=COUMachine)}
app = MysqlInnodbClusterApplication(
app = MysqlInnodbCluster(
name=charm,
can_upgrade_to="9.0",
charm=charm,
Expand Down
28 changes: 14 additions & 14 deletions tests/unit/apps/test_auxiliary_subordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import pytest

from cou.apps.auxiliary_subordinate import (
OpenStackAuxiliarySubordinateApplication,
OvnSubordinateApplication,
AuxiliarySubordinateApplication,
OvnSubordinate,
)
from cou.exceptions import ApplicationError
from cou.steps import ApplicationUpgradePlan, PreUpgradeStep, UpgradeStep
Expand All @@ -32,7 +32,7 @@
def test_auxiliary_subordinate(model):
"""Test auxiliary subordinate application."""
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OpenStackAuxiliarySubordinateApplication(
app = AuxiliarySubordinateApplication(
name="keystone-mysql-router",
can_upgrade_to="",
charm="mysql-router",
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_auxiliary_subordinate_upgrade_plan_to_victoria(model):
"""Test auxiliary subordinate application upgrade plan to victoria."""
target = OpenStackRelease("victoria")
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OpenStackAuxiliarySubordinateApplication(
app = AuxiliarySubordinateApplication(
name="keystone-mysql-router",
can_upgrade_to="8.0/stable",
charm="mysql-router",
Expand Down Expand Up @@ -104,9 +104,9 @@ def test_auxiliary_subordinate_upgrade_plan_to_victoria(model):


def test_ovn_subordinate(model):
"""Test the correctness of instantiating OvnSubordinateApplication."""
"""Test the correctness of instantiating OvnSubordinate."""
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OvnSubordinateApplication(
app = OvnSubordinate(
name="ovn-chassis",
can_upgrade_to="22.03/stable",
charm="ovn-chassis",
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_ovn_subordinate(model):


def test_ovn_workload_ver_lower_than_22_subordinate(model):
"""Test the OvnSubordinateApplication with lower version than 22."""
"""Test the OvnSubordinate with lower version than 22."""
target = OpenStackRelease("victoria")
machines = {"0": MagicMock(spec_set=COUMachine)}
exp_msg = (
Expand All @@ -145,7 +145,7 @@ def test_ovn_workload_ver_lower_than_22_subordinate(model):
"https://docs.openstack.org/charm-guide/latest/project/procedures/"
"ovn-upgrade-2203.html"
)
app = OvnSubordinateApplication(
app = OvnSubordinate(
name="ovn-chassis",
can_upgrade_to="22.03/stable",
charm="ovn-chassis",
Expand All @@ -171,10 +171,10 @@ def test_ovn_workload_ver_lower_than_22_subordinate(model):


def test_ovn_subordinate_upgrade_plan(model):
"""Test generating plan for OvnSubordinateApplication."""
"""Test generating plan for OvnSubordinate."""
target = OpenStackRelease("victoria")
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OvnSubordinateApplication(
app = OvnSubordinate(
name="ovn-chassis",
can_upgrade_to="22.03/stable",
charm="ovn-chassis",
Expand Down Expand Up @@ -214,14 +214,14 @@ def test_ovn_subordinate_upgrade_plan(model):


def test_ovn_subordinate_upgrade_plan_cant_upgrade_charm(model):
"""Test generating plan for OvnSubordinateApplication failing.
"""Test generating plan for OvnSubordinate failing.
The ovn chassis 22.03 is considered yoga. If it's not necessary to upgrade the charm code,
there is no steps to upgrade.
"""
target = OpenStackRelease("victoria")
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OvnSubordinateApplication(
app = OvnSubordinate(
name="ovn-chassis",
can_upgrade_to="",
charm="ovn-chassis",
Expand Down Expand Up @@ -256,7 +256,7 @@ def test_ceph_dashboard_upgrade_plan_ussuri_to_victoria(model):
"""Test when ceph version remains the same between os releases."""
target = OpenStackRelease("victoria")
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OpenStackAuxiliarySubordinateApplication(
app = AuxiliarySubordinateApplication(
name="ceph-dashboard",
can_upgrade_to="octopus/stable",
charm="ceph-dashboard",
Expand Down Expand Up @@ -299,7 +299,7 @@ def test_ceph_dashboard_upgrade_plan_xena_to_yoga(model):
"""Test when ceph version changes between os releases."""
target = OpenStackRelease("yoga")
machines = {"0": MagicMock(spec_set=COUMachine)}
app = OpenStackAuxiliarySubordinateApplication(
app = AuxiliarySubordinateApplication(
name="ceph-dashboard",
can_upgrade_to="pacific/stable",
charm="ceph-dashboard",
Expand Down
Loading

0 comments on commit 3ddc771

Please sign in to comment.