package testutils

import "google.golang.org/grpc/xds/internal/testutils"

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

Index

Functions

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.

Types

type TestResourceWatcher

type TestResourceWatcher struct {
	// UpdateCh is the channel on which xDS client updates are delivered.
	UpdateCh chan *xdsresource.ResourceData
	// AmbientErrorCh is the channel on which ambient errors from the xDS
	// client are delivered.
	AmbientErrorCh chan error
	// ResourceErrorCh is the channel on which resource errors from the xDS
	// client are delivered.
	ResourceErrorCh chan struct{}
}

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.

func NewTestResourceWatcher

func NewTestResourceWatcher() *TestResourceWatcher

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

func (*TestResourceWatcher) AmbientError

func (w *TestResourceWatcher) AmbientError(err error, onDone func())

AmbientError is invoked by the xDS client to report the latest ambient error.

func (*TestResourceWatcher) ResourceChanged

func (w *TestResourceWatcher) ResourceChanged(data xdsresource.ResourceData, onDone func())

ResourceChanged is invoked by the xDS client to report the latest update.

func (*TestResourceWatcher) ResourceError

func (w *TestResourceWatcher) ResourceError(err error, onDone func())

ResourceError is invoked by the xDS client to report the latest error to stop watching the resource.

Source Files

resource_watcher.go testutils.go

Directories

PathSynopsis
xds/internal/testutils/fakeclientPackage fakeclient provides a fake implementation of an xDS client.
Version
v1.73.0 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
25 seconds ago

Tools for package owners.