Skip to content

Commit f328c2d

Browse files
committed
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 <[email protected]>
1 parent 344234c commit f328c2d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/pybind/mgr/cephadm/tests/test_upgrade.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from cephadm import CephadmOrchestrator
88
from cephadm.upgrade import CephadmUpgrade, UpgradeState
99
from cephadm.ssh import HostConnectionError
10+
from cephadm.utils import ContainerInspectInfo
1011
from orchestrator import OrchestratorError, DaemonDescription
1112
from .fixtures import _run_cephadm, wait, with_host, with_service, \
1213
receive_agent_metadata, async_side_effect
@@ -80,6 +81,30 @@ def test_upgrade_resume_clear_health_warnings(_rm_health_warning, cephadm_module
8081
_rm_health_warning.assert_has_calls(calls_list, any_order=True)
8182

8283

84+
@mock.patch('cephadm.upgrade.CephadmUpgrade._get_current_version', lambda _: (17, 2, 6))
85+
@mock.patch("cephadm.serve.CephadmServe._get_container_image_info")
86+
def test_upgrade_check_with_ceph_version(_get_img_info, cephadm_module: CephadmOrchestrator):
87+
# This test was added to avoid screwing up the image base so that
88+
# when the version was added to it it made an incorrect image
89+
# The issue caused the image to come out as
90+
# quay.io/ceph/ceph:v18:v18.2.0
91+
# see https://tracker.ceph.com/issues/63150
92+
_img = ''
93+
94+
def _fake_get_img_info(img_name):
95+
nonlocal _img
96+
_img = img_name
97+
return ContainerInspectInfo(
98+
'image_id',
99+
'18.2.0',
100+
'digest'
101+
)
102+
103+
_get_img_info.side_effect = _fake_get_img_info
104+
cephadm_module.upgrade_check('', '18.2.0')
105+
assert _img == 'quay.io/ceph/ceph:v18.2.0'
106+
107+
83108
@mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}'))
84109
@pytest.mark.parametrize("use_repo_digest",
85110
[

0 commit comments

Comments
 (0)