Documentation ¶
Overview ¶
Package sandbox provides API for testing NSM chains such as Forwarder, NSC, NSMgrs, Registries, NSE.
Index ¶
- Constants
- func AddSRVEntry(r dnsresolve.Resolver, name, service string, u *url.URL) (err error)
- func CheckURLFree(u *url.URL) bool
- func CloneURL(u *url.URL) *url.URL
- func DialOptions(options ...DialOption) []grpc.DialOption
- func GenerateExpiringToken(duration time.Duration) token.GeneratorFunc
- func GenerateTestToken(_ credentials.AuthInfo) (string, time.Time, error)
- func NewFakeResolver() dnsresolve.Resolver
- func SetupDefaultNode(ctx context.Context, tokenGenerator token.GeneratorFunc, node *Node, ...)
- func UniqueName(prefix string) string
- func WithInsecureRPCCredentials() grpc.DialOption
- func WithInsecureStreamRPCCredentials() grpc.DialOption
- type Builder
- func (b *Builder) Build() *Domain
- func (b *Builder) SetDNSDomainName(name string) *Builder
- func (b *Builder) SetDNSResolver(d dnsresolve.Resolver) *Builder
- func (b *Builder) SetNSMgrProxySupplier(f SupplyNSMgrProxyFunc) *Builder
- func (b *Builder) SetNSMgrSupplier(f SupplyNSMgrFunc) *Builder
- func (b *Builder) SetNodeSetup(f SetupNodeFunc) *Builder
- func (b *Builder) SetNodesCount(nodesCount int) *Builder
- func (b *Builder) SetRegistryDefaultExpiration(d time.Duration) *Builder
- func (b *Builder) SetRegistryProxySupplier(f SupplyRegistryProxyFunc) *Builder
- func (b *Builder) SetRegistrySupplier(f SupplyRegistryFunc) *Builder
- func (b *Builder) SetTokenGenerateFunc(f token.GeneratorFunc) *Builder
- func (b *Builder) UseUnixSockets() *Builder
- type DialOption
- type Domain
- type EndpointEntry
- type ForwarderOption
- type NSMgrEntry
- type Node
- func (n *Node) NewClient(ctx context.Context, generatorFunc token.GeneratorFunc, ...) networkservice.NetworkServiceClient
- func (n *Node) NewEndpoint(ctx context.Context, nse *registryapi.NetworkServiceEndpoint, ...) *EndpointEntry
- func (n *Node) NewForwarder(ctx context.Context, nse *registryapi.NetworkServiceEndpoint, ...) *EndpointEntry
- func (n *Node) NewNSMgr(ctx context.Context, name string, serveURL *url.URL, ...) *NSMgrEntry
- type RegistryEntry
- type SetupNodeFunc
- type SupplyNSMgrFunc
- type SupplyNSMgrProxyFunc
- type SupplyRegistryFunc
- type SupplyRegistryProxyFunc
Constants ¶
const ( // DialTimeout is a default dial timeout for the sandbox tests DialTimeout = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func AddSRVEntry ¶ added in v1.7.0
AddSRVEntry adds a DNS record to r using name and service as the key, and the host and port in u as the values. r must be a Resolver that was created by NewFakeDNSResolver.
func CheckURLFree ¶ added in v1.1.0
CheckURLFree returns is given url is free for Listen
func DialOptions ¶ added in v1.1.0
func DialOptions(options ...DialOption) []grpc.DialOption
DialOptions is a helper method for building []grpc.DialOption for testing
func GenerateExpiringToken ¶
func GenerateExpiringToken(duration time.Duration) token.GeneratorFunc
GenerateExpiringToken returns a token generator with the specified expiration duration.
func GenerateTestToken ¶
GenerateTestToken generates test token
func NewFakeResolver ¶ added in v1.7.0
func NewFakeResolver() dnsresolve.Resolver
NewFakeResolver returns a fake Resolver that can have records added to it using AddSRVEntry.
func SetupDefaultNode ¶ added in v1.1.0
func SetupDefaultNode(ctx context.Context, tokenGenerator token.GeneratorFunc, node *Node, supplyNSMgr SupplyNSMgrFunc)
SetupDefaultNode setups NSMgr and default Forwarder on the given node
func UniqueName ¶ added in v1.1.0
UniqueName creates unique name with the given prefix
func WithInsecureRPCCredentials ¶
func WithInsecureRPCCredentials() grpc.DialOption
WithInsecureRPCCredentials makes passed call option with credentials.PerRPCCredentials insecure.
func WithInsecureStreamRPCCredentials ¶
func WithInsecureStreamRPCCredentials() grpc.DialOption
WithInsecureStreamRPCCredentials makes passed call option with credentials.PerRPCCredentials insecure.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder implements builder pattern for building NSM Domain
func NewBuilder ¶
NewBuilder creates new SandboxBuilder
func (*Builder) SetDNSDomainName ¶
SetDNSDomainName sets DNS domain name for the building NSM domain
func (*Builder) SetDNSResolver ¶
func (b *Builder) SetDNSResolver(d dnsresolve.Resolver) *Builder
SetDNSResolver sets DNS resolver for proxy registries
func (*Builder) SetNSMgrProxySupplier ¶
func (b *Builder) SetNSMgrProxySupplier(f SupplyNSMgrProxyFunc) *Builder
SetNSMgrProxySupplier replaces default nsmgr-proxy supplier to custom function
func (*Builder) SetNSMgrSupplier ¶
func (b *Builder) SetNSMgrSupplier(f SupplyNSMgrFunc) *Builder
SetNSMgrSupplier replaces default nsmgr supplier to custom function
func (*Builder) SetNodeSetup ¶
func (b *Builder) SetNodeSetup(f SetupNodeFunc) *Builder
SetNodeSetup replaces default node setup to custom function
func (*Builder) SetNodesCount ¶
SetNodesCount sets nodes count
func (*Builder) SetRegistryDefaultExpiration ¶ added in v1.7.1
SetRegistryDefaultExpiration sets default expiration for endpoints
func (*Builder) SetRegistryProxySupplier ¶
func (b *Builder) SetRegistryProxySupplier(f SupplyRegistryProxyFunc) *Builder
SetRegistryProxySupplier replaces default memory registry supplier to custom function
func (*Builder) SetRegistrySupplier ¶
func (b *Builder) SetRegistrySupplier(f SupplyRegistryFunc) *Builder
SetRegistrySupplier replaces default memory registry supplier to custom function
func (*Builder) SetTokenGenerateFunc ¶
func (b *Builder) SetTokenGenerateFunc(f token.GeneratorFunc) *Builder
SetTokenGenerateFunc sets function for the token generation
func (*Builder) UseUnixSockets ¶
UseUnixSockets sets 1 node and mark it to use unix socket to listen on.
type DialOption ¶ added in v1.1.0
type DialOption func(o *dialOpts)
DialOption is an option pattern for DialOptions
func WithTokenGenerator ¶ added in v1.1.0
func WithTokenGenerator(tokenGenerator token.GeneratorFunc) DialOption
WithTokenGenerator sets tokenGenerator for DialOptions
type Domain ¶
type Domain struct { Nodes []*Node NSMgrProxy *NSMgrEntry Registry *RegistryEntry RegistryProxy *RegistryEntry DNSResolver dnsresolve.Resolver Name string // contains filtered or unexported fields }
Domain contains attached to domain nodes, registry
func (*Domain) NewNSRegistryClient ¶ added in v1.1.0
func (d *Domain) NewNSRegistryClient(ctx context.Context, generatorFunc token.GeneratorFunc, opts ...registryclient.Option) registryapi.NetworkServiceRegistryClient
NewNSRegistryClient creates new NS registry client for the domain
type EndpointEntry ¶
type EndpointEntry struct { Name string URL *url.URL endpoint.Endpoint registryapi.NetworkServiceEndpointRegistryClient // contains filtered or unexported fields }
EndpointEntry is pair of endpoint.Endpoint and url.URL
type ForwarderOption ¶ added in v1.10.0
type ForwarderOption func(*forwarderOptions)
ForwarderOption is an option to configure a forwarder for sandbox
func WithForwarderAdditionalFunctionalityClient ¶ added in v1.10.0
func WithForwarderAdditionalFunctionalityClient(a ...networkservice.NetworkServiceClient) ForwarderOption
WithForwarderAdditionalFunctionalityClient adds an additionalFunctionality to client chain
func WithForwarderAdditionalFunctionalityServer ¶ added in v1.10.0
func WithForwarderAdditionalFunctionalityServer(a ...networkservice.NetworkServiceServer) ForwarderOption
WithForwarderAdditionalFunctionalityServer adds an additionalFunctionality to server chain
type NSMgrEntry ¶
type NSMgrEntry struct { Name string URL *url.URL nsmgr.Nsmgr // contains filtered or unexported fields }
NSMgrEntry is pair of nsmgr.Nsmgr and url.URL
type Node ¶
type Node struct { NSMgr *NSMgrEntry Forwarders map[string]*EndpointEntry // contains filtered or unexported fields }
Node is a NSMgr with Forwarder, NSE registry clients
func (*Node) NewClient ¶
func (n *Node) NewClient( ctx context.Context, generatorFunc token.GeneratorFunc, additionalOpts ...client.Option, ) networkservice.NetworkServiceClient
NewClient starts a new client and connects it to the node NSMgr
func (*Node) NewEndpoint ¶
func (n *Node) NewEndpoint( ctx context.Context, nse *registryapi.NetworkServiceEndpoint, generatorFunc token.GeneratorFunc, additionalFunctionality ...networkservice.NetworkServiceServer, ) *EndpointEntry
NewEndpoint starts a new endpoint and registers it on the node NSMgr
func (*Node) NewForwarder ¶
func (n *Node) NewForwarder( ctx context.Context, nse *registryapi.NetworkServiceEndpoint, generatorFunc token.GeneratorFunc, opts ...ForwarderOption, ) *EndpointEntry
NewForwarder starts a new forwarder and registers it on the node NSMgr
func (*Node) NewNSMgr ¶ added in v1.1.0
func (n *Node) NewNSMgr( ctx context.Context, name string, serveURL *url.URL, generatorFunc token.GeneratorFunc, supplyNSMgr SupplyNSMgrFunc, ) *NSMgrEntry
NewNSMgr creates a new NSMgr
type RegistryEntry ¶
type RegistryEntry struct { URL *url.URL registry.Registry // contains filtered or unexported fields }
RegistryEntry is pair of registry.Registry and url.URL
type SetupNodeFunc ¶
SetupNodeFunc setups each node on Builder.Build() stage
type SupplyNSMgrFunc ¶
type SupplyNSMgrFunc func(ctx context.Context, tokenGenerator token.GeneratorFunc, options ...nsmgr.Option) nsmgr.Nsmgr
SupplyNSMgrFunc supplies NSMGR
type SupplyNSMgrProxyFunc ¶
type SupplyNSMgrProxyFunc func(ctx context.Context, regURL, proxyURL *url.URL, tokenGenerator token.GeneratorFunc, options ...nsmgrproxy.Option) nsmgr.Nsmgr
SupplyNSMgrProxyFunc nsmgr proxy
type SupplyRegistryFunc ¶
type SupplyRegistryFunc func(ctx context.Context, tokenGenerator token.GeneratorFunc, defaultExpiration time.Duration, proxyRegistryURL *url.URL, options ...grpc.DialOption) registry.Registry
SupplyRegistryFunc supplies Registry
type SupplyRegistryProxyFunc ¶
type SupplyRegistryProxyFunc func(ctx context.Context, tokenGenerator token.GeneratorFunc, dnsResolver dnsresolve.Resolver, options ...proxydns.Option) registry.Registry
SupplyRegistryProxyFunc supplies registry proxy