diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 41513a7fea9..d9236e81ffd 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -1386,10 +1386,10 @@ class TestCephadm(object): _get_daemon_types.return_value = ['crash'] _hosts.return_value = [hostname, 'other_host'] cephadm_module.inventory.add_host(HostSpec(hostname)) - # should raise an error which will get stored in OrchResult object - retval = cephadm_module.enter_host_maintenance(hostname) - assert retval.exception_str - assert not retval.result_str() + + with pytest.raises(OrchestratorError, match='Failed to place host1 into maintenance for cluster fsid'): + cephadm_module.enter_host_maintenance(hostname) + assert not cephadm_module.inventory._inventory[hostname]['status'] @mock.patch("cephadm.serve.CephadmServe._run_cephadm") @@ -1418,10 +1418,10 @@ class TestCephadm(object): _get_daemon_types.return_value = ['crash'] _hosts.return_value = [hostname, 'other_host'] cephadm_module.inventory.add_host(HostSpec(hostname, status='maintenance')) - # should raise an error which will get stored in OrchResult object - retval = cephadm_module.exit_host_maintenance(hostname) - assert retval.exception_str - assert not retval.result_str() + + with pytest.raises(OrchestratorError, match='Failed to exit maintenance state for host host1, cluster fsid'): + cephadm_module.exit_host_maintenance(hostname) + assert cephadm_module.inventory._inventory[hostname]['status'] == 'maintenance' @mock.patch("cephadm.ssh.SSHManager._remote_connection") diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 6b31ba7d451..ab48bfe629d 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -125,6 +125,9 @@ def handle_orch_error(f: Callable[..., T]) -> Callable[..., 'OrchResult[T]']: return OrchResult(f(*args, **kwargs)) except Exception as e: logger.exception(e) + import os + if 'UNITTEST' in os.environ: + raise # This makes debugging of Tracebacks from unittests a bit easier return OrchResult(None, exception=e) return cast(Callable[..., OrchResult[T]], wrapper)