Documentation
¶
Index ¶
- type Harness
- type Option
- func WithLogger(log *slog.Logger) Option
- func WithMaxSuspendedWorkflows(n int) Option
- func WithMeterProvider(mp metric.MeterProvider) Option
- func WithModules(m ...pkg_autoflow.Module) Option
- func WithPoolOptions(opts ...pgtool.PoolOption) Option
- func WithTracerProvider(tp trace.TracerProvider) Option
- func WithWorkflows(register ...func(*autocore.Registry) error) Option
- type RemoteModule
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.
type Option ¶
type Option func(*config)
Option configures a Harness.
func WithLogger ¶ added in v19.4.0
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
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.
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)