package fakexds

import "google.golang.org/grpc/xds/internal/client/fakexds"

Package fakexds provides a very basic fake implementation of the xDS server for unit testing purposes.

Index

Types

type LRSServer

type LRSServer struct {
	// ReportingInterval will be sent in the first response to control reporting
	// interval.
	ReportingInterval *durationpb.Duration
	// ExpectedEDSClusterName is checked against the first LRS request. The RPC
	// is failed if they don't match.
	ExpectedEDSClusterName string
	// contains filtered or unexported fields
}

LRSServer implements the LRS service, and is to be installed on the fakexds server. It collects load reports, and returned them later for comparison.

func (*LRSServer) GetDrops

func (lrss *LRSServer) GetDrops() map[string]uint64

GetDrops returns the drops reported to this server.

func (*LRSServer) StreamLoadStats

func (lrss *LRSServer) StreamLoadStats(stream lrsgrpc.LoadReportingService_StreamLoadStatsServer) error

StreamLoadStats implements LRS service.

type Request

type Request struct {
	Req *discoverypb.DiscoveryRequest
	Err error
}

Request wraps an xDS request and error.

type Response

type Response struct {
	Resp *discoverypb.DiscoveryResponse
	Err  error
}

Response wraps an xDS response and error.

type Server

type Server struct {
	// RequestChan is a buffered channel on which the fake server writes the
	// received requests onto.
	RequestChan chan *Request
	// ResponseChan is a buffered channel from which the fake server reads the
	// responses that it must send out to the client.
	ResponseChan chan *Response
	// Address is the host:port on which the fake xdsServer is listening on.
	Address string
	// LRS is the LRS server installed.
	LRS *LRSServer
}

Server is a very basic implementation of a fake xDS server. It provides a request and response channel for the user to control the requests that are expected and the responses that needs to be sent out.

func StartServer

func StartServer(t *testing.T) (*Server, func())

StartServer starts a fakexds.Server. The returned function should be invoked by the caller once the test is done.

func (*Server) DeltaAggregatedResources

DeltaAggregatedResources helps implement the ADS service.

func (*Server) GetClientConn

func (fs *Server) GetClientConn(t *testing.T) (*grpc.ClientConn, func())

GetClientConn returns a grpc.ClientConn talking to the fake server. The returned function should be invoked by the caller once the test is done.

func (*Server) StreamAggregatedResources

StreamAggregatedResources is the fake implementation to handle an ADS stream.

Source Files

fakexds.go lrsserver.go

Version
v1.26.0
Published
Dec 17, 2019
Platform
js/wasm
Imports
17 packages
Last checked
4 minutes ago

Tools for package owners.