@@ -400,6 +400,42 @@ def test_daemon_action_fail(self, cephadm_module: CephadmOrchestrator):
400400
401401 assert 'myerror' in '' .join (evs )
402402
403+ @mock .patch ("cephadm.serve.CephadmServe._run_cephadm" , _run_cephadm ('[]' ))
404+ def test_daemon_action_event_timestamp_update (self , cephadm_module : CephadmOrchestrator ):
405+ # Test to make sure if a new daemon event is created with the same subject
406+ # and message that the timestamp of the event is updated to let users know
407+ # when it most recently occurred.
408+ cephadm_module .service_cache_timeout = 10
409+ with with_host (cephadm_module , 'test' ):
410+ with with_service (cephadm_module , RGWSpec (service_id = 'myrgw.foobar' , unmanaged = True )) as _ , \
411+ with_daemon (cephadm_module , RGWSpec (service_id = 'myrgw.foobar' ), 'test' ) as daemon_id :
412+
413+ d_name = 'rgw.' + daemon_id
414+
415+ now = str_to_datetime ('2023-10-18T22:45:29.119250Z' )
416+ with mock .patch ("cephadm.inventory.datetime_now" , lambda : now ):
417+ c = cephadm_module .daemon_action ('redeploy' , d_name )
418+ assert wait (cephadm_module ,
419+ c ) == f"Scheduled to redeploy rgw.{ daemon_id } on host 'test'"
420+
421+ CephadmServe (cephadm_module )._check_daemons ()
422+
423+ d_events = cephadm_module .events .get_for_daemon (d_name )
424+ assert len (d_events ) == 1
425+ assert d_events [0 ].created == now
426+
427+ later = str_to_datetime ('2023-10-18T23:46:37.119250Z' )
428+ with mock .patch ("cephadm.inventory.datetime_now" , lambda : later ):
429+ c = cephadm_module .daemon_action ('redeploy' , d_name )
430+ assert wait (cephadm_module ,
431+ c ) == f"Scheduled to redeploy rgw.{ daemon_id } on host 'test'"
432+
433+ CephadmServe (cephadm_module )._check_daemons ()
434+
435+ d_events = cephadm_module .events .get_for_daemon (d_name )
436+ assert len (d_events ) == 1
437+ assert d_events [0 ].created == later
438+
403439 @pytest .mark .parametrize (
404440 "action" ,
405441 [
0 commit comments