Skip to content

Add oplog-shape, lifecycle, wait and error helpers to the executor test DSL - #4728

Draft
vigoo wants to merge 24 commits into
mainfrom
test-dsl-oplog-shape
Draft

vigoo wants to merge 24 commits into
mainfrom
test-dsl-oplog-shape

Conversation

@vigoo

@vigoo vigoo commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

This change adds helpers to the worker-executor test DSL and converts the first tests to use them. It is the start of the readability refactor of the worker-executor and integration test suites. The behaviour of the tests does not change.

The change has eight commits. The first commit adds the oplog-shape helpers. The second commit adds the lifecycle, wait and error helpers. The next three commits add test doubles at the boundaries where the executor leaves its process: blob storage, the worker service and the registry. The sixth commit moves the remote fork, resume, preparation and session paths of the tests to the emulated worker service. The seventh commit adds two typed error checks. The last commit adds the invocation request builder and the raw session helper.

The branch is rebased on main after #4717. #4717 added golem_test_framework::dsl::oplog_shape::assert_settled_oplog, which checks the same rules as OplogShape. The first commit removes it and converts its callers (see below).

Oplog-shape helpers

Helpers

  • OplogView is an extension trait on the slice of PublicOplogEntryWithIndex that get_oplog returns. It only selects entries and never asserts:
    • starts_of(function) gives the Start entries of a host function.
    • call(start) gives a CallRecord with the Start, End, Cancelled, CompletionDelivered and CompletionDiscarded entries of one call.
    • invocation(id) gives the started, terminal and settled entries of one invocation.
    • describe() gives a compact rendering for assertion messages.
  • OplogShape checks the settled-history rules of golem-worker-executor-tests/tests/AGENTS.md in one place:
    • Every invocation has exactly one AgentInvocationStarted and exactly one terminal.
    • Every Start has exactly one terminal.
    • No Start, End or Cancelled of an invocation comes after its AgentInvocationSettled, or after its terminal when it writes no Settled.
    • Every AgentInvocationStarted has its terminal before the next one.

A test must name each documented exception, with the call or invocation that it applies to: crashed_during, left_incomplete_on_drop, settled_by_later_invocation or in_flight. If a test names an exception that does not occur, the check fails. Thus a stale exception cannot hide a regression. The options no_background_work, forbid and invocations keep the stricter checks that local copies made.

assert_settled panics with #[track_caller]. ensure_settled returns an error, for a test that must run its own cleanup after a failure.

Conversions

  • The 5 local assert_settled_history copies under api/interruption/host/** now call OplogShape. Each copy keeps the entries that it forbade before. Each copy also forbids AgentInvocationFailed now, because the old copies required an AgentInvocationFinished.
  • The local terminal_count copies under api/interruption/host/** now use call(start).terminal_count().
  • In websocket.rs, the hand-written oplog filters now use call(start), and describe_oplog now uses describe().
  • In rpc/gc_timed_cleanup.rs, the terminal and positional part of assert_settled_history now uses OplogShape. The checks specific to that file stay: no wasm-rpc::drop call, every SpanClosed names an upsert Start, and the history has a finished invocation.
  • The 5 callers of assert_settled_oplog in tool_streaming now call OplogShape, and assert_settled_oplog is removed. Its one rule that OplogShape did not have moves into OplogShape: a Start that names its invocation, through driver, invocation_id or parent_start_index, must end before the terminal of that invocation, also when another invocation started between them.
  • This rule now applies to every caller of OplogShape. Four tests of rpc/gc_timed_cleanup.rs leave calls for the next invocation on purpose: cache futures, an RPC future that is never awaited, and a cache-fill destructor. These tests now name those calls with settled_by_later_invocation. Each test already found these calls and checked that the next invocation ends them. The local assert_settled_history takes the calls as an argument; its other callers pass none.
  • tests/AGENTS.md now tells authors to use the helpers instead of a local copy.

Stricter checks

These checks are stricter than the copies that they replace:

  • The old copies compared each Start and End with the last AgentInvocationFinished in the oplog. OplogShape checks the position of each entry against the terminal of its own invocation.
  • gc_timed_cleanup.rs required at least one terminal per Start. It now requires exactly one, and it checks the position of each Start and its terminal against the invocation that the Start names.
  • The positional rule also rejects a Cancelled after its invocation settled. gc_timed_cleanup.rs and gc_heap.rs already rejected this case.

gc_heap.rs and middleware_acceptance.rs keep their local checks. They check things that the helper does not check: an End without a Start, and span outcomes.

Tests

The affected tests ran with the test files of main and with this change, with the same result. The tests are the websocket.rs tests, the api::interruption::host p2, p3, websocket and blob filesystem families, and rpc::gc_timed_cleanup. Tests that need the managed XFS runner are ignored.

These tests could not run, because their TypeScript and Effect components were not built:

  • websocket_echo_ts
  • websocket_report_loss_ts_public_wrapper_replacement
  • websocket_report_loss_effect_joins_initialization_before_replacement
  • ts_snapshot_restore_replays_gc_released_clients

Lifecycle, wait and error helpers

The second commit converts websocket.rs and agent.rs to these helpers.

Helpers

  • executor.restart(Teardown::Drop | Shutdown | Release) tears the executor down and starts a new one on the same storage, with the start function and arguments that created it. The executor records them in a private field. start_customized and its wrappers (start, start_with_snapshot_policy, and the others), start_with_overrides and start_with_redis_oplog_config record them. For other start functions, restart fails before it tears anything down.
    • Drop is drop(executor).
    • Shutdown is shutdown_and_wait_for_invocation_loops() and then drop(executor).
    • Release is release(), which evicts the cached agents and waits until the service graph is released.
    • restart_with(teardown, overrides) starts the new executor with other overrides. A test uses it when the restart changes the overrides on purpose.
  • within(timeout, what, future) in golem_test_framework::dsl is tokio::time::timeout with an error that names what the test waited for. GATE_TIMEOUT (10s) bounds a wait for a gate the test armed. SETTLE_TIMEOUT (30s) bounds a wait for a state that needs a reconstruction or a full invocation. Other waits use a named constant of their file.
  • WorkerLogEventStream::wait_for_stdout(line, timeout) reads events until one is the stdout line.
  • invoke_agent_session returns the rejection or failure as a typed InvocationError inside the anyhow::Error. Its Display is the same text as before, so a test that still checks the text passes. assert_worker_error!(error, pattern [if guard] [, message]) checks the worker error of the invocation by its variant.

Conversions

  • websocket.rs: every restart, every tokio::time::timeout and the stdout loop. Every timeout keeps its value.
  • agent.rs: the restarts, the named timeouts, and the error checks on invocation errors. The new patterns fix the variant and compare the message for equality, so they are stricter than the substring checks they replace. Errors that do not come from an invocation session keep their text check: start_agent, resume, fork, a guest Result<_, String>, and the checks of the multi-language method_failure_test! macro.
  • tests/AGENTS.md names the helpers.

Two failure modes change, and no scenario changes:

  • A pool-permit wait in websocket.rs that timed out panicked through expect. It now returns an error that names the permit.
  • In two loops of websocket.rs, the loop locals (pool, admission) now drop before the executor. The gate and the permit are still dropped explicitly, in the same order as before.

Tests

The websocket.rs tests and the Rust-fixture tests of agent.rs ran with the test files of the first commit and with this change, with the same result. Tests that need the managed XFS runner are ignored. These tests could not run, because their TypeScript, Effect and Go components were not built: websocket_echo_ts, websocket_report_loss_ts_public_wrapper_replacement, websocket_report_loss_effect_joins_initialization_before_replacement, ts_snapshot_restore_replays_gc_released_clients, and the agent.rs tests on the TypeScript, Effect, Scala, MoonBit and Go fixtures.

Test doubles at the executor's service boundaries

Many tests replaced or wrapped an executor service to change one or two operations. These copies were long, and some of them replaced the production code of the call that the test is about. The four commits put the test double at the boundary where the executor leaves its process. The production code on the executor's side of the boundary runs.

Blob storage: BlobStorageDecorator

  • A test implements BlobStorageDecorator for its fault or observation state and overrides only the operations that it changes. Every other operation calls the wrapped storage. The operations that BlobStorageBackend defines from other operations keep that definition, built from the decorator's operations, so they reach the changed operations.
  • wrap_blob_storage() gives the value of TestExecutorOverrides::wrap_blob_storage. DecoratedBlobStorage<D, I> can also wrap a concrete backend, as oplog_blob_archive.rs does with the S3 backend.
  • Conversions: oplog_unreadable.rs, hot_update.rs, tool_streaming/rdbms_drop.rs, blob_mutation_storage.rs and oplog_blob_archive.rs. A wrapper method that did more than delegate keeps its body.

Worker service: EmulatedWorkerService

  • The executor calls the worker service through its production RemoteWorkerProxy. In the executor tests nothing listened at public_worker_api, so the permission tests replaced the proxy with LocalCardTransferProxy copies and connected them to the executor after each start.
  • EmulatedWorkerService is an in-process golem.worker.v1.WorkerService on 127.0.0.1. TestExecutorOverrides::with_worker_service points public_worker_api at it. Each executor start, including restart, attaches the executor to the service, so the connect calls after each start go away.
  • It answers DeliverCardTransfer with the system-only check of the real handler, and ResumeWorker, and forwards both to the executor. It records card transfers. WorkerServiceOptions choose when it records a transfer and whether it delivers it, and lose_response_of_card_transfer answers a delivered transfer with an error.
  • Every failure is an answer in the response body, never a gRPC status, so the proxy's client never retries a call and never delivers a transfer twice. An RPC that the service does not emulate answers unimplemented.
  • The service does not emulate routing or the error mapping of the real worker service. An executor error reaches the proxy unchanged, so a test checks the error code of the executor.
  • Conversions: the card-transfer proxies of effect_permissions.rs, agent_sdk_ts/permissions.rs, agent_sdk_go/permissions.rs, permission_cards_scala.rs, scope_cards/moonbit.rs and api/mod.rs, and the users of the accepting proxies in hot_update.rs, instance_layer.rs and tool_streaming/matrix_client_resource_acceptance.rs. Each setup records a transfer at the same time as the copy that it replaces.
  • wrap_worker_proxy stays in this commit, because fork.rs still uses it. The last commit removes it.

Remote paths: the full worker-service emulator

  • fork.rs had LocalResumeProxy, a WorkerProxy that wrap_worker_proxy put in place of the production proxy. It forwarded resume, fork, preparation and invocation sessions to the executor in process, filled in the component owner, held or lost a resume response, and counted session requests. The last commit removes it, remote_rpc_preparing_on and the wrap_worker_proxy hook, and moves this behaviour into EmulatedWorkerService. The executor keeps its production RemoteWorkerProxy for these calls.
  • New WorkerServiceOptions:
    • component_owner(account_id) makes the service answer PrepareWorker and ForkWorker, and fill the owner into the start of an InvokeAgentSession. The real worker service finds the owner of the component; the emulated service gets it as an option. Without it, PrepareWorker and ForkWorker answer unimplemented.
    • hold_after_resume(notify): the first successful resume notifies and then never answers. It is the checkpoint of the crash window between resume and its response.
    • lose_resume_response(): the next successful resume answers the internal error "lost fork resume response".
  • session_evidence() gives RemoteRpcEvidence (session_requests, joined_observer_acceptances, resume_attach_requests). The field sessions is renamed session_requests.
  • remote_rpc(shard_service) gives a production RemoteInvocationRpc over a RemoteWorkerProxy at the service, for a test that calls an agent of another executor.
  • The service accepts gRPC messages up to 32 MiB, as the real worker service does by default.
  • with_worker_service panics when the overrides already have a worker service, so a helper cannot silently replace the emulator of its caller.
  • The test bodies of fork.rs do not change; only its start helpers change. worker_initialization.rs gets setup_with_worker_service, and rpc.rs reads the renamed field.

Behaviour changes that no test observes:

  • On the resume setups, a call that the service does not emulate now answers unimplemented at once. Before, it went to the unused default public_worker_api address and failed after the connect retries. The executor classifies both failures as transient and retries them in the same way.
  • On the resume setups, a card transfer is now delivered. Before, it failed. No test on these setups sends a card transfer.
  • After restart, the service forwards to the new executor. Before, the proxy kept the client of the first executor.

Registry: EmulatedRegistryService

  • No executor test ran the production card service, CardServiceDefault. The permission tests replaced it with hand-written card services that disagreed with production and with each other.
  • EmulatedRegistryService is an in-process golem.registry.v1.RegistryService that answers BatchGetCards, CreateRuntimeCard and RevokeCard from an in-memory store, as the registry does. TestExecutorOverrides::with_registry gives the executor CardServiceDefault over a production GrpcRegistryService client at the service. A test adds the initial cards with add_card.
  • with_registry replaces only the registry client of the card service. The executor's shared registry client also serves agent types, resource limits and the issuer lookup, which the service does not answer.
  • The service does not check which cards a caller may revoke, and it sends no registry invalidations. A revoke that the executor makes updates the executor's cache from the response, so no converted test needs the invalidation stream.
  • Conversions: the card services of effect_permissions.rs, agent_sdk_go/permissions.rs, agent_sdk_ts/permissions.rs and permission_cards_scala.rs. scope_cards.rs, tool_runtime_bypass and revert_replay_tail keep their own card services, because they inject faults and gates at the card-service level.

Behaviour changes:

  • The production card service treats a card that the registry does not have as revoked. The old doubles answered unknown (Scala) or live (TypeScript) for the initial cards that the tests did not register. The TypeScript and Scala tests now register the initial cards of every agent type.
  • The Scala target's wallet now lists its live initial template card. Three expected wallet listings of the Scala scenario change: kinds-plain=template, kinds-lent=scope,template and receiver-kinds=template. The Go and TypeScript scenarios already expected the template card in the wallet of an agent whose card is live.
  • The revoke counts of the Effect, TypeScript and Go scenarios do not change.

Tests

The tests that use the converted doubles ran with the test files of the second commit and with this change. Every test had the same result, except the three Scala wallet listings above. These tests ran: the blob-storage tests of the converted files; the permission-card tests on the Effect, TypeScript, Go, Scala and MoonBit fixtures; the card-transfer and fork-lifecycle tests of api/mod.rs; and the wallet tests of hot_update.rs, instance_layer.rs and matrix_client_resource_acceptance.rs. a_manual_update_whose_target_initial_file_does_not_load_fails_only_the_update fails with and without this change, because of the local environment.

The tests that reach the changed start helpers ran with the test files of the fifth commit and with this change, with the same result: the fork.rs tests, and the fork, resume and preparation tests of rpc.rs, filesystem_snapshots.rs, hot_update.rs, scheduled_durable.rs, scope_cards.rs, tool_streaming and worker_initialization.rs. The tests that read RemoteRpcEvidence are ignored on main. With --include-ignored, fork_and_revert_streaming_rpc_join_the_original_remote_invocation, fork_dropping_inherited_rpc_output_does_not_cancel_original_reader and forks_of_agent_rpc_outputs_finish_without_inherited_attachments fail with and without this change, with the same error.

Typed error checks

Two standalone-tool tests checked only the worker error of a failed invocation. Both variants of InvocationError carry a worker error. The tests now also check the variant: the owner that loses its component tool activation is rejected before acceptance, and a same-key caller of a retained startup failure gets the failure outcome.

Invocation requests and raw sessions

Helpers

  • executor.invocation(&component, method) gives an InvocationStartBuilder. It always sets the auth context, an anonymous caller, the environment, the component owner and an idempotency key. It sets every other field only through a method: on_agent, on_key, input, input_record, idempotency_key, with_request_key, with_component_id, allow_streams, mode, freshness, caller, fresh_attempt and expect_fingerprint. Thus a converted start sends the same fields as the literal that it replaces. build() gives the protobuf, so a test that sends an unusual start can still change it.
  • executor.open_session(start) and executor.resume_session(resume) give an InvocationSession. The session validates every frame in both directions with InvocationSessionState, as the old loops did. open_unvalidated_session and resume_unvalidated_session skip the validation, for a test of a frame that the protocol refuses.
  • The session reads with acceptance, accepted, ready, next, message and wait_for_result. It sends with send, send_request, send_unvalidated, send_input, finish_input, end_input and cancel_output. The stream frames take the epoch and the durable stream ID from the acceptance. collect and collect_with_output read to the end and give a SessionOutcome with the result, the terminal (SessionTerminal::Succeeded, Failed or Rejected, with the typed InvocationError) and the output items.
  • InvocationSessionResultExt gives method_result and first_output_stream. The free functions resume_attach, stream_reference, id_target, key_target and start_target_id build the other protobuf parts. id_target, key_target and start_target_id move from agent.rs.

Conversions

  • The hand-built InvocationStart literals and session loops of rpc.rs, agent.rs, fork.rs, api/mod.rs, hot_update.rs, invocation_context.rs, rpc/websocket_crash_probe.rs, tool_runtime_bypass/permission_admission.rs, tool_streaming/tool_result_delivery.rs and standalone_tool.rs. rpc.rs loses its local session helpers open_raw_session and await_session_readiness.
  • The DSL itself: invoke_and_await_target and invoke_agent_with_key build their start with the builder, and invoke_agent_session is open_session and collect.
  • These literals stay, because each one tests a missing or invalid field, or has no executor in scope: the invalid start of rpc.rs, the oversized opening frame, the lookups without a method, fork.rs's expiring_session_request and worker_initialization.rs.
  • rpc.rs's local receive_invocation_session and invoke_agent_session still return Result<_, String>, and their callers still compare the text. A later change of the rpc.rs tests converts them.

Behaviour changes that no test observes:

  • The request channel of a session holds 8 frames. Some loops used 1.
  • The output cancellation of output_consumer_cancel_after_result_remains_a_valid_terminal_session takes its epoch from the acceptance. The old loop sent the literal 1, which is the epoch of the acceptance in that test.
  • invoke_agent_session returns an error for an AttachmentRevoked frame, where it panicked before. Some of its error messages have new text; no test compares them.

Tests

main changed the golem:api/oplog@1.5.0 WIT, so every test component was built again with the rebased CLI and SDKs.

The tests of the converted files, the top-level tool_streaming tests and tool_streaming::standalone_middleware ran with the test files of the seventh commit and with this change. Every test had the same result, except the four gc_timed_cleanup tests above, which fail without the first commit's named calls and pass with them. The permission-card tests of the third to fifth commits ran with both test binaries and pass.

These tests fail with and without this change, because the built-in tool components were not built again: the builtin_git_*, builtin_node_*, builtin_javascript_*, builtin_web_fetch_* and git_network_probe_* tests, typescript_guest_recursive_rm_removes_tool_created_output and the two python_sidecar tests.

Crash and promise checkpoint servers

Helpers

  • CrashCheckpointServer::start() and PromiseCheckpointServer::start() move the in-process checkpoint servers from tool_streaming/mod.rs into golem-worker-executor-test-utils. The protocol, the bind address, the 30 s wait (SETTLE_TIMEOUT) and the error texts do not change.
  • agent_env(prefix) gives the environment that points a component at the server: {prefix}_CRASH_CHECKPOINT_PORT and {prefix}_CRASH_CHECKPOINT_GATE_PORT, or {prefix}_PROMISE_CHECKPOINT_PORT. The empty prefix gives the names without a prefix.
  • reach(name) waits for the next arrival and asserts its name. recv() waits without a timeout or a name check, and try_next() reads an arrival that is already queued. CrashCheckpoint::release() lets the component continue; dropping the arrival without a release keeps the gate shut. PromiseCheckpoint has name and oplog_index.
  • Dropping a server stops it. The old promise server was a plain JoinHandle, so it ran on after the test; its receiver was already dropped at the same point, so a late announcement failed in both versions.

Conversions

  • Every server start in the tool_streaming tests and their submodules. The hand-built env maps become agent_env calls.
  • typed_tool_output_stream_waits_for_producer_and_is_durable_through_nonidentity_middleware keeps its own held-HTTP server. It now sends one local HeldPromiseCheckpoint per request on one channel, where it sent two arrivals of the old types on two channels. The two old name checks compared the same string from the same request.
  • held_http_crash_recovery.rs and mcp_stdout.rs keep their own servers, which use a different protocol.

Tests

The 166 tests of the converted files ran with the test files of the previous commit and with this change, and every test had the same result. The built-in tool tests above fail in both runs. middleware_acceptance::output_redaction_preserves_structured_stream_error_and_completed_replay and trapped_leaf_observers::nested_leaf_trap_notifies_external_caller_while_primary_waits_on_silent_tcp also fail in both runs.

In-process HTTP stubs

Helper

  • LocalHttpServer::serve(router) binds 127.0.0.1:0, serves the router in the current tracing span, and stops the server when the value is dropped. port() and url(path) give the address.

Conversions

  • The axum stubs of the test files outside tool_streaming. The router stays in the test. An abort() of the old task becomes a drop of the server at the same place. Helpers and fixture structs that returned or held the task now return or hold the server.
  • Five stubs ran as detached tasks after their helper returned. Their helpers now return the server, and the callers hold it to the end of the test.
  • These stubs stay as they are, because the test waits for the server task to end or selects on it: three in http/concurrent_recovery.rs, the JoinSet server of wasi.rs, the checkpoint server of mcp_stdout.rs, one in api/mod.rs and the graceful-shutdown server of reconstruction.rs.
  • The stubs bound 0.0.0.0 or 127.0.0.1. They now bind 127.0.0.1. The components reach them through localhost or 127.0.0.1.

Tests

The tests of the converted files ran with the test files of the previous commit and with this change, and every test had the same result. The two oplog_processor tests could not run, because the oplog_processor_release component was not built. The MoonBit custom-scope tests and the external_durable_stream tests fail in both runs, because their components were not built again.

Tool deployment fixtures

Helper

  • ToolDeployment::new(account_id, &provider_component) builds the ToolDeploymentState of one provider. tools(definitions) registers each definition with type IDs in definition order, and bound_to(agent_type) binds every registered tool to the agent type. The options provider_name, account_email, deployment_revision, provision_env, config_keys_readable, filesystem_access(tool, access) and shell(tool) set the fields that the old copies set differently.
  • The provider name comes from the stored component. Two tests store the provider under another name, so they set provider_name to keep the recorded value.

Conversions

  • The deployment_state function of tool_streaming and its calls. The old function bound capable-streaming with filesystem access whenever the deployment registered it. The Rust provider defines that tool, so its calls use the local rust_provider_deployment, which sets the access. The two loops that can deploy golem:bash mark bash as the shell.
  • The deployment_state function of tool_runtime_bypass.
  • tool_discovery.rs keeps its own fixture, because it invents tool definitions from names and gives each tool its own component.

Tests

A temporary build computed the old and the new deployment at every converted call and asserted that they are equal. The tool_streaming and tool_runtime_bypass tests ran with it. The assertion found the two calls with the other provider name.

Shared invocation sessions

Helpers

  • InvocationStartBuilder and InvocationSession move from the executor test utils to golem-test-framework (dsl::invocation_session). InvocationError and assert_worker_error! move with them (dsl::invocation_error). The executor DSL and the integration DSL now build and read invocation sessions with the same code.
  • InvocationStartBuilder::new(component, method, auth_ctx) and for_tool(component, tool, auth_ctx) set only the method or the tool, the auth context, an anonymous caller, the environment and a fresh idempotency key. The component owner (component_owner), the agent type ID (local_type_ids, agent_type_id), the target (on_agent, on_key, target) and the input (input, input_record, input_value) stay unset until a method sets them. The executor sets the component owner and the type IDs itself, because the worker service sets them in production. So a converted request sends the fields that it sent before.
  • InvocationSession::open(first, validate, connect) starts the session on the RPC that connect opens. The executor DSL connects to the executor. TestUserContext::open_session and resume_session connect to the InvocationSession RPC of the worker service.
  • The session keeps the durable mapping of each stream from every frame that announces it. stream_mapping(stream) returns it.
  • keep_unsent_frames keeps the frames that the session cannot send after the other side completes the RPC, instead of failing. The integration tests need this, because the worker service can complete the call while the test still sends frames.
  • The shared target helpers id_target, key_target and proto_agent_key replace the copies in integration-tests/src/agents.rs and in the executor DSL.

Conversions

  • integration-tests/src/invocation_session.rs: the session that reattaches after a fault is now ReattachingSession, so that its name is different from the shared InvocationSession. It builds its start requests with the shared builder.
  • tests/api/streaming_rpc.rs: invoke_agent_session and TrustedInvocationSession keep their signatures and their failure messages, and use the shared session.
  • tests/api/agent_identity.rs uses the shared target helpers.

Behaviour

  • The request channel of every session holds 32 frames.

Tests

A temporary build compared each converted integration request with the old literal request, after it replaced the random request key. All requests were equal. The api::streaming_rpc and api::agent_identity::ephemeral_grpc integration tests, the streaming_session_recovery tests and the fault_matrix rows ran before and after this change with the same result.

HTTP test contexts

Helpers

  • HttpTestContext::builder(wasm_name, package_name) replaces the chain make_test_context, make_test_context_with_openapi_endpoint, make_test_context_with_files and make_test_context_with_files_and_setup. agents(names) adds agent types with the default HTTP options, agent_with(name, options) adds one agent type with its own options, openapi_endpoint(prefix) sets the OpenAPI endpoint prefix, files(agent_type, entries) adds initial files, and before_component(setup) runs a step after the domain registration and before the component is stored. build(deps) runs the body of the old make_test_context_with_files_and_setup. The defaults are the values that the short functions passed.
  • DomainEnvironment::create(deps) is the prelude that the HTTP and the MCP contexts share: a user without auto-deploy, an application and an environment with security overrides, and the registered domain {environment}.golem.cloud. It returns the user, the application, the environment, the domain and the registry client as named fields.
  • per_database_test_context!(Context, build) writes the three PerWorker dependencies test_context, test_context_postgres and test_context_sqlite. test_r names a dependency after the path of its type and its tag, so the macro takes the context type as a plain name, and the calling module imports EnvBasedTestDependencies.

Conversions

  • The seven custom_api files that wrote the three dependencies by hand, and mcp.rs.
  • The other calls of the old functions in custom_api, and durable_context in fault_matrix.rs.
  • raw_http_router.rs named its dependencies raw_router_context*. They now have the names from the macro. The tests still name their parameter raw_router_context, because test_r resolves a dependency by its type and its tag. Three tests in this file called the old dependency constructor directly to get their own context. They now call build_raw_router_context, so each of them still gets its own context.
  • http_test_context.rs is also compiled into the fault-matrix and http-handler-lifecycle test binaries, which use only part of the builder. So the builder methods allow dead code, and the macro allows being unused.

Tests

The custom_api tests, the http-handler-lifecycle tests and the fault_matrix durable-stream rows ran before and after this change with the same result.

Deployments from a plan

Helper

  • deployment_from_plan(&plan, version) in golem_test_framework::dsl returns the DeploymentCreation of the environment that the plan describes: the plan's current revision and hash, the version, and no defaults, tools, MCP imports or tool middlewares. A test sets other fields with struct-update syntax, so each override stays visible: DeploymentCreation { publish_tools, ..deployment_from_plan(&plan, "1.0.0") }. DeploymentCreation is a golem-common type, so a free function is used instead of an extension trait.
  • deploy_environment_with builds its default with it.

Conversions

  • The DeploymentCreation literals of api/deployment.rs, and the local deployment_creation and empty_deployment_creation functions of api/deployment.rs, owner_environment_resolution.rs and gol40_chunk_g_environment_resolution_acceptance.rs.
  • Twelve requests sent current_revision: None and now send the plan's current revision. A temporary build asserted at each of these requests that the plan's current revision is None. The tests passed with the assertion.
  • Two requests keep an explicit current_revision, because it does not come from the plan. fail_with_409_on_hash_mismatch keeps its literal, because it has no plan.

Tests

The api::deployment, owner_environment_resolution and gol40_chunk_g_environment_resolution_acceptance tests ran before and after this change with the same result. full_deployment_sqlite fails in both runs when it runs after full_deployment_postgres, because both register the fixed domain full-deployment-test.golem.cloud. It passes alone.

Websocket executor tests

Shared helpers

  • TestExecutorOverrides::configured(f) returns overrides that only change the executor configuration. It replaces the struct literal that sets configure and nothing else.
  • TestDsl::invoke_and_await_typed::<T> and invoke_and_await_typed_with_key::<T> invoke an agent method, wait for the result and decode it with AgentResult::into_typed. They are default trait methods, so the executor DSL and the integration DSL both get them.

Conversions in websocket.rs

  • WebsocketTest is the fixture of the file: a context, an executor and the stored component. start uses start, and start_with_connection_limit uses start_with_overrides with the pool limit, as the tests did before.
  • TestPeer::start(Accept, PeerScript) replaces nine copies of an in-process websocket server. Accept keeps how the old server accepted connections (one connection, a loop that serves each connection inline, or a task for each connection). PeerScript keeps what it did on a connection. Each test drops the peer where it aborted the server before.
  • WebsocketAgent keeps the component, the agent key and the worker of one agent. Its start_contention and contention_result methods replace the repeated invocations of the contention method.
  • connect_persisted_handle, park_contention_receives and interrupt_parked_receives replace the setup that the reconnect-coordination tests repeated. assert_reports_session_loss replaces the repeated check of probe_report_loss. crash_at_call_end replaces gate.abort() followed by shutdown_and_wait_for_invocation_loops(); the wait for the gate stays at the call site, because some tests do work between the wait and the crash.
  • The longest tests put each phase in a named function that takes and returns the executor, because a restart replaces the executor.
  • Typed values replace the raw SchemaValue::Result comparisons and the get_result_error_string helper.
  • websocket_report_loss_replacement_connect_and_initialization_crashes looped over four independent cases. It is now four tests, websocket_report_loss_replacement_{connect,initialization}_crashes_{before,after}_end. Each test states its expected result.

Tests

The websocket:: tests ran before and after this change with the same result.

WASI executor tests

Shared helpers

  • ExecutorTest in golem-worker-executor-test-utils replaces the file-local WebsocketTest. ExecutorTest::start creates a context, starts the executor with start and stores the component unchanged. ExecutorTest::start_with_overrides does the same with start_with_overrides. websocket.rs now uses it, and start_with_connection_limit(.., n) became start_with_overrides(.., connection_limit(n)).
  • TestWorkerExecutor::spawn_invoke_and_await and spawn_invoke_and_await_with_key start an invocation in a background task and return its JoinHandle. They clone what the task needs and keep the tracing span.
  • TestWorkerExecutor::wait_for_oplog and wait_for_committed_oplog read the public oplog until a predicate holds and return that oplog. On timeout, the error names what the test waited for and describes the oplog. The committed form commits the oplog before each read, so the Start of a running call becomes visible.

Conversions in wasi.rs

  • The file stays one file. wasi/linux.rs does not change, so wasi.rs keeps the items that it uses under #[cfg(target_os = "linux")].
  • The function-local use lines are at the top of the file. Durations are named constants, and within replaces tokio::time::timeout where a timeout fails the test.
  • Typed values replace the raw SchemaValue results. Records decode into structs that mirror the guest types. The decoder reads record fields by position, so the record length checks are removed.
  • executor.restart(Teardown::Drop) replaces drop(executor) followed by the same start function. p3_wait_for_restart_preserves_recorded_deadline keeps the explicit drop and start, because the deadline must expire while no executor runs. A restart stays explicit also where the test drops a server between the two steps.
  • The interrupt checks match WorkerExecutorError::Runtime with the interrupt text. failing_worker matches InvocationFailed and PreviousInvocationFailed, and checks that their stderr holds the guest's log line and panic message. The guest-returned strings stay substring checks, because they are guest output.
  • OplogView replaces the hand-written scans of Start and terminal entries. WaitProgress counts the Start and End of an interrupted wait and the invocations after a boundary. incomplete_starts returns the open Start entries after a boundary.
  • File-local fixtures replace repeated setup: ClockWithServer (a Clock agent whose PORT points to a local server), PoolContention with slow_then_fast_server (the two connection-pool tests), SilentFirstTcpServer (the TCP interrupt test), CountingServer, initial_file, config_entry and listed_nodes.
  • The interrupt tests, the UDP repair test and the pool restart test put their steps in labeled phases. The 92-line report of initial_file_p3_parity_impl is a constant.

Tests

The wasi:: and websocket:: tests ran before and after this change with the same result.

RPC executor tests, part 1

This part changes the first half of rpc.rs: the unary, suspension, memory and output-stream tests. The input-stream, fork, revert and generated-client tests follow in part 2. The submodules in rpc/ do not change.

Shared helpers

  • TestWorkerExecutor::wait_for_suspended_unload(agent_id, timeout) waits until the agent's status is Suspended and the executor has unloaded it. One timeout covers both waits. The select! that proves that the invocation did not finish first stays at the call site.
  • OplogView::method_starts(method_name) returns the AgentInvocationStarted entries of the agent method invocations with that method name. It replaces the hand-written scans that count or find the start of a method.
  • OutputLedger in golem_test_framework::dsl records the stream mappings, output items and stream ends that a test reads from one or more sessions. It checks each frame: the producer sequence continues its stream, no item follows the end of its stream, a stream ends once with a sequence equal to its item count, no durable offset repeats, and every frame names the durable stream ID of its mapping, also when the mapping arrives after the frame. ensure_complete checks that every stream with frames was mapped and every mapped stream ended.

Conversions in rpc.rs

  • OutputLedger replaces the hand-written wire checks of four session readers. Each reader now checks all the rules, where before it checked a different subset. output_prefix_survives_autonomous_suspension keeps two explicit checks that the ledger allows: a stream is mapped before its first frame, and a stream is mapped once.
  • output_prefix_survives_autonomous_suspension moves the check of the suspended prefix to check_suspended_prefix, and the decoding of the journal to OutputJournal::read. ProducerStreams derives the durable stream IDs of the producer's records.
  • streaming_output_resume_restores_exact_cursors names its four phases. One ledger spans both sessions, so the resumed session must continue each stream from its cursor.
  • ExecutorTest, restart, within with named constants, spawn_invoke_and_await_with_key, wait_for_oplog, invoke_and_await_typed and TestExecutorOverrides::configured replace the hand-written setup, restarts, timeouts, background invocations and oplog polls. fast_rpc_suspension holds the RPC suspension settings that three tests repeat.
  • stream_session_records, finished_count and ConsumerReadOrdinals replace repeated decoding of stream session records and counts of finished invocations.
  • The resume refusal, the inactive ephemeral resume and AttemptConflict stay text checks. The executor reports them as InvalidRequest, which names its category only in its text, or through an API that returns only the formatted error.

Tests

The rpc:: tests ran before and after this change with the same result. This includes the four session readers that now check the whole output wire contract.

RPC executor tests, part 2

This part changes the second half of rpc.rs: the input-stream, joined-origin, fork, revert, generated-client, kept-handle and cancellation tests. The submodules in rpc/ do not change.

Conversions in rpc.rs

  • ExecutorTest, restart, within with named constants, spawn_invoke_and_await, wait_for_oplog, wait_for_suspended_unload and invoke_and_await_typed replace the hand-written setup, restarts, timeouts, background invocations, oplog polls and result decoding. RELOAD_TIMEOUT names the wait for an unloaded agent to load again by its own wake-up.
  • OplogView replaces the hand-written scans of RPC Start entries, their End entries, method starts and invocation starts.
  • The joined-origin tests match WorkerExecutorError::PreviousInvocationFailed instead of its text.
  • OutputLedger checks the output wire contract in typescript_streaming_guest_abi_e2e and in each run of effect_concurrent_stream_with_pending_websocket_readers.
  • The reports of the generated Rust and TypeScript clients and of the TypeScript reflection test decode into structs that mirror the guest types: StreamingRpcReport, TsStreamingRpcReport and ReflectionDiscoveryReport. The decoder reads record fields by position and does not check their number, so the record length checks stay.
  • File-local fixtures replace repeated setup: KeptHandle (a caller that keeps an RPC handle to a child, for the five kept-handle tests), TsCancelledCall (the aborted call to a blocked TypeScript agent, for the two cancellation tests), ConsumedInput and wait_for_detached_session.
  • Tests that repeat one scenario over a case list run each case in a named function: durable_read_case, fork_join_case and fork_drop_case. The fork cases are ignored tests; they still compile.
  • The producer-failure checks of the generated clients stay text checks, because the session reports only the failure message. The denial of direct RPC stays a text check, because the executor replaces the details of every denial with one text.

Tests

The rpc:: tests ran before and after this change with the same result.

RPC executor tests, part 3: the rpc/ submodules

This part changes the eight files in rpc/. It has two commits.

RpcDecorator (first commit)

  • RpcDecorator gives each Rpc method the wrapped Rpc as inner and forwards to it by default. A test double overrides only the methods that it changes. wrap_rpc gives the value for TestExecutorOverrides::wrap_rpc. This is the same shape as BlobStorageDecorator.
  • The four hand-written Rpc wrappers in rpc/ and RecordingRpc and FailingRpc now implement RpcDecorator. The streaming methods keep the default of the Rpc trait, as all the old wrappers did.
  • HoldResponseRpc and the RecordingRpc in worker_initialization.rs still make a new double on each executor start, because their state must start empty after a restart. The other doubles share one double across restarts. Their state was already shared. The shared RecordingRpc::call_count has no reader at those sites.
  • abort_and_restart ends a crash window: it aborts the test task of a running invocation and restarts the executor. With Teardown::Shutdown, the executor shuts down before the abort, as the old tests did.
  • committed_oplog, OplogView::last_index_of and OplogView::invocation_starts replace repeated commit-and-read steps and oplog scans.

Conversions in rpc/ (second commit)

  • ExecutorTest, restart, restart_with, abort_and_restart, spawn_invoke_and_await*, wait_for_committed_oplog, within with named constants and OplogView replace the hand-written setup, restarts, crash windows, timeouts, oplog polls and oplog scans.
  • rpc.rs gets helpers that the submodules share: snapshot_every_nth_invocation, expect_snapshot_loaded, expect_snapshot_rejected, stored_create_requests, agent_caller, is_rpc_not_found, KeptHandle::keep_with and TsPromiseId. TsPromiseId is a derived schema type that replaces the hand decoder of TypeScript promise IDs and the copy of its structs in input_gc.rs.
  • effect_duplex_websocket_crash_continuation ran two cases that share nothing in one loop. It is now two tests, effect_duplex_websocket_continuation_without_crash and effect_duplex_websocket_continuation_with_crash, which call one case function.
  • completed_invocation_cache_drops_repair_inside_next_invocation names its three phases: the original run, the first repair and the second replay. The phases share state, so the test stays one test. input_gc.rs splits its scenario into the run to the snapshot and one check function for each of the two outcomes.
  • The kept-handle deletion tests match WorkerExecutorError::InvocationFailed and the AgentError::Unknown of the stored oplog instead of the formatted error. The refusal is still found in the message of the error, because the executor puts the RpcError of the schedule into the trap message.
  • input_gc.rs checks the settled history with OplogShape. It keeps its check that no durable call follows the last finished invocation, because OplogShape applies that rule to each invocation by its own terminal.
  • The eprintln! diagnostics of the replay-barrier and hint probes move into assertion messages.

Tests

The rpc:: tests ran before and after this change with the same result, with the split websocket test in place of the old one. The in_function_retry::, worker_initialization:: and interruption::host::rpc tests, which use RecordingRpc and FailingRpc, also ran with the same result.

Worker initialization executor tests

This part changes worker_initialization.rs, invocation_receipts.rs and create_config_admission.rs. It has two commits.

Stored-oplog queries and create senders (first commit)

  • StoredOplogView queries the stored oplog that stored_oplog returns. invocation_counts gives the counts of the pending, started and finished invocation entries. invocation gives the positions of the entries of one invocation. create_requests gives the Create requests. The positions are indexes into the stored oplog, because the stored entries have no oplog index. stored_create_requests in rpc.rs goes away.
  • send_create_worker and send_prepare_worker send a CreateWorkerRequest and decode the response into the success record or the typed WorkerExecutorError. A response without a result fails the test.
  • CALL_TIMEOUT (20 s) joins GATE_TIMEOUT and SETTLE_TIMEOUT. It replaces TERMINAL_TIMEOUT of the rpc tests.

Conversions (second commit)

  • InitializationTest replaces the three setup functions that returned tuples. system_create_request replaces the hand-built create requests. A test that needs another field changes it with struct update syntax. The constructor tests and the warm create test keep a request without an idempotency key, as before.
  • ConstructorGate replaces the four loops that wait for the promise index that the constructor prints, and completes that promise.
  • constructor_self_schedule_survives_restart_but_self_call_is_rejected ran two cases that share nothing in one loop. It is now two tests, constructor_self_call_is_rejected and constructor_self_schedule_survives_restart.
  • create_waits_for_constructor_gate names the phase before the restart in grpc_create_waits_for_prepared_constructor. The phases share state, so the test stays one test.
  • restart, restart_with, within with named constants and ExecutorTest replace the hand-written restarts, timeouts and setup. The recorded-failure test still restarts with the default overrides, as before.
  • The create errors are matched as typed WorkerExecutorError values. AgentCreationFailed.details stays a text check, because it carries the message of the guest.

Tests

The worker_initialization:: tests ran before and after this change with the same result, with the split self-call test in place of the old one. The rpc::create_crash_window, rpc::held_response_restart and rpc::kept_handle tests, which the first commit changes, also ran with the same result.

Tool discovery executor tests

This part changes tool_discovery.rs. It has two commits.

Environment-state helpers (first commit)

  • TestExecutorOverrides::with_environment_state gives the executor an environment state service. It has the same shape as with_registry and with_worker_service.
  • TestEnvironmentStateService::deploy_tools and remove_tools publish or remove the tool deployment of a component. They take the environment, the ID and the revision from the component. set_tool_deployment stays for the other keys. The other test files adopt both helpers in their own parts.

Conversion (second commit)

  • DiscoveryTest replaces the setup that each test wrote by hand. HostApiAgent and the typed calls on DiscoveryTest (all_tools, tool, record_all_tools, recorded_tools, call_tool and its variants) replace the invoke and decode chains. The calls without an idempotency key still send none.
  • DynamicTool replaces the fixture of one MCP import: the deployment, the observation of the import and the credential of the tool. mcp_server serves a handler at /mcp. The three longer MCP stubs become named types with the same handler bodies.
  • OplogView::starts_of and call(start) replace the scans of Start and End entries. recorded_discovery replaces assert_recorded_discovery_snapshot. It requires exactly one End for the discovery, where the old code took the first.
  • restart and abort_and_restart replace drop(executor) and the next start. In five places, the old code changed the service between the drop and the start. That change now comes before the restart. At each of those points no invocation runs: every invocation returned, or the agent is suspended and resumes only on an explicit resume after the start.
  • The missing middleware component, the missing deployment revision, the failed first import, the host tool that is not installed and the HTTP call limit are matched as typed WorkerExecutorError values. The executor puts the cause into the message of the agent error, so that message is still a text check. The tool errors that reach the guest as Result<(), String> stay text checks.
  • dynamic_tool_http_limits_apply_before_dispatch ran three cases that share nothing in one loop. It is now three tests that call http_limit_case: dynamic_tool_per_invocation_http_limit_traps_before_dispatch, dynamic_tool_within_http_limits_dispatches_once and dynamic_tool_monthly_http_limit_suspends_before_dispatch.
  • tool_discovery_host_filters_and_uses_caller_deployment_scope, dynamic_tool_invocation_replays_committed_response_without_upstream_or_credentials and dynamic_tool_invalid_params_forces_refresh_to_distinguish_removal_from_exclusion name their phases as functions. Their last checks count the calls of all phases, so each stays one test.

Tests

The tool_discovery:: tests ran before and after this change with the same result, with the three limit tests in place of the old one. The mcp_stdout:: test, which uses deployment_state of this file, also ran with the same result. The scope_cards:: tests, which also use deployment_state, could not run in the sandbox, because their MySQL container did not start. deployment_state does not change.

@netlify

netlify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for golemcloud canceled.

Name Link
🔨 Latest commit 2340086
🔍 Latest deploy log https://app.netlify.com/projects/golemcloud/deploys/6b0b54244448522ad2319639

@vigoo vigoo changed the title Check oplog-shape invariants with shared OplogShape and OplogView test helpers Add oplog-shape, lifecycle, wait and error helpers to the executor test DSL Nov 26, 2026
vigoo and others added 8 commits November 27, 2026 13:03
…pers

Add OplogView, read-only queries over a public oplog, and OplogShape, the
settled-history invariants of golem-worker-executor-tests/tests/AGENTS.md
with named exceptions. Replace the local assert_settled_history and
terminal_count copies under api/interruption/host, the oplog filters in
websocket.rs, and the shared part of the rpc/gc_timed_cleanup.rs check.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
…elpers

Add TestWorkerExecutor::restart and restart_with with Teardown, which
restart an executor on the same storage with the start function that
created it; within, GATE_TIMEOUT and SETTLE_TIMEOUT for waits that name
what they wait for; WorkerLogEventStream::wait_for_stdout; and a typed
InvocationError from invoke_agent_session with assert_worker_error!.
Convert websocket.rs and agent.rs to use them.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Add BlobStorageDecorator and DecoratedBlobStorage to the worker-executor
test utils. A decorator overrides only the blob-storage operations it
changes; every other operation calls the wrapped storage, and the
operations that BlobStorageBackend derives from others keep that
definition over the decorator. wrap_blob_storage() gives the value of
TestExecutorOverrides::wrap_blob_storage. Replace the hand-written
BlobStorageBackend wrappers in oplog_unreadable.rs, hot_update.rs,
tool_streaming/rdbms_drop.rs, blob_mutation_storage.rs and
oplog_blob_archive.rs.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Add EmulatedWorkerService, an in-process golem.worker.v1.WorkerService
on 127.0.0.1, and TestExecutorOverrides::with_worker_service, which
points public_worker_api at it. The executor keeps its production
RemoteWorkerProxy, and each start, including restart, attaches the
executor to the service. The service forwards DeliverCardTransfer
(after the system-only check) and ResumeWorker to the executor, records
the card transfers, and can answer a delivered transfer with a lost
response. It answers every failure in the response body, so the proxy
never retries a call. Replace the LocalCardTransferProxy copies in the
permission tests and RecordingWorkerProxy and the accepting card-transfer
proxies in api/mod.rs, and remove the connect calls after each start.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Add EmulatedRegistryService, an in-process golem.registry.v1 server that
answers BatchGetCards, CreateRuntimeCard and RevokeCard from an
in-memory card store as the registry does, and
TestExecutorOverrides::with_registry, which gives the executor the
production CardServiceDefault over a GrpcRegistryService client at it.
Replace the hand-written card services in effect_permissions.rs,
agent_sdk_go/permissions.rs, agent_sdk_ts/permissions.rs and
permission_cards_scala.rs. The TypeScript and Scala tests now register
the initial cards of every agent type, because the production card
service treats a card that the registry does not have as revoked. The
Scala target's wallet now lists its live initial template card, so three
expected wallet listings of the Scala scenario include "template". Tell
test authors in tests/AGENTS.md to use these test doubles.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
…er service

Move the behaviour of LocalResumeProxy in fork.rs into
EmulatedWorkerService, and remove LocalResumeProxy,
remote_rpc_preparing_on and the wrap_worker_proxy hook. The executor
keeps its production RemoteWorkerProxy for these calls.

WorkerServiceOptions::component_owner makes the service answer
PrepareWorker and ForkWorker and fill the owner into the start of an
InvokeAgentSession. hold_after_resume and lose_resume_response hold or
lose the response of a successful resume. session_evidence() gives the
RemoteRpcEvidence counters (sessions is renamed session_requests), and
remote_rpc() gives a production RemoteInvocationRpc at the service. The
service accepts messages up to the 32 MiB default of the real worker
service. with_worker_service panics when the overrides already have a
worker service, so a helper cannot replace its caller's emulator.

The test bodies of fork.rs do not change. worker_initialization.rs gets
setup_with_worker_service, and tests/AGENTS.md names the new options.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
The standalone owner that loses its component tool activation is rejected
before acceptance, and a same-key caller of a retained startup failure gets
the failure outcome. Both tests checked only the worker error, which either
variant of InvocationError carries.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
Add InvocationStartBuilder (executor.invocation(&component, method)) and
InvocationSession (executor.open_session(start)) to the worker-executor
test DSL. The builder fills the fields that every test start repeats and
sets every other field only through a named method, so a converted start
sends the same fields as before. The session validates every frame in
both directions, sends input, stream ends and output cancellations with
the epoch and durable stream IDs of the acceptance, and reads a session to
a typed SessionOutcome.

Convert the hand-built InvocationStart literals and session loops of
rpc.rs, agent.rs, fork.rs, api/mod.rs, hot_update.rs,
invocation_context.rs, websocket_crash_probe.rs, permission_admission.rs,
tool_result_delivery.rs and standalone_tool.rs, and the DSL's own
invoke_and_await_target, invoke_agent_with_key and invoke_agent_session.
Move id_target, key_target and start_target_id from agent.rs to the DSL.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
@vigoo
vigoo force-pushed the test-dsl-oplog-shape branch from 38ed055 to f599752 Compare November 27, 2026 14:38
vigoo and others added 16 commits November 27, 2026 15:31
CrashCheckpointServer and PromiseCheckpointServer replace the tuple-returning
start functions of tool_streaming/mod.rs. agent_env(prefix) replaces the
hand-built env maps, reach(name) replaces next_*_checkpoint, and
CrashCheckpoint::release() replaces sending on the release channel.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
LocalHttpServer::serve(router) binds 127.0.0.1:0, serves the router in the
current tracing span and stops the server on drop. The axum stubs of the
executor tests outside tool_streaming use it; helpers and fixtures that kept
the server task now keep the server.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
Replace the tool_streaming deployment_state fixture and its positional
arguments with the ToolDeployment builder in golem-worker-executor-test-utils.
The provider name defaults to the stored component name; sites whose stored
component name differs set it explicitly.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
Move InvocationStartBuilder, InvocationSession, InvocationError and
assert_worker_error! to golem-test-framework, so that the executor DSL
and the integration DSL build and read invocation sessions with the
same code. TestUserContext opens sessions on the worker service.
The reattaching session of the integration tests is now
ReattachingSession.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
Replace the make_test_context function chain with a builder, share
the domain environment prelude between the HTTP and MCP contexts as
DomainEnvironment, and write the per-database test dependencies
with per_database_test_context!.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
Replace the 15-field DeploymentCreation literals and the local
deployment_creation helpers with deployment_from_plan and
struct-update overrides, and build the default deployment of
deploy_environment_with with it.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
Add TestExecutorOverrides::configured and TestDsl::invoke_and_await_typed
(with a _with_key variant). In websocket.rs, a WebsocketTest fixture and a
configurable in-process TestPeer replace the repeated setup and nine copies
of a websocket server. Typed results replace raw schema value comparisons,
the longest tests run their phases as named functions, related checks are
grouped with labels, and the four independent cases of the replacement
crash test are now four tests.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
…ion helpers

Add ExecutorTest, spawn_invoke_and_await and wait_for_oplog to the executor
test utilities, and use ExecutorTest in place of the websocket file's own
fixture.

In wasi.rs, decode results into typed values, replace hand-made restarts
with restart, read oplogs through OplogView, match interrupt and guest
failures by their worker error, name the timeouts, and move repeated setup
into small fixtures. The longest tests now run in labeled phases. No
scenario or check is removed.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
… helpers

The first half of rpc.rs covers unary RPC, RPC suspension, RPC memory and
durable output streams. Its tests now use the shared test DSL instead of
hand-written setup, restarts, timeouts, polling loops and oplog scans.

Three helpers are new. wait_for_suspended_unload waits until an agent is
suspended and unloaded. OplogView::method_starts finds the starts of a
method. OutputLedger records the frames of invocation sessions and checks
the output wire contract on each one; four session readers use it instead
of their own partial checks.

The longest tests put their phases in named functions or labelled steps.
Every old assertion is kept, and the rpc tests give the same results.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
…eports

Convert the second half of rpc.rs: the input-stream, joined-origin, fork,
revert, generated-client, kept-handle and cancellation tests.

The tests use ExecutorTest, restart, within with named timeouts,
spawn_invoke_and_await, wait_for_oplog and OplogView instead of hand-written
setup, spawns, timeouts and oplog scans. OutputLedger checks the output wire
contract in the TypeScript guest-ABI and Effect websocket tests. The generated
client and reflection reports decode into structs that mirror the guest types.
KeptHandle and TsCancelledCall hold the setup shared by the kept-handle and
cancellation tests, and scenario loops run each case in a named function.
The joined-origin tests match PreviousInvocationFailed instead of its text.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
…t DSL

RpcDecorator gives each Rpc method the wrapped Rpc and forwards to it by
default, so a test double overrides only the methods it changes. The four
hand-written Rpc wrappers in the rpc submodules, and RecordingRpc and
FailingRpc, now implement it instead of forwarding every method by hand.

Also add TestWorkerExecutor::abort_and_restart for the crash window that
aborts a running invocation and restarts the executor,
TestWorkerExecutor::committed_oplog, and OplogView::last_index_of and
OplogView::invocation_starts.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
The eight tests files under rpc/ now use ExecutorTest, the restart and
crash-window helpers, within with named timeouts, and OplogView instead
of hand-written setup, restarts, polls and oplog scans.

rpc.rs gets helpers the submodules share: snapshot_every_nth_invocation,
expect_snapshot_loaded and expect_snapshot_rejected, stored_create_requests,
agent_caller, is_rpc_not_found, KeptHandle::keep_with, and TsPromiseId,
a derived schema type for TypeScript promise IDs.

The duplex websocket crash probe is split into a test with a crash and
one without. The completed-invocation cache repair test and the input GC
scenario name their phases. The kept-handle deletion tests match the
typed invocation error instead of its formatted text.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
…he test DSL

StoredOplogView queries the stored oplog that stored_oplog returns: the
counts of pending, started and finished invocation entries, the positions
of one invocation's entries, and the Create requests.

TestWorkerExecutor::send_create_worker and send_prepare_worker send a
CreateWorkerRequest and decode the response into its success record or
the typed WorkerExecutorError.

CALL_TIMEOUT (20 s) joins GATE_TIMEOUT and SETTLE_TIMEOUT. It replaces the
local TERMINAL_TIMEOUT of the rpc tests, and the rpc tests read Create
requests through StoredOplogView.

Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
Co-authored-by: Amp <amp@ampcode.com>
The worker initialization tests and their invocation receipt and create
config admission submodules now use ExecutorTest, restart, within with
named timeouts, StoredOplogView and the typed create senders instead of
hand-written setup, restarts, timeouts, oplog counts and response decoding.

InitializationTest replaces the setup functions that returned tuples.
system_create_request builds the create requests, and ConstructorGate
waits for the promise index that a constructor prints and completes it.

The self-call test ran two independent cases in one loop. It is now two
tests: constructor_self_call_is_rejected and
constructor_self_schedule_survives_restart.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
…st DSL

TestExecutorOverrides::with_environment_state gives the executor an
environment state service, as with_registry and with_worker_service do for
their services.

TestEnvironmentStateService::deploy_tools and remove_tools publish or
remove the tool deployment of a component, keyed by its environment, ID
and revision.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386
The tool discovery tests now use DiscoveryTest for their setup, typed
calls on HostApiAgent instead of invoke and decode chains, DynamicTool for
the one-import MCP fixture, OplogView queries instead of hand-written oplog
scans, restart and abort_and_restart instead of dropping and starting the
executor, and typed WorkerExecutorError matches for executor failures.

The HTTP limit test ran three independent cases in a loop. It is now three
tests that call one case function. The three longest tests name their
phases as functions and stay single tests, because their final counters
cover every phase.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a217cc-8783-7629-823d-c51f30cad386

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant