@@ -109,7 +109,43 @@ def test_polling_without_invocation_as_full_subpanel():
109109 assert not error_message
110110
111111
112- def run_workflow_simulation (yaml_str : str , display_configuration : Optional [DisplayConfiguration ] = None ):
112+ def test_fail_fast_enabled_with_job_failure ():
113+ """Test that fail_fast=True returns error when a job fails."""
114+ final_invocation_state , job_state , error_message = run_workflow_simulation (
115+ SCENARIO_1 , fail_fast = True
116+ )
117+ # Invocation should still be scheduled (workflow scheduling succeeded)
118+ assert final_invocation_state == "scheduled"
119+ assert job_state == "failed"
120+ # fail_fast should detect the failed job and return error message
121+ assert error_message
122+ assert "Failed to run workflow, at least one job is in [failed] state." in error_message
123+
124+
125+ def test_fail_fast_disabled_with_job_failure ():
126+ """Test that fail_fast=False does not report job failures as errors."""
127+ final_invocation_state , job_state , error_message = run_workflow_simulation (
128+ SCENARIO_1 , fail_fast = False
129+ )
130+ # Invocation should be scheduled (workflow scheduling succeeded)
131+ assert final_invocation_state == "scheduled"
132+ assert job_state == "failed"
133+ # Without fail_fast, job failures shouldn't cause error messages
134+ # (unless invocation itself fails, which it doesn't in this case)
135+ assert error_message is None
136+
137+
138+ def test_fail_fast_enabled_with_successful_workflow ():
139+ """Test that fail_fast=True works normally when no jobs fail."""
140+ final_invocation_state , job_state , error_message = run_workflow_simulation (
141+ SCENARIO_MULTIPLE_OK_SUBWORKFLOWS , fail_fast = True
142+ )
143+ assert final_invocation_state == "scheduled"
144+ assert job_state == "ok"
145+ assert not error_message
146+
147+
148+ def run_workflow_simulation (yaml_str : str , display_configuration : Optional [DisplayConfiguration ] = None , fail_fast : bool = False ):
113149 simulation = parse_workflow_simulation_from_string (yaml_str )
114150 invocation_id = simulation .id
115151 invocation_api = SimulatedApi (simulation )
@@ -122,6 +158,7 @@ def run_workflow_simulation(yaml_str: str, display_configuration: Optional[Displ
122158 invocation_api ,
123159 polling_tracker ,
124160 display ,
161+ fail_fast = fail_fast ,
125162 )
126163
127164
0 commit comments