From 97cd898f31b952e1e12a0d01316a76b2fccde763 Mon Sep 17 00:00:00 2001 From: jneo8 Date: Tue, 11 Jun 2024 17:58:38 +0800 Subject: [PATCH 1/8] feat: Restart ceilometer-agent-compute after nova-compute upgrade Fix: #427 --- cou/apps/core.py | 39 ++++++++++++++++++++++++- cou/utils/juju_utils.py | 38 ++++++++++++++++++++++-- tests/unit/apps/test_core.py | 45 +++++++++++++++++++++++++++-- tests/unit/utils/test_juju_utils.py | 30 +++++++++++++++++-- 4 files changed, 142 insertions(+), 10 deletions(-) diff --git a/cou/apps/core.py b/cou/apps/core.py index d4082b74..77d58005 100644 --- a/cou/apps/core.py +++ b/cou/apps/core.py @@ -106,7 +106,44 @@ def post_upgrade_steps( :return: List of post upgrade steps. :rtype: list[PostUpgradeStep] """ - return self._get_enable_scheduler_step(units) + super().post_upgrade_steps(target, units) + 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: + return [] + steps = [] + for unit in units: + for subordinate in unit.subordinates: + if "ceilometer-agent" in subordinate.name: + service = "ceilometer-agent-compute" + steps.append( + PostUpgradeStep( + description=( + f"Restart subordinate service for 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 def _get_unit_upgrade_steps(self, unit: Unit, force: bool) -> UnitUpgradeStep: """Get the upgrade steps for a single unit. diff --git a/cou/utils/juju_utils.py b/cou/utils/juju_utils.py index 124198bf..6ed02732 100644 --- a/cou/utils/juju_utils.py +++ b/cou/utils/juju_utils.py @@ -19,9 +19,9 @@ import asyncio import logging import os -from dataclasses import dataclass +from dataclasses import dataclass, field from datetime import datetime -from typing import Any, Callable, Optional +from typing import Any, Callable, List, Optional from juju.action import Action from juju.application import Application as JujuApplication @@ -142,6 +142,22 @@ class Machine: az: Optional[str] = None # simple deployments may not have azs +@dataclass(frozen=True) +class SubordinateUnit: + """Representation of a single unit of subordinate unit.""" + + name: str + workload_version: str + + def __repr__(self) -> str: + """App representation. + + :return: Name of the application + :rtype: str + """ + return self.name + + @dataclass(frozen=True) class Unit: """Representation of a single unit of application.""" @@ -149,6 +165,7 @@ class Unit: name: str machine: Machine workload_version: str + subordinates: List[SubordinateUnit] = field(default_factory=lambda: [], compare=False) def __repr__(self) -> str: """App representation. @@ -367,6 +384,13 @@ async def get_applications(self) -> dict[str, Application]: full_status = await self.get_status() machines = await self._get_machines() + for app, status in full_status.applications.items(): + logger.debug(app) + for name, unit in status.units.items(): + logger.debug(name) + logger.debug(unit) + logger.debug(unit.subordinates) + return { app: Application( name=app, @@ -383,7 +407,15 @@ async def get_applications(self) -> dict[str, Application]: series=status.series, subordinate_to=status.subordinate_to, units={ - name: Unit(name, machines[unit.machine], unit.workload_version) + name: Unit( + name, + machines[unit.machine], + unit.workload_version, + [ + SubordinateUnit(subordinate_name, subordinate.workload_version) + for subordinate_name, subordinate in unit.subordinates.items() + ], + ) for name, unit in status.units.items() }, workload_version=status.workload_version, diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index ae1d3bdf..727cb9b0 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -32,7 +32,7 @@ ) from cou.utils import app_utils from cou.utils import nova_compute as nova_compute_utils -from cou.utils.juju_utils import Unit +from cou.utils.juju_utils import SubordinateUnit, Unit from cou.utils.openstack import OpenStackRelease from tests.unit.utils import assert_steps, dedent_plan, generate_cou_machine @@ -631,7 +631,14 @@ 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") -def test_nova_compute_post_upgrade_steps(mock_enable, mock_expected_target, mock_wait_step, model): +@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, +): app = _generate_nova_compute_app(model) target = OpenStackRelease("victoria") units = list(app.units.values()) @@ -640,6 +647,7 @@ def test_nova_compute_post_upgrade_steps(mock_enable, mock_expected_target, mock 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]) @@ -708,6 +716,32 @@ def test_nova_compute_get_enable_scheduler_step(model, units): assert app._get_enable_scheduler_step(units_selected) == expected_step +@pytest.mark.parametrize( + "units", + [ + [f"nova-compute/{unit}" for unit in range(1)], + [f"nova-compute/{unit}" for unit in range(2)], + [f"nova-compute/{unit}" for unit in range(3)], + ], +) +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=f"Restart subordinate service for 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) @@ -770,7 +804,12 @@ def _generate_nova_compute_app(model): channel = "ussuri/stable" units = { - f"nova-compute/{unit_num}": Unit(f"nova-compute/{unit_num}", MagicMock(), "21.0.1") + f"nova-compute/{unit_num}": Unit( + f"nova-compute/{unit_num}", + MagicMock(), + "21.0.1", + [SubordinateUnit("ceilometer-agent/{unit_num}", "14.1.0")], + ) for unit_num in range(3) } app = NovaCompute( diff --git a/tests/unit/utils/test_juju_utils.py b/tests/unit/utils/test_juju_utils.py index 54aafad6..4a6d53b8 100644 --- a/tests/unit/utils/test_juju_utils.py +++ b/tests/unit/utils/test_juju_utils.py @@ -625,10 +625,16 @@ def _generate_juju_machine(machine_id: str) -> MagicMock: return machine -def _generate_unit_status(app: str, unit_id: int, machine_id: str) -> tuple[str, MagicMock]: +def _generate_unit_status( + app: str, + unit_id: int, + machine_id: str, + subordinates: dict[str, MagicMock] = {}, +) -> tuple[str, MagicMock]: """Generate unit name and status.""" status = MagicMock(spec_set=UnitStatus)() status.machine = machine_id + status.subordinates = subordinates return f"{app}/{unit_id}", status @@ -678,7 +684,9 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model } exp_units_from_status = { "app1": dict([_generate_unit_status("app1", i, f"{i}") for i in range(3)]), - "app2": dict([_generate_unit_status("app2", 0, "0")]), + "app2": dict( + [_generate_unit_status("app2", 0, "0", dict([_generate_unit_status("app4", 0, "")]))] + ), "app3": dict([_generate_unit_status("app3", 0, "1")]), "app4": {}, # subordinate application has no units defined in juju status } @@ -712,7 +720,18 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model series=status.series, subordinate_to=status.subordinate_to, units={ - name: juju_utils.Unit(name, exp_machines[unit.machine], unit.workload_version) + name: juju_utils.Unit( + name, + exp_machines[unit.machine], + unit.workload_version, + [ + juju_utils.SubordinateUnit( + subordinate_name, + subordinate.workload_version, + ) + for subordinate_name, subordinate in unit.subordinates.items() + ], + ) for name, unit in exp_units_from_status[app].items() }, workload_version=status.workload_version, @@ -746,3 +765,8 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model def test_unit_repr(): unit = juju_utils.Unit(name="foo/0", machine=MagicMock(), workload_version="1") assert repr(unit) == "foo/0" + + +def test_suborinate_unit_repr(): + unit = juju_utils.SubordinateUnit(name="foo/0", workload_version="1") + assert repr(unit) == "foo/0" From c5d0902172145780ae246d0cb8b1bd0a1a752d5d Mon Sep 17 00:00:00 2001 From: jneo8 Date: Thu, 13 Jun 2024 16:48:10 +0800 Subject: [PATCH 2/8] fix: Use charm name instead of application name for conditation --- cou/apps/core.py | 2 +- cou/utils/juju_utils.py | 29 +++++++++++++----- tests/unit/apps/test_core.py | 2 +- tests/unit/utils/test_juju_utils.py | 47 ++++++++++++++++++++++------- 4 files changed, 59 insertions(+), 21 deletions(-) diff --git a/cou/apps/core.py b/cou/apps/core.py index 77d58005..9d7041dc 100644 --- a/cou/apps/core.py +++ b/cou/apps/core.py @@ -127,7 +127,7 @@ def _get_restart_subordinate_services_steps( steps = [] for unit in units: for subordinate in unit.subordinates: - if "ceilometer-agent" in subordinate.name: + if "ceilometer-agent" == subordinate.charm: service = "ceilometer-agent-compute" steps.append( PostUpgradeStep( diff --git a/cou/utils/juju_utils.py b/cou/utils/juju_utils.py index 6ed02732..5066f3b5 100644 --- a/cou/utils/juju_utils.py +++ b/cou/utils/juju_utils.py @@ -147,6 +147,7 @@ class SubordinateUnit: """Representation of a single unit of subordinate unit.""" name: str + charm: str workload_version: str def __repr__(self) -> str: @@ -292,6 +293,15 @@ async def _get_application(self, name: str) -> JujuApplication: return app + async def _get_applications(self) -> dict[str, JujuApplication]: + """Return a map of application-name:Application for all applications. + + :returns: Dictionary of the applications found in the model. + :rtype: dict[str, Application] + """ + model = await self._get_model() + return model.applications + async def _get_machines(self) -> dict[str, Machine]: """Get all the machines in the model. @@ -371,7 +381,7 @@ async def connect(self) -> None: retry_backoff=DEFAULT_MODEL_RETRY_BACKOFF, ) - @retry + # @retry async def get_applications(self) -> dict[str, Application]: """Return list of applications with all relevant information. @@ -384,12 +394,11 @@ async def get_applications(self) -> dict[str, Application]: full_status = await self.get_status() machines = await self._get_machines() - for app, status in full_status.applications.items(): - logger.debug(app) - for name, unit in status.units.items(): - logger.debug(name) - logger.debug(unit) - logger.debug(unit.subordinates) + applications = await self._get_applications() + unit_charm_mapping: dict[str, str] = {} + for name, app in applications.items(): + for unit in app.units: + unit_charm_mapping[unit.name] = app.charm_name return { app: Application( @@ -412,7 +421,11 @@ async def get_applications(self) -> dict[str, Application]: machines[unit.machine], unit.workload_version, [ - SubordinateUnit(subordinate_name, subordinate.workload_version) + SubordinateUnit( + subordinate_name, + unit_charm_mapping[subordinate_name], + subordinate.workload_version, + ) for subordinate_name, subordinate in unit.subordinates.items() ], ) diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index 727cb9b0..2489a9f0 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -808,7 +808,7 @@ def _generate_nova_compute_app(model): f"nova-compute/{unit_num}", MagicMock(), "21.0.1", - [SubordinateUnit("ceilometer-agent/{unit_num}", "14.1.0")], + [SubordinateUnit("ceilometer-agent/{unit_num}", "ceilometer-agent", "14.1.0")], ) for unit_num in range(3) } diff --git a/tests/unit/utils/test_juju_utils.py b/tests/unit/utils/test_juju_utils.py index 4a6d53b8..f4ed92c4 100644 --- a/tests/unit/utils/test_juju_utils.py +++ b/tests/unit/utils/test_juju_utils.py @@ -584,10 +584,10 @@ async def test_get_machines(mocked_model): } mocked_model.machines = {f"{i}": _generate_juju_machine(f"{i}") for i in range(3)} mocked_model.units = { - "my_app1/0": _generate_juju_unit("my_app1", "0"), - "my_app1/1": _generate_juju_unit("my_app1", "1"), - "my_app1/2": _generate_juju_unit("my_app1", "2"), - "my_app2/0": _generate_juju_unit("my_app2", "0"), + "my_app1/0": _generate_juju_unit("my_app1", "0", "0"), + "my_app1/1": _generate_juju_unit("my_app1", "1", "1"), + "my_app1/2": _generate_juju_unit("my_app1", "2", "2"), + "my_app2/0": _generate_juju_unit("my_app2", "0", "0"), } mocked_model.applications = { "my_app1": _generate_juju_app("app1"), @@ -600,9 +600,22 @@ async def test_get_machines(mocked_model): assert machines == expected_machines -def _generate_juju_unit(app: str, machine_id: str) -> MagicMock: +@pytest.mark.asyncio +async def test__get_applications(mocked_model): + """Test Model getting applications from model.""" + expected = "expect-applications" + mocked_model.applications = "expect-applications" + + model = juju_utils.Model("test-model") + applications = await model._get_applications() + + assert applications == expected + + +def _generate_juju_unit(app: str, id: str, machine_id: str) -> MagicMock: unit = MagicMock(set=Unit)() unit.application = app + unit.name = f"{app}/{id}" unit.machine.id = machine_id return unit @@ -635,6 +648,7 @@ def _generate_unit_status( status = MagicMock(spec_set=UnitStatus)() status.machine = machine_id status.subordinates = subordinates + status.charm = app return f"{app}/{unit_id}", status @@ -648,7 +662,13 @@ def _generate_app_status(units: dict[str, MagicMock]) -> MagicMock: @pytest.mark.asyncio @patch("cou.utils.juju_utils.Model.get_status") @patch("cou.utils.juju_utils.Model._get_machines") -async def test_get_applications(mock_get_machines, mock_get_status, mocked_model): +@patch("cou.utils.juju_utils.Model._get_applications") +async def test_get_applications( + mock_get_applications, + mock_get_machines, + mock_get_status, + mocked_model, +): """Test Model getting applications from model. Getting application from status, where model contain 3 applications deployed on 3 machines. @@ -691,20 +711,23 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model "app4": {}, # subordinate application has no units defined in juju status } exp_units = { - "app1": [_generate_juju_unit("app1", f"{i}") for i in range(3)], - "app2": [_generate_juju_unit("app2", "0")], - "app3": [_generate_juju_unit("app3", "0")], - "app4": [_generate_juju_unit("app4", "0")], + "app1": [_generate_juju_unit("app1", f"{i}", f"{i}") for i in range(3)], + "app2": [_generate_juju_unit("app2", "0", "0")], + "app3": [_generate_juju_unit("app3", "0", "0")], + "app4": [_generate_juju_unit("app4", "0", "0")], } mocked_model.applications = {app: MagicMock(spec_set=Application)() for app in exp_apps} + for app in exp_apps: mocked_model.applications[app].get_config = AsyncMock() mocked_model.applications[app].units = exp_units[app] + mocked_model.applications[app].charm_name = app 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_get_applications.return_value = mocked_model.applications model = juju_utils.Model("test-model") exp_apps = { @@ -727,6 +750,7 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model [ juju_utils.SubordinateUnit( subordinate_name, + subordinate.charm, subordinate.workload_version, ) for subordinate_name, subordinate in unit.subordinates.items() @@ -744,6 +768,7 @@ async def test_get_applications(mock_get_machines, mock_get_status, mocked_model # check mocked objects mock_get_status.assert_awaited_once_with() mock_get_machines.assert_awaited_once_with() + mock_get_applications.assert_called_once_with() for app in full_status_apps: mocked_model.applications[app].get_config.assert_awaited_once_with() @@ -768,5 +793,5 @@ def test_unit_repr(): def test_suborinate_unit_repr(): - unit = juju_utils.SubordinateUnit(name="foo/0", workload_version="1") + unit = juju_utils.SubordinateUnit(name="foo/0", charm="foo", workload_version="1") assert repr(unit) == "foo/0" From 7ed93f346c3bb4734403f2eb041abb0026cecb8b Mon Sep 17 00:00:00 2001 From: jneo8 Date: Fri, 14 Jun 2024 01:38:54 +0800 Subject: [PATCH 3/8] fix: Remove workload_version in subordinate unit --- cou/utils/juju_utils.py | 4 +--- tests/unit/apps/test_core.py | 2 +- tests/unit/utils/test_juju_utils.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cou/utils/juju_utils.py b/cou/utils/juju_utils.py index 5066f3b5..b00e4d0f 100644 --- a/cou/utils/juju_utils.py +++ b/cou/utils/juju_utils.py @@ -148,7 +148,6 @@ class SubordinateUnit: name: str charm: str - workload_version: str def __repr__(self) -> str: """App representation. @@ -381,7 +380,7 @@ async def connect(self) -> None: retry_backoff=DEFAULT_MODEL_RETRY_BACKOFF, ) - # @retry + @retry async def get_applications(self) -> dict[str, Application]: """Return list of applications with all relevant information. @@ -424,7 +423,6 @@ async def get_applications(self) -> dict[str, Application]: SubordinateUnit( subordinate_name, unit_charm_mapping[subordinate_name], - subordinate.workload_version, ) for subordinate_name, subordinate in unit.subordinates.items() ], diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index 2489a9f0..793d60f7 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -808,7 +808,7 @@ def _generate_nova_compute_app(model): f"nova-compute/{unit_num}", MagicMock(), "21.0.1", - [SubordinateUnit("ceilometer-agent/{unit_num}", "ceilometer-agent", "14.1.0")], + [SubordinateUnit("ceilometer-agent/{unit_num}", "ceilometer-agent")], ) for unit_num in range(3) } diff --git a/tests/unit/utils/test_juju_utils.py b/tests/unit/utils/test_juju_utils.py index f4ed92c4..78ee5d0f 100644 --- a/tests/unit/utils/test_juju_utils.py +++ b/tests/unit/utils/test_juju_utils.py @@ -751,7 +751,6 @@ async def test_get_applications( juju_utils.SubordinateUnit( subordinate_name, subordinate.charm, - subordinate.workload_version, ) for subordinate_name, subordinate in unit.subordinates.items() ], @@ -793,5 +792,5 @@ def test_unit_repr(): def test_suborinate_unit_repr(): - unit = juju_utils.SubordinateUnit(name="foo/0", charm="foo", workload_version="1") + unit = juju_utils.SubordinateUnit(name="foo/0", charm="foo") assert repr(unit) == "foo/0" From e9270fb5a09e015354e8520547f054c31b195f07 Mon Sep 17 00:00:00 2001 From: jneo8 Date: Fri, 14 Jun 2024 10:52:41 +0800 Subject: [PATCH 4/8] refactor: Remove _get_applications --- cou/apps/base.py | 1 + cou/utils/juju_utils.py | 22 ++++------------------ tests/unit/steps/test_analyze.py | 7 +++++++ tests/unit/utils/test_juju_utils.py | 22 +--------------------- 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/cou/apps/base.py b/cou/apps/base.py index c96d0074..69e62d3a 100644 --- a/cou/apps/base.py +++ b/cou/apps/base.py @@ -122,6 +122,7 @@ def __str__(self) -> str: "machine": unit.machine.machine_id, "workload_version": unit.workload_version, "o7k_version": str(self.get_latest_o7k_version(unit)), + "subordinates": ",".join([subordinate.name for subordinate in unit.subordinates]), } for unit in self.units.values() }, diff --git a/cou/utils/juju_utils.py b/cou/utils/juju_utils.py index b00e4d0f..3757f91c 100644 --- a/cou/utils/juju_utils.py +++ b/cou/utils/juju_utils.py @@ -292,15 +292,6 @@ async def _get_application(self, name: str) -> JujuApplication: return app - async def _get_applications(self) -> dict[str, JujuApplication]: - """Return a map of application-name:Application for all applications. - - :returns: Dictionary of the applications found in the model. - :rtype: dict[str, Application] - """ - model = await self._get_model() - return model.applications - async def _get_machines(self) -> dict[str, Machine]: """Get all the machines in the model. @@ -392,12 +383,7 @@ 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() - - applications = await self._get_applications() - unit_charm_mapping: dict[str, str] = {} - for name, app in applications.items(): - for unit in app.units: - unit_charm_mapping[unit.name] = app.charm_name + print(model.applications) return { app: Application( @@ -421,10 +407,10 @@ async def get_applications(self) -> dict[str, Application]: unit.workload_version, [ SubordinateUnit( - subordinate_name, - unit_charm_mapping[subordinate_name], + subordinate, + model.applications[subordinate.split("/")[0]] ) - for subordinate_name, subordinate in unit.subordinates.items() + for subordinate, subordinate_unit in unit.subordinates.items() ], ) for name, unit in status.units.items() diff --git a/tests/unit/steps/test_analyze.py b/tests/unit/steps/test_analyze.py index 50dde2d9..1c296fcd 100644 --- a/tests/unit/steps/test_analyze.py +++ b/tests/unit/steps/test_analyze.py @@ -51,16 +51,19 @@ def test_analysis_dump(model): machine: '0' workload_version: 17.0.1 o7k_version: ussuri + subordinates: '' keystone/1: name: keystone/1 machine: '1' workload_version: 17.0.1 o7k_version: ussuri + subordinates: '' keystone/2: name: keystone/2 machine: '2' workload_version: 17.0.1 o7k_version: ussuri + subordinates: '' machines: '0': id: '0' @@ -93,16 +96,19 @@ def test_analysis_dump(model): machine: '0' workload_version: 16.4.2 o7k_version: ussuri + subordinates: '' cinder/1: name: cinder/1 machine: '1' workload_version: 16.4.2 o7k_version: ussuri + subordinates: '' cinder/2: name: cinder/2 machine: '2' workload_version: 16.4.2 o7k_version: ussuri + subordinates: '' machines: '0': id: '0' @@ -135,6 +141,7 @@ def test_analysis_dump(model): machine: '0' workload_version: '3.8' o7k_version: yoga + subordinates: '' machines: '0': id: '0' diff --git a/tests/unit/utils/test_juju_utils.py b/tests/unit/utils/test_juju_utils.py index 78ee5d0f..1a20c37e 100644 --- a/tests/unit/utils/test_juju_utils.py +++ b/tests/unit/utils/test_juju_utils.py @@ -600,18 +600,6 @@ async def test_get_machines(mocked_model): assert machines == expected_machines -@pytest.mark.asyncio -async def test__get_applications(mocked_model): - """Test Model getting applications from model.""" - expected = "expect-applications" - mocked_model.applications = "expect-applications" - - model = juju_utils.Model("test-model") - applications = await model._get_applications() - - assert applications == expected - - def _generate_juju_unit(app: str, id: str, machine_id: str) -> MagicMock: unit = MagicMock(set=Unit)() unit.application = app @@ -662,13 +650,7 @@ def _generate_app_status(units: dict[str, MagicMock]) -> MagicMock: @pytest.mark.asyncio @patch("cou.utils.juju_utils.Model.get_status") @patch("cou.utils.juju_utils.Model._get_machines") -@patch("cou.utils.juju_utils.Model._get_applications") -async def test_get_applications( - mock_get_applications, - mock_get_machines, - mock_get_status, - mocked_model, -): +async def test_get_applications(mock_get_machines ,mock_get_status, mocked_model): """Test Model getting applications from model. Getting application from status, where model contain 3 applications deployed on 3 machines. @@ -727,7 +709,6 @@ async def test_get_applications( 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_get_applications.return_value = mocked_model.applications model = juju_utils.Model("test-model") exp_apps = { @@ -767,7 +748,6 @@ async def test_get_applications( # check mocked objects mock_get_status.assert_awaited_once_with() mock_get_machines.assert_awaited_once_with() - mock_get_applications.assert_called_once_with() for app in full_status_apps: mocked_model.applications[app].get_config.assert_awaited_once_with() From 794242659c4de6ff0157481b2dc933ae9db9504f Mon Sep 17 00:00:00 2001 From: jneo8 Date: Fri, 14 Jun 2024 13:22:52 +0800 Subject: [PATCH 5/8] test: Add to core and hypervisor planning tests --- cou/apps/core.py | 2 +- cou/utils/juju_utils.py | 1 - tests/unit/apps/test_core.py | 7 ++++++- tests/unit/steps/test_hypervisor.py | 12 +++++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cou/apps/core.py b/cou/apps/core.py index 9d7041dc..c10c6a38 100644 --- a/cou/apps/core.py +++ b/cou/apps/core.py @@ -123,7 +123,7 @@ def _get_restart_subordinate_services_steps( :rtype: list[PostUpgradeStep] """ if not units: - return [] + units = list(self.units.values()) steps = [] for unit in units: for subordinate in unit.subordinates: diff --git a/cou/utils/juju_utils.py b/cou/utils/juju_utils.py index 3757f91c..9722dd0a 100644 --- a/cou/utils/juju_utils.py +++ b/cou/utils/juju_utils.py @@ -383,7 +383,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() - print(model.applications) return { app: Application( diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index 793d60f7..2d8530dd 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -855,6 +855,9 @@ 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 subordinate service for unit: ceilometer-agent/0 + Restart subordinate service for unit: ceilometer-agent/1 + Restart subordinate service for 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 @@ -865,6 +868,7 @@ def test_nova_compute_upgrade_plan(model): name=f"nova-compute/{unit}", workload_version="21.0.0", machine=machines[f"{unit}"], + subordinates=[SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent")] ) for unit in range(3) } @@ -884,7 +888,6 @@ def test_nova_compute_upgrade_plan(model): ) plan = nova_compute.generate_upgrade_plan(target, False) - assert str(plan) == exp_plan @@ -908,6 +911,7 @@ 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 subordinate service for 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 """ @@ -918,6 +922,7 @@ def test_nova_compute_upgrade_plan_single_unit(model): name=f"nova-compute/{unit}", workload_version="21.0.0", machine=machines[f"{unit}"], + subordinates=[SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent")] ) for unit in range(3) } diff --git a/tests/unit/steps/test_hypervisor.py b/tests/unit/steps/test_hypervisor.py index 76df230c..6c57c0c1 100644 --- a/tests/unit/steps/test_hypervisor.py +++ b/tests/unit/steps/test_hypervisor.py @@ -25,7 +25,7 @@ UpgradeStep, ) from cou.steps.hypervisor import AZs, HypervisorGroup, HypervisorUpgradePlanner -from cou.utils.juju_utils import Application, Machine, Unit +from cou.utils.juju_utils import Application, Machine, Unit, SubordinateUnit from cou.utils.openstack import OpenStackRelease from tests.unit.utils import dedent_plan, generate_cou_machine @@ -420,6 +420,7 @@ 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 subordinate service for 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' @@ -437,6 +438,7 @@ 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 subordinate service for 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' @@ -454,6 +456,7 @@ 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 subordinate service for 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 """ @@ -498,6 +501,7 @@ def test_hypervisor_upgrade_plan(model): name=f"nova-compute/{unit}", workload_version="21.0.0", machine=machines[f"{unit}"], + subordinates=[SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent")] ) for unit in range(3) }, @@ -547,6 +551,7 @@ 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 subordinate service for 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 """ @@ -591,6 +596,7 @@ def test_hypervisor_upgrade_plan_single_machine(model): name=f"nova-compute/{unit}", workload_version="21.0.0", machine=machines[f"{unit}"], + subordinates=[SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent")] ) for unit in range(3) }, @@ -639,6 +645,7 @@ 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 subordinate service for 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 """ @@ -701,16 +708,19 @@ def test_hypervisor_upgrade_plan_some_units_upgraded(model): name="nova-compute/0", workload_version="22.0.0", machine=machines["0"], + subordinates=[SubordinateUnit(name="ceilometer-agent/0", charm="ceilometer-agent")] ), "nova-compute/1": Unit( name="nova-compute/1", workload_version="22.0.0", machine=machines["1"], + subordinates=[SubordinateUnit(name="ceilometer-agent/1", charm="ceilometer-agent")] ), "nova-compute/2": Unit( name="nova-compute/2", workload_version="21.0.0", machine=machines["2"], + subordinates=[SubordinateUnit(name="ceilometer-agent/2", charm="ceilometer-agent")] ), }, workload_version="22.0.0", From 2108e58960454828e9689fb95652f9ac4c95d404 Mon Sep 17 00:00:00 2001 From: jneo8 Date: Fri, 14 Jun 2024 15:50:55 +0800 Subject: [PATCH 6/8] test: Add restart nova subordinate services to mock_plans test --- cou/apps/base.py | 8 ++- cou/apps/core.py | 2 +- cou/utils/juju_utils.py | 3 +- .../018346c5-f95c-46df-a34e-9a78bdec0018.yaml | 61 ++++++++++++++++++- .../9eb9af6a-b919-4cf9-8f2f-9df16a1556be.yaml | 45 ++++++++++++++ tests/mocked_plans/sample_plans/base.yaml | 5 ++ tests/mocked_plans/utils.py | 15 ++++- tests/unit/apps/test_core.py | 18 +++--- tests/unit/steps/test_analyze.py | 14 ++--- tests/unit/steps/test_hypervisor.py | 32 ++++++---- tests/unit/utils/test_juju_utils.py | 2 +- 11 files changed, 172 insertions(+), 33 deletions(-) diff --git a/cou/apps/base.py b/cou/apps/base.py index 69e62d3a..c3aeee97 100644 --- a/cou/apps/base.py +++ b/cou/apps/base.py @@ -122,7 +122,13 @@ def __str__(self) -> str: "machine": unit.machine.machine_id, "workload_version": unit.workload_version, "o7k_version": str(self.get_latest_o7k_version(unit)), - "subordinates": ",".join([subordinate.name for subordinate in unit.subordinates]), + "subordinates": { + subordinate.name: { + "name": subordinate.name, + "charm": subordinate.charm, + } + for subordinate in unit.subordinates + }, } for unit in self.units.values() }, diff --git a/cou/apps/core.py b/cou/apps/core.py index c10c6a38..1b886e2b 100644 --- a/cou/apps/core.py +++ b/cou/apps/core.py @@ -132,7 +132,7 @@ def _get_restart_subordinate_services_steps( steps.append( PostUpgradeStep( description=( - f"Restart subordinate service for unit: {subordinate.name}" + f"Restart subordinate service for unit: '{subordinate.name}'" ), coro=self.model.run_on_unit( unit_name=subordinate.name, diff --git a/cou/utils/juju_utils.py b/cou/utils/juju_utils.py index 9722dd0a..b853666c 100644 --- a/cou/utils/juju_utils.py +++ b/cou/utils/juju_utils.py @@ -406,8 +406,7 @@ async def get_applications(self) -> dict[str, Application]: unit.workload_version, [ SubordinateUnit( - subordinate, - model.applications[subordinate.split("/")[0]] + subordinate, model.applications[subordinate.split("/")[0]] ) for subordinate, subordinate_unit in unit.subordinates.items() ], 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 c38691bb..3d29d0c6 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 @@ -319,6 +319,10 @@ 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 subordinate service for unit: 'ceilometer-agent/0' + Restart subordinate service for unit: 'ceilometer-agent/2' + Restart subordinate service for unit: 'ceilometer-agent/3' + Restart subordinate service for 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' @@ -386,6 +390,10 @@ 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 subordinate service for unit: 'ceilometer-agent/1' + Restart subordinate service for unit: 'ceilometer-agent/10' + Restart subordinate service for unit: 'ceilometer-agent/11' + Restart subordinate service for 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' @@ -453,6 +461,10 @@ 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 subordinate service for unit: 'ceilometer-agent/4' + Restart subordinate service for unit: 'ceilometer-agent/6' + Restart subordinate service for unit: 'ceilometer-agent/7' + Restart subordinate service for 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 @@ -6738,61 +6750,108 @@ applications: machine: '21' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/0: + name: ceilometer-agent/0 + charm: ceilometer-agent nova-compute-kvm/1: name: nova-compute-kvm/1 machine: '22' workload_version: 21.2.4 - o7k_version: ussuri + subordinates: + ceilometer-agent/1: + name: ceilometer-agent/1 + charm: ceilometer-agent nova-compute-kvm/10: name: nova-compute-kvm/10 machine: '31' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/10: + name: ceilometer-agent/10 + charm: ceilometer-agent nova-compute-kvm/11: name: nova-compute-kvm/11 machine: '32' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/11: + name: ceilometer-agent/11 + charm: ceilometer-agent nova-compute-kvm/2: name: nova-compute-kvm/2 machine: '23' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/2: + name: ceilometer-agent/2 + charm: ceilometer-agent nova-compute-kvm/3: name: nova-compute-kvm/3 machine: '24' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/3: + name: ceilometer-agent/3 + charm: ceilometer-agent nova-compute-kvm/4: name: nova-compute-kvm/4 machine: '25' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/4: + name: ceilometer-agent/4 + charm: ceilometer-agent nova-compute-kvm/5: name: nova-compute-kvm/5 machine: '26' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/5: + name: ceilometer-agent/5 + charm: ceilometer-agent nova-compute-kvm/6: name: nova-compute-kvm/6 machine: '27' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/6: + name: ceilometer-agent/6 + charm: ceilometer-agent nova-compute-kvm/7: name: nova-compute-kvm/7 machine: '28' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/7: + name: ceilometer-agent/7 + charm: ceilometer-agent nova-compute-kvm/8: name: nova-compute-kvm/8 machine: '29' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/8: + name: ceilometer-agent/8 + charm: ceilometer-agent nova-compute-kvm/9: name: nova-compute-kvm/9 machine: '30' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/9: + name: ceilometer-agent/9 + charm: ceilometer-agent machines: '21': id: '21' 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 9aade41b..cec713ea 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 @@ -341,6 +341,9 @@ 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 subordinate service for unit: 'ceilometer-agent/0' + Restart subordinate service for unit: 'ceilometer-agent/2' + Restart subordinate service for 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' @@ -373,6 +376,9 @@ 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 subordinate service for unit: 'ceilometer-agent/1' + Restart subordinate service for unit: 'ceilometer-agent/6' + Restart subordinate service for 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' @@ -405,6 +411,9 @@ 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 subordinate service for unit: 'ceilometer-agent/4' + Restart subordinate service for unit: 'ceilometer-agent/5' + Restart subordinate service for 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 @@ -5304,46 +5313,82 @@ applications: machine: '0' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/0: + name: ceilometer-agent/0 + charm: ceilometer-agent nova-compute/1: name: nova-compute/1 machine: '1' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/1: + name: ceilometer-agent/1 + charm: ceilometer-agent nova-compute/2: name: nova-compute/2 machine: '2' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/2: + name: ceilometer-agent/2 + charm: ceilometer-agent nova-compute/3: name: nova-compute/3 machine: '3' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/3: + name: ceilometer-agent/3 + charm: ceilometer-agent nova-compute/4: name: nova-compute/4 machine: '4' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/4: + name: ceilometer-agent/4 + charm: ceilometer-agent nova-compute/5: name: nova-compute/5 machine: '5' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/5: + name: ceilometer-agent/5 + charm: ceilometer-agent nova-compute/6: name: nova-compute/6 machine: '6' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/6: + name: ceilometer-agent/6 + charm: ceilometer-agent nova-compute/7: name: nova-compute/7 machine: '7' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/7: + name: ceilometer-agent/7 + charm: ceilometer-agent nova-compute/8: name: nova-compute/8 machine: '8' workload_version: 21.2.4 o7k_version: ussuri + subordinates: + ceilometer-agent/8: + name: ceilometer-agent/8 + charm: ceilometer-agent machines: '5': id: '5' diff --git a/tests/mocked_plans/sample_plans/base.yaml b/tests/mocked_plans/sample_plans/base.yaml index 5b17c52f..7b50036e 100644 --- a/tests/mocked_plans/sample_plans/base.yaml +++ b/tests/mocked_plans/sample_plans/base.yaml @@ -32,6 +32,7 @@ plan: | ├── Upgrade the unit: 'nova-compute/0' ├── Resume the unit: 'nova-compute/0' Enable nova-compute scheduler from unit: 'nova-compute/0' + Restart subordinate service for 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 @@ -132,6 +133,10 @@ applications: machine: '1' workload_version: 21.0.0 o7k_version: ussuri + subordinates: + ceilometer-agent/0: + name: ceilometer-agent/0 + charm: ceilometer-agent machines: '1': id: '1' diff --git a/tests/mocked_plans/utils.py b/tests/mocked_plans/utils.py index 11f16e10..b61fcf40 100644 --- a/tests/mocked_plans/utils.py +++ b/tests/mocked_plans/utils.py @@ -18,7 +18,7 @@ import yaml -from cou.utils.juju_utils import Application, Machine, Model, Unit +from cou.utils.juju_utils import Application, Machine, Model, SubordinateUnit, Unit from tests.unit.utils import dedent_plan @@ -64,7 +64,18 @@ def parse_sample_plan_file(source: Path) -> tuple[Model, str]: series=app_data["series"], subordinate_to=app_data["subordinate_to"], units={ - name: Unit(name, machines[unit["machine"]], unit["workload_version"]) + name: Unit( + name, + machines[unit["machine"]], + unit["workload_version"], + [ + SubordinateUnit( + subordinate["name"], + subordinate["charm"], + ) + for _, subordinate in unit.get("subordinates", {}).items() + ], + ) for name, unit in app_data["units"].items() }, workload_version=app_data["workload_version"], diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index 2d8530dd..99ca9d44 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -729,7 +729,7 @@ def test_nova_compute_get_restart_subordinate_services_steps(model, units): units_selected = [app.units[unit] for unit in units] assert app._get_restart_subordinate_services_steps(units_selected) == [ PostUpgradeStep( - description=f"Restart subordinate service for unit: {unit.subordinates[0].name}", + description=f"Restart subordinate service for unit: '{unit.subordinates[0].name}'", coro=model.run_on_unit( unit_name=unit.subordinates[0].name, command=( @@ -855,9 +855,9 @@ 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 subordinate service for unit: ceilometer-agent/0 - Restart subordinate service for unit: ceilometer-agent/1 - Restart subordinate service for unit: ceilometer-agent/2 + Restart subordinate service for unit: 'ceilometer-agent/0' + Restart subordinate service for unit: 'ceilometer-agent/1' + Restart subordinate service for 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 @@ -868,7 +868,9 @@ def test_nova_compute_upgrade_plan(model): name=f"nova-compute/{unit}", workload_version="21.0.0", machine=machines[f"{unit}"], - subordinates=[SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent")] + subordinates=[ + SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent"), + ], ) for unit in range(3) } @@ -911,7 +913,7 @@ 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 subordinate service for unit: ceilometer-agent/0 + Restart subordinate service for 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 """ @@ -922,7 +924,9 @@ def test_nova_compute_upgrade_plan_single_unit(model): name=f"nova-compute/{unit}", workload_version="21.0.0", machine=machines[f"{unit}"], - subordinates=[SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent")] + subordinates=[ + SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent"), + ], ) for unit in range(3) } diff --git a/tests/unit/steps/test_analyze.py b/tests/unit/steps/test_analyze.py index 1c296fcd..3ab96a3e 100644 --- a/tests/unit/steps/test_analyze.py +++ b/tests/unit/steps/test_analyze.py @@ -51,19 +51,19 @@ def test_analysis_dump(model): machine: '0' workload_version: 17.0.1 o7k_version: ussuri - subordinates: '' + subordinates: {} keystone/1: name: keystone/1 machine: '1' workload_version: 17.0.1 o7k_version: ussuri - subordinates: '' + subordinates: {} keystone/2: name: keystone/2 machine: '2' workload_version: 17.0.1 o7k_version: ussuri - subordinates: '' + subordinates: {} machines: '0': id: '0' @@ -96,19 +96,19 @@ def test_analysis_dump(model): machine: '0' workload_version: 16.4.2 o7k_version: ussuri - subordinates: '' + subordinates: {} cinder/1: name: cinder/1 machine: '1' workload_version: 16.4.2 o7k_version: ussuri - subordinates: '' + subordinates: {} cinder/2: name: cinder/2 machine: '2' workload_version: 16.4.2 o7k_version: ussuri - subordinates: '' + subordinates: {} machines: '0': id: '0' @@ -141,7 +141,7 @@ def test_analysis_dump(model): machine: '0' workload_version: '3.8' o7k_version: yoga - subordinates: '' + subordinates: {} machines: '0': id: '0' diff --git a/tests/unit/steps/test_hypervisor.py b/tests/unit/steps/test_hypervisor.py index 6c57c0c1..26af7c88 100644 --- a/tests/unit/steps/test_hypervisor.py +++ b/tests/unit/steps/test_hypervisor.py @@ -25,7 +25,7 @@ UpgradeStep, ) from cou.steps.hypervisor import AZs, HypervisorGroup, HypervisorUpgradePlanner -from cou.utils.juju_utils import Application, Machine, Unit, SubordinateUnit +from cou.utils.juju_utils import Application, Machine, SubordinateUnit, Unit from cou.utils.openstack import OpenStackRelease from tests.unit.utils import dedent_plan, generate_cou_machine @@ -420,7 +420,7 @@ 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 subordinate service for unit: ceilometer-agent/0 + Restart subordinate service for 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' @@ -438,7 +438,7 @@ 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 subordinate service for unit: ceilometer-agent/1 + Restart subordinate service for 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' @@ -456,7 +456,7 @@ 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 subordinate service for unit: ceilometer-agent/2 + Restart subordinate service for 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 """ @@ -501,7 +501,9 @@ def test_hypervisor_upgrade_plan(model): name=f"nova-compute/{unit}", workload_version="21.0.0", machine=machines[f"{unit}"], - subordinates=[SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent")] + subordinates=[ + SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent") + ], ) for unit in range(3) }, @@ -551,7 +553,7 @@ 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 subordinate service for unit: ceilometer-agent/0 + Restart subordinate service for 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 """ @@ -596,7 +598,9 @@ def test_hypervisor_upgrade_plan_single_machine(model): name=f"nova-compute/{unit}", workload_version="21.0.0", machine=machines[f"{unit}"], - subordinates=[SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent")] + subordinates=[ + SubordinateUnit(name=f"ceilometer-agent/{unit}", charm="ceilometer-agent"), + ], ) for unit in range(3) }, @@ -645,7 +649,7 @@ 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 subordinate service for unit: ceilometer-agent/2 + Restart subordinate service for 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 """ @@ -708,19 +712,25 @@ def test_hypervisor_upgrade_plan_some_units_upgraded(model): name="nova-compute/0", workload_version="22.0.0", machine=machines["0"], - subordinates=[SubordinateUnit(name="ceilometer-agent/0", charm="ceilometer-agent")] + subordinates=[ + SubordinateUnit(name="ceilometer-agent/0", charm="ceilometer-agent") + ], ), "nova-compute/1": Unit( name="nova-compute/1", workload_version="22.0.0", machine=machines["1"], - subordinates=[SubordinateUnit(name="ceilometer-agent/1", charm="ceilometer-agent")] + subordinates=[ + SubordinateUnit(name="ceilometer-agent/1", charm="ceilometer-agent") + ], ), "nova-compute/2": Unit( name="nova-compute/2", workload_version="21.0.0", machine=machines["2"], - subordinates=[SubordinateUnit(name="ceilometer-agent/2", charm="ceilometer-agent")] + subordinates=[ + SubordinateUnit(name="ceilometer-agent/2", charm="ceilometer-agent") + ], ), }, workload_version="22.0.0", diff --git a/tests/unit/utils/test_juju_utils.py b/tests/unit/utils/test_juju_utils.py index 1a20c37e..26fcef75 100644 --- a/tests/unit/utils/test_juju_utils.py +++ b/tests/unit/utils/test_juju_utils.py @@ -650,7 +650,7 @@ def _generate_app_status(units: dict[str, MagicMock]) -> MagicMock: @pytest.mark.asyncio @patch("cou.utils.juju_utils.Model.get_status") @patch("cou.utils.juju_utils.Model._get_machines") -async def test_get_applications(mock_get_machines ,mock_get_status, mocked_model): +async def test_get_applications(mock_get_machines, mock_get_status, mocked_model): """Test Model getting applications from model. Getting application from status, where model contain 3 applications deployed on 3 machines. From 5a57b66d3897d1776c960b3dfdbf2516c9b124f6 Mon Sep 17 00:00:00 2001 From: jneo8 Date: Tue, 18 Jun 2024 11:15:31 +0800 Subject: [PATCH 7/8] test: Make unit test use more static variables --- tests/unit/apps/test_core.py | 6 +++--- tests/unit/utils/test_juju_utils.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index 99ca9d44..a5254c60 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -719,9 +719,9 @@ def test_nova_compute_get_enable_scheduler_step(model, units): @pytest.mark.parametrize( "units", [ - [f"nova-compute/{unit}" for unit in range(1)], - [f"nova-compute/{unit}" for unit in range(2)], - [f"nova-compute/{unit}" for unit in range(3)], + ["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): diff --git a/tests/unit/utils/test_juju_utils.py b/tests/unit/utils/test_juju_utils.py index 26fcef75..6a254076 100644 --- a/tests/unit/utils/test_juju_utils.py +++ b/tests/unit/utils/test_juju_utils.py @@ -600,10 +600,10 @@ async def test_get_machines(mocked_model): assert machines == expected_machines -def _generate_juju_unit(app: str, id: str, machine_id: str) -> MagicMock: +def _generate_juju_unit(app: str, unit_id: str, machine_id: str) -> MagicMock: unit = MagicMock(set=Unit)() unit.application = app - unit.name = f"{app}/{id}" + unit.name = f"{app}/{unit_id}" unit.machine.id = machine_id return unit From 8a2fe2337471d5f691f8333ab3bf8a9ee7fd0b7e Mon Sep 17 00:00:00 2001 From: jneo8 Date: Tue, 18 Jun 2024 16:08:45 +0800 Subject: [PATCH 8/8] style: Update restart service message --- cou/apps/core.py | 3 ++- .../018346c5-f95c-46df-a34e-9a78bdec0018.yaml | 24 +++++++++---------- .../9eb9af6a-b919-4cf9-8f2f-9df16a1556be.yaml | 18 +++++++------- tests/mocked_plans/sample_plans/base.yaml | 2 +- tests/unit/apps/test_core.py | 13 ++++++---- tests/unit/steps/test_hypervisor.py | 10 ++++---- 6 files changed, 37 insertions(+), 33 deletions(-) diff --git a/cou/apps/core.py b/cou/apps/core.py index 1b886e2b..1581a90c 100644 --- a/cou/apps/core.py +++ b/cou/apps/core.py @@ -132,7 +132,8 @@ def _get_restart_subordinate_services_steps( steps.append( PostUpgradeStep( description=( - f"Restart subordinate service for unit: '{subordinate.name}'" + "Restart service ceilometer-agent-compute " + f"for subordinate unit: '{subordinate.name}'" ), coro=self.model.run_on_unit( unit_name=subordinate.name, 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 3d29d0c6..8b9a7846 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 @@ -319,10 +319,10 @@ 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 subordinate service for unit: 'ceilometer-agent/0' - Restart subordinate service for unit: 'ceilometer-agent/2' - Restart subordinate service for unit: 'ceilometer-agent/3' - Restart subordinate service for unit: 'ceilometer-agent/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' @@ -390,10 +390,10 @@ 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 subordinate service for unit: 'ceilometer-agent/1' - Restart subordinate service for unit: 'ceilometer-agent/10' - Restart subordinate service for unit: 'ceilometer-agent/11' - Restart subordinate service for unit: 'ceilometer-agent/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' @@ -461,10 +461,10 @@ 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 subordinate service for unit: 'ceilometer-agent/4' - Restart subordinate service for unit: 'ceilometer-agent/6' - Restart subordinate service for unit: 'ceilometer-agent/7' - Restart subordinate service for unit: 'ceilometer-agent/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 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 cec713ea..34460299 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 @@ -341,9 +341,9 @@ 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 subordinate service for unit: 'ceilometer-agent/0' - Restart subordinate service for unit: 'ceilometer-agent/2' - Restart subordinate service for unit: 'ceilometer-agent/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' @@ -376,9 +376,9 @@ 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 subordinate service for unit: 'ceilometer-agent/1' - Restart subordinate service for unit: 'ceilometer-agent/6' - Restart subordinate service for unit: 'ceilometer-agent/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' @@ -411,9 +411,9 @@ 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 subordinate service for unit: 'ceilometer-agent/4' - Restart subordinate service for unit: 'ceilometer-agent/5' - Restart subordinate service for unit: 'ceilometer-agent/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 diff --git a/tests/mocked_plans/sample_plans/base.yaml b/tests/mocked_plans/sample_plans/base.yaml index 7b50036e..11f5dec5 100644 --- a/tests/mocked_plans/sample_plans/base.yaml +++ b/tests/mocked_plans/sample_plans/base.yaml @@ -32,7 +32,7 @@ plan: | ├── Upgrade the unit: 'nova-compute/0' ├── Resume the unit: 'nova-compute/0' Enable nova-compute scheduler from unit: 'nova-compute/0' - Restart subordinate service for unit: 'ceilometer-agent/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 diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index a5254c60..f5a9d0d8 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -729,7 +729,10 @@ def test_nova_compute_get_restart_subordinate_services_steps(model, units): units_selected = [app.units[unit] for unit in units] assert app._get_restart_subordinate_services_steps(units_selected) == [ PostUpgradeStep( - description=f"Restart subordinate service for unit: '{unit.subordinates[0].name}'", + 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=( @@ -855,9 +858,9 @@ 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 subordinate service for unit: 'ceilometer-agent/0' - Restart subordinate service for unit: 'ceilometer-agent/1' - Restart subordinate service for unit: 'ceilometer-agent/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 @@ -913,7 +916,7 @@ 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 subordinate service for unit: 'ceilometer-agent/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 """ diff --git a/tests/unit/steps/test_hypervisor.py b/tests/unit/steps/test_hypervisor.py index 26af7c88..232edf37 100644 --- a/tests/unit/steps/test_hypervisor.py +++ b/tests/unit/steps/test_hypervisor.py @@ -420,7 +420,7 @@ 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 subordinate service for unit: 'ceilometer-agent/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' @@ -438,7 +438,7 @@ 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 subordinate service for unit: 'ceilometer-agent/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' @@ -456,7 +456,7 @@ 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 subordinate service for unit: 'ceilometer-agent/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 """ @@ -553,7 +553,7 @@ 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 subordinate service for unit: 'ceilometer-agent/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 """ @@ -649,7 +649,7 @@ 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 subordinate service for unit: 'ceilometer-agent/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 """