You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add in-memory test host for orchestrations (durabletasktest) - #183
Adds a durabletasktest package for running orchestrations and activities inside a test process, with no emulator, network port, or Azure resource. The design follows the in-memory testing backends in the .NET, Python, and JavaScript SDKs.
Design
internal/inmemory implements TaskHubSidecarService in memory: instance state, history, an orchestration/activity work queue, completion-token leases, and real-time timers.
durabletasktest.Host serves that backend over bufconn and runs the real TaskHubGrpcWorker (via NewTaskHubGrpcWorkerWithConnectionFactory) plus a TaskHubGrpcClient. Orchestrations therefore use the same worker, executor, and client paths as they do against DTS.
durabletasktest.New(t, registry) starts a host and registers its cleanup with the test. NewHost(ctx, registry) is for callers that manage the lifetime themselves.
Errors use the shared gRPC status/reason mapping, so clients see the usual sentinels (ErrDuplicateInstance, ErrInstanceNotFound, ErrNotCompleted, ErrInvalidState, ErrFeatureNotSupported).
Supported
Activities, sub-orchestrations, timers, external events, SendEvent, continue-as-new (including carryover events), suspend/resume, terminate (including recursive), restart, QueryInstances, ListInstanceIDs, single/batch/filter purge (including recursive), history streaming, scheduled start, ID reuse policy, and worker work-item filters. When a work-item stream closes, its leased work is re-queued.
Not included
Virtual time. Timers fire in real time, which matches the other SDKs' test backends.
Durable entities and rewind. Entity RPCs and RewindInstance return Unimplemented (ErrFeatureNotSupported). An orchestration that calls, signals, or locks an entity fails with a NotSupported failure.
Extended sessions and chunked completions. The worker falls back to standard completions.
Payloads over the 4 MiB message limit. History is streamed, and new events are split across turns. A single event that can't fit fails the instance with OrchestrationWorkItemTooLarge. Requests over 4 MiB are rejected with ResourceExhausted, as DTS does. An activity result over 4 MiB fails the task with non-retriable ActivityResponseTooLarge instead of being redelivered; Fail oversized activity and entity completions instead of abandoning and re-executing them #202 tracks the equivalent worker behavior against DTS. QueryInstances rejects TaskHubNames filters, because the host has no task hub identity.
README.md documents usage and limitations. CI coverage now includes both new packages.
Adds an in-memory TaskHubSidecarService implementation and a durabletasktest package that runs the real worker and client against it over bufconn. Durable entities, rewind, and virtual time are not supported.
Refs #180
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved critical defects in partial-response handling and recursive termination can corrupt orchestration replay and terminate unrelated replacement instances.
Adds durabletasktest, an in-process testing surface for orchestrations that uses the existing worker, executor, and client without an emulator or external service.
Changes:
Adds a test host with automatic cleanup and configurable worker/client options.
Implements an in-memory service for work dispatch, orchestration state, history, and instance management, using real-time timers.
Adds tests, usage documentation, and CI coverage for the new packages.
File
Description
README.md
Documents test-host usage, limitations, and coverage commands.
internal/inmemory/work.go
Implements work leasing, filtering, completion, and orchestration actions.
internal/inmemory/work_test.go
Tests continue-as-new event carryover and stale-result removal.
internal/inmemory/server.go
Implements instance state, timers, lifecycle operations, and history streaming.
internal/inmemory/query.go
Adds instance queries, ID pagination, and purge operations.
durabletasktest/host.go
Provides the public host over an in-memory gRPC transport.
durabletasktest/host_test.go
Exercises execution, events, timers, management, and unsupported features.
CHANGELOG.md
Records the new testing package and supported capabilities.
The reason will be displayed to describe this comment to others. Learn more.
Reusing the real worker and client makes this a useful test host. I would fix two cases where the host can hang otherwise-valid orchestration tests: an activity backlog can block orchestration dispatch, and a replay history over 4 MiB can stop the worker. The existing partial-turn replay and recursive-termination threads also need to be addressed before merge.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The host’s gRPC and history-event limits reject supported large payloads, and suspending or resuming a scheduled orchestration can prematurely signal that it has started.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Raise gRPC limits to support payloads over 4 MiB
durabletasktest/host.go:126
The host's default 4 MiB gRPC receive limits reject a 5 MiB orchestration input or activity result, although DTS connections allow 64 MiB (durabletaskscheduler/options.go:27–30). Configure compatible send/receive limits on the server and every connection created by dial. Also align the individual-history-event limit at internal/inmemory/server.go:485–486 so those payloads remain replayable through history streaming.
Preserve scheduled-start status when suspending or resuming
internal/inmemory/server.go:320
Suspending an instance before its scheduled start changes its status to SUSPENDED, so WaitForOrchestrationStart returns even though scheduling still blocks execution. Resuming before that time also reports RUNNING prematurely (server.go:431–433). Track actual start independently of suspension, use it for the start waiter and resume status while allowing terminal outcomes to unblock waiters, and cover scheduled-start suspend/resume in a regression test.
Suspending an instance before its scheduled start set its status to
SUSPENDED, so WaitForInstanceStart returned even though the scheduled
start still blocked execution, and resuming it reported RUNNING before
any turn ran. Record when the first turn commits, wait on that (or a
terminal status), and resume a never-started instance to PENDING.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
New events that together exceeded 4 MiB were sent in one work item. The
worker rejected the message as non-retryable and stopped, so the test
hung. Lease only the leading new events that fit and leave the rest for
later turns, as DTS does. If a single event can't fit, fail the instance
with a clear error instead of stopping the worker.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Recursive termination can miss newly created children, task-hub query filters are silently ignored, and stream-owned lease recovery lacks coverage for outstanding leases and completion races.
The in-memory service has no task hub identity, so a query scoped to
task hub names previously ignored the filter and returned every
instance. Return Unimplemented with the FEATURE_UNSUPPORTED reason so
the client reports api.ErrFeatureNotSupported. QueryInstances is the
only RPC that accepts task hub names.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…nation
A recursive TerminateInstance that arrives while the parent's turn is
leased terminates the parent's existing children, but the in-flight
turn could still commit a new sub-orchestration that kept running after
the parent ended. When a turn creates a sub-orchestration and the parent
has a recursive termination pending or in that turn, terminate the new
child too.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Lease orchestration and activity work on one stream, close it while the
leases are outstanding, and check that a replacement stream receives the
same work with pending events in order and that the original completion
tokens are rejected with NotFound.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A worker completion over gRPC's default 4 MiB server receive limit was
rejected at the transport. The worker then abandoned the work item and
the host dispatched it again, so the activity ran forever.
The in-memory server now accepts large messages at the transport and
enforces the DTS-equivalent 4 MiB limit itself. Oversized requests are
still rejected with ResourceExhausted, but an activity completion over
the limit fails the task with the non-retriable ActivityResponseTooLarge
error type, so the orchestration observes a TaskFailed event and the
activity isn't run again. oversizedCompletionFailure is shared so entity
completions can use the same check.
The host's client connections now mirror DTS connection defaults: a
64 MiB receive limit and no send limit. Outgoing work items and history
chunks remain within 4 MiB.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The termination fast path can permanently discard a pending ExecutionStarted event after abandonment, leaving history without an execution identity and causing execution-ID validation to fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #180
Adds a
durabletasktestpackage for running orchestrations and activities inside a test process, with no emulator, network port, or Azure resource. The design follows the in-memory testing backends in the .NET, Python, and JavaScript SDKs.Design
internal/inmemoryimplementsTaskHubSidecarServicein memory: instance state, history, an orchestration/activity work queue, completion-token leases, and real-time timers.durabletasktest.Hostserves that backend overbufconnand runs the realTaskHubGrpcWorker(viaNewTaskHubGrpcWorkerWithConnectionFactory) plus aTaskHubGrpcClient. Orchestrations therefore use the same worker, executor, and client paths as they do against DTS.durabletasktest.New(t, registry)starts a host and registers its cleanup with the test.NewHost(ctx, registry)is for callers that manage the lifetime themselves.ErrDuplicateInstance,ErrInstanceNotFound,ErrNotCompleted,ErrInvalidState,ErrFeatureNotSupported).Supported
Activities, sub-orchestrations, timers, external events,
SendEvent, continue-as-new (including carryover events), suspend/resume, terminate (including recursive), restart,QueryInstances,ListInstanceIDs, single/batch/filter purge (including recursive), history streaming, scheduled start, ID reuse policy, and worker work-item filters. When a work-item stream closes, its leased work is re-queued.Not included
RewindInstancereturnUnimplemented(ErrFeatureNotSupported). An orchestration that calls, signals, or locks an entity fails with aNotSupportedfailure.OrchestrationWorkItemTooLarge. Requests over 4 MiB are rejected withResourceExhausted, as DTS does. An activity result over 4 MiB fails the task with non-retriableActivityResponseTooLargeinstead of being redelivered; Fail oversized activity and entity completions instead of abandoning and re-executing them #202 tracks the equivalent worker behavior against DTS.QueryInstancesrejectsTaskHubNamesfilters, because the host has no task hub identity.README.mddocuments usage and limitations. CI coverage now includes both new packages.