e2e
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package e2e provides utilities for end2end testing of xDS functionality.
Index¶
- Constants
- Variables
- func ClusterResourceWithOptions(opts ClusterOptions) *v3clusterpb.Cluster
- func DefaultBootstrapContents(t *testing.T, nodeID, serverURI string) []byte
- func DefaultClientListener(target, routeName string) *v3listenerpb.Listener
- func DefaultCluster(clusterName, edsServiceName string, secLevel SecurityLevel) *v3clusterpb.Cluster
- func DefaultEndpoint(clusterName string, host string, ports []uint32) *v3endpointpb.ClusterLoadAssignment
- func DefaultFileWatcherConfig(certPath, keyPath, caPath string) json.RawMessage
- func DefaultRouteConfig(routeName, vhDomain, clusterName string) *v3routepb.RouteConfiguration
- func DefaultServerListener(host string, port uint32, secLevel SecurityLevel, routeName string) *v3listenerpb.Listener
- func DefaultServerListenerWithRouteConfigName(host string, port uint32, secLevel SecurityLevel, routeName string) *v3listenerpb.Listener
- func EndpointResourceWithOptions(opts EndpointOptions) *v3endpointpb.ClusterLoadAssignment
- func HTTPFilter(name string, config proto.Message) *v3httppb.HttpFilter
- func RouteConfigFilterAction(routeName string) *v3routepb.RouteConfiguration
- func RouteConfigNoRouteMatch(routeName string) *v3routepb.RouteConfiguration
- func RouteConfigNonForwardingAction(routeName string) *v3routepb.RouteConfiguration
- func RouteConfigResourceWithOptions(opts RouteConfigOptions) *v3routepb.RouteConfiguration
- func SPIFFEBootstrapContents(t *testing.T, nodeID, serverURI string) []byte
- func SPIFFEFileWatcherConfig(certPath, keyPath, caPath, spiffeBundleMapPath string) json.RawMessage
- type BackendOptions
- type ClusterOptions
- type ClusterType
- type EndpointOptions
- type LoadBalancingPolicy
- type LocalityID
- type LocalityOptions
- type ManagementServer
- type ManagementServerOptions
- type ResourceParams
- type RouteConfigClusterSpecifierType
- type RouteConfigOptions
- type SecurityLevel
- type UpdateOptions
Constants¶
const (// ServerListenerResourceNameTemplate is the Listener resource name template// used on the server side.ServerListenerResourceNameTemplate = "grpc/server?xds.resource.listening_address=%s"// ClientSideCertProviderInstance is the certificate provider instance name// used in the Cluster resource on the client side.ClientSideCertProviderInstance = "client-side-certificate-provider-instance"// ServerSideCertProviderInstance is the certificate provider instance name// used in the Listener resource on the server side.ServerSideCertProviderInstance = "server-side-certificate-provider-instance")
Variables¶
var RouterHTTPFilter =HTTPFilter("router", &v3routerpb.Router{})RouterHTTPFilter is the HTTP Filter configuration for the Router filter.
Functions¶
funcClusterResourceWithOptions¶added inv1.50.0
func ClusterResourceWithOptions(optsClusterOptions) *v3clusterpb.Cluster
ClusterResourceWithOptions returns an xDS Cluster resource configured withthe provided options.
funcDefaultBootstrapContents¶added inv1.58.0
DefaultBootstrapContents creates a default bootstrap configuration with thegiven node ID and server URI. It also creates certificate providerconfiguration and sets the listener resource name template to be used on theserver side.
funcDefaultClientListener¶
func DefaultClientListener(target, routeNamestring) *v3listenerpb.Listener
DefaultClientListener returns a basic xds Listener resource to be used onthe client side.
funcDefaultCluster¶
func DefaultCluster(clusterName, edsServiceNamestring, secLevelSecurityLevel) *v3clusterpb.Cluster
DefaultCluster returns a basic xds Cluster resource.
funcDefaultEndpoint¶
func DefaultEndpoint(clusterNamestring, hoststring, ports []uint32) *v3endpointpb.ClusterLoadAssignment
DefaultEndpoint returns a basic xds Endpoint resource.
funcDefaultFileWatcherConfig¶
func DefaultFileWatcherConfig(certPath, keyPath, caPathstring)json.RawMessage
DefaultFileWatcherConfig is a helper function to create a default certificateprovider plugin configuration. The test is expected to have setup the filesappropriately before this configuration is used to instantiate providers.
funcDefaultRouteConfig¶
func DefaultRouteConfig(routeName, vhDomain, clusterNamestring) *v3routepb.RouteConfiguration
DefaultRouteConfig returns a basic xds RouteConfig resource.
funcDefaultServerListener¶
func DefaultServerListener(hoststring, portuint32, secLevelSecurityLevel, routeNamestring) *v3listenerpb.Listener
DefaultServerListener returns a basic xds Listener resource to be used on theserver side. The returned Listener resource contains an inline routeconfiguration with the name of routeName.
funcDefaultServerListenerWithRouteConfigName¶added inv1.60.0
func DefaultServerListenerWithRouteConfigName(hoststring, portuint32, secLevelSecurityLevel, routeNamestring) *v3listenerpb.Listener
DefaultServerListenerWithRouteConfigName returns a basic xds Listenerresource to be used on the server side. The returned Listener resourcecontains a RouteConfiguration resource name that needs to be resolved.
funcEndpointResourceWithOptions¶added inv1.54.0
func EndpointResourceWithOptions(optsEndpointOptions) *v3endpointpb.ClusterLoadAssignment
EndpointResourceWithOptions returns an xds Endpoint resource configured withthe provided options.
funcHTTPFilter¶
func HTTPFilter(namestring, configproto.Message) *v3httppb.HttpFilter
HTTPFilter constructs an xds HttpFilter with the provided name and config.
funcRouteConfigFilterAction¶added inv1.61.0
func RouteConfigFilterAction(routeNamestring) *v3routepb.RouteConfiguration
RouteConfigFilterAction returns an xDS RouteConfig resource which specifiesto route to a route specifying route filter action. Since this is not typenon forwarding action, this should fail requests that match to this serverside.
funcRouteConfigNoRouteMatch¶added inv1.61.0
func RouteConfigNoRouteMatch(routeNamestring) *v3routepb.RouteConfiguration
RouteConfigNoRouteMatch returns an xDS RouteConfig resource which a routewith no route match. This will be NACKed by the xDS Client.
funcRouteConfigNonForwardingAction¶added inv1.61.0
func RouteConfigNonForwardingAction(routeNamestring) *v3routepb.RouteConfiguration
RouteConfigNonForwardingAction returns an xDS RouteConfig resource whichspecifies to route to a route specifying non forwarding action. This isintended to be used on the server side for RDS requests, and corresponds tothe inline route configuration in DefaultServerListener.
funcRouteConfigResourceWithOptions¶added inv1.54.0
func RouteConfigResourceWithOptions(optsRouteConfigOptions) *v3routepb.RouteConfiguration
RouteConfigResourceWithOptions returns a RouteConfiguration resourceconfigured with the provided options.
funcSPIFFEBootstrapContents¶added inv1.73.0
SPIFFEBootstrapContents creates a bootstrap configuration with the given nodeID and server URI. It also creates certificate provider configuration usingSPIFFE certificates and sets the listener resource name template to be usedon the server side.
funcSPIFFEFileWatcherConfig¶added inv1.73.0
func SPIFFEFileWatcherConfig(certPath, keyPath, caPath, spiffeBundleMapPathstring)json.RawMessage
SPIFFEFileWatcherConfig is a helper function to create a default certificateprovider plugin configuration. The test is expected to have setup the filesappropriately before this configuration is used to instantiate providers.
Types¶
typeBackendOptions¶added inv1.57.0
type BackendOptions struct {// Ports on which the backend is accepting connections. All backends// are expected to run on localhost, hence host name is not stored here.Ports []uint32// Health status of the backend. Default is UNKNOWN which is treated the// same as HEALTHY.HealthStatusv3corepb.HealthStatus// Weight sets the backend weight. Defaults to 1.Weightuint32// Metadata sets the LB endpoint metadata (envoy.lb FilterMetadata field).// Seehttps://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/base.proto#envoy-v3-api-msg-config-core-v3-metadataMetadata map[string]any}BackendOptions contains options to configure individual backends in alocality.
typeClusterOptions¶added inv1.50.0
type ClusterOptions struct {TypeClusterType// ClusterName is the name of the Cluster resource.ClusterNamestring// ServiceName is the EDS service name of the Cluster. Applicable only when// cluster type is EDS.ServiceNamestring// ChildNames is the list of child Cluster names. Applicable only when// cluster type is Aggregate.ChildNames []string// DNSHostName is the dns host name of the Cluster. Applicable only when the// cluster type is DNS.DNSHostNamestring// DNSPort is the port number of the Cluster. Applicable only when the// cluster type is DNS.DNSPortuint32// Policy is the LB policy to be used.PolicyLoadBalancingPolicy// SecurityLevel determines the security configuration for the Cluster.SecurityLevelSecurityLevel// EnableLRS adds a load reporting configuration with a config source// pointing to self.EnableLRSbool}ClusterOptions contains options to configure a Cluster resource.
typeClusterType¶added inv1.59.0
type ClusterTypeint
ClusterType specifies the type of the Cluster resource.
const (// ClusterTypeEDS specifies a Cluster that uses EDS to resolve endpoints.ClusterTypeEDSClusterType =iota// ClusterTypeLogicalDNS specifies a Cluster that uses DNS to resolve// endpoints.ClusterTypeLogicalDNS// ClusterTypeAggregate specifies a Cluster that is made up of child// clusters.ClusterTypeAggregate)
typeEndpointOptions¶added inv1.54.0
type EndpointOptions struct {// ClusterName is the name of the Cluster resource (or EDS service name)// containing the endpoints specified below.ClusterNamestring// Host is the hostname of the endpoints. In our e2e tests, hostname must// always be "localhost".Hoststring// Localities is a set of localities belonging to this resource.Localities []LocalityOptions// DropPercents is a map from drop category to a drop percentage. If unset,// no drops are configured.DropPercents map[string]int}EndpointOptions contains options to configure an Endpoint (orClusterLoadAssignment) resource.
typeLoadBalancingPolicy¶added inv1.50.0
type LoadBalancingPolicyint
LoadBalancingPolicy determines the policy used for balancing load acrossendpoints in the Cluster.
const (// LoadBalancingPolicyRoundRobin results in the use of the weighted_target// LB policy to balance load across localities and endpoints in the cluster.LoadBalancingPolicyRoundRobinLoadBalancingPolicy =iota// LoadBalancingPolicyRingHash results in the use of the ring_hash LB policy// as the leaf policy.LoadBalancingPolicyRingHash)
typeLocalityID¶added inv1.69.0
LocalityID represents a locality identifier.
typeLocalityOptions¶added inv1.56.0
type LocalityOptions struct {// Name is the unique locality name.Namestring// Weight is the weight of the locality, used for load balancing.Weightuint32// Backends is a set of backends belonging to this locality.Backends []BackendOptions// Priority is the priority of the locality. Defaults to 0.Priorityuint32// Locality is the locality identifier. If not specified, a random// identifier is generated.LocalityLocalityID}LocalityOptions contains options to configure a Locality.
typeManagementServer¶
type ManagementServer struct {// Address is the host:port on which the management server is listening for// new connections.Addressstring// LRSServer points to the fake LRS server implementation. Set only if the// SupportLoadReportingService option was set to true when creating this// management server.LRSServer *fakeserver.Server// contains filtered or unexported fields}ManagementServer is a thin wrapper around the xDS control planeimplementation provided by envoyproxy/go-control-plane.
funcStartManagementServer¶
func StartManagementServer(t *testing.T, optsManagementServerOptions) *ManagementServer
StartManagementServer initializes a management server which implements theAggregatedDiscoveryService endpoint. The management server is initializedwith no resources. Tests should call the Update() method to change theresource snapshot held by the management server, as per by the test logic.
Registers a cleanup function on t to stop the management server.
func (*ManagementServer)Update¶
func (s *ManagementServer) Update(ctxcontext.Context, optsUpdateOptions)error
Update changes the resource snapshot held by the management server, whichupdates connected clients as required.
typeManagementServerOptions¶added inv1.49.0
type ManagementServerOptions struct {// Listener to accept connections on. If nil, a TPC listener on a local port// will be created and used.Listenernet.Listener// SupportLoadReportingService, if set, results in the load reporting// service being registered on the same port as that of ADS.SupportLoadReportingServicebool// AllowResourceSubSet allows the management server to respond to requests// before all configured resources are explicitly named in the request. The// default behavior that we want is for the management server to wait for// all configured resources to be requested before responding to any of// them, since this is how we have run our tests historically, and should be// set to true only for tests which explicitly require the other behavior.AllowResourceSubsetbool// ServerFeaturesIgnoreResourceDeletion, if set, results in a bootstrap config// where the server features list contains `ignore_resource_deletion`. This// results in gRPC ignoring resource deletions from the management server, as// per A53.ServerFeaturesIgnoreResourceDeletionbool// OnStreamOpen is called when an xDS stream is opened. The callback is// invoked with the assigned stream ID and the type URL from the incoming// request (or "" for ADS).//// Returning an error from this callback will end processing and close the// stream. OnStreamClosed will still be called.OnStreamOpen func(context.Context,int64,string)error// OnStreamClosed is called immediately prior to closing an xDS stream. The// callback is invoked with the stream ID of the stream being closed.OnStreamClosed func(int64, *v3corepb.Node)// OnStreamRequest is called when a request is received on the stream. The// callback is invoked with the stream ID of the stream on which the request// was received and the received request.//// Returning an error from this callback will end processing and close the// stream. OnStreamClosed will still be called.OnStreamRequest func(int64, *v3discoverypb.DiscoveryRequest)error// OnStreamResponse is called immediately prior to sending a response on the// stream. The callback is invoked with the stream ID of the stream on which// the response is being sent along with the incoming request and the outgoing// response.OnStreamResponse func(context.Context,int64, *v3discoverypb.DiscoveryRequest, *v3discoverypb.DiscoveryResponse)}ManagementServerOptions contains options to be passed to the managementserver during creation.
typeResourceParams¶
type ResourceParams struct {// DialTarget is the client's dial target. This is used as the name of the// Listener resource.DialTargetstring// NodeID is the id of the xdsClient to which this update is to be pushed.NodeIDstring// Host is the host of the default Endpoint resource.Hoststring// port is the port of the default Endpoint resource.Portuint32// SecLevel controls the security configuration in the Cluster resource.SecLevelSecurityLevel}ResourceParams wraps the arguments to be passed to DefaultClientResources.
typeRouteConfigClusterSpecifierType¶added inv1.54.0
type RouteConfigClusterSpecifierTypeint
RouteConfigClusterSpecifierType determines the cluster specifier type for theroute actions configured in the returned RouteConfiguration resource.
const (// RouteConfigClusterSpecifierTypeCluster results in the cluster specifier// being set to a RouteAction_Cluster.RouteConfigClusterSpecifierTypeClusterRouteConfigClusterSpecifierType =iota// RouteConfigClusterSpecifierTypeWeightedCluster results in the cluster// specifier being set to RouteAction_WeightedClusters.RouteConfigClusterSpecifierTypeWeightedCluster// RouteConfigClusterSpecifierTypeClusterSpecifierPlugin results in the// cluster specifier being set to a RouteAction_ClusterSpecifierPlugin.RouteConfigClusterSpecifierTypeClusterSpecifierPlugin)
typeRouteConfigOptions¶added inv1.54.0
type RouteConfigOptions struct {// RouteConfigName is the name of the RouteConfiguration resource.RouteConfigNamestring// ListenerName is the name of the Listener resource which uses this// RouteConfiguration.ListenerNamestring// ClusterSpecifierType determines the cluster specifier type.ClusterSpecifierTypeRouteConfigClusterSpecifierType// ClusterName is name of the cluster resource used when the cluster// specifier type is set to RouteConfigClusterSpecifierTypeCluster.//// Default value of "A" is used if left unspecified.ClusterNamestring// WeightedClusters is a map from cluster name to weights, and is used when// the cluster specifier type is set to// RouteConfigClusterSpecifierTypeWeightedCluster.//// Default value of {"A": 75, "B": 25} is used if left unspecified.WeightedClusters map[string]int// The below two fields specify the name of the cluster specifier plugin and// its configuration, and are used when the cluster specifier type is set to// RouteConfigClusterSpecifierTypeClusterSpecifierPlugin. Tests are expected// to provide valid values for these fields when appropriate.ClusterSpecifierPluginNamestringClusterSpecifierPluginConfig *anypb.Any}RouteConfigOptions contains options to configure a RouteConfigurationresource.
typeSecurityLevel¶
type SecurityLevelint
SecurityLevel allows the test to control the security level to be used in theresource returned by this package.
const (// SecurityLevelNone is used when no security configuration is required.SecurityLevelNoneSecurityLevel =iota// SecurityLevelTLS is used when security configuration corresponding to TLS// is required. Only the server presents an identity certificate in this// configuration.SecurityLevelTLS// SecurityLevelMTLS is used when security configuration corresponding to// mTLS is required. Both client and server present identity certificates in// this configuration.SecurityLevelMTLS// SecurityLevelTLSWithSystemRootCerts is used when security configuration// corresponding to TLS is required. Only the server presents an identity// certificate in this configuration and the client uses system root certs// to validate the server certificate.SecurityLevelTLSWithSystemRootCerts)
typeUpdateOptions¶
type UpdateOptions struct {// NodeID is the id of the client to which this update is to be pushed.NodeIDstring// Endpoints, Clusters, Routes, and Listeners are the updated list of xds// resources for the server. All must be provided with each Update.Endpoints []*v3endpointpb.ClusterLoadAssignmentClusters []*v3clusterpb.ClusterRoutes []*v3routepb.RouteConfigurationListeners []*v3listenerpb.Listener// SkipValidation indicates whether we want to skip validation (by not// calling snapshot.Consistent()). It can be useful for negative tests,// where we send updates that the client will NACK.SkipValidationbool}UpdateOptions wraps parameters to be passed to the Update() method.
funcDefaultClientResources¶
func DefaultClientResources(paramsResourceParams)UpdateOptions
DefaultClientResources returns a set of resources (LDS, RDS, CDS, EDS) for aclient to generically connect to one server.