Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions docs/testing/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,15 @@ CI.

=== "Python"

Set the `DURABLE_EXECUTION_TIME_SCALE` environment variable to a float that multiplies
`context.wait()` durations. Step retry delays use the configured
`next_attempt_delay_seconds` at real wall-clock time and the scale does not apply to
them.
Pass `skip_time=True` to `DurableFunctionTestRunner`. The runner uses a virtual clock
that skips modeled delays instantly. Both `context.wait()` durations and step retry
delays complete in zero wall-clock time. `skip_time` defaults to `True`.

```python
runner = DurableFunctionTestRunner(handler=handler, skip_time=True)
```

Set `skip_time=False` to assert on real wait durations.

=== "Java"

Expand Down Expand Up @@ -549,8 +554,15 @@ See [Authoring: Skip time in tests](authoring.md#skip-time-in-tests) for an over

=== "Python"

Not applicable. Configure with the `DURABLE_EXECUTION_TIME_SCALE` environment variable
and the `poll_interval` constructor argument.
```python
DurableFunctionTestRunner(handler, skip_time=True, poll_interval=1.0)
```

**Fields:**

- `skip_time` (optional) Use a virtual clock that skips modeled delays instantly.
Defaults to `True`.
- `poll_interval` (optional) Seconds between internal polling cycles. Defaults to `1.0`.

=== "Java"

Expand Down
15 changes: 7 additions & 8 deletions docs/testing/authoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,16 @@ runner collapses these delays so tests finish in milliseconds.

=== "Python"

Set the `DURABLE_EXECUTION_TIME_SCALE` environment variable to a float that multiplies
`context.wait()` durations. Set it to `0` for instant waits, or to a small fraction such
as `0.01` to run waits at 100x speed. Step retry delays use the configured
`next_attempt_delay_seconds` at real wall-clock time, and the scale does not apply to
them. Keep retry delays short in tests, or configure a retry strategy with a low
`initial_delay_seconds`.
Pass `skip_time=True` to `DurableFunctionTestRunner` (the default). The runner uses a
virtual clock that advances instantly through modeled delays. Both `context.wait()`
durations and step retry delays complete in zero wall-clock time.

```bash
DURABLE_EXECUTION_TIME_SCALE=0 pytest tests/my_wait_tests.py
```python
runner = DurableFunctionTestRunner(handler=handler, skip_time=True)
```

Set `skip_time=False` to assert on real wait durations.

=== "Java"

`runUntilComplete()` calls `advanceTime()` after each invocation. `advanceTime()`
Expand Down
6 changes: 3 additions & 3 deletions docs/testing/workflow-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ skipping. Each SDK handles this differently.

=== "Python"

Set the `DURABLE_EXECUTION_TIME_SCALE` environment variable to scale `context.wait()`
durations. Set it to `0.0` for instant waits, or to a small fraction such as `0.01` to
run waits at 100x speed. The scale does not apply to step retry delays.
`DurableFunctionTestRunner` defaults to `skip_time=True`, so the runner completes
`context.wait()` durations instantly via a virtual clock. The 24-hour wait resolves in
milliseconds.

```python
--8<-- "examples/python/testing/examples/long-waits.py"
Expand Down
7 changes: 2 additions & 5 deletions examples/python/testing/examples/long-waits.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import os

os.environ["DURABLE_EXECUTION_TIME_SCALE"] = "0.0"

from aws_durable_execution_sdk_python import DurableContext, durable_execution, durable_step
from aws_durable_execution_sdk_python.types import StepContext
from aws_durable_execution_sdk_python.config import Duration
Expand All @@ -22,7 +18,8 @@ def handler(event, context: DurableContext) -> str:


def test_completes_with_long_wait():
runner = DurableFunctionTestRunner(handler=handler)
# skip_time=True is the default; the 24-hour wait completes instantly.
runner = DurableFunctionTestRunner(handler=handler, skip_time=True)
with runner:
result = runner.run(timeout=10)

Expand Down
Loading