@@ -231,16 +231,19 @@ def test_stream_error_cases(dbos: DBOS) -> None:
231231def test_stream_workflow_recovery (dbos : DBOS ) -> None :
232232 """Test that stream operations are properly recovered during workflow replay."""
233233
234- call_count = 0
234+ workflow_call_count = 0
235+ step_call_count = 0
235236
236237 @DBOS .step ()
237238 def counting_step () -> int :
238- nonlocal call_count
239- call_count += 1
240- return call_count
239+ nonlocal step_call_count
240+ step_call_count += 1
241+ return step_call_count
241242
242243 @DBOS .workflow ()
243244 def recovery_test_workflow () -> None :
245+ nonlocal workflow_call_count
246+ workflow_call_count += 1
244247 count1 = counting_step ()
245248 DBOS .write_stream ("recovery_stream" , f"step_{ count1 } " )
246249
@@ -254,13 +257,18 @@ def recovery_test_workflow() -> None:
254257 with SetWorkflowID (wfid ):
255258 recovery_test_workflow ()
256259
260+ # Validate stream contents
261+ values = list (DBOS .read_stream (wfid , "recovery_stream" ))
262+ assert values == ["step_1" , "step_2" ]
263+
257264 # Reset call count and run the same workflow ID again (should replay)
258- call_count = 0
265+ dbos . _sys_db . update_workflow_outcome ( wfid , "PENDING" )
259266 with SetWorkflowID (wfid ):
260267 recovery_test_workflow ()
261268
262- # The counting step should not have been called again (replayed from recorded results)
263- assert call_count == 0
269+ # The workflow should have been called again
270+ assert workflow_call_count == 2
271+ assert step_call_count == 2
264272
265273 # Stream should still be readable and contain the same values
266274 values = list (DBOS .read_stream (wfid , "recovery_stream" ))
0 commit comments