Skip to content

Commit

Permalink
test_workflow_failure_types_configured
Browse files Browse the repository at this point in the history
Run tests sequentially and fix reference to workflow.NondeterminismError
  • Loading branch information
dandavison committed Jan 23, 2025
1 parent fd4b79d commit ad14060
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions tests/worker/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from typing_extensions import Literal, Protocol, runtime_checkable

import temporalio.worker
import temporalio.workflow
from temporalio import activity, workflow
from temporalio.api.common.v1 import Payload, Payloads, WorkflowExecution
from temporalio.api.enums.v1 import EventType
Expand Down Expand Up @@ -85,7 +86,6 @@
ApplicationError,
CancelledError,
ChildWorkflowError,
FailureError,
TemporalError,
TimeoutError,
WorkflowAlreadyStartedError,
Expand Down Expand Up @@ -5041,61 +5041,58 @@ async def run_scenario(
update_scenario=scenario,
)

# Run all tasks concurrently
await asyncio.gather(
# When unconfigured completely, confirm task fails as normal
run_scenario(
await run_scenario(
FailureTypesUnconfiguredWorkflow,
FailureTypesScenario.THROW_CUSTOM_EXCEPTION,
expect_task_fail=True,
),
run_scenario(
)
await run_scenario(
FailureTypesUnconfiguredWorkflow,
FailureTypesScenario.CAUSE_NON_DETERMINISM,
expect_task_fail=True,
),
)
# When configured at the worker level explicitly, confirm not task fail
# but rather expected exceptions
run_scenario(
await run_scenario(
FailureTypesUnconfiguredWorkflow,
FailureTypesScenario.THROW_CUSTOM_EXCEPTION,
worker_level_failure_exception_type=FailureTypesCustomException,
),
run_scenario(
)
await run_scenario(
FailureTypesUnconfiguredWorkflow,
FailureTypesScenario.CAUSE_NON_DETERMINISM,
worker_level_failure_exception_type=workflow.NondeterminismError,
),
worker_level_failure_exception_type=temporalio.workflow.NondeterminismError,
)
# When configured at the worker level inherited
run_scenario(
await run_scenario(
FailureTypesUnconfiguredWorkflow,
FailureTypesScenario.THROW_CUSTOM_EXCEPTION,
worker_level_failure_exception_type=Exception,
),
run_scenario(
)
await run_scenario(
FailureTypesUnconfiguredWorkflow,
FailureTypesScenario.CAUSE_NON_DETERMINISM,
worker_level_failure_exception_type=Exception,
),
)
# When configured at the workflow level explicitly
run_scenario(
await run_scenario(
FailureTypesConfiguredExplicitlyWorkflow,
FailureTypesScenario.THROW_CUSTOM_EXCEPTION,
),
run_scenario(
)
await run_scenario(
FailureTypesConfiguredExplicitlyWorkflow,
FailureTypesScenario.CAUSE_NON_DETERMINISM,
),
)
# When configured at the workflow level inherited
run_scenario(
await run_scenario(
FailureTypesConfiguredInheritedWorkflow,
FailureTypesScenario.THROW_CUSTOM_EXCEPTION,
),
run_scenario(
)
await run_scenario(
FailureTypesConfiguredInheritedWorkflow,
FailureTypesScenario.CAUSE_NON_DETERMINISM,
),
)
)


@workflow.defn(failure_exception_types=[Exception])
Expand Down

0 comments on commit ad14060

Please sign in to comment.