]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: test_cephadm: Add some more tests for OrchestratorEvent
authorSebastian Wagner <sewagner@redhat.com>
Wed, 8 Sep 2021 14:58:14 +0000 (16:58 +0200)
committerSebastian Wagner <sewagner@redhat.com>
Mon, 3 Jan 2022 13:59:53 +0000 (14:59 +0100)
Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
(cherry picked from commit 7d1bea2bb8777ac6c4d08b9042af1f6597ed2906)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index 235b16682c7847d46f4520b9d3f84fb31619f6f1..6ca92478c4acdb551df1910f234422a85f4926a4 100644 (file)
@@ -2436,9 +2436,14 @@ Then run the following:
     @handle_orch_error
     def add_daemon(self, spec: ServiceSpec) -> List[str]:
         ret: List[str] = []
-        for d_type in service_to_daemon_types(spec.service_type):
-            ret.extend(self._add_daemon(d_type, spec))
-        return ret
+        try:
+            with orchestrator.set_exception_subject('service', spec.service_name(), overwrite=True):
+                for d_type in service_to_daemon_types(spec.service_type):
+                    ret.extend(self._add_daemon(d_type, spec))
+                return ret
+        except OrchestratorError as e:
+            self.events.from_orch_error(e)
+            raise
 
     @handle_orch_error
     def apply_mon(self, spec: ServiceSpec) -> str:
index 368b79f55c73356d355a0d66c7fef0a3d2cf6121..22113eebd5547a60cc72c4c008dd9d3a040fd477 100644 (file)
@@ -299,14 +299,16 @@ class TestCephadm(object):
             with with_service(cephadm_module, RGWSpec(service_id='myrgw.foobar', unmanaged=True)) as _, \
                     with_daemon(cephadm_module, RGWSpec(service_id='myrgw.foobar'), 'test') as daemon_id:
 
-                c = cephadm_module.daemon_action('redeploy', 'rgw.' + daemon_id)
+                d_name = 'rgw.' + daemon_id
+
+                c = cephadm_module.daemon_action('redeploy', d_name)
                 assert wait(cephadm_module,
                             c) == f"Scheduled to redeploy rgw.{daemon_id} on host 'test'"
 
                 for what in ('start', 'stop', 'restart'):
-                    c = cephadm_module.daemon_action(what, 'rgw.' + daemon_id)
+                    c = cephadm_module.daemon_action(what, d_name)
                     assert wait(cephadm_module,
-                                c) == F"Scheduled to {what} rgw.{daemon_id} on host 'test'"
+                                c) == F"Scheduled to {what} {d_name} on host 'test'"
 
                 # Make sure, _check_daemons does a redeploy due to monmap change:
                 cephadm_module._store['_ceph_get/mon_map'] = {
@@ -317,6 +319,13 @@ class TestCephadm(object):
 
                 CephadmServe(cephadm_module)._check_daemons()
 
+                assert cephadm_module.events.get_for_daemon(d_name) == [
+                    OrchestratorEvent(mock.ANY, 'daemon', d_name, 'INFO',
+                                      f"Deployed {d_name} on host \'test\'"),
+                    OrchestratorEvent(mock.ANY, 'daemon', d_name, 'INFO',
+                                      f"stop {d_name} from host \'test\'"),
+                ]
+
     @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('[]'))
     def test_daemon_action_fail(self, cephadm_module: CephadmOrchestrator):
         cephadm_module.service_cache_timeout = 10
@@ -1002,6 +1011,12 @@ class TestCephadm(object):
                             'prefix': 'auth rm',
                             'entity': entity,
                         })
+                    assert cephadm_module.events.get_for_service(spec.service_name()) == [
+                        OrchestratorEvent(mock.ANY, 'service', spec.service_name(), 'INFO',
+                                          "service was created"),
+                        OrchestratorEvent(mock.ANY, 'service', spec.service_name(), 'ERROR',
+                                          "fail"),
+                    ]
 
     @mock.patch("cephadm.serve.CephadmServe._run_cephadm")
     def test_daemon_place_fail_health_warning(self, _run_cephadm, cephadm_module):