testutils

package
v1.54.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var EmptyNodeProtoV2 = &v2corepb.Node{}

EmptyNodeProtoV2 is a v2 Node proto with no fields set.

View Source
var EmptyNodeProtoV3 = &v3corepb.Node{}

EmptyNodeProtoV3 is a v3 Node proto with no fields set.

Functions

func BuildResourceName added in v1.44.0

func BuildResourceName(typ xdsresource.ResourceType, auth, id string, ctxParams map[string]string) string

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

func LocalityIDToProto added in v1.31.0

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

LocalityIDToProto converts a LocalityID to its proto representation.

func ServerConfigForAddress added in v1.54.0

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.

Types

type AddLocalityOptions added in v1.32.0

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

AddLocalityOptions contains options when adding locality to the builder.

type ClusterLoadAssignmentBuilder added in v1.32.0

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

ClusterLoadAssignmentBuilder builds a ClusterLoadAssignment, aka EDS response.

func NewClusterLoadAssignmentBuilder added in v1.32.0

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

NewClusterLoadAssignmentBuilder creates a ClusterLoadAssignmentBuilder.

func (*ClusterLoadAssignmentBuilder) AddLocality added in v1.32.0

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

AddLocality adds a locality to the builder.

func (*ClusterLoadAssignmentBuilder) Build added in v1.32.0

Build builds ClusterLoadAssignment.

type TestResourceWatcher added in v1.54.0

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
}

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 the channels provided by this tyep to get access to updates and errors sent by the xDS client.

func NewTestResourceWatcher added in v1.54.0

func NewTestResourceWatcher() *TestResourceWatcher

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

func (*TestResourceWatcher) OnError added in v1.54.0

func (w *TestResourceWatcher) OnError(err error)

OnError is invoked by the xDS client to report errors.

func (*TestResourceWatcher) OnResourceDoesNotExist added in v1.54.0

func (w *TestResourceWatcher) OnResourceDoesNotExist()

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

func (*TestResourceWatcher) OnUpdate added in v1.54.0

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

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

Directories

Path Synopsis
Package fakeclient provides a fake implementation of an xDS client.
Package fakeclient provides a fake implementation of an xDS client.

Jump to

Keyboard shortcuts

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