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
- func Config(up *Upstream) *config.Config
- func DeadUpstream(t *testing.T) string
- func DialUnix(t *testing.T, path string) *grpc.ClientConn
- type Fixture
- type Upstream
- func (u *Upstream) Addr() string
- func (u *Upstream) GetSystemInfo(ctx context.Context, req *workflowservice.GetSystemInfoRequest) (*workflowservice.GetSystemInfoResponse, error)
- func (u *Upstream) Listen() config.ListenConfig
- func (u *Upstream) Metadata() metadata.MD
- func (u *Upstream) QueryWorkflow(ctx context.Context, req *workflowservice.QueryWorkflowRequest) (*workflowservice.QueryWorkflowResponse, error)
- func (u *Upstream) Requests() []proto.Message
Constants ¶
const (
// DefaultUpstream is the name [Config] gives the upstream it wires up.
DefaultUpstream = "workers"
)
Variables ¶
This section is empty.
Functions ¶
func 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 ¶
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.
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 ¶
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 ¶
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) Client ¶
func (f *Fixture) Client() workflowservice.WorkflowServiceClient
Client is a WorkflowService client on the gateway connection.
func (*Fixture) 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 ¶
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 ¶
NewUpstream starts a fake frontend on a loopback port over plaintext and stops it when the test ends.
func (*Upstream) GetSystemInfo ¶
func (u *Upstream) GetSystemInfo( ctx context.Context, req *workflowservice.GetSystemInfoRequest, ) (*workflowservice.GetSystemInfoResponse, error)
GetSystemInfo records the call and answers with an empty response. It is the smallest WorkflowService method that needs no namespace argument.
func (*Upstream) Listen ¶ added in v0.6.0
func (u *Upstream) Listen() config.ListenConfig
Listen is the client-side configuration needed to dial this upstream. A plaintext fake has to say so explicitly, because a target with no TLS block verifies the peer against the system root pool.
func (*Upstream) Metadata ¶
Metadata is the incoming metadata of the most recent request, or nil before the first one arrives.
func (*Upstream) QueryWorkflow ¶
func (u *Upstream) QueryWorkflow( ctx context.Context, req *workflowservice.QueryWorkflowRequest, ) (*workflowservice.QueryWorkflowResponse, error)
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.