From 17726aee8feb676589a57cdbb92ebd1cdea64d67 Mon Sep 17 00:00:00 2001 From: Adam King Date: Tue, 10 Oct 2023 12:42:57 -0400 Subject: [PATCH] mgr/cephadm: add unit test to for upgrade check with --ceph-version This is actually meant to make sure we don't screw up the image base. See https://tracker.ceph.com/issues/63150 to see what we're trying to avoid happening again Signed-off-by: Adam King (cherry picked from commit f328c2d7e75c4ce969d21f7c8b9ae2401baee5e1) --- src/pybind/mgr/cephadm/tests/test_upgrade.py | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/pybind/mgr/cephadm/tests/test_upgrade.py b/src/pybind/mgr/cephadm/tests/test_upgrade.py index 7aa46f90276..3b5c305b5f0 100644 --- a/src/pybind/mgr/cephadm/tests/test_upgrade.py +++ b/src/pybind/mgr/cephadm/tests/test_upgrade.py @@ -7,6 +7,7 @@ from ceph.deployment.service_spec import PlacementSpec, ServiceSpec from cephadm import CephadmOrchestrator from cephadm.upgrade import CephadmUpgrade, UpgradeState from cephadm.ssh import HostConnectionError +from cephadm.utils import ContainerInspectInfo from orchestrator import OrchestratorError, DaemonDescription from .fixtures import _run_cephadm, wait, with_host, with_service, \ receive_agent_metadata, async_side_effect @@ -80,6 +81,30 @@ def test_upgrade_resume_clear_health_warnings(_rm_health_warning, cephadm_module _rm_health_warning.assert_has_calls(calls_list, any_order=True) +@mock.patch('cephadm.upgrade.CephadmUpgrade._get_current_version', lambda _: (17, 2, 6)) +@mock.patch("cephadm.serve.CephadmServe._get_container_image_info") +def test_upgrade_check_with_ceph_version(_get_img_info, cephadm_module: CephadmOrchestrator): + # This test was added to avoid screwing up the image base so that + # when the version was added to it it made an incorrect image + # The issue caused the image to come out as + # quay.io/ceph/ceph:v18:v18.2.0 + # see https://tracker.ceph.com/issues/63150 + _img = '' + + def _fake_get_img_info(img_name): + nonlocal _img + _img = img_name + return ContainerInspectInfo( + 'image_id', + '18.2.0', + 'digest' + ) + + _get_img_info.side_effect = _fake_get_img_info + cephadm_module.upgrade_check('', '18.2.0') + assert _img == 'quay.io/ceph/ceph:v18.2.0' + + @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}')) @pytest.mark.parametrize("use_repo_digest", [ -- 2.39.5