@@ -22,13 +22,11 @@ use crate::integ_tests::{activity_functions::echo, metrics_tests};
2222use assert_matches:: assert_matches;
2323use std:: {
2424 collections:: { HashMap , HashSet } ,
25- sync:: atomic:: { AtomicUsize , Ordering } ,
2625 time:: Duration ,
2726} ;
2827use temporal_client:: { WfClientExt , WorkflowClientTrait , WorkflowExecutionResult , WorkflowOptions } ;
2928use temporal_sdk:: {
30- ActivityOptions , LocalActivityOptions , WfContext , WorkflowResult ,
31- interceptors:: WorkerInterceptor ,
29+ ActivityOptions , LocalActivityOptions , WfContext , interceptors:: WorkerInterceptor ,
3230} ;
3331use temporal_sdk_core:: { CoreRuntime , replay:: HistoryForReplay } ;
3432use temporal_sdk_core_api:: {
@@ -57,7 +55,7 @@ use temporal_sdk_core_test_utils::{
5755 init_core_and_create_wf, init_core_replay_preloaded, prom_metrics, schedule_activity_cmd,
5856} ;
5957use tokio:: { join, sync:: Notify , time:: sleep} ;
60- use uuid :: Uuid ;
58+
6159// TODO: We should get expected histories for these tests and confirm that the history at the end
6260// matches.
6361
@@ -85,56 +83,6 @@ async fn parallel_workflows_same_queue() {
8583 core. run_until_done ( ) . await . unwrap ( ) ;
8684}
8785
88- static RUN_CT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
89-
90- pub ( crate ) async fn cache_evictions_wf ( command_sink : WfContext ) -> WorkflowResult < ( ) > {
91- RUN_CT . fetch_add ( 1 , Ordering :: SeqCst ) ;
92- command_sink. timer ( Duration :: from_secs ( 1 ) ) . await ;
93- Ok ( ( ) . into ( ) )
94- }
95-
96- #[ tokio:: test]
97- async fn workflow_lru_cache_evictions ( ) {
98- let wf_type = "workflow_lru_cache_evictions" ;
99- let mut starter = CoreWfStarter :: new ( wf_type) ;
100- starter
101- . worker_config
102- . workflow_task_poller_behavior ( PollerBehavior :: SimpleMaximum ( 2_usize ) )
103- . no_remote_activities ( true )
104- . max_cached_workflows ( 1_usize ) ;
105- let mut worker = starter. worker ( ) . await ;
106- worker. register_wf ( wf_type. to_string ( ) , cache_evictions_wf) ;
107-
108- let n_workflows = 3 ;
109- for _ in 0 ..n_workflows {
110- worker
111- . submit_wf (
112- format ! ( "wce-{}" , Uuid :: new_v4( ) ) ,
113- wf_type. to_string ( ) ,
114- vec ! [ ] ,
115- WorkflowOptions :: default ( ) ,
116- )
117- . await
118- . unwrap ( ) ;
119- }
120- struct CacheAsserter ;
121- #[ async_trait:: async_trait( ?Send ) ]
122- impl WorkerInterceptor for CacheAsserter {
123- async fn on_workflow_activation_completion ( & self , _: & WorkflowActivationCompletion ) { }
124- fn on_shutdown ( & self , sdk_worker : & temporal_sdk:: Worker ) {
125- // 0 since the sdk worker force-evicts and drains everything on shutdown.
126- assert_eq ! ( sdk_worker. cached_workflows( ) , 0 ) ;
127- }
128- }
129- worker
130- . run_until_done_intercepted ( Some ( CacheAsserter ) )
131- . await
132- . unwrap ( ) ;
133- // The wf must have started more than # workflows times, since all but one must experience
134- // an eviction
135- assert ! ( RUN_CT . load( Ordering :: SeqCst ) > n_workflows) ;
136- }
137-
13886// Ideally this would be a unit test, but returning a pending future with mockall bloats the mock
13987// code a bunch and just isn't worth it. Do it when https://github.com/asomers/mockall/issues/189 is
14088// fixed.
0 commit comments