rls

package
v1.68.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package rls contains utilities for RouteLookupService e2e tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 SetupFakeRLSServer

func SetupFakeRLSServer(t *testing.T, lis net.Listener, opts ...grpc.ServerOption) (*FakeRouteLookupServer, chan struct{})

SetupFakeRLSServer starts and returns a fake RouteLookupService server listening on the given listener or on a random local port. Also returns a channel for tests to get notified whenever the RouteLookup RPC is invoked on the fake server.

This function sets up the fake server to respond with an empty response for the RouteLookup RPCs. Tests can override this by calling the SetResponseCallback() method on the returned fake server.

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 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