testautoflow

package
v19.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness struct {
	Flowcore *flowcore.Engine
	Autocore autocore.Client
	DB       *pgxpool.Pool
	// ChannelTokens is what a module would be given in production. A module under
	// test is built before the harness, so a test that needs it hands its module an
	// indirection and fills it in from here.
	ChannelTokens *flowcore.ChannelTokens
	// contains filtered or unexported fields
}

Harness runs real AutoFlow flows on a production-shaped autocore engine. Flowcore drives flows; Autocore is the autocore-level client for workflow state lookups; DB is the autocore-level escape hatch for fault injection and assertions (e.g. testautocore.WaitForState(t, h.DB, ...)).

func NewHarness

func NewHarness(t *testing.T, central, workflow *pgxpool.Pool, redis rueidis.Client, opts ...Option) *Harness

NewHarness builds the production AutoFlow composition against the per-test central and workflow databases (e.g. from AutocorePostgres.WithDBs), runs the engine, and blocks until it owns its shards.

func (*Harness) Stop added in v19.4.0

func (h *Harness) Stop(t *testing.T)

Stop shuts the autocore engine down and waits for it to return, failing the test if it has not within engineStopTimeout. The harness cleanup stops the engine as well, so only a test observing the shutdown itself calls Stop.

type Option

type Option func(*config)

Option configures a Harness.

func WithLogger added in v19.4.0

func WithLogger(log *slog.Logger) Option

WithLogger makes the engine log through log rather than through the test's own output, for a test that reads the log back.

func WithMaxSuspendedWorkflows added in v19.3.0

func WithMaxSuspendedWorkflows(n int) Option

WithMaxSuspendedWorkflows overrides how many workflow goroutines may stay suspended between rounds. Pass 0 to make every suspension fail, which turns every round into a cold replay: the only way for a test to exercise the replay path, since a warm resume continues the goroutine from its yield instead.

func WithMeterProvider added in v19.4.0

func WithMeterProvider(mp metric.MeterProvider) Option

WithMeterProvider records the metrics of the engine and of its database pools with mp. Without it they are dropped.

func WithModules

func WithModules(m ...pkg_autoflow.Module) Option

WithModules registers AutoFlow modules (real or a generated MockModule) for the flow under test. Loading an unregistered module name fails the flow with a clear error.

func WithPoolOptions added in v19.4.0

func WithPoolOptions(opts ...pgtool.PoolOption) Option

WithPoolOptions applies opts to every runtime pool the engine opens on the central and workflow databases, ahead of the engine's own options, so the engine's settings win where they overlap. DDL and migration handles are not affected. For tests that observe the engine's statements.

func WithTracerProvider added in v19.4.0

func WithTracerProvider(tp trace.TracerProvider) Option

WithTracerProvider records the spans of the engine and of its database pools with tp. Without it they are dropped.

func WithWorkflows added in v19.4.0

func WithWorkflows(register ...func(*autocore.Registry) error) Option

WithWorkflows registers autocore workflows on the harness registry before the engine starts, for tests that drive Go workflows rather than AutoFlow flows.

type RemoteModule

type RemoteModule struct {
	TB           testing.TB
	Client       pkg_autoflow_rpc.ModuleAPIClient
	TunnelClient pkg_autoflow_rpc.ModuleTunnelAPIClient
	// contains filtered or unexported fields
}

RemoteModule is a remote AutoFlow module that can be used for testing.

func (*RemoteModule) Registered added in v19.4.0

func (m *RemoteModule) Registered() <-chan struct{}

Registered is closed once kas has accepted the module descriptor. A workflow that loads the module before that fails, so start workflows only after this is closed.

func (*RemoteModule) Run

func (m *RemoteModule) Run(ctx context.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL