File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ rand_distr = "0.4"
2929sha2 = " 0.10.7" # Added SHA-2 cryptographic hash functions
3030sha3 = { version = " 0.10" , optional = true }
3131blake3 = { version = " 1" , optional = true }
32- rand = " 0.8"
3332serde_bytes = " 0.11"
3433wide = " 0.7"
3534warp = " 0.3"
Original file line number Diff line number Diff line change @@ -73,4 +73,9 @@ impl Runtime {
7373 pub fn shard_manager ( & self ) -> Option < Arc < ShardManager > > {
7474 self . shard_manager . clone ( )
7575 }
76+
77+ /// Expose the shutdown sender for testing and external monitoring
78+ pub fn shutdown_sender ( & self ) -> Option < mpsc:: Sender < ( ) > > {
79+ self . shutdown_tx . clone ( )
80+ }
7681}
Original file line number Diff line number Diff line change 1+ use amazon_rose_forest:: { core:: metrics:: MetricsCollector , nerv:: runtime:: Runtime } ;
2+ use std:: sync:: Arc ;
3+ use tokio:: time:: { timeout, Duration } ;
4+
5+ #[ tokio:: test]
6+ async fn runtime_start_initializes_shard_manager ( ) {
7+ let metrics = Arc :: new ( MetricsCollector :: new ( ) ) ;
8+ let mut runtime = Runtime :: new ( metrics. clone ( ) ) ;
9+ runtime. start ( ) . await . unwrap ( ) ;
10+ assert ! ( runtime. shard_manager( ) . is_some( ) ) ;
11+ runtime. stop ( ) . await . unwrap ( ) ;
12+ }
13+
14+ #[ tokio:: test]
15+ async fn runtime_stop_sends_shutdown_signal ( ) {
16+ let metrics = Arc :: new ( MetricsCollector :: new ( ) ) ;
17+ let mut runtime = Runtime :: new ( metrics) ;
18+ runtime. start ( ) . await . unwrap ( ) ;
19+
20+ runtime. stop ( ) . await . unwrap ( ) ;
21+
22+ if let Some ( tx) = runtime. shutdown_sender ( ) {
23+ // The channel should close once the background task handles the shutdown message
24+ let closed = timeout ( Duration :: from_secs ( 1 ) , tx. closed ( ) ) . await ;
25+ assert ! ( closed. is_ok( ) , "shutdown signal not processed in time" ) ;
26+ } else {
27+ panic ! ( "shutdown channel missing" ) ;
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments