fakeserver

package
v1.68.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package fakeserver provides a fake implementation of the management server.

This package is recommended only for scenarios which cannot be tested using the xDS management server (which uses envoy-go-control-plane) provided by the `internal/testutils/xds/e2e` package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Req proto.Message
	Err error
}

Request wraps the request protobuf (xds/LRS) and error received by the Server in a call to stream.Recv().

type Response

type Response struct {
	Resp proto.Message
	Err  error
}

Response wraps the response protobuf (xds/LRS) and error that the Server should send out to the client through a call to stream.Send()

type Server

type Server struct {
	// XDSRequestChan is a channel on which received xDS requests are made
	// available to the users of this Server.
	XDSRequestChan *testutils.Channel
	// XDSResponseChan is a channel on which the Server accepts xDS responses
	// to be sent to the client.
	XDSResponseChan chan *Response
	// LRSRequestChan is a channel on which received LRS requests are made
	// available to the users of this Server.
	LRSRequestChan *testutils.Channel
	// LRSResponseChan is a channel on which the Server accepts the LRS
	// response to be sent to the client.
	LRSResponseChan chan *Response
	// LRSStreamOpenChan is a channel on which the Server sends notifications
	// when a new LRS stream is created.
	LRSStreamOpenChan *testutils.Channel
	// LRSStreamCloseChan is a channel on which the Server sends notifications
	// when an existing LRS stream is closed.
	LRSStreamCloseChan *testutils.Channel
	// NewConnChan is a channel on which the fake server notifies receipt of new
	// connection attempts. Tests can gate on this event before proceeding to
	// other actions which depend on a connection to the fake server being up.
	NewConnChan *testutils.Channel
	// Address is the host:port on which the Server is listening for requests.
	Address string
	// contains filtered or unexported fields
}

Server is a fake implementation of xDS and LRS protocols. It listens on the same port for both services and exposes a bunch of channels to send/receive messages.

This server is recommended only for scenarios which cannot be tested using the xDS management server (which uses envoy-go-control-plane) provided by the `internal/testutils/xds/e2e` package.

func NewServer

func NewServer(addr string) *Server

NewServer returns a new instance of Server, set to accept requests on addr. It is the responsibility of the caller to register the exported ADS and LRS services on an appropriate gRPC server. Most usages should prefer StartServer() instead of this.

func StartServer

func StartServer(lis net.Listener) (*Server, func(), error)

StartServer makes a new Server and gets it to start listening on the given net.Listener. If the given net.Listener is nil, a new one is created on a local port for gRPC requests. The returned cancel function should be invoked by the caller upon completion of the test.

func (Server) StreamLoadStats

func (lrsS Server) StreamLoadStats(s v3lrsgrpc.LoadReportingService_StreamLoadStatsServer) error

Jump to

Keyboard shortcuts

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