e2e

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0, Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package e2e contains utilities for end-to-end RouteLookupService tests.

Index

Constants

View Source
const (
	// RLSChildPolicyTargetNameField is a top-level field name to add to the child
	// policy's config, whose value is set to the target for the child policy.
	RLSChildPolicyTargetNameField = "Backend"
	// RLSChildPolicyBadTarget is a value which is considered a bad target by the
	// child policy. This is useful to test bad child policy configuration.
	RLSChildPolicyBadTarget = "bad-target"
)

Variables

View Source
var ErrParseConfigBadTarget = errors.New("backend field set to RLSChildPolicyBadTarget")

ErrParseConfigBadTarget is the error returned from ParseConfig when the backend field is set to RLSChildPolicyBadTarget.

Functions

func RegisterRLSChildPolicy

func RegisterRLSChildPolicy(name string, bf *BalancerFuncs)

RegisterRLSChildPolicy registers a balancer builder with the given name, to be used as a child policy for the RLS LB policy.

The child policy uses a pickfirst balancer under the hood to send all traffic to the single backend specified by the `RLSChildPolicyTargetNameField` field in its configuration which looks like: {"Backend": "Backend-address"}.

Types

type BalancerFuncs

type BalancerFuncs struct {
	UpdateClientConnState func(cfg *RLSChildPolicyConfig) error
	Close                 func()
}

BalancerFuncs is a set of callbacks which get invoked when the corresponding method on the child policy is invoked.

type FakeRouteLookupServer

type FakeRouteLookupServer struct {
	rlsgrpc.UnimplementedRouteLookupServiceServer
	Address string
	// contains filtered or unexported fields
}

FakeRouteLookupServer is a fake implementation of the RouteLookupService.

It is safe for concurrent use.

func StartFakeRouteLookupServer

func StartFakeRouteLookupServer(t *testing.T, lis net.Listener, opts ...grpc.ServerOption) (*FakeRouteLookupServer, func())

StartFakeRouteLookupServer starts a fake RLS server listening for requests on lis. If lis is nil, it creates a new listener on a random local port. The returned cancel function should be invoked by the caller upon completion of the test.

func (*FakeRouteLookupServer) RouteLookup

RouteLookup implements the RouteLookupService.

func (*FakeRouteLookupServer) SetRequestCallback

func (s *FakeRouteLookupServer) SetRequestCallback(f func(*rlspb.RouteLookupRequest))

SetRequestCallback sets a callback to be invoked on every RLS request. The callback is given the incoming request, and tests can use this to verify that the request matches its expectations.

func (*FakeRouteLookupServer) SetResponseCallback

SetResponseCallback sets a callback to be invoked on every RLS request. If this callback is set, the response returned by the fake server depends on the value returned by the callback. If this callback is not set, the fake server responds with an empty response.

type RLSChildPolicyConfig

type RLSChildPolicyConfig struct {
	serviceconfig.LoadBalancingConfig
	Backend string // The target for which this child policy was created.
	Random  string // A random field to test child policy config changes.
}

RLSChildPolicyConfig is the LB config for the test child policy.

type RLSConfig

type RLSConfig struct {
	RouteLookupConfig                *rlspb.RouteLookupConfig
	ChildPolicy                      *internalserviceconfig.BalancerConfig
	ChildPolicyConfigTargetFieldName string
}

RLSConfig is a utility type to build service config for the RLS LB policy.

func (*RLSConfig) LoadBalancingConfig

func (c *RLSConfig) LoadBalancingConfig() (serviceconfig.LoadBalancingConfig, error)

LoadBalancingConfig generates load balancing config which can used as part of a ClientConnState update to the RLS LB policy.

func (*RLSConfig) ServiceConfigJSON

func (c *RLSConfig) ServiceConfigJSON() (string, error)

ServiceConfigJSON generates service config with a load balancing config corresponding to the RLS LB policy.

type RouteLookupResponse

type RouteLookupResponse struct {
	Resp *rlspb.RouteLookupResponse
	Err  error
}

RouteLookupResponse wraps an RLS response and the associated error to be sent to a client when the RouteLookup RPC is invoked.

Jump to

Keyboard shortcuts

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