...

Package testutils

import "google.golang.org/grpc/xds/internal/testutils"
Overview
Index
Subdirectories

Overview ▾

Package testutils provides utility types, for use in xds tests.

Variables

EmptyNodeProtoV2 is a v2 Node proto with no fields set.

var EmptyNodeProtoV2 = &v2corepb.Node{}

EmptyNodeProtoV3 is a v3 Node proto with no fields set.

var EmptyNodeProtoV3 = &v3corepb.Node{}

func BuildResourceName

func BuildResourceName(typeName, auth, id string, ctxParams map[string]string) string

BuildResourceName returns the resource name in the format of an xdstp:// resource.

func LocalityIDToProto

func LocalityIDToProto(l internal.LocalityID) *v2corepb.Locality

LocalityIDToProto converts a LocalityID to its proto representation.

func ServerConfigForAddress

func ServerConfigForAddress(t *testing.T, addr string) *bootstrap.ServerConfig

ServerConfigForAddress returns a bootstrap.ServerConfig for the given address with default values of insecure channel_creds and v3 server_features.

type AddLocalityOptions

AddLocalityOptions contains options when adding locality to the builder.

type AddLocalityOptions struct {
    Health []v2corepb.HealthStatus
    Weight []uint32
}

type ClusterLoadAssignmentBuilder

ClusterLoadAssignmentBuilder builds a ClusterLoadAssignment, aka EDS response.

type ClusterLoadAssignmentBuilder struct {
    // contains filtered or unexported fields
}

func NewClusterLoadAssignmentBuilder

func NewClusterLoadAssignmentBuilder(clusterName string, dropPercents map[string]uint32) *ClusterLoadAssignmentBuilder

NewClusterLoadAssignmentBuilder creates a ClusterLoadAssignmentBuilder.

func (*ClusterLoadAssignmentBuilder) AddLocality

func (clab *ClusterLoadAssignmentBuilder) AddLocality(subzone string, weight uint32, priority uint32, addrsWithPort []string, opts *AddLocalityOptions)

AddLocality adds a locality to the builder.

func (*ClusterLoadAssignmentBuilder) Build

func (clab *ClusterLoadAssignmentBuilder) Build() *v2xdspb.ClusterLoadAssignment

Build builds ClusterLoadAssignment.

type TestResourceWatcher

TestResourceWatcher implements the xdsresource.ResourceWatcher interface, used to receive updates on watches registered with the xDS client, when using the resource-type agnostic WatchResource API.

Tests can use the channels provided by this type to get access to updates and errors sent by the xDS client.

type TestResourceWatcher struct {
    // UpdateCh is the channel on which xDS client updates are delivered.
    UpdateCh chan *xdsresource.ResourceData
    // ErrorCh is the channel on which errors from the xDS client are delivered.
    ErrorCh chan error
    // ResourceDoesNotExistCh is the channel used to indicate calls to OnResourceDoesNotExist
    ResourceDoesNotExistCh chan struct{}
}

func NewTestResourceWatcher

func NewTestResourceWatcher() *TestResourceWatcher

NewTestResourceWatcher returns a TestResourceWatcher to watch for resources via the xDS client.

func (*TestResourceWatcher) OnError

func (w *TestResourceWatcher) OnError(err error)

OnError is invoked by the xDS client to report the latest error.

func (*TestResourceWatcher) OnResourceDoesNotExist

func (w *TestResourceWatcher) OnResourceDoesNotExist()

OnResourceDoesNotExist is used by the xDS client to report that the resource being watched no longer exists.

func (*TestResourceWatcher) OnUpdate

func (w *TestResourceWatcher) OnUpdate(data xdsresource.ResourceData)

OnUpdate is invoked by the xDS client to report the latest update on the resource being watched.

Subdirectories

Name Synopsis
..