@@ -83,15 +83,7 @@ async fn legacy_query(#[case] include_history: bool) {
8383 . unwrap ( ) ;
8484 } ;
8585 let clear_eviction = || async {
86- let t = worker. poll_workflow_activation ( ) . await . unwrap ( ) ;
87- assert_matches ! (
88- t. jobs[ 0 ] . variant,
89- Some ( workflow_activation_job:: Variant :: RemoveFromCache ( _) )
90- ) ;
91- worker
92- . complete_workflow_activation ( WorkflowActivationCompletion :: empty ( t. run_id ) )
93- . await
94- . unwrap ( ) ;
86+ worker. handle_eviction ( ) . await ;
9587 } ;
9688
9789 first_wft ( ) . await ;
@@ -324,15 +316,7 @@ async fn query_failure_because_nondeterminism(#[values(true, false)] legacy: boo
324316 core. complete_workflow_activation ( WorkflowActivationCompletion :: empty ( task. run_id ) )
325317 . await
326318 . unwrap ( ) ;
327- let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
328- assert_matches ! (
329- task. jobs[ 0 ] . variant,
330- Some ( workflow_activation_job:: Variant :: RemoveFromCache ( _) )
331- ) ;
332- core. complete_workflow_activation ( WorkflowActivationCompletion :: empty ( task. run_id ) )
333- . await
334- . unwrap ( ) ;
335-
319+ core. handle_eviction ( ) . await ;
336320 core. shutdown ( ) . await ;
337321}
338322
@@ -372,23 +356,31 @@ async fn legacy_query_after_complete(#[values(false, true)] full_history: bool)
372356 mock. worker_cfg ( |wc| wc. max_cached_workflows = 10 ) ;
373357 let core = mock_worker ( mock) ;
374358
375- let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
376- core. complete_workflow_activation ( WorkflowActivationCompletion :: from_cmd (
377- task. run_id ,
378- start_timer_cmd ( 1 , Duration :: from_secs ( 1 ) ) ,
379- ) )
380- . await
381- . unwrap ( ) ;
382- let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
383- core. complete_workflow_activation ( WorkflowActivationCompletion :: from_cmds (
384- task. run_id ,
385- vec ! [ CompleteWorkflowExecution { result: None } . into( ) ] ,
386- ) )
387- . await
388- . unwrap ( ) ;
359+ let activations = || async {
360+ let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
361+ core. complete_workflow_activation ( WorkflowActivationCompletion :: from_cmd (
362+ task. run_id ,
363+ start_timer_cmd ( 1 , Duration :: from_secs ( 1 ) ) ,
364+ ) )
365+ . await
366+ . unwrap ( ) ;
367+ let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
368+ core. complete_workflow_activation ( WorkflowActivationCompletion :: from_cmds (
369+ task. run_id ,
370+ vec ! [ CompleteWorkflowExecution { result: None } . into( ) ] ,
371+ ) )
372+ . await
373+ . unwrap ( ) ;
374+ } ;
375+ activations ( ) . await ;
376+
377+ if !full_history {
378+ core. handle_eviction ( ) . await ;
379+ activations ( ) . await ;
380+ }
389381
390382 // We should get queries two times
391- for _ in 1 ..=2 {
383+ for i in 1 ..=2 {
392384 let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
393385 let query = assert_matches ! (
394386 task. jobs. as_slice( ) ,
@@ -402,6 +394,10 @@ async fn legacy_query_after_complete(#[values(false, true)] full_history: bool)
402394 ) )
403395 . await
404396 . unwrap ( ) ;
397+ if i == 1 {
398+ core. handle_eviction ( ) . await ;
399+ activations ( ) . await ;
400+ }
405401 }
406402
407403 core. shutdown ( ) . await ;
@@ -770,8 +766,6 @@ async fn legacy_query_combined_with_timer_fire_repro() {
770766 } ,
771767 {
772768 let mut pr = hist_to_poll_resp ( & t, wfid. to_owned ( ) , ResponseType :: ToTaskNum ( 2 ) ) ;
773- // Strip history, we need to look like we hit the cache for a legacy query
774- pr. history = Some ( History { events : vec ! [ ] } ) ;
775769 pr. query = Some ( WorkflowQuery {
776770 query_type : "query-type" . to_string ( ) ,
777771 query_args : Some ( b"hi" . into ( ) ) ,
@@ -788,41 +782,44 @@ async fn legacy_query_combined_with_timer_fire_repro() {
788782 mock. worker_cfg ( |wc| wc. max_cached_workflows = 1 ) ;
789783 let core = mock_worker ( mock) ;
790784
791- let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
792- core. complete_workflow_activation ( WorkflowActivationCompletion :: from_cmds (
793- task. run_id ,
794- vec ! [
795- schedule_activity_cmd(
796- 1 ,
797- "whatever" ,
798- "1" ,
799- ActivityCancellationType :: TryCancel ,
800- Duration :: from_secs( 60 ) ,
801- Duration :: from_secs( 60 ) ,
802- ) ,
803- start_timer_cmd( 1 , Duration :: from_secs( 1 ) ) ,
804- ] ,
805- ) )
806- . await
807- . unwrap ( ) ;
785+ let activations = || async {
786+ let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
787+ core. complete_workflow_activation ( WorkflowActivationCompletion :: from_cmds (
788+ task. run_id ,
789+ vec ! [
790+ schedule_activity_cmd(
791+ 1 ,
792+ "whatever" ,
793+ "1" ,
794+ ActivityCancellationType :: TryCancel ,
795+ Duration :: from_secs( 60 ) ,
796+ Duration :: from_secs( 60 ) ,
797+ ) ,
798+ start_timer_cmd( 1 , Duration :: from_secs( 1 ) ) ,
799+ ] ,
800+ ) )
801+ . await
802+ . unwrap ( ) ;
808803
809- let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
810- core. complete_workflow_activation ( WorkflowActivationCompletion :: from_cmd (
811- task. run_id ,
812- RequestCancelActivity { seq : 1 } . into ( ) ,
813- ) )
814- . await
815- . unwrap ( ) ;
804+ let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
805+ core. complete_workflow_activation ( WorkflowActivationCompletion :: from_cmd (
806+ task. run_id ,
807+ RequestCancelActivity { seq : 1 } . into ( ) ,
808+ ) )
809+ . await
810+ . unwrap ( ) ;
816811
817- // First should get the activity resolve
818- let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
819- assert_matches ! (
820- task. jobs. as_slice( ) ,
821- [ WorkflowActivationJob {
822- variant: Some ( workflow_activation_job:: Variant :: ResolveActivity ( _) ) ,
823- } ]
824- ) ;
825- core. complete_execution ( & task. run_id ) . await ;
812+ // First should get the activity resolve
813+ let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
814+ assert_matches ! (
815+ task. jobs. as_slice( ) ,
816+ [ WorkflowActivationJob {
817+ variant: Some ( workflow_activation_job:: Variant :: ResolveActivity ( _) ) ,
818+ } ]
819+ ) ;
820+ core. complete_execution ( & task. run_id ) . await ;
821+ } ;
822+ activations ( ) . await ;
826823
827824 // Then the queries
828825 let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
@@ -840,6 +837,9 @@ async fn legacy_query_combined_with_timer_fire_repro() {
840837 . await
841838 . unwrap ( ) ;
842839
840+ core. handle_eviction ( ) . await ;
841+ activations ( ) . await ;
842+
843843 let task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
844844 assert_matches ! (
845845 task. jobs. as_slice( ) ,
0 commit comments