dataplanetest

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package dataplanetest runs a dataplane for a test, either constructed directly or assembled from the production fx modules, together with the fake upstreams and connections needed to drive it.

Index

Constants

View Source
const (
	// DefaultUpstream is the name [Config] gives the upstream it wires up.
	DefaultUpstream = "workers"
)

Variables

This section is empty.

Functions

func Config

func Config(up *Upstream) *config.Config

Config returns a minimal valid configuration: an ephemeral gateway port and one upstream named DefaultUpstream pointed at up, routed to by default.

func DeadUpstream

func DeadUpstream(t *testing.T) string

DeadUpstream returns a loopback address with nothing behind it, by taking a port from the kernel and immediately giving it back. The window in which something else could claim that port is small enough to live with in a test, and it is the only way to name an address that is guaranteed unreachable now and free later.

func DialUnix

func DialUnix(t *testing.T, path string) *grpc.ClientConn

DialUnix returns a client connection to the unix socket at path, closed when the test ends.

Types

type Fixture

type Fixture struct {
	// contains filtered or unexported fields
}

Fixture is a running dataplane and the connections needed to drive it. It stops when the test ends.

func Start

func Start(t *testing.T, cfg *config.Config) *Fixture

Start constructs a dataplane directly, the way the production fx module does, and starts it. Every request is admitted and no vault is built, so a cfg configuring inbound auth or encryption is rejected rather than silently exercised without them; use StartApp for those.

func StartApp

func StartApp(t *testing.T, cfg *config.Config) *Fixture

StartApp assembles and starts the whole production module graph around cfg, so config-driven collaborators the dataplane cannot build for itself, an inbound authenticator and an encryption vault, come from the same modules production uses. Prefer Start when a test needs neither.

func (*Fixture) Addr

func (f *Fixture) Addr() string

Addr is the address the gateway is accepting on.

func (*Fixture) Client

Client is a WorkflowService client on the gateway connection.

func (*Fixture) Context

func (f *Fixture) Context() context.Context

Context returns a context for one request, bounded by a deadline so a call that never completes fails the test rather than hanging it.

func (*Fixture) UpstreamConn

func (f *Fixture) UpstreamConn(name string) *grpc.ClientConn

UpstreamConn is a client connection to the named upstream's own unix socket, the path a local worker bypassing the gateway would dial.

type Upstream

type Upstream struct {
	workflowservice.UnimplementedWorkflowServiceServer
	// contains filtered or unexported fields
}

Upstream is a fake Temporal frontend standing in for the service a dataplane forwards to. It records every request and its metadata, answers GetSystemInfo with an empty response, and echoes QueryWorkflow's arguments back as its result.

func NewTLSUpstream

func NewTLSUpstream(t *testing.T) *Upstream

NewTLSUpstream starts a fake frontend over TLS. Its Upstream.TLSConfig carries the CA and client identity needed to dial it, which is the only way to exercise credentials that refuse to travel over an insecure transport.

func NewUpstream

func NewUpstream(t *testing.T) *Upstream

NewUpstream starts a fake frontend on a loopback port over plaintext and stops it when the test ends.

func (*Upstream) Addr

func (u *Upstream) Addr() string

Addr is the host:port the fake frontend is accepting on.

func (*Upstream) GetSystemInfo

GetSystemInfo records the call and answers with an empty response. It is the smallest WorkflowService method that needs no namespace argument.

func (*Upstream) Metadata

func (u *Upstream) Metadata() metadata.MD

Metadata is the incoming metadata of the most recent request, or nil before the first one arrives.

func (*Upstream) QueryWorkflow

QueryWorkflow records the call and echoes the query arguments back as the result, so one call exercises both directions of an interceptor that rewrites payloads.

func (*Upstream) Requests

func (u *Upstream) Requests() []proto.Message

Requests returns every request received so far, in arrival order.

func (*Upstream) TLSConfig

func (u *Upstream) TLSConfig() *config.TLSConfig

TLSConfig is the client-side configuration needed to dial this upstream, or nil when it serves plaintext.

Jump to

Keyboard shortcuts

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