@@ -896,10 +896,7 @@ async fn workflow_failures_only_reported_once() {
896
896
#[ tokio:: test]
897
897
async fn max_wft_respected ( ) {
898
898
let total_wfs = 100 ;
899
- let wf_ids: Vec < _ > = ( 0 ..total_wfs)
900
- . into_iter ( )
901
- . map ( |i| format ! ( "fake-wf-{i}" ) )
902
- . collect ( ) ;
899
+ let wf_ids: Vec < _ > = ( 0 ..total_wfs) . map ( |i| format ! ( "fake-wf-{i}" ) ) . collect ( ) ;
903
900
let hists = wf_ids. iter ( ) . map ( |wf_id| {
904
901
let hist = canned_histories:: single_timer ( "1" ) ;
905
902
FakeWfResponses {
@@ -1027,7 +1024,7 @@ async fn activity_not_canceled_when_also_completed_repro(hist_batches: &'static
1027
1024
#[ tokio:: test]
1028
1025
async fn lots_of_workflows ( ) {
1029
1026
let total_wfs = 500 ;
1030
- let hists = ( 0 ..total_wfs) . into_iter ( ) . map ( |i| {
1027
+ let hists = ( 0 ..total_wfs) . map ( |i| {
1031
1028
let wf_id = format ! ( "fake-wf-{i}" ) ;
1032
1029
let hist = canned_histories:: single_timer ( "1" ) ;
1033
1030
FakeWfResponses {
@@ -1705,9 +1702,7 @@ async fn pagination_works_with_tasks_from_completion() {
1705
1702
t. add_by_type ( EventType :: WorkflowExecutionStarted ) ;
1706
1703
t. add_full_wf_task ( ) ;
1707
1704
t. add_we_signaled ( "sig" , vec ! [ ] ) ;
1708
- t. add_full_wf_task ( ) ;
1709
- t. add_workflow_execution_completed ( ) ;
1710
- let get_exec_resp: GetWorkflowExecutionHistoryResponse = t. get_history_info ( 2 ) . unwrap ( ) . into ( ) ;
1705
+ t. add_workflow_task_scheduled_and_started ( ) ;
1711
1706
1712
1707
let mut mock = mock_workflow_client ( ) ;
1713
1708
let mut needs_pag_resp = hist_to_poll_resp ( & t, wfid. to_owned ( ) , ResponseType :: OneTask ( 2 ) ) . resp ;
@@ -1722,9 +1717,13 @@ async fn pagination_works_with_tasks_from_completion() {
1722
1717
mock. expect_complete_workflow_task ( )
1723
1718
. times ( 1 )
1724
1719
. returning ( |_| Ok ( Default :: default ( ) ) ) ;
1720
+
1721
+ let get_exec_resp: GetWorkflowExecutionHistoryResponse =
1722
+ t. get_full_history_info ( ) . unwrap ( ) . into ( ) ;
1725
1723
mock. expect_get_workflow_execution_history ( )
1726
1724
. returning ( move |_, _, _| Ok ( get_exec_resp. clone ( ) ) )
1727
1725
. times ( 1 ) ;
1726
+
1728
1727
let mut mock = single_hist_mock_sg ( wfid, t, [ 1 ] , mock, true ) ;
1729
1728
mock. worker_cfg ( |wc| wc. max_cached_workflows = 2 ) ;
1730
1729
let core = mock_worker ( mock) ;
@@ -2162,23 +2161,15 @@ async fn fetching_to_continue_replay_works() {
2162
2161
t. add_full_wf_task ( ) ; // end 14
2163
2162
let mut fetch_resp: GetWorkflowExecutionHistoryResponse =
2164
2163
t. get_full_history_info ( ) . unwrap ( ) . into ( ) ;
2165
- // Should only contain events after 7
2166
- if let Some ( ref mut h) = fetch_resp. history {
2167
- h. events . retain ( |e| e. event_id >= 8 ) ;
2168
- }
2169
2164
// And indicate that even *more* needs to be fetched after this, so we see a request for the
2170
2165
// next page happen.
2171
2166
fetch_resp. next_page_token = vec ! [ 2 ] ;
2172
2167
2173
2168
let timer_started_event_id = t. add_by_type ( EventType :: TimerStarted ) ;
2174
2169
t. add_timer_fired ( timer_started_event_id, "1" . to_string ( ) ) ;
2175
2170
t. add_full_wf_task ( ) ;
2176
- let mut final_fetch_resp: GetWorkflowExecutionHistoryResponse =
2171
+ let final_fetch_resp: GetWorkflowExecutionHistoryResponse =
2177
2172
t. get_full_history_info ( ) . unwrap ( ) . into ( ) ;
2178
- // Should have only the final event
2179
- if let Some ( ref mut h) = final_fetch_resp. history {
2180
- h. events . retain ( |e| e. event_id >= 15 ) ;
2181
- }
2182
2173
2183
2174
let tasks = vec ! [
2184
2175
ResponseType :: ToTaskNum ( 1 ) ,
@@ -2273,15 +2264,25 @@ async fn ensure_fetching_fail_during_complete_sends_task_failure() {
2273
2264
t. add_full_wf_task ( ) ; // started 3
2274
2265
t. add_we_signaled ( "sig1" , vec ! [ ] ) ;
2275
2266
t. add_full_wf_task ( ) ; // started 7
2276
- t. add_we_signaled ( "sig2" , vec ! [ ] ) ;
2267
+
2268
+ // Need a command event after here so the paginator will know it has two complete WFTs and
2269
+ // processing can begin before needing to fetch again
2270
+ t. add_by_type ( EventType :: TimerStarted ) ;
2277
2271
t. add_full_wf_task ( ) ; // started 11
2278
2272
t. add_workflow_execution_completed ( ) ;
2279
2273
2280
- let mut first_poll = hist_to_poll_resp ( & t, wfid, ResponseType :: ToTaskNum ( 1 ) ) . resp ;
2281
- first_poll. next_page_token = vec ! [ 1 ] ;
2282
- first_poll. previous_started_event_id = 3 ;
2274
+ let mut first_poll = hist_to_poll_resp ( & t, wfid, ResponseType :: OneTask ( 4 ) ) . resp ;
2275
+ // History is partial so fetch will happen. We have to lie here and make up a previous started
2276
+ // which really makes no sense, otherwise the paginator eagerly fetches and will fail before we
2277
+ // ever start anything -- which is good -- but this test wants to make sure a fetching failure
2278
+ // during a completion is handled correctly. That may no longer actually be a thing that can
2279
+ // happen.
2280
+ first_poll. previous_started_event_id = 0 ;
2281
+ first_poll. started_event_id = 11 ;
2283
2282
2284
- let mut next_page: GetWorkflowExecutionHistoryResponse = t. get_history_info ( 2 ) . unwrap ( ) . into ( ) ;
2283
+ let mut next_page: GetWorkflowExecutionHistoryResponse =
2284
+ t. get_full_history_info ( ) . unwrap ( ) . into ( ) ;
2285
+ next_page. history . as_mut ( ) . unwrap ( ) . events . truncate ( 9 ) ;
2285
2286
next_page. next_page_token = vec ! [ 2 ] ;
2286
2287
2287
2288
let mut mock = mock_workflow_client ( ) ;
@@ -2291,9 +2292,6 @@ async fn ensure_fetching_fail_during_complete_sends_task_failure() {
2291
2292
Ok ( next_page. clone ( ) )
2292
2293
} )
2293
2294
. times ( 1 ) ;
2294
- let mut really_empty_fetch_resp: GetWorkflowExecutionHistoryResponse =
2295
- t. get_history_info ( 1 ) . unwrap ( ) . into ( ) ;
2296
- really_empty_fetch_resp. history = Some ( Default :: default ( ) ) ;
2297
2295
mock. expect_get_workflow_execution_history ( )
2298
2296
. returning ( move |_, _, _| {
2299
2297
error ! ( "Called fetch second time!" ) ;
@@ -2314,24 +2312,13 @@ async fn ensure_fetching_fail_during_complete_sends_task_failure() {
2314
2312
. await
2315
2313
. unwrap ( ) ;
2316
2314
2317
- let wf_task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
2318
- assert_matches ! (
2319
- wf_task. jobs. as_slice( ) ,
2320
- [ WorkflowActivationJob {
2321
- variant: Some ( workflow_activation_job:: Variant :: SignalWorkflow ( _) ) ,
2322
- } , ]
2323
- ) ;
2324
- core. complete_workflow_activation ( WorkflowActivationCompletion :: empty ( wf_task. run_id ) )
2325
- . await
2326
- . unwrap ( ) ;
2327
-
2328
2315
// Expect to see eviction b/c of history fetching error here.
2329
2316
let wf_task = core. poll_workflow_activation ( ) . await . unwrap ( ) ;
2330
2317
assert_matches ! (
2331
2318
wf_task. jobs. as_slice( ) ,
2332
2319
[ WorkflowActivationJob {
2333
- variant: Some ( workflow_activation_job:: Variant :: RemoveFromCache ( _ ) ) ,
2334
- } , ]
2320
+ variant: Some ( workflow_activation_job:: Variant :: RemoveFromCache ( c ) ) ,
2321
+ } ] if c . message . contains ( "Fetching history" )
2335
2322
) ;
2336
2323
2337
2324
core. shutdown ( ) . await ;
@@ -2401,7 +2388,6 @@ async fn core_internal_flags() {
2401
2388
. copied( )
2402
2389
. collect:: <HashSet <_>>( ) ,
2403
2390
CoreInternalFlags :: all_except_too_high( )
2404
- . into_iter( )
2405
2391
. map( |f| f as u32 )
2406
2392
. collect( )
2407
2393
) ;
0 commit comments