File tree Expand file tree Collapse file tree
lib/saluki-core/src/runtime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1342,6 +1342,32 @@ mod tests {
13421342 ) ;
13431343 }
13441344
1345+ #[ tokio:: test]
1346+ async fn permanent_child_is_restarted_on_clean_exit ( ) {
1347+ // A permanent worker that completes cleanly must still be restarted -- this is what distinguishes
1348+ // `Permanent` from `Transient`, which is left stopped after a clean exit.
1349+ let permanent = MockWorker :: completing ( "permanent-worker" , Duration :: from_millis ( 50 ) ) ;
1350+ let permanent_count = permanent. start_count ( ) ;
1351+
1352+ let mut sup = Supervisor :: new ( "test-sup" ) . unwrap ( ) . with_restart_strategy (
1353+ RestartStrategy :: one_to_one ( ) . with_intensity_and_period ( 20 , Duration :: from_secs ( 10 ) ) ,
1354+ ) ;
1355+ // Added with the default restart policy, which is `Permanent`.
1356+ sup. add_worker ( permanent) ;
1357+
1358+ let ( tx, handle) = run_supervisor_with_trigger ( sup) . await ;
1359+
1360+ sleep ( Duration :: from_millis ( 300 ) ) . await ;
1361+ let _ = tx. send ( ( ) ) ;
1362+
1363+ let result = timeout ( Duration :: from_secs ( 2 ) , handle) . await . unwrap ( ) . unwrap ( ) ;
1364+ assert ! ( result. is_ok( ) ) ;
1365+ assert ! (
1366+ permanent_count. load( Ordering :: SeqCst ) >= 2 ,
1367+ "permanent worker must be restarted even after a clean exit"
1368+ ) ;
1369+ }
1370+
13451371 #[ tokio:: test]
13461372 async fn temporary_failures_do_not_consume_restart_intensity ( ) {
13471373 // With intensity=1, two *restartable* failures within the period would shut the supervisor down. Here several
You can’t perform that action at this time.
0 commit comments