From 80158fb05b5f56bf52c3b13393303c3c6e5a12c2 Mon Sep 17 00:00:00 2001 From: Ray Chan Date: Tue, 17 Sep 2024 18:24:01 +0800 Subject: [PATCH] Remove unused code and small refactoring (#534) * Revert "Add subordinate units information for Application. (#497)" This reverts commit 98950e774d69e857b5370decd7cbe2121ff4c1cd. * Partially revert "feat: Restart ceilometer-agent-compute after nova-compute upgrade (#435)" This partially reverts commit a966c9db22bef449ae8e82b64d72277b54b02057. * Small refactoring --- cou/apps/base.py | 1 - cou/apps/core.py | 40 +--- cou/apps/factory.py | 1 - cou/steps/ceph.py | 47 ++--- cou/steps/nova_cloud_controller.py | 42 ++-- cou/steps/plan.py | 32 ++- cou/utils/juju_utils.py | 29 ++- .../018346c5-f95c-46df-a34e-9a78bdec0018.yaml | 75 ------- .../9eb9af6a-b919-4cf9-8f2f-9df16a1556be.yaml | 74 ------- tests/mocked_plans/sample_plans/base.yaml | 7 - tests/mocked_plans/utils.py | 1 - tests/unit/apps/test_auxiliary.py | 47 +---- tests/unit/apps/test_auxiliary_subordinate.py | 13 -- tests/unit/apps/test_base.py | 39 +--- tests/unit/apps/test_channel_based.py | 9 - tests/unit/apps/test_core.py | 60 +----- tests/unit/apps/test_subordinate.py | 9 - tests/unit/steps/test_analyze.py | 22 --- tests/unit/steps/test_ceph.py | 187 +++--------------- tests/unit/steps/test_hypervisor.py | 11 -- .../unit/steps/test_nova_cloud_controller.py | 54 ++--- tests/unit/steps/test_plan.py | 45 ++--- tests/unit/utils.py | 21 +- tests/unit/utils/test_juju_utils.py | 10 - 24 files changed, 198 insertions(+), 678 deletions(-) diff --git a/cou/apps/base.py b/cou/apps/base.py index 5fab113a..0c71eb8a 100644 --- a/cou/apps/base.py +++ b/cou/apps/base.py @@ -115,7 +115,6 @@ def __str__(self) -> str: "origin": self.origin, "series": self.series, "subordinate_to": self.subordinate_to, - "subordinate_units": self.subordinate_units, "workload_version": self.workload_version, "units": { unit.name: { diff --git a/cou/apps/core.py b/cou/apps/core.py index cdf98f08..4fd17d1e 100644 --- a/cou/apps/core.py +++ b/cou/apps/core.py @@ -106,45 +106,7 @@ def post_upgrade_steps( :return: List of post upgrade steps. :rtype: list[PostUpgradeStep] """ - return ( - self._get_enable_scheduler_step(units) - + self._get_restart_subordinate_services_steps(units) - + super().post_upgrade_steps(target, units) - ) - - def _get_restart_subordinate_services_steps( - self, units: Optional[list[Unit]] - ) -> list[PostUpgradeStep]: - """Get step to restart all subordinate services if they aren't running. - - :param units: Units to restart subordinate services. - :type units: Optional[list[Unit]] - :return: Steps to restart to subordinate services - :rtype: list[PostUpgradeStep] - """ - if not units: - units = list(self.units.values()) - steps = [] - for unit in units: - for subordinate in unit.subordinates: - if "ceilometer-agent" == subordinate.charm: - service = "ceilometer-agent-compute" - steps.append( - PostUpgradeStep( - description=( - "Restart service ceilometer-agent-compute " - f"for subordinate unit: '{subordinate.name}'" - ), - coro=self.model.run_on_unit( - unit_name=subordinate.name, - command=( - f"systemctl is-active --quiet {service}" - f" || systemctl restart {service}" - ), - ), - ) - ) - return steps + return self._get_enable_scheduler_step(units) + super().post_upgrade_steps(target, units) def _get_unit_upgrade_steps(self, unit: Unit, force: bool) -> UnitUpgradeStep: """Get the upgrade steps for a single unit. diff --git a/cou/apps/factory.py b/cou/apps/factory.py index 338d0786..bfdfa4a9 100644 --- a/cou/apps/factory.py +++ b/cou/apps/factory.py @@ -57,7 +57,6 @@ def create(cls, app: Application) -> Optional[OpenStackApplication]: series=app.series, subordinate_to=app.subordinate_to, units=app.units, - subordinate_units=app.subordinate_units, workload_version=app.workload_version, actions=app.actions, ) diff --git a/cou/steps/ceph.py b/cou/steps/ceph.py index f1352606..3bab0378 100644 --- a/cou/steps/ceph.py +++ b/cou/steps/ceph.py @@ -15,6 +15,7 @@ """Functions for prereq steps related to ceph.""" import json import logging +from typing import Sequence from cou.exceptions import ( ApplicationError, @@ -22,7 +23,7 @@ RunUpgradeError, UnitNotFound, ) -from cou.utils.juju_utils import Application, Model +from cou.utils.juju_utils import Application, Model, get_applications_by_charm_name from cou.utils.openstack import CEPH_RELEASES logger = logging.getLogger(__name__) @@ -97,25 +98,7 @@ async def _get_current_osd_release(unit: str, model: Model) -> str: return current_osd_release -async def _get_applications(model: Model) -> list[Application]: - """Get the all ceph mon application(s) from the model. - - :param model: The juju model to work with - :type model: Model - :return: A list of ceph-mon applications - :type: Application - :raise ApplicationNotFound: if ceph-mon no founnd - """ - apps = await model.get_applications() - ceph_mon_apps = [app for app in apps.values() if app.charm == "ceph-mon"] - if not ceph_mon_apps: - raise ApplicationNotFound( - "'ceph-mon' application not found, is this a valid OpenStack cloud?" - ) - return ceph_mon_apps - - -async def _get_unit_name(ceph_mon_app: Application) -> str: +def _get_unit_name(ceph_mon_app: Application) -> str: """Get the one of the unit's name from ceph mon application. :param ceph_mon_app: The ceph mon application @@ -130,7 +113,7 @@ async def _get_unit_name(ceph_mon_app: Application) -> str: return ceph_mon_units[0].name -async def osd_noout(model: Model, enable: bool) -> None: +async def osd_noout(model: Model, apps: Sequence[Application], enable: bool) -> None: """Set or unset 'noout' for ceph cluster(s). Note this will set or unset 'noout' flag for all ceph clusters present in @@ -138,11 +121,13 @@ async def osd_noout(model: Model, enable: bool) -> None: :param model: The juju model to work with :type model: Model + :param apps: List of Application + :type apps: Sequence[Application] :param enable: True to set noout, False to unset noout :type enable: bool """ try: - ceph_mon_apps = await _get_applications(model) + ceph_mon_apps = get_applications_by_charm_name(apps, "ceph-mon") except ApplicationNotFound as e: logger.warning("%s", str(e)) logger.warning("Skip changing 'noout', because there's no ceph-mon applications.") @@ -150,7 +135,7 @@ async def osd_noout(model: Model, enable: bool) -> None: for ceph_mon_app in ceph_mon_apps: try: - ceph_mon_unit_name = await _get_unit_name(ceph_mon_app) + ceph_mon_unit_name = _get_unit_name(ceph_mon_app) except UnitNotFound as e: logger.warning("%s", str(e)) logger.warning( @@ -177,7 +162,7 @@ async def get_osd_noout_state(model: Model, unit_name: str) -> bool: return "noout" in json.loads(results["stdout"].strip()).get("flags_set", []) -async def assert_osd_noout_state(model: Model, state: bool) -> None: +async def assert_osd_noout_state(model: Model, apps: Sequence[Application], state: bool) -> None: """Assert ceph cluster is set (state=True) or unset (state=False). Note this will assert 'noout' flag is in the desired state for all ceph @@ -185,12 +170,14 @@ async def assert_osd_noout_state(model: Model, state: bool) -> None: :param model: The juju model to work with :type model: Model + :param apps:List of Application + :type apps: Sequence[Application] :param state: True noout is set, otherwise False :type state: bool :raise ApplicationError: if noout is not in desired state """ try: - ceph_mon_apps = await _get_applications(model) + ceph_mon_apps = get_applications_by_charm_name(apps, "ceph-mon") except ApplicationNotFound as e: logger.warning("%s", str(e)) logger.warning("Skip verifying 'noout', because there's no ceph-mon applications.") @@ -199,7 +186,7 @@ async def assert_osd_noout_state(model: Model, state: bool) -> None: error = False for ceph_mon_app in ceph_mon_apps: try: - ceph_mon_unit_name = await _get_unit_name(ceph_mon_app) + ceph_mon_unit_name = _get_unit_name(ceph_mon_app) except UnitNotFound as e: logger.warning("%s", str(e)) logger.warning( @@ -242,7 +229,7 @@ async def set_require_osd_release_option_on_unit(model: Model, unit_name: str) - await model.run_on_unit(unit_name=unit_name, command=set_command, timeout=600) -async def set_require_osd_release_option(model: Model) -> None: +async def set_require_osd_release_option(model: Model, apps: Sequence[Application]) -> None: """Check and set the correct value for require-osd-release on all ceph-mon unit. This function compares the value of require-osd-release option with the @@ -254,10 +241,12 @@ async def set_require_osd_release_option(model: Model) -> None: :param model: Model object :type model: Model + :param apps:List of Application + :type apps: Sequence[Application] :raises CommandRunFailed: When a command fails to run. """ try: - ceph_mon_apps = await _get_applications(model) + ceph_mon_apps = get_applications_by_charm_name(apps, "ceph-mon") except ApplicationNotFound as e: logger.warning("%s", str(e)) logger.warning( @@ -267,7 +256,7 @@ async def set_require_osd_release_option(model: Model) -> None: for ceph_mon_app in ceph_mon_apps: try: - ceph_mon_unit_name = await _get_unit_name(ceph_mon_app) + ceph_mon_unit_name = _get_unit_name(ceph_mon_app) except UnitNotFound as e: logger.warning("%s", str(e)) logger.warning( diff --git a/cou/steps/nova_cloud_controller.py b/cou/steps/nova_cloud_controller.py index 22adc580..9ce8a3b3 100644 --- a/cou/steps/nova_cloud_controller.py +++ b/cou/steps/nova_cloud_controller.py @@ -14,15 +14,15 @@ """Functions for prereq steps relating to nova.""" import logging -from typing import Optional +from typing import Optional, Sequence -from cou.exceptions import ApplicationNotFound, COUException, UnitNotFound -from cou.utils.juju_utils import Model +from cou.exceptions import COUException, UnitNotFound +from cou.utils.juju_utils import Application, Model, get_applications_by_charm_name logger = logging.getLogger(__name__) -async def archive(model: Model, *, batch_size: int) -> None: +async def archive(model: Model, apps: Sequence[Application], *, batch_size: int) -> None: """Archive data on a nova-cloud-controller unit. The archive-data action only runs a single batch, @@ -32,12 +32,14 @@ async def archive(model: Model, *, batch_size: int) -> None: https://docs.openstack.org/project-deploy-guide/charm-deployment-guide/wallaby/upgrade-openstack.html#archive-old-database-data :param model: juju model to work with :type model: Model + :param apps: Applications in the model + :type apps: Sequence of Applications :param batch_size: batch-size to pass to the archive-data action (default is 1000; decrease if performance issues seen) :type batch_size: int :raises COUException: if action returned unexpected output """ # noqa: E501 line too long - unit_name: str = await _get_nova_cloud_controller_unit_name(model) + unit_name: str = _get_nova_cloud_controller_unit_name(apps) # The archive-data action only archives a single batch, # so we must run it in a loop until everything is archived. while True: @@ -64,12 +66,14 @@ async def archive(model: Model, *, batch_size: int) -> None: logger.debug("Potentially more data to archive...") -async def purge(model: Model, before: Optional[str]) -> None: +async def purge(model: Model, apps: Sequence[Application], before: Optional[str]) -> None: """Purge data on a nova-cloud-controller unit. The purge-data action delete rows from shadow tables. :param model: juju model to work with :type model: Model + :param apps: Applications in the model + :type apps: Sequence of Applications :param before: specifying before will delete data from all shadow tables that is older than the data provided. Date string format should be YYYY-MM-DD[HH:mm][:ss] @@ -79,7 +83,7 @@ async def purge(model: Model, before: Optional[str]) -> None: if before is not None: action_params = {"before": before} - unit_name: str = await _get_nova_cloud_controller_unit_name(model) + unit_name: str = _get_nova_cloud_controller_unit_name(apps) action = await model.run_action( unit_name=unit_name, action_name="purge-data", @@ -102,27 +106,21 @@ async def purge(model: Model, before: Optional[str]) -> None: logger.info("purge-data action succeeded on %s", unit_name) -async def _get_nova_cloud_controller_unit_name(model: Model) -> str: +def _get_nova_cloud_controller_unit_name(apps: Sequence[Application]) -> str: """Get nova-cloud-controller application's first unit's name. Assumes only a single nova-cloud-controller application is deployed. - :param model: juju model to work with - :type model: Model + :param apps: Applications in the model + :type apps: Sequence of Applications :return: unit name :rtype: str :raises UnitNotFound: When cannot find a valid unit for 'nova-cloud-controller' :raises ApplicationNotFound: When cannot find a 'nova-cloud-controller' application """ - status = await model.get_status() - for app_name, app_config in status.applications.items(): - charm_name = await model.get_charm_name(app_name) - if charm_name == "nova-cloud-controller": - units = list(app_config.units.keys()) - if units: - return units[0] - raise UnitNotFound( - f"Cannot find unit for 'nova-cloud-controller' in model '{model.name}'." - ) - - raise ApplicationNotFound(f"Cannot find 'nova-cloud-controller' in model '{model.name}'.") + apps = get_applications_by_charm_name(apps, "nova-cloud-controller") + for app in apps: + units = list(app.units.keys()) + if units: + return units[0] + raise UnitNotFound("Cannot find unit for 'nova-cloud-controller'.") diff --git a/cou/steps/plan.py b/cou/steps/plan.py index 5bcfb7e5..2355caee 100644 --- a/cou/steps/plan.py +++ b/cou/steps/plan.py @@ -137,7 +137,9 @@ async def post_upgrade_sanity_checks(analysis_result: Analysis) -> None: """ messages = [] try: - await ceph.assert_osd_noout_state(analysis_result.model, state=False) + await ceph.assert_osd_noout_state( + analysis_result.model, analysis_result.apps_control_plane, state=False + ) except ApplicationError: messages.append("Detected ceph 'noout' set, please unset noout for ceph cluster.") @@ -435,7 +437,9 @@ def _get_pre_upgrade_steps(analysis_result: Analysis, args: CLIargs) -> list[Pre PreUpgradeStep( description="Verify ceph cluster 'noout' is unset", parallel=False, - coro=ceph.assert_osd_noout_state(analysis_result.model, state=False), + coro=ceph.assert_osd_noout_state( + analysis_result.model, analysis_result.apps_control_plane, state=False + ), ), PreUpgradeStep( description="Verify that all OpenStack applications are in idle state", @@ -503,7 +507,11 @@ def _get_purge_data_steps(analysis_result: Analysis, args: CLIargs) -> list[PreU return [ PreUpgradeStep( description=msg, - coro=purge(analysis_result.model, before=args.purge_before), + coro=purge( + analysis_result.model, + analysis_result.apps_data_plane, # we only need to pass nova-cloud-controller + before=args.purge_before, + ), ) ] return [] @@ -523,7 +531,11 @@ def _get_archive_data_steps(analysis_result: Analysis, args: CLIargs) -> list[Pr return [ PreUpgradeStep( description="Archive old database data on nova-cloud-controller", - coro=archive(analysis_result.model, batch_size=args.archive_batch_size), + coro=archive( + analysis_result.model, + analysis_result.apps_data_plane, + batch_size=args.archive_batch_size, + ), ) ] return [] @@ -543,7 +555,9 @@ def _get_set_noout_steps(analysis_result: Analysis, args: CLIargs) -> list[PreUp return [ PreUpgradeStep( description="Set ceph cluster 'noout' flag before data plane upgrade", - coro=ceph.osd_noout(analysis_result.model, enable=True), + coro=ceph.osd_noout( + analysis_result.model, analysis_result.apps_control_plane, enable=True + ), ) ] PlanStatus.add_message( @@ -570,14 +584,18 @@ def _get_post_upgrade_steps(analysis_result: Analysis, args: CLIargs) -> list[Po steps.append( PostUpgradeStep( "Ensure ceph-mon's 'require-osd-release' option matches the 'ceph-osd' version", - coro=ceph.set_require_osd_release_option(analysis_result.model), + coro=ceph.set_require_osd_release_option( + analysis_result.model, analysis_result.apps_control_plane + ), ) ) if args.set_noout: steps.append( PostUpgradeStep( description="Unset ceph cluster 'noout' flag after data plane upgrade", - coro=ceph.osd_noout(analysis_result.model, enable=False), + coro=ceph.osd_noout( + analysis_result.model, analysis_result.apps_control_plane, enable=False + ), ) ) return steps diff --git a/cou/utils/juju_utils.py b/cou/utils/juju_utils.py index 7ce254d8..dc186c52 100644 --- a/cou/utils/juju_utils.py +++ b/cou/utils/juju_utils.py @@ -21,7 +21,7 @@ import os from dataclasses import dataclass, field from datetime import datetime -from typing import Any, Callable, List, Optional +from typing import Any, Callable, List, Optional, Sequence from juju.action import Action from juju.application import Application as JujuApplication @@ -175,8 +175,7 @@ class Application: origin: str series: str subordinate_to: list[str] - units: dict[str, Unit] # subordainte apps does not have units, use subodinate_units instead - subordinate_units: list[SubordinateUnit] # this is the units for subordinate apps + units: dict[str, Unit] workload_version: str actions: dict[str, str] = field(default_factory=lambda: {}, compare=False) @@ -368,10 +367,6 @@ async def get_applications(self) -> dict[str, Application]: # information the status than from objects. e.g. workload_version for unit full_status = await self.get_status() machines = await self._get_machines() - subordinate_units = { - SubordinateUnit(name, model.applications[name.split("/")[0]].charm_name) - for name in model.subordinate_units - } return { app: Application( @@ -403,7 +398,6 @@ async def get_applications(self) -> dict[str, Application]: ) for name, unit in status.units.items() }, - subordinate_units=[su for su in subordinate_units if su.name.split("/")[0] == app], workload_version=status.workload_version, actions=await model.applications[app].get_actions(), ) @@ -766,3 +760,22 @@ async def get_application_status(self, app_name: str) -> ApplicationStatus: if name == app_name: return app raise ApplicationNotFound(f"Cannot find '{app_name}' in model '{self.name}'.") + + +def get_applications_by_charm_name( + apps: Sequence[Application], charm_name: str +) -> Sequence[Application]: + """Get all applications based on the charm name. + + :param apps: List of Application + :type apps: Sequence[Application] + :param charm_name: The charm name + :type charm_name: str + :return: A list of Application filtered by charm name + :type: Sequence[Application] + :raise ApplicationNotFound: When cannot find a valid application with that name + """ + filtered_apps = [app for app in apps if app.charm == charm_name] + if not filtered_apps: + raise ApplicationNotFound(f"Application with '{charm_name}' not found") + return filtered_apps diff --git a/tests/mocked_plans/sample_plans/018346c5-f95c-46df-a34e-9a78bdec0018.yaml b/tests/mocked_plans/sample_plans/018346c5-f95c-46df-a34e-9a78bdec0018.yaml index 71777eb7..72fcb368 100644 --- a/tests/mocked_plans/sample_plans/018346c5-f95c-46df-a34e-9a78bdec0018.yaml +++ b/tests/mocked_plans/sample_plans/018346c5-f95c-46df-a34e-9a78bdec0018.yaml @@ -393,10 +393,6 @@ plan: | Enable nova-compute scheduler from unit: 'nova-compute-kvm/2' Enable nova-compute scheduler from unit: 'nova-compute-kvm/3' Enable nova-compute scheduler from unit: 'nova-compute-kvm/9' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/0' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/2' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/3' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/9' Wait for up to 2400s for model '018346c5-f95c-46df-a34e-9a78bdec0018' to reach the idle state Verify that the workload of 'nova-compute-kvm' has been upgraded on units: nova-compute-kvm/0, nova-compute-kvm/2, nova-compute-kvm/3, nova-compute-kvm/9 Upgrade plan for [cinder-volume/1, cinder-volume/10, cinder-volume/11, cinder-volume/5, nova-compute-kvm/1, nova-compute-kvm/10, nova-compute-kvm/11, nova-compute-kvm/5] in 'zone3' to 'victoria' @@ -468,10 +464,6 @@ plan: | Enable nova-compute scheduler from unit: 'nova-compute-kvm/10' Enable nova-compute scheduler from unit: 'nova-compute-kvm/11' Enable nova-compute scheduler from unit: 'nova-compute-kvm/5' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/1' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/10' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/11' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/5' Wait for up to 2400s for model '018346c5-f95c-46df-a34e-9a78bdec0018' to reach the idle state Verify that the workload of 'nova-compute-kvm' has been upgraded on units: nova-compute-kvm/1, nova-compute-kvm/10, nova-compute-kvm/11, nova-compute-kvm/5 Upgrade plan for [cinder-volume/4, cinder-volume/6, cinder-volume/7, cinder-volume/8, nova-compute-kvm/4, nova-compute-kvm/6, nova-compute-kvm/7, nova-compute-kvm/8] in 'zone1' to 'victoria' @@ -543,10 +535,6 @@ plan: | Enable nova-compute scheduler from unit: 'nova-compute-kvm/6' Enable nova-compute scheduler from unit: 'nova-compute-kvm/7' Enable nova-compute scheduler from unit: 'nova-compute-kvm/8' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/4' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/6' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/7' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/8' Wait for up to 2400s for model '018346c5-f95c-46df-a34e-9a78bdec0018' to reach the idle state Verify that the workload of 'nova-compute-kvm' has been upgraded on units: nova-compute-kvm/4, nova-compute-kvm/6, nova-compute-kvm/7, nova-compute-kvm/8 Remaining Data Plane principal(s) upgrade plan @@ -623,7 +611,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 10.0.0 units: aodh/0: @@ -724,7 +711,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - aodh workload_version: 8.0.32 @@ -839,7 +825,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 14.1.0 units: ceilometer/0: @@ -909,7 +894,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-compute-kvm workload_version: 14.1.0 @@ -1248,7 +1232,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - ceph-mon workload_version: '' @@ -1311,7 +1294,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 15.2.17 units: ceph-mon/0: @@ -1387,7 +1369,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 15.2.17 units: ceph-osd/0: @@ -1499,7 +1480,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 15.2.17 units: ceph-radosgw/0: @@ -1624,7 +1604,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 16.4.2 units: cinder/0: @@ -1703,7 +1682,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder workload_version: 16.4.2 @@ -1769,7 +1747,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder-volume workload_version: 16.4.2 @@ -2108,7 +2085,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder-volume workload_version: 16.4.2 @@ -2447,7 +2423,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder-volume workload_version: 16.4.2 @@ -2814,7 +2789,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder workload_version: 8.0.32 @@ -2935,7 +2909,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 16.4.2 units: cinder-volume/0: @@ -3360,7 +3333,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder-volume workload_version: 8.0.32 @@ -3731,7 +3703,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 10.0.2 units: designate/1: @@ -3808,7 +3779,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 9.16.48 units: designate-bind/0: @@ -3905,7 +3875,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - designate workload_version: 8.0.32 @@ -4023,7 +3992,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 20.2.0 units: glance/0: @@ -4127,7 +4095,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - glance workload_version: 8.0.32 @@ -4195,7 +4162,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: '' units: glance-simplestreams-sync/0: @@ -4259,7 +4225,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 4.3.4 units: gnocchi/0: @@ -4360,7 +4325,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - gnocchi workload_version: 8.0.32 @@ -4420,7 +4384,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - aodh - nrpe-container @@ -4481,7 +4444,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - ceilometer - nrpe-container @@ -4539,7 +4501,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder - nrpe-container @@ -4606,7 +4567,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - designate - nrpe-container @@ -4670,7 +4630,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - glance - nrpe-container @@ -4734,7 +4693,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - gnocchi - nrpe-container @@ -4795,7 +4753,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - heat - nrpe-container @@ -4859,7 +4816,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nrpe-container - openstack-dashboard @@ -4926,7 +4882,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - keystone - nrpe-container @@ -4993,7 +4948,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - neutron-api - nrpe-container @@ -5057,7 +5011,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-cloud-controller - nrpe-container @@ -5121,7 +5074,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nrpe-container - octavia @@ -5188,7 +5140,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nrpe-container - placement @@ -5249,7 +5200,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - ceph-radosgw - nrpe-container @@ -5307,7 +5257,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nrpe-host - vault @@ -5420,7 +5369,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 14.2.0 units: heat/0: @@ -5524,7 +5472,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - heat workload_version: 8.0.32 @@ -5650,7 +5597,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 17.0.1 units: keystone/0: @@ -5729,7 +5675,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - keystone workload_version: 17.0.1 @@ -5823,7 +5768,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - keystone workload_version: 8.0.32 @@ -5909,7 +5853,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 3.8.2 units: landscape-rabbitmq-server/0: @@ -6005,7 +5948,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 8.0.32 units: mysql-innodb-cluster/0: @@ -6124,7 +6066,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 16.4.2 units: neutron-api/0: @@ -6228,7 +6169,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - neutron-api workload_version: 8.0.32 @@ -6302,7 +6242,6 @@ applications: value: false origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-compute-kvm workload_version: 16.4.2 @@ -6652,7 +6591,6 @@ applications: value: true origin: ch series: focal - subordinate_units: [] subordinate_to: - octavia workload_version: 16.4.2 @@ -6773,7 +6711,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 21.2.4 units: nova-cloud-controller/0: @@ -6883,7 +6820,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 21.2.4 units: nova-compute-kvm/0: @@ -7355,7 +7291,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-cloud-controller workload_version: 8.0.32 @@ -7450,7 +7385,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 6.2.2 units: octavia/10: @@ -7529,7 +7463,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - openstack-dashboard workload_version: 5.0.0 @@ -7595,7 +7528,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - glance-simplestreams-sync workload_version: 0.9.12 @@ -7652,7 +7584,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - octavia workload_version: 8.0.32 @@ -7773,7 +7704,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 18.3.5 units: openstack-dashboard/0: @@ -7880,7 +7810,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - openstack-dashboard workload_version: 8.0.32 @@ -7978,7 +7907,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 3.0.1 units: placement/3: @@ -8079,7 +8007,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - placement workload_version: 8.0.32 @@ -8160,7 +8087,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 3.8.2 units: rabbitmq-server/0: @@ -8252,7 +8178,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - vault workload_version: 8.0.32 diff --git a/tests/mocked_plans/sample_plans/9eb9af6a-b919-4cf9-8f2f-9df16a1556be.yaml b/tests/mocked_plans/sample_plans/9eb9af6a-b919-4cf9-8f2f-9df16a1556be.yaml index 41705038..8b2891d3 100644 --- a/tests/mocked_plans/sample_plans/9eb9af6a-b919-4cf9-8f2f-9df16a1556be.yaml +++ b/tests/mocked_plans/sample_plans/9eb9af6a-b919-4cf9-8f2f-9df16a1556be.yaml @@ -436,9 +436,6 @@ plan: | Enable nova-compute scheduler from unit: 'nova-compute/0' Enable nova-compute scheduler from unit: 'nova-compute/2' Enable nova-compute scheduler from unit: 'nova-compute/3' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/0' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/2' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/3' Wait for up to 2400s for model '9eb9af6a-b919-4cf9-8f2f-9df16a1556be' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/0, nova-compute/2, nova-compute/3 Upgrade plan for [nova-compute/1, nova-compute/6, nova-compute/8] in 'az3' to 'victoria' @@ -473,9 +470,6 @@ plan: | Enable nova-compute scheduler from unit: 'nova-compute/1' Enable nova-compute scheduler from unit: 'nova-compute/6' Enable nova-compute scheduler from unit: 'nova-compute/8' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/1' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/6' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/8' Wait for up to 2400s for model '9eb9af6a-b919-4cf9-8f2f-9df16a1556be' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/1, nova-compute/6, nova-compute/8 Upgrade plan for [nova-compute/4, nova-compute/5, nova-compute/7] in 'az2' to 'victoria' @@ -510,9 +504,6 @@ plan: | Enable nova-compute scheduler from unit: 'nova-compute/4' Enable nova-compute scheduler from unit: 'nova-compute/5' Enable nova-compute scheduler from unit: 'nova-compute/7' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/4' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/5' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/7' Wait for up to 2400s for model '9eb9af6a-b919-4cf9-8f2f-9df16a1556be' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/4, nova-compute/5, nova-compute/7 Remaining Data Plane principal(s) upgrade plan @@ -568,7 +559,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 3.8.2 units: @@ -639,7 +629,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 15.2.16 units: @@ -766,7 +755,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 17.0.1 units: @@ -871,7 +859,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 10.0.0 units: @@ -973,7 +960,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 10.1.0 units: @@ -1101,7 +1087,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 14.1.0 units: @@ -1204,7 +1189,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 15.2.16 units: @@ -1326,7 +1310,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 16.4.2 units: @@ -1431,7 +1414,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 10.0.2 units: @@ -1502,7 +1484,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 9.16.1 units: @@ -1608,7 +1589,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 20.2.0 units: @@ -1710,7 +1690,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 4.3.4 units: @@ -1835,7 +1814,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 14.2.0 units: @@ -1960,7 +1938,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 16.4.2 units: @@ -2057,7 +2034,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 22.03.2 units: @@ -2150,7 +2126,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 3.0.1 units: @@ -2275,7 +2250,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 21.2.4 units: @@ -2400,7 +2374,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 18.3.5 units: @@ -2505,7 +2478,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 6.2.2 units: @@ -2579,7 +2551,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - barbican workload_version: 3.0.1 @@ -2639,7 +2610,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - ceph-mon workload_version: '' @@ -2690,7 +2660,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder workload_version: 16.4.2 @@ -2754,7 +2723,6 @@ applications: type: string origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: '' units: @@ -2785,7 +2753,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - heat - nrpe @@ -2843,7 +2810,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nrpe - placement @@ -2901,7 +2867,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nrpe - openstack-dashboard @@ -2962,7 +2927,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - ceilometer - nrpe @@ -3017,7 +2981,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - barbican - nrpe @@ -3078,7 +3041,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - openstack-loadbalancer workload_version: '' @@ -3126,7 +3088,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nrpe - octavia @@ -3187,7 +3148,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nrpe - vault @@ -3248,7 +3208,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-cloud-controller - nrpe @@ -3306,7 +3265,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - designate - nrpe @@ -3364,7 +3322,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - gnocchi - nrpe @@ -3422,7 +3379,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - aodh - nrpe @@ -3480,7 +3436,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - ceph-radosgw - nrpe @@ -3535,7 +3490,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - keystone - nrpe @@ -3596,7 +3550,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - glance - nrpe @@ -3654,7 +3607,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder - nrpe @@ -3715,7 +3667,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - neutron-api - nrpe @@ -3776,7 +3727,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - keystone workload_version: 17.0.1 @@ -3864,7 +3814,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 8.0.30 units: @@ -3957,7 +3906,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-cloud-controller workload_version: 8.0.30 @@ -4042,7 +3990,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - heat workload_version: 8.0.30 @@ -4127,7 +4074,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - designate workload_version: 8.0.30 @@ -4212,7 +4158,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - placement workload_version: 8.0.30 @@ -4297,7 +4242,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - vault workload_version: 8.0.30 @@ -4385,7 +4329,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - openstack-dashboard workload_version: 8.0.31 @@ -4473,7 +4416,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - glance workload_version: 8.0.30 @@ -4558,7 +4500,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - keystone workload_version: 8.0.30 @@ -4646,7 +4587,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - neutron-api workload_version: 8.0.30 @@ -4734,7 +4674,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - aodh workload_version: 8.0.30 @@ -4819,7 +4758,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - cinder workload_version: 8.0.30 @@ -4907,7 +4845,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - gnocchi workload_version: 8.0.35 @@ -4992,7 +4929,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - octavia workload_version: 8.0.30 @@ -5080,7 +5016,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: - barbican workload_version: 8.0.30 @@ -5140,7 +5075,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - neutron-api workload_version: 16.4.2 @@ -5200,7 +5134,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - openstack-dashboard workload_version: 5.0.0 @@ -5260,7 +5193,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - glance-simplestreams-sync workload_version: 0.9.12 @@ -5298,7 +5230,6 @@ applications: value: true origin: ch series: focal - subordinate_units: [] subordinate_to: - octavia workload_version: 22.03.2 @@ -5358,7 +5289,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 1.7.9 units: @@ -5465,7 +5395,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 21.2.4 units: @@ -5784,7 +5713,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 15.2.16 units: @@ -6059,7 +5987,6 @@ applications: config: {} origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-compute workload_version: 14.1.0 @@ -6301,7 +6228,6 @@ applications: value: true origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-compute workload_version: 22.03.2 diff --git a/tests/mocked_plans/sample_plans/base.yaml b/tests/mocked_plans/sample_plans/base.yaml index 235a66ad..83f6d594 100644 --- a/tests/mocked_plans/sample_plans/base.yaml +++ b/tests/mocked_plans/sample_plans/base.yaml @@ -45,7 +45,6 @@ plan: | ├── Upgrade the unit: 'nova-compute/0' ├── Resume the unit: 'nova-compute/0' Enable nova-compute scheduler from unit: 'nova-compute/0' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/0' Wait for up to 2400s for model 'base' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/0 Remaining Data Plane principal(s) upgrade plan @@ -73,7 +72,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 17.0.1 units: keystone/0: @@ -96,7 +94,6 @@ applications: series: focal subordinate_to: - keystone - subordinate_units: [] workload_version: 17.0.1 units: {} machines: @@ -114,7 +111,6 @@ applications: value: distro origin: ch series: focal - subordinate_units: [] subordinate_to: [] workload_version: 15.2.0 units: @@ -141,7 +137,6 @@ applications: origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 21.0.0 units: nova-compute/0: @@ -168,10 +163,8 @@ applications: value: false origin: ch series: focal - subordinate_units: [] subordinate_to: - nova-compute - subordinate_units: [] workload_version: '22.3' units: {} machines: diff --git a/tests/mocked_plans/utils.py b/tests/mocked_plans/utils.py index ba6e18a2..b61fcf40 100644 --- a/tests/mocked_plans/utils.py +++ b/tests/mocked_plans/utils.py @@ -63,7 +63,6 @@ def parse_sample_plan_file(source: Path) -> tuple[Model, str]: origin=app_data["origin"], series=app_data["series"], subordinate_to=app_data["subordinate_to"], - subordinate_units=app_data["subordinate_units"], units={ name: Unit( name, diff --git a/tests/unit/apps/test_auxiliary.py b/tests/unit/apps/test_auxiliary.py index 7c75b571..d97726f4 100644 --- a/tests/unit/apps/test_auxiliary.py +++ b/tests/unit/apps/test_auxiliary.py @@ -59,7 +59,6 @@ def test_auxiliary_app(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -96,7 +95,6 @@ def test_auxiliary_app_cs(model): origin="cs", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -136,7 +134,6 @@ def test_auxiliary_upgrade_plan_ussuri_to_victoria_change_channel(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -229,7 +226,6 @@ def test_auxiliary_upgrade_plan_ussuri_to_victoria(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -309,7 +305,6 @@ def test_auxiliary_upgrade_plan_ussuri_to_victoria_ch_migration(model): origin="cs", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -388,7 +383,6 @@ def test_rabbitmq_server_upgrade_plan_ussuri_to_victoria_auto_restart_False(mode origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -519,7 +513,6 @@ def test_auxiliary_upgrade_plan_unknown_track(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -553,7 +546,6 @@ def test_auxiliary_app_unknown_version_raise_ApplicationError(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={unit.name: unit}, workload_version=version, ) @@ -579,7 +571,6 @@ def test_auxiliary_raise_error_unknown_series(model): origin="ch", series=series, subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -618,7 +609,6 @@ def test_auxiliary_raise_error_o7k_not_on_lookup(o7k_release, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -656,7 +646,6 @@ def test_auxiliary_raise_halt_upgrade(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -693,7 +682,6 @@ def test_auxiliary_no_origin_setting_raise_halt_upgrade(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -745,7 +733,6 @@ def test_auxiliary_no_suitable_channel(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -775,7 +762,6 @@ def test_ceph_mon_app(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -810,7 +796,6 @@ def test_ceph_mon_upgrade_plan_xena_to_yoga(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -906,7 +891,6 @@ def test_ceph_mon_upgrade_plan_ussuri_to_victoria(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -989,7 +973,6 @@ def test_ovn_principal(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -1029,7 +1012,6 @@ def test_ovn_workload_ver_lower_than_22_principal(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -1061,7 +1043,6 @@ def test_ovn_version_pinning_principal(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -1100,7 +1081,6 @@ def test_ovn_no_compatible_o7k_release(channel, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -1137,7 +1117,6 @@ def test_ovn_check_version_pinning_version_pinning_config_False(app, config, mod origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{app}/0": Unit( name=f"{app}/0", @@ -1163,7 +1142,6 @@ def test_ovn_check_version_pinning_version_pinning_config_True(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "ovn-dedicated-chassis/0": Unit( name="ovn-dedicated-chassis/0", @@ -1194,7 +1172,6 @@ def test_ovn_principal_upgrade_plan(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -1276,7 +1253,6 @@ def test_mysql_innodb_cluster_upgrade(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -1356,7 +1332,6 @@ def test_ceph_osd_pre_upgrade_steps(mock_pre_upgrade_steps, target, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"ceph-osd/{i}": Unit( name=f"ceph-osd/{i}", @@ -1395,7 +1370,6 @@ async def test_ceph_osd_verify_nova_compute_no_app(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"ceph-osd/{i}": Unit( name=f"ceph-osd/{i}", @@ -1430,7 +1404,6 @@ def test_auxiliary_upgrade_by_unit(mock_super, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -1479,7 +1452,6 @@ async def test_ceph_osd_verify_nova_compute_pass(mock_lookup, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"ceph-osd/{i}": Unit( name=f"ceph-osd/{i}", @@ -1519,7 +1491,6 @@ async def test_ceph_osd_verify_nova_compute_fail(mock_lookup, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"ceph-osd/{i}": Unit( name=f"ceph-osd/{i}", @@ -1566,7 +1537,6 @@ def test_ceph_osd_upgrade_plan(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"ceph-osd/{i}": Unit( name=f"ceph-osd/{i}", @@ -1617,19 +1587,7 @@ def test_need_current_channel_refresh_auxiliary( target = OpenStackRelease("victoria") app_name = "app" app = AuxiliaryApplication( - app_name, - can_upgrade_to, - app_name, - "3.9/stable", - {}, - {}, - model, - "ch", - "focal", - [], - {}, - [], - "1", + app_name, can_upgrade_to, app_name, "3.9/stable", {}, {}, model, "ch", "focal", [], {}, "1" ) assert app._need_current_channel_refresh(target) is exp_result @@ -1659,7 +1617,6 @@ def test_expected_current_channel_auxiliary(mock_o7k_release, model, channel, or origin=origin, series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="15.2.0", ) @@ -1683,7 +1640,6 @@ def test_auxiliary_wrong_channel(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", @@ -1720,7 +1676,6 @@ def get_vault_o7k_app(model, config, series: str = "jammy"): origin="ch", series=series, subordinate_to=[], - subordinate_units=[], units={ f"{charm}/0": Unit( name=f"{charm}/0", diff --git a/tests/unit/apps/test_auxiliary_subordinate.py b/tests/unit/apps/test_auxiliary_subordinate.py index 0c03ffcc..07569c7e 100644 --- a/tests/unit/apps/test_auxiliary_subordinate.py +++ b/tests/unit/apps/test_auxiliary_subordinate.py @@ -22,7 +22,6 @@ ) from cou.exceptions import ApplicationError, HaltUpgradePlanGeneration from cou.steps import ApplicationUpgradePlan, PreUpgradeStep, UpgradeStep -from cou.utils.juju_utils import SubordinateUnit from cou.utils.openstack import OpenStackRelease from tests.unit.utils import assert_steps, dedent_plan, generate_cou_machine @@ -41,7 +40,6 @@ def test_auxiliary_subordinate(model): origin="ch", series="focal", subordinate_to=["keystone"], - subordinate_units=[SubordinateUnit("keystone-mysql-router/0", "mysql-router")], units={}, workload_version="8.0", ) @@ -71,7 +69,6 @@ def test_auxiliary_subordinate_upgrade_plan_to_victoria(model): origin="ch", series="focal", subordinate_to=["keystone"], - subordinate_units=[SubordinateUnit("keystone-mysql-router/0", "mysql-router")], units={}, workload_version="8.0", ) @@ -111,7 +108,6 @@ def test_ovn_subordinate(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassis/0", "ovn-chassis")], units={}, workload_version="22.3", ) @@ -146,7 +142,6 @@ def test_ovn_workload_ver_lower_than_22_subordinate(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassisr/0", "ovn-chassis")], units={}, workload_version="20.3", ) @@ -172,7 +167,6 @@ def test_ovn_version_pinning_subordinate(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassisr/0", "ovn-chassis")], units={}, workload_version="22.3", ) @@ -196,7 +190,6 @@ def test_ovn_subordinate_upgrade_plan(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassisr/0", "ovn-chassis")], units={}, workload_version="22.3", ) @@ -246,7 +239,6 @@ def test_ovn_subordinate_upgrade_plan_cant_upgrade_charm(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassisr/0", "ovn-chassis")], units={}, workload_version="22.3", ) @@ -270,7 +262,6 @@ def test_ceph_dashboard_upgrade_plan_ussuri_to_victoria(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassisr/0", "ovn-chassis")], units={}, workload_version="15.2.0", ) @@ -313,7 +304,6 @@ def test_ceph_dashboard_upgrade_plan_xena_to_yoga(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassisr/0", "ovn-chassis")], units={}, workload_version="16.2.0", ) @@ -377,7 +367,6 @@ def test_auxiliary_subordinate_latest_stable(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassisr/0", "ovn-chassis")], units={}, workload_version="", ) @@ -397,7 +386,6 @@ def test_auxiliary_subordinate_channel_o7k_release_raise(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassisr/0", "ovn-chassis")], units={}, workload_version="", ) @@ -430,7 +418,6 @@ def test_hacluster_change_channel(model): origin="ch", series="focal", subordinate_to=["keystone"], - subordinate_units=[SubordinateUnit("keystone-hacluster/0", "hacluster")], units={}, workload_version="2.0.3", ) diff --git a/tests/unit/apps/test_base.py b/tests/unit/apps/test_base.py index d996b35e..39024209 100644 --- a/tests/unit/apps/test_base.py +++ b/tests/unit/apps/test_base.py @@ -41,7 +41,6 @@ def test_openstack_application_magic_functions(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -78,7 +77,6 @@ def test_application_get_latest_o7k_version_failed(mock_find_compatible_versions origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={f"{app_name}/0": unit}, workload_version=unit.workload_version, ) @@ -132,7 +130,6 @@ def test_set_action_managed_upgrade(charm_config, enable, exp_description, model origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -166,7 +163,6 @@ def test_get_pause_unit_step(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={f"{unit.name}": unit}, workload_version="1", ) @@ -200,7 +196,6 @@ def test_get_resume_unit_step(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={f"{app_name}/0": unit}, workload_version="1", ) @@ -234,7 +229,6 @@ def test_get_openstack_upgrade_step(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={f"{app_name}/0": unit}, workload_version="1", ) @@ -262,7 +256,7 @@ def test_get_upgrade_current_release_packages_step(mock_upgrade_packages, units, } app = OpenStackApplication( - app_name, "", charm, channel, {}, {}, model, "ch", "focal", [], app_units, [], "21.0.1" + app_name, "", charm, channel, {}, {}, model, "ch", "focal", [], app_units, "21.0.1" ) expected_calls = ( @@ -294,7 +288,7 @@ def test_get_reached_expected_target_step(mock_workload_upgrade, units, model): app_units = {f"my_app/{unit}": Unit(f"my_app/{unit}", mock, mock) for unit in range(3)} app = OpenStackApplication( - app_name, "", charm, channel, {}, {}, model, "ch", "focal", [], app_units, [], "21.0.1" + app_name, "", charm, channel, {}, {}, model, "ch", "focal", [], app_units, "21.0.1" ) expected_calls = [call(target, units)] if units else [call(target, list(app.units.values()))] @@ -329,7 +323,7 @@ def test_check_channel_error(): "are using the right track." ) app = OpenStackApplication( - name, "", name, channel, {}, {}, MagicMock(), "ch", series, [], {}, [], "1" + name, "", name, channel, {}, {}, MagicMock(), "ch", series, [], {}, "1" ) with pytest.raises(ApplicationError, match=exp_error_msg): @@ -341,7 +335,7 @@ def test_check_auto_restarts(config): """Test function to verify that enable-auto-restarts is disabled.""" app_name = "app" app = OpenStackApplication( - app_name, "", app_name, "stable", config, {}, MagicMock(), "ch", "focal", [], {}, [], "1" + app_name, "", app_name, "stable", config, {}, MagicMock(), "ch", "focal", [], {}, "1" ) app._check_auto_restarts() @@ -357,7 +351,7 @@ def test_check_auto_restarts_error(): ) config = {"enable-auto-restarts": {"value": False}} app = OpenStackApplication( - app_name, "", app_name, "stable", config, {}, MagicMock(), "ch", "focal", [], {}, [], "1" + app_name, "", app_name, "stable", config, {}, MagicMock(), "ch", "focal", [], {}, "1" ) with pytest.raises(ApplicationError, match=exp_error_msg): @@ -372,7 +366,7 @@ def test_check_application_target(o7k_release, apt_source_codename): release = OpenStackRelease("ussuri") app_name = "app" app = OpenStackApplication( - app_name, "", app_name, "stable", {}, {}, MagicMock(), "ch", "focal", [], {}, [], "1" + app_name, "", app_name, "stable", {}, {}, MagicMock(), "ch", "focal", [], {}, "1" ) o7k_release.return_value = apt_source_codename.return_value = release @@ -387,7 +381,7 @@ def test_check_application_target_can_upgrade(o7k_release, apt_source_codename): release = OpenStackRelease("ussuri") app_name = "app" app = OpenStackApplication( - app_name, "stable", app_name, "stable", {}, {}, MagicMock(), "ch", "focal", [], {}, [], "1" + app_name, "stable", app_name, "stable", {}, {}, MagicMock(), "ch", "focal", [], {}, "1" ) o7k_release.return_value = apt_source_codename.return_value = release @@ -405,7 +399,7 @@ def test_check_application_target_error(o7k_release, apt_source_codename): f"{target}. Ignoring." ) app = OpenStackApplication( - app_name, "", app_name, "stable", {}, {}, MagicMock(), "ch", "focal", [], {}, [], "1" + app_name, "", app_name, "stable", {}, {}, MagicMock(), "ch", "focal", [], {}, "1" ) o7k_release.return_value = apt_source_codename.return_value = target @@ -457,7 +451,6 @@ def test_check_mismatched_versions_exception(mock_o7k_release_units, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="18.1.0", ) @@ -509,7 +502,6 @@ def test_check_mismatched_versions_with_nova_compute(mock_o7k_release_units, mod origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="18.1.0", ) @@ -554,7 +546,6 @@ def test_check_mismatched_versions(mock_o7k_release_units, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="17.0.1", ) @@ -579,7 +570,6 @@ def test_get_charmhub_migration_step(o7k_release, model): origin="cs", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -613,7 +603,6 @@ def test_get_change_channel_possible_downgrade_step(o7k_release, model, channel) origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -644,7 +633,6 @@ def test_get_refresh_current_channel_step(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -676,7 +664,6 @@ def test_get_refresh_charm_step_skip( origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -708,7 +695,6 @@ def test_get_refresh_charm_step_refresh_current_channel( origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -760,7 +746,6 @@ def test_get_refresh_charm_step_change_to_openstack_channels( origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -816,7 +801,6 @@ def test_get_refresh_charm_step_charmhub_migration( origin="cs", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -863,7 +847,6 @@ def test_extract_from_uca_source(model, config, exp_result): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -884,7 +867,6 @@ def test_extract_from_uca_source_raise(wrong_uca, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -916,7 +898,6 @@ def test_apt_source_codename(config, exp_result, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "app/0": Unit( name="app/0", @@ -956,7 +937,6 @@ def test_apt_source_codename_empty_or_without_origin_setting(mock_o7k_release, c origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "app/0": Unit( name="app/0", @@ -989,7 +969,6 @@ def test_apt_source_codename_unknown_source(source_value, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "app/0": Unit( name="app/0", @@ -1027,7 +1006,6 @@ def test_need_crossgrade(model, channel, origin, exp_result): origin=origin, series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) @@ -1055,7 +1033,6 @@ def test_expected_current_channel(mock_o7k_release, model, channel, origin): origin=origin, series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) diff --git a/tests/unit/apps/test_channel_based.py b/tests/unit/apps/test_channel_based.py index 73a53cc8..8a81c332 100644 --- a/tests/unit/apps/test_channel_based.py +++ b/tests/unit/apps/test_channel_based.py @@ -50,7 +50,6 @@ def test_application_versionless(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="", ) @@ -101,7 +100,6 @@ def test_channel_based_application_latest_stable(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="", ) @@ -130,7 +128,6 @@ def test_application_gnocchi_ussuri(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "gnocchi/0": Unit( name="gnocchi/0", @@ -163,7 +160,6 @@ def test_application_gnocchi_xena(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "gnocchi/0": Unit( name="gnocchi/0", @@ -199,7 +195,6 @@ def test_application_designate_bind_ussuri(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "designate-bind/0": Unit( name="designate-bind/0", @@ -229,7 +224,6 @@ def test_application_versionless_upgrade_plan_ussuri_to_victoria(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "glance-simplestreams-sync/0": Unit( name="glance-simplestreams-sync/0", @@ -315,7 +309,6 @@ def test_application_gnocchi_upgrade_plan_ussuri_to_victoria(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "gnocchi/0": Unit( name="gnocchi/0", @@ -410,7 +403,6 @@ def test_application_designate_bind_upgrade_plan_ussuri_to_victoria(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "designate-bind/0": Unit( name="designate-bind/0", @@ -522,7 +514,6 @@ def test_expected_current_channel_channel_based( origin=origin, series="focal", subordinate_to=[], - subordinate_units=[], units={}, workload_version="1", ) diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index 02937403..6475b231 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -69,7 +69,6 @@ def test_application_different_wl(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="18.1.0", ) @@ -96,7 +95,6 @@ async def test_application_verify_workload_upgrade(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -142,7 +140,6 @@ async def test_application_verify_workload_upgrade_fail(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -184,7 +181,6 @@ def test_upgrade_plan_ussuri_to_victoria(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"keystone/{unit}": Unit( name=f"keystone/{unit}", @@ -281,7 +277,6 @@ def test_upgrade_plan_ussuri_to_victoria_ch_migration(model): origin="cs", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"keystone/{unit}": Unit( name=f"keystone/{unit}", @@ -381,7 +376,6 @@ def test_upgrade_plan_channel_on_next_o7k_release(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"keystone/{unit}": Unit( name=f"keystone/{unit}", @@ -461,7 +455,6 @@ def test_upgrade_plan_origin_already_on_next_openstack_release(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"keystone/{unit}": Unit( name=f"keystone/{unit}", @@ -554,7 +547,6 @@ def test_upgrade_plan_application_already_upgraded(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"keystone/{unit}": Unit( name=f"keystone/{unit}", @@ -589,7 +581,6 @@ def test_upgrade_plan_application_already_disable_action_managed(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"keystone/{unit}": Unit( name=f"keystone/{unit}", @@ -681,14 +672,7 @@ def test_nova_compute_pre_upgrade_steps( @patch("cou.apps.base.OpenStackApplication._get_wait_step") @patch("cou.apps.base.OpenStackApplication._get_reached_expected_target_step") @patch("cou.apps.core.NovaCompute._get_enable_scheduler_step") -@patch("cou.apps.core.NovaCompute._get_restart_subordinate_services_steps") -def test_nova_compute_post_upgrade_steps( - mock_restart_subordinate, - mock_enable, - mock_expected_target, - mock_wait_step, - model, -): +def test_nova_compute_post_upgrade_steps(mock_enable, mock_expected_target, mock_wait_step, model): app = _generate_nova_compute_app(model) target = OpenStackRelease("victoria") units = list(app.units.values()) @@ -697,7 +681,6 @@ def test_nova_compute_post_upgrade_steps( mock_enable.assert_called_once_with(units) mock_expected_target.assert_called_once_with(target, units) mock_wait_step.assert_called_once_with() - mock_restart_subordinate.assert_called_once_with(units) @pytest.mark.parametrize("force", [True, False]) @@ -766,35 +749,6 @@ def test_nova_compute_get_enable_scheduler_step(model, units): assert app._get_enable_scheduler_step(units_selected) == expected_step -@pytest.mark.parametrize( - "units", - [ - ["nova-compute/0"], - ["nova-compute/0", "nova-compute/1"], - ["nova-compute/0", "nova-compute/1", "nova-compute/2"], - ], -) -def test_nova_compute_get_restart_subordinate_services_steps(model, units): - app = _generate_nova_compute_app(model) - units_selected = [app.units[unit] for unit in units] - assert app._get_restart_subordinate_services_steps(units_selected) == [ - PostUpgradeStep( - description=( - "Restart service ceilometer-agent-compute " - f"for subordinate unit: '{unit.subordinates[0].name}'" - ), - coro=model.run_on_unit( - unit_name=unit.subordinates[0].name, - command=( - "systemctl is-active --quiet ceilometer-agent-compute" - " || systemctl restart ceilometer-agent-compute" - ), - ), - ) - for unit in units_selected - ] - - def test_nova_compute_get_enable_scheduler_step_no_units(model): """Enable the scheduler on all units if no units are passed.""" app = _generate_nova_compute_app(model) @@ -866,7 +820,7 @@ def _generate_nova_compute_app(model): for unit_num in range(3) } app = NovaCompute( - app_name, "", charm, channel, {}, {}, model, "cs", "focal", [], units, [], "21.0.1" + app_name, "", charm, channel, {}, {}, model, "cs", "focal", [], units, "21.0.1" ) return app @@ -910,9 +864,6 @@ def test_nova_compute_upgrade_plan(model): Enable nova-compute scheduler from unit: 'nova-compute/0' Enable nova-compute scheduler from unit: 'nova-compute/1' Enable nova-compute scheduler from unit: 'nova-compute/2' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/0' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/1' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/2' Wait for up to 2400s for model 'test_model' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/0, nova-compute/1, nova-compute/2 """ # noqa: E501 line too long @@ -940,7 +891,6 @@ def test_nova_compute_upgrade_plan(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="21.0.0", ) @@ -971,7 +921,6 @@ def test_nova_compute_upgrade_plan_single_unit(model): ├── Upgrade the unit: 'nova-compute/0' ├── Resume the unit: 'nova-compute/0' Enable nova-compute scheduler from unit: 'nova-compute/0' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/0' Wait for up to 2400s for model 'test_model' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/0 """ @@ -999,7 +948,6 @@ def test_nova_compute_upgrade_plan_single_unit(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="21.0.0", ) @@ -1052,7 +1000,6 @@ def test_cinder_upgrade_plan(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="16.4.2", ) @@ -1108,7 +1055,6 @@ def test_cinder_upgrade_plan_single_unit(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units=units, workload_version="16.4.2", ) @@ -1133,7 +1079,6 @@ def test_swift_application_not_supported(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "swift-proxy/0": Unit( name="swift-proxy/0", @@ -1171,7 +1116,6 @@ def test_core_wrong_channel(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", diff --git a/tests/unit/apps/test_subordinate.py b/tests/unit/apps/test_subordinate.py index 861825e1..3fcc85af 100644 --- a/tests/unit/apps/test_subordinate.py +++ b/tests/unit/apps/test_subordinate.py @@ -19,7 +19,6 @@ from cou.apps.subordinate import SubordinateApplication from cou.exceptions import ApplicationError from cou.steps import ApplicationUpgradePlan, PreUpgradeStep, UpgradeStep -from cou.utils.juju_utils import SubordinateUnit from cou.utils.openstack import OpenStackRelease from tests.unit.utils import assert_steps, generate_cou_machine @@ -40,7 +39,6 @@ def test_o7k_release(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="18.1.0", ) @@ -63,7 +61,6 @@ def test_generate_upgrade_plan(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="18.1.0", ) @@ -122,7 +119,6 @@ def test_channel_valid(model, channel): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="18.1.0", ) @@ -158,7 +154,6 @@ def test_channel_setter_invalid(model, channel): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="18.1.0", ) @@ -190,7 +185,6 @@ def test_generate_plan_ch_migration(model, channel): origin="cs", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="", ) @@ -248,7 +242,6 @@ def test_generate_plan_from_to(model, from_os, to_os): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="18.1.0", ) @@ -307,7 +300,6 @@ def test_generate_plan_in_same_version(model, from_to): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="18.1.0", ) @@ -365,7 +357,6 @@ def test_expected_current_channel_subordinate( origin=origin, series="focal", subordinate_to=["keystone"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="1", ) diff --git a/tests/unit/steps/test_analyze.py b/tests/unit/steps/test_analyze.py index ee4d68e0..c1e07cd3 100644 --- a/tests/unit/steps/test_analyze.py +++ b/tests/unit/steps/test_analyze.py @@ -28,7 +28,6 @@ from tests.unit.utils import generate_cou_machine -@pytest.mark.asyncio def test_analysis_dump(model): """Test analysis dump.""" expected_result = dedent( @@ -45,7 +44,6 @@ def test_analysis_dump(model): origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 17.0.1 units: keystone/0: @@ -91,7 +89,6 @@ def test_analysis_dump(model): origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: 16.4.2 units: cinder/0: @@ -137,7 +134,6 @@ def test_analysis_dump(model): origin: ch series: focal subordinate_to: [] - subordinate_units: [] workload_version: '3.8' units: rabbitmq-server/0: @@ -170,7 +166,6 @@ def test_analysis_dump(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"keystone/{unit}": Unit( name=f"keystone/{unit}", workload_version="17.0.1", machine=machines[f"{unit}"] @@ -190,7 +185,6 @@ def test_analysis_dump(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -211,7 +205,6 @@ def test_analysis_dump(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"cinder/{unit}": Unit( name=f"cinder/{unit}", @@ -278,7 +271,6 @@ async def test_analysis_create(mock_split_apps, mock_populate, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -299,7 +291,6 @@ async def test_analysis_create(mock_split_apps, mock_populate, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -320,7 +311,6 @@ async def test_analysis_create(mock_split_apps, mock_populate, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "cinder/0": Unit( name="cinder/0", @@ -361,7 +351,6 @@ async def test_analysis_create_with_skip_apps(mock_populate, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -382,7 +371,6 @@ async def test_analysis_create_with_skip_apps(mock_populate, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -403,7 +391,6 @@ async def test_analysis_create_with_skip_apps(mock_populate, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "cinder/0": Unit( name="cinder/0", @@ -424,7 +411,6 @@ async def test_analysis_create_with_skip_apps(mock_populate, model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "vault/0": Unit( name="vault/0", @@ -465,7 +451,6 @@ async def test_analysis_detect_current_cloud_o7k_release_different_releases(mode origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -486,7 +471,6 @@ async def test_analysis_detect_current_cloud_o7k_release_different_releases(mode origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -507,7 +491,6 @@ async def test_analysis_detect_current_cloud_o7k_release_different_releases(mode origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "cinder/0": Unit( name="cinder/0", @@ -541,7 +524,6 @@ async def test_analysis_detect_current_cloud_series_different_series(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -562,7 +544,6 @@ async def test_analysis_detect_current_cloud_series_different_series(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "rabbitmq-server/0": Unit( name="rabbitmq-server/0", @@ -583,7 +564,6 @@ async def test_analysis_detect_current_cloud_series_different_series(model): origin="ch", series="bionic", # change cinder to Bionic series subordinate_to=[], - subordinate_units=[], units={ "cinder/0": Unit( name="cinder/0", @@ -692,7 +672,6 @@ def test_min_o7k_release_apps(model, channel_keystone, channel_gnocchi, origin, origin=origin, series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -714,7 +693,6 @@ def test_min_o7k_release_apps(model, channel_keystone, channel_gnocchi, origin, origin=origin, series="focal", subordinate_to=[], - subordinate_units=[], units={ "gnocchi": Unit( name="gnocchi/0", diff --git a/tests/unit/steps/test_ceph.py b/tests/unit/steps/test_ceph.py index bda0dbe8..5bad0aa2 100644 --- a/tests/unit/steps/test_ceph.py +++ b/tests/unit/steps/test_ceph.py @@ -12,90 +12,37 @@ # See the License for the specific language governing permissions and # limitations under the License. import json -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import AsyncMock, patch import pytest -from cou.exceptions import ( - ApplicationError, - ApplicationNotFound, - RunUpgradeError, - UnitNotFound, -) +from cou.exceptions import ApplicationError, RunUpgradeError, UnitNotFound from cou.steps import ceph -from cou.utils.juju_utils import Application, Unit - - -@pytest.mark.asyncio -async def test_get_application(model) -> None: - ceph_mon_1 = MagicMock(spec_set=Application)() - ceph_mon_1.name = "ceph-mon-1" - ceph_mon_1.charm = "ceph-mon" - - ceph_mon_2 = MagicMock(spec_set=Application)() - ceph_mon_2.name = "ceph-mon-2" - ceph_mon_2.charm = "ceph-mon" - - model.get_applications.return_value = { - "ceph-mon-1": ceph_mon_1, - "ceph-mon-2": ceph_mon_2, - } - ceph_mon_apps = await ceph._get_applications(model) - assert len(ceph_mon_apps) == 2 - - -@pytest.mark.asyncio -async def test_get_application_error(model) -> None: - model.get_applications.return_value = {} - - with pytest.raises(ApplicationNotFound): - await ceph._get_applications(model) +from tests.unit.utils import get_applications @pytest.mark.asyncio async def test_get_unit_name(model) -> None: - ceph_mon_1 = MagicMock(spec_set=Application)() - ceph_mon_1.name = "ceph-mon" - ceph_mon_unit = MagicMock(spec_set=Unit)() - ceph_mon_unit.name = "ceph-mon/0" - ceph_mon_1.units = {"ceph-mon/0": ceph_mon_unit} + apps = get_applications("ceph-mon") - ceph_mon_unit_name = await ceph._get_unit_name(ceph_mon_1) - assert ceph_mon_unit_name == "ceph-mon/0" + ceph_mon_unit_name = ceph._get_unit_name(apps[0]) + + assert ceph_mon_unit_name == "ceph-mon-0/0" @pytest.mark.asyncio async def test_get_unit_name_error(model) -> None: - ceph_mon_1 = MagicMock(spec_set=Application)() - ceph_mon_1.name = "ceph-mon" - ceph_mon_1.units = {} + apps = get_applications("ceph-mon", unit_count=0) with pytest.raises(UnitNotFound): - await ceph._get_unit_name(ceph_mon_1) + await ceph._get_unit_name(apps[0]) @pytest.mark.asyncio async def test_osd_noout(model) -> None: - ceph_mon_1_unit = MagicMock(spec_set=Unit)() - ceph_mon_1_unit.name = "ceph-mon-1/0" - ceph_mon_1 = MagicMock(spec_set=Application)() - ceph_mon_1.name = "ceph-mon-1" - ceph_mon_1.charm = "ceph-mon" - ceph_mon_1.units = {"ceph-mon-1/0": ceph_mon_1_unit} - - ceph_mon_2_unit = MagicMock(spec_set=Unit)() - ceph_mon_2_unit.name = "ceph-mon-2/0" - ceph_mon_2 = MagicMock(spec_set=Application)() - ceph_mon_2.name = "ceph-mon-2" - ceph_mon_2.charm = "ceph-mon" - ceph_mon_2.units = {"ceph-mon-2/0": ceph_mon_2_unit} - - model.get_applications.return_value = { - "ceph-mon-1": ceph_mon_1, - "ceph-mon-2": ceph_mon_2, - } + apps = get_applications("ceph-mon", app_count=2) - await ceph.osd_noout(model, True) + await ceph.osd_noout(model, apps, True) model.run_action.assert_awaited() assert model.run_action.await_count == 2 @@ -103,25 +50,18 @@ async def test_osd_noout(model) -> None: @pytest.mark.asyncio async def test_osd_noout_no_ceph_mon_app(model) -> None: - model.get_applications.return_value = {} + apps = [] - await ceph.osd_noout(model, True) + await ceph.osd_noout(model, apps, True) model.run_action.assert_not_awaited() @pytest.mark.asyncio async def test_osd_noout_no_ceph_mon_units(model) -> None: - ceph_mon = MagicMock(spec_set=Application)() - ceph_mon.name = "ceph-mon" - ceph_mon.charm = "ceph-mon" - ceph_mon.units = {} - - model.get_applications.return_value = { - "ceph-mon": ceph_mon, - } + apps = get_applications("ceph-mon", unit_count=0) - await ceph.osd_noout(model, True) + await ceph.osd_noout(model, apps, True) model.run_action.assert_not_awaited() @@ -129,62 +69,28 @@ async def test_osd_noout_no_ceph_mon_units(model) -> None: @pytest.mark.asyncio @patch("cou.steps.ceph.get_osd_noout_state") async def test_assert_osd_noout_state_same(mock_get_osd_noout_state, model) -> None: - ceph_mon_1_unit = MagicMock(spec_set=Unit)() - ceph_mon_1_unit.name = "ceph-mon-1/0" - ceph_mon_1 = MagicMock(spec_set=Application)() - ceph_mon_1.name = "ceph-mon-1" - ceph_mon_1.charm = "ceph-mon" - ceph_mon_1.units = {"ceph-mon-1/0": ceph_mon_1_unit} - - ceph_mon_2_unit = MagicMock(spec_set=Unit)() - ceph_mon_2_unit.name = "ceph-mon-2/0" - ceph_mon_2 = MagicMock(spec_set=Application)() - ceph_mon_2.name = "ceph-mon-2" - ceph_mon_2.charm = "ceph-mon" - ceph_mon_2.units = {"ceph-mon-2/0": ceph_mon_2_unit} - - model.get_applications.return_value = { - "ceph-mon-1": ceph_mon_1, - "ceph-mon-2": ceph_mon_2, - } - + apps = get_applications("ceph-mon", app_count=2) mock_get_osd_noout_state.return_value = True - await ceph.assert_osd_noout_state(model, True) + + await ceph.assert_osd_noout_state(model, apps, True) @pytest.mark.asyncio @patch("cou.steps.ceph.get_osd_noout_state") async def test_assert_osd_noout_state_different(mock_get_osd_noout_state, model) -> None: - ceph_mon_1_unit = MagicMock(spec_set=Unit)() - ceph_mon_1_unit.name = "ceph-mon-1/0" - ceph_mon_1 = MagicMock(spec_set=Application)() - ceph_mon_1.name = "ceph-mon-1" - ceph_mon_1.charm = "ceph-mon" - ceph_mon_1.units = {"ceph-mon-1/0": ceph_mon_1_unit} - - ceph_mon_2_unit = MagicMock(spec_set=Unit)() - ceph_mon_2_unit.name = "ceph-mon-2/0" - ceph_mon_2 = MagicMock(spec_set=Application)() - ceph_mon_2.name = "ceph-mon-2" - ceph_mon_2.charm = "ceph-mon" - ceph_mon_2.units = {"ceph-mon-2/0": ceph_mon_2_unit} - - model.get_applications.return_value = { - "ceph-mon-1": ceph_mon_1, - "ceph-mon-2": ceph_mon_2, - } - + apps = get_applications("ceph-mon", app_count=2) mock_get_osd_noout_state.return_value = False + with pytest.raises(ApplicationError): - await ceph.assert_osd_noout_state(model, True) + await ceph.assert_osd_noout_state(model, apps, True) @pytest.mark.asyncio @patch("cou.steps.ceph.get_osd_noout_state") async def test_assert_osd_noout_state_no_app(mock_get_osd_noout_state, model) -> None: - model.get_applications.return_value = {} + apps = [] - await ceph.assert_osd_noout_state(model, True) + await ceph.assert_osd_noout_state(model, apps, True) mock_get_osd_noout_state.assert_not_awaited() @@ -192,16 +98,9 @@ async def test_assert_osd_noout_state_no_app(mock_get_osd_noout_state, model) -> @pytest.mark.asyncio @patch("cou.steps.ceph.get_osd_noout_state") async def test_assert_osd_noout_state_no_units(mock_get_osd_noout_state, model) -> None: - ceph_mon = MagicMock(spec_set=Application)() - ceph_mon.name = "ceph-mon" - ceph_mon.charm = "ceph-mon" - ceph_mon.units = {} - - model.get_applications.return_value = { - "ceph-mon": ceph_mon, - } + apps = get_applications("ceph-mon", unit_count=0) - await ceph.assert_osd_noout_state(model, True) + await ceph.assert_osd_noout_state(model, apps, True) mock_get_osd_noout_state.assert_not_awaited() @@ -211,26 +110,9 @@ async def test_assert_osd_noout_state_no_units(mock_get_osd_noout_state, model) async def test_set_require_osd_release_option( mock_set_require_osd_release_option_on_unit, model ) -> None: - ceph_mon_1_unit = MagicMock(spec_set=Unit)() - ceph_mon_1_unit.name = "ceph-mon-1/0" - ceph_mon_1 = MagicMock(spec_set=Application)() - ceph_mon_1.name = "ceph-mon-1" - ceph_mon_1.charm = "ceph-mon" - ceph_mon_1.units = {"ceph-mon-1/0": ceph_mon_1_unit} - - ceph_mon_2_unit = MagicMock(spec_set=Unit)() - ceph_mon_2_unit.name = "ceph-mon-2/0" - ceph_mon_2 = MagicMock(spec_set=Application)() - ceph_mon_2.name = "ceph-mon-2" - ceph_mon_2.charm = "ceph-mon" - ceph_mon_2.units = {"ceph-mon-2/0": ceph_mon_2_unit} - - model.get_applications.return_value = { - "ceph-mon-1": ceph_mon_1, - "ceph-mon-2": ceph_mon_2, - } + apps = get_applications("ceph-mon", app_count=2) - await ceph.set_require_osd_release_option(model) + await ceph.set_require_osd_release_option(model, apps) mock_set_require_osd_release_option_on_unit.assert_awaited() assert mock_set_require_osd_release_option_on_unit.await_count == 2 @@ -241,9 +123,9 @@ async def test_set_require_osd_release_option( async def test_set_require_osd_release_option_no_app( mock_set_require_osd_release_option_on_unit, model ) -> None: - model.get_applications.return_value = {} + apps = [] - await ceph.set_require_osd_release_option(model) + await ceph.set_require_osd_release_option(model, apps) mock_set_require_osd_release_option_on_unit.assert_not_awaited() @@ -253,16 +135,9 @@ async def test_set_require_osd_release_option_no_app( async def test_set_require_osd_release_option_no_units( mock_set_require_osd_release_option_on_unit, model ) -> None: - ceph_mon = MagicMock(spec_set=Application)() - ceph_mon.name = "ceph-mon" - ceph_mon.charm = "ceph-mon" - ceph_mon.units = {} - - model.get_applications.return_value = { - "ceph-mon": ceph_mon, - } + apps = get_applications("ceph-mon", unit_count=0) - await ceph.set_require_osd_release_option(model) + await ceph.set_require_osd_release_option(model, apps) mock_set_require_osd_release_option_on_unit.assert_not_awaited() diff --git a/tests/unit/steps/test_hypervisor.py b/tests/unit/steps/test_hypervisor.py index 746951bc..2a52a8f7 100644 --- a/tests/unit/steps/test_hypervisor.py +++ b/tests/unit/steps/test_hypervisor.py @@ -424,7 +424,6 @@ def test_hypervisor_upgrade_plan(model): Wait for up to 300s for app 'cinder' to reach the idle state Verify that the workload of 'cinder' has been upgraded on units: cinder/0 Enable nova-compute scheduler from unit: 'nova-compute/0' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/0' Wait for up to 2400s for model 'test_model' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/0 Upgrade plan for [nova-compute/1] in 'az-1' to 'victoria' @@ -444,7 +443,6 @@ def test_hypervisor_upgrade_plan(model): ├── Upgrade the unit: 'nova-compute/1' ├── Resume the unit: 'nova-compute/1' Enable nova-compute scheduler from unit: 'nova-compute/1' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/1' Wait for up to 2400s for model 'test_model' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/1 Upgrade plan for [nova-compute/2] in 'az-2' to 'victoria' @@ -464,7 +462,6 @@ def test_hypervisor_upgrade_plan(model): ├── Upgrade the unit: 'nova-compute/2' ├── Resume the unit: 'nova-compute/2' Enable nova-compute scheduler from unit: 'nova-compute/2' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/2' Wait for up to 2400s for model 'test_model' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/2 """ @@ -484,7 +481,6 @@ def test_hypervisor_upgrade_plan(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "cinder/0": Unit( name="cinder/0", @@ -505,7 +501,6 @@ def test_hypervisor_upgrade_plan(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"nova-compute/{unit}": Unit( name=f"nova-compute/{unit}", @@ -567,7 +562,6 @@ def test_hypervisor_upgrade_plan_single_machine(model): Wait for up to 300s for app 'cinder' to reach the idle state Verify that the workload of 'cinder' has been upgraded on units: cinder/0 Enable nova-compute scheduler from unit: 'nova-compute/0' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/0' Wait for up to 2400s for model 'test_model' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/0 """ @@ -587,7 +581,6 @@ def test_hypervisor_upgrade_plan_single_machine(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "cinder/0": Unit( name="cinder/0", @@ -608,7 +601,6 @@ def test_hypervisor_upgrade_plan_single_machine(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ f"nova-compute/{unit}": Unit( name=f"nova-compute/{unit}", @@ -665,7 +657,6 @@ def test_hypervisor_upgrade_plan_some_units_upgraded(model): Wait for up to 300s for app 'cinder' to reach the idle state Verify that the workload of 'cinder' has been upgraded on units: cinder/2 Enable nova-compute scheduler from unit: 'nova-compute/2' - Restart service ceilometer-agent-compute for subordinate unit: 'ceilometer-agent/2' Wait for up to 2400s for model 'test_model' to reach the idle state Verify that the workload of 'nova-compute' has been upgraded on units: nova-compute/2 """ @@ -689,7 +680,6 @@ def test_hypervisor_upgrade_plan_some_units_upgraded(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "cinder/0": Unit( name="cinder/0", @@ -724,7 +714,6 @@ def test_hypervisor_upgrade_plan_some_units_upgraded(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "nova-compute/0": Unit( name="nova-compute/0", diff --git a/tests/unit/steps/test_nova_cloud_controller.py b/tests/unit/steps/test_nova_cloud_controller.py index dd0d9d49..94a0e7e5 100644 --- a/tests/unit/steps/test_nova_cloud_controller.py +++ b/tests/unit/steps/test_nova_cloud_controller.py @@ -18,19 +18,19 @@ from cou.exceptions import ApplicationNotFound, COUException, UnitNotFound from cou.steps.nova_cloud_controller import archive, purge -from tests.unit.utils import get_status +from tests.unit.utils import get_applications @pytest.mark.asyncio async def test_archive_succeeds(model): - model.get_charm_name.side_effect = lambda x: x + apps = get_applications("nova-cloud-controller") model.run_action.return_value = action = MagicMock() action.results = {"archive-deleted-rows": "Nothing was archived."} - await archive(model, batch_size=999) + await archive(model, apps, batch_size=999) model.run_action.assert_awaited_once_with( - unit_name="nova-cloud-controller/0", + unit_name=list(apps[0].units.values())[0].name, action_name="archive-data", raise_on_failure=True, action_params={"batch-size": 999}, @@ -39,7 +39,7 @@ async def test_archive_succeeds(model): @pytest.mark.asyncio async def test_archive_with_broken_charm_action(model): - model.get_charm_name.side_effect = lambda x: x + apps = get_applications("nova-cloud-controller") model.run_action.return_value = action = MagicMock() # simulate the expected archive-deleted-rows key missing action.results = {} @@ -47,10 +47,10 @@ async def test_archive_with_broken_charm_action(model): # It should raise an expected exception # (this will be more graceful than a KeyError for example). with pytest.raises(COUException, match="archive-deleted-rows"): - await archive(model, batch_size=999) + await archive(model, apps, batch_size=999) model.run_action.assert_awaited_once_with( - unit_name="nova-cloud-controller/0", + unit_name=list(apps[0].units.values())[0].name, action_name="archive-data", raise_on_failure=True, action_params={"batch-size": 999}, @@ -60,42 +60,37 @@ async def test_archive_with_broken_charm_action(model): @pytest.mark.asyncio async def test_archive_app_not_found(model): # Update the mocked status so a nova-cloud-controller charm doesn't exist - status = get_status() - del status.applications["nova-cloud-controller"] - model.get_status = AsyncMock(return_value=status) + apps = [] with pytest.raises(ApplicationNotFound): - await archive(model, batch_size=999) + await archive(model, apps, batch_size=999) model.run_action.assert_not_called() @pytest.mark.asyncio async def test_archive_unit_not_found(model): - # Update the mocked status so nova-cloud-controller doesn't have any units - status = get_status() - status.applications["nova-cloud-controller"].units = {} - model.get_status = AsyncMock(return_value=status) + apps = get_applications("nova-cloud-controller", unit_count=0) with pytest.raises(UnitNotFound): - await archive(model, batch_size=999) + await archive(model, apps, batch_size=999) model.run_action.assert_not_called() @pytest.mark.asyncio async def test_archive_handles_multiple_batches(model): - model.get_charm_name.side_effect = lambda x: x + apps = get_applications("nova-cloud-controller") model.run_action.side_effect = [ MagicMock(results={"archive-deleted-rows": "placeholder 25 rows"}), MagicMock(results={"archive-deleted-rows": "Nothing was archived."}), ] - await archive(model, batch_size=999) + await archive(model, apps, batch_size=999) assert model.run_action.call_count == 2 expected_call = call( - unit_name="nova-cloud-controller/0", + unit_name=list(apps[0].units.values())[0].name, action_name="archive-data", raise_on_failure=True, action_params={"batch-size": 999}, @@ -110,25 +105,30 @@ async def test_archive_handles_multiple_batches(model): "Purge all", None, {"output": "fake-msg"}, - ["purge-data action succeeded on %s", "nova-cloud-controller/0"], + ["purge-data action succeeded on %s", "nova-cloud-controller-0/0"], ), ( "Purge before", "2000-01-02", {"output": "fake-msg"}, - ["purge-data action succeeded on %s", "nova-cloud-controller/0"], + ["purge-data action succeeded on %s", "nova-cloud-controller-0/0"], ), ( "No data deleted", None, {"output": "Purging stale soft-deleted rows and no data was deleted"}, - ["purge-data action succeeded on %s (no data was deleted)", "nova-cloud-controller/0"], + [ + "purge-data action succeeded on %s (no data was deleted)", + "nova-cloud-controller-0/0", + ], ), ], ) @patch("cou.steps.nova_cloud_controller.logger") @pytest.mark.asyncio async def test_purge(mock_logger, case, before, action_output, log_msg, model): + apps = get_applications("nova-cloud-controller") + params = {} if before: params["before"] = before @@ -136,12 +136,12 @@ async def test_purge(mock_logger, case, before, action_output, log_msg, model): model.run_action.return_value = AsyncMock() model.run_action.return_value.results = action_output - await purge(model, before) + await purge(model, apps, before) mock_logger.info.assert_called_with(*log_msg) model.run_action.assert_awaited_once_with( action_name="purge-data", - unit_name="nova-cloud-controller/0", + unit_name=list(apps[0].units.values())[0].name, raise_on_failure=True, action_params=params, ) @@ -167,7 +167,7 @@ async def test_purge(mock_logger, case, before, action_output, log_msg, model): None, {"output": "Purging stale soft-deleted rows failed"}, ( - "purge-data action failed on nova-cloud-controller/0," + "purge-data action failed on nova-cloud-controller-0/0," " please check unit's debug log" " for more details." ), @@ -176,6 +176,8 @@ async def test_purge(mock_logger, case, before, action_output, log_msg, model): ) @pytest.mark.asyncio async def test_purge_err(case, before, action_output, err_msg, model): + apps = get_applications("nova-cloud-controller") + params = {} if before: params["before"] = before @@ -184,4 +186,4 @@ async def test_purge_err(case, before, action_output, err_msg, model): model.run_action.return_value.results = action_output with pytest.raises(COUException, match=err_msg): - await purge(model, {}) + await purge(model, apps, {}) diff --git a/tests/unit/steps/test_plan.py b/tests/unit/steps/test_plan.py index c26e58a6..a753aa8a 100644 --- a/tests/unit/steps/test_plan.py +++ b/tests/unit/steps/test_plan.py @@ -49,7 +49,7 @@ from cou.steps.nova_cloud_controller import archive, purge from cou.steps.vault import verify_vault_is_unsealed from cou.utils import app_utils -from cou.utils.juju_utils import Machine, SubordinateUnit, Unit +from cou.utils.juju_utils import Machine, Unit from cou.utils.openstack import OpenStackRelease from tests.unit.utils import dedent_plan, generate_cou_machine @@ -238,7 +238,6 @@ async def test_generate_plan(mock_filter_hypervisors, model, cli_args): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -259,7 +258,6 @@ async def test_generate_plan(mock_filter_hypervisors, model, cli_args): origin="ch", series="focal", subordinate_to=["keystone"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="17.0.1", ) @@ -275,7 +273,6 @@ async def test_generate_plan(mock_filter_hypervisors, model, cli_args): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "nova-compute/0": Unit( name="nova-compute/0", @@ -297,7 +294,6 @@ async def test_generate_plan(mock_filter_hypervisors, model, cli_args): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "ceph-osd/0": Unit( name="ceph-osd/0", @@ -319,7 +315,6 @@ async def test_generate_plan(mock_filter_hypervisors, model, cli_args): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassis/0", "ovn-chassis")], units={}, workload_version="22.3", ) @@ -409,7 +404,6 @@ async def test_generate_plan_with_warning_messages(mock_filter_hypervisors, mode origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "keystone/0": Unit( name="keystone/0", @@ -435,7 +429,6 @@ async def test_generate_plan_with_warning_messages(mock_filter_hypervisors, mode origin="ch", series="focal", subordinate_to=["keystone"], - subordinate_units=[SubordinateUnit("keystone-ldap/0", "keystone-ldap")], units={}, workload_version="17.0.1", ) @@ -451,7 +444,6 @@ async def test_generate_plan_with_warning_messages(mock_filter_hypervisors, mode origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "nova-compute/0": Unit( name="nova-compute/0", @@ -473,7 +465,6 @@ async def test_generate_plan_with_warning_messages(mock_filter_hypervisors, mode origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "ceph-osd/0": Unit( name="ceph-osd/0", @@ -495,7 +486,6 @@ async def test_generate_plan_with_warning_messages(mock_filter_hypervisors, mode origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassis/0", "ovn-chassis")], units={}, workload_version="22.3", ) @@ -1085,7 +1075,11 @@ def test_get_pre_upgrade_steps( PreUpgradeStep( description="Verify ceph cluster 'noout' is unset", parallel=False, - coro=ceph.assert_osd_noout_state(mock_analysis_result.model, state=False), + coro=ceph.assert_osd_noout_state( + mock_analysis_result.model, + mock_analysis_result.apps_control_plane, + state=False, + ), ), PreUpgradeStep( description="Verify that all OpenStack applications are in idle state", @@ -1141,7 +1135,9 @@ def test_get_archive_data_steps(cli_args, model): assert steps == [ PreUpgradeStep( description="Archive old database data on nova-cloud-controller", - coro=archive(mock_analysis_result.model, batch_size=2000), + coro=archive( + mock_analysis_result.model, mock_analysis_result.apps_data_plane, batch_size=2000 + ), ) ] @@ -1224,7 +1220,11 @@ def test_get_purge_data_steps( expected_steps = [ PreUpgradeStep( description=msg, - coro=purge(mock_analysis_result.model, before=cli_args.purge_before), + coro=purge( + mock_analysis_result.model, + mock_analysis_result.apps_data_plane, + before=cli_args.purge_before, + ), ) ] steps = cou_plan._get_purge_data_steps(mock_analysis_result, cli_args) @@ -1255,11 +1255,15 @@ def test_get_post_upgrade_steps_ceph_mon(upgrade_group): assert post_upgrade_steps == [ PostUpgradeStep( "Ensure ceph-mon's 'require-osd-release' option matches the 'ceph-osd' version", - coro=set_require_osd_release_option(analysis_result.model), + coro=set_require_osd_release_option( + analysis_result.model, analysis_result.apps_control_plane + ), ), PostUpgradeStep( description="Unset ceph cluster 'noout' flag after data plane upgrade", - coro=ceph.osd_noout(analysis_result.model, enable=False), + coro=ceph.osd_noout( + analysis_result.model, analysis_result.apps_control_plane, enable=False + ), ), ] @@ -1468,7 +1472,6 @@ def test_separate_hypervisors_apps(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "nova-compute/0": Unit( name="nova-compute/0", @@ -1494,7 +1497,6 @@ def test_separate_hypervisors_apps(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "cinder/0": Unit( name="cinder/0", @@ -1517,7 +1519,6 @@ def test_separate_hypervisors_apps(model): origin="ch", series="focal", subordinate_to=["nova-compute"], - subordinate_units=[SubordinateUnit("ovn-chassis/0", "ovn-chassis")], units={}, workload_version="22.3", ) @@ -1534,7 +1535,6 @@ def test_separate_hypervisors_apps(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "ceph-osd/0": Unit( name="ceph-osd/0", @@ -1557,7 +1557,6 @@ def test_separate_hypervisors_apps(model): origin="ch", series="focal", subordinate_to=[], - subordinate_units=[], units={ "ceph-osd/0": Unit( name="ceph-osd/0", @@ -1766,6 +1765,8 @@ def test_get_set_noout_steps(mock_analysis, cli_args): assert step == [ PreUpgradeStep( description="Set ceph cluster 'noout' flag before data plane upgrade", - coro=ceph.osd_noout(mock_analysis.model, enable=True), + coro=ceph.osd_noout( + mock_analysis.model, mock_analysis.apps_control_plane, enable=True + ), ) ] diff --git a/tests/unit/utils.py b/tests/unit/utils.py index d61524ee..9c408aca 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -19,7 +19,7 @@ from juju.client.client import FullStatus from cou.steps import BaseStep -from cou.utils.juju_utils import Machine +from cou.utils.juju_utils import Application, Machine, Unit def assert_steps(step_1: BaseStep, step_2: BaseStep) -> None: @@ -45,6 +45,25 @@ def dedent_plan(plan: str) -> str: return result +def get_applications( + charm_name: str, app_count: int = 1, unit_count: int = 1 +) -> list[Application]: + """Get mocked applications.""" + apps = [] + for i in range(app_count): + app = MagicMock(spec_set=Application)() + app.name = f"{charm_name}-{i}" + app.charm = charm_name + units = {} + for j in range(unit_count): + unit = MagicMock(spec_set=Unit)() + unit.name = f"{charm_name}-{i}/{j}" + units[unit.name] = unit + app.units = units + apps.append(app) + return apps + + def get_status(): """Help function to load Juju status from json file.""" current_path = Path(__file__).parent.resolve() diff --git a/tests/unit/utils/test_juju_utils.py b/tests/unit/utils/test_juju_utils.py index be2a714b..9d4723ed 100644 --- a/tests/unit/utils/test_juju_utils.py +++ b/tests/unit/utils/test_juju_utils.py @@ -810,8 +810,6 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model app1/2 active idle 2 10.147.4.3 app2/0* active idle 0 10.147.4.1 app4/0* active idle 10.147.4.1 - app4/1* active idle 10.147.4.1 - app4/2* active idle 10.147.4.1 app3/0* active idle 1 10.147.4.2 Machine State Address Inst id Base AZ Message @@ -841,7 +839,6 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model } mocked_model.applications = {app: MagicMock(spec_set=Application)() for app in exp_apps} - mocked_model.subordinate_units = {f"app4/{i}" for i in range(3)} for app in exp_apps: mocked_model.applications[app].get_actions = AsyncMock() @@ -852,10 +849,6 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model full_status_apps = {app: _generate_app_status(exp_units_from_status[app]) for app in exp_apps} mock_get_status.return_value.applications = full_status_apps mock_get_machines.return_value = exp_machines - mock_subordinate_units = { - juju_utils.SubordinateUnit(name, mocked_model.applications[name.split("/")[0]].charm_name) - for name in mocked_model.subordinate_units - } model = juju_utils.Model("test-model") exp_apps = { @@ -885,9 +878,6 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model ) for name, unit in exp_units_from_status[app].items() }, - subordinate_units=[ - su for su in mock_subordinate_units if su.name.split("/")[0] == app - ], workload_version=status.workload_version, ) for app, status in full_status_apps.items()