grpc: google.golang.org/grpc/xds/internal/client/fakexds Index | Files

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

Package Files

fakexds.go lrsserver.go

type LRSServer Uses

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 Uses

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

GetDrops returns the drops reported to this server.

func (*LRSServer) StreamLoadStats Uses

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

StreamLoadStats implements LRS service.

type Request Uses

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

Request wraps an xDS request and error.

type Response Uses

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

Response wraps an xDS response and error.

type Server Uses

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 Uses

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 Uses

func (fs *Server) DeltaAggregatedResources(adsgrpc.AggregatedDiscoveryService_DeltaAggregatedResourcesServer) error

DeltaAggregatedResources helps implement the ADS service.

func (*Server) GetClientConn Uses

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 Uses

func (fs *Server) StreamAggregatedResources(s adsgrpc.AggregatedDiscoveryService_StreamAggregatedResourcesServer) error

StreamAggregatedResources is the fake implementation to handle an ADS stream.

Package fakexds imports 17 packages (graph). Updated 2019-12-01. Refresh now. Tools for package owners.