From d67864476a1f002c7fc4c5f128b0bd64ef2eac43 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Thu, 10 Apr 2025 11:52:59 +0530 Subject: [PATCH] mgr/cephadm/tests: handle "stop" daemon action in test_cephadm.py Handle ok_to_stop logic for "stop" in test_daemon_action. Daemon "stop" needs force=true, so test for OrchestratorError when it's not passed. Signed-off-by: Vallari Agrawal --- src/pybind/mgr/cephadm/tests/test_cephadm.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 87fe08633fa58..a1cebc0b7789d 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -393,19 +393,20 @@ class TestCephadm(object): assert wait(cephadm_module, c) == f"Scheduled to redeploy rgw.{daemon_id} on host 'test'" - for what in ('start', 'stop'): - c = cephadm_module.daemon_action(what, d_name) - assert wait(cephadm_module, - c) == F"Scheduled to {what} {d_name} on host 'test'" + c = cephadm_module.daemon_action('start', d_name) + assert wait(cephadm_module, + c) == F"Scheduled to start {d_name} on host 'test'" for what in ('start', 'stop', 'restart'): c = cephadm_module.daemon_action(what, d_name, force=True) assert wait(cephadm_module, c) == F"Scheduled to {what} {d_name} on host 'test'" - with pytest.raises(OrchestratorError, match=f"Unable to restart daemon {d_name}"): - c = cephadm_module.daemon_action('restart', d_name) - wait(cephadm_module, c) + for what in ('stop', 'restart'): + with pytest.raises(OrchestratorError, match=f"Unable to {what} daemon {d_name}"): + c = cephadm_module.daemon_action(what, d_name) + wait(cephadm_module, c) + # Make sure, _check_daemons does a redeploy due to monmap change: cephadm_module._store['_ceph_get/mon_map'] = { 'modified': datetime_to_str(datetime_now()), -- 2.39.5