mock

package
v0.0.0-...-4280267 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Types defines the mock config descriptor
	Types = model.ConfigDescriptor{model.MockConfig}

	// ExampleRouteRule is an example route rule
	ExampleRouteRule = &proxyconfig.RouteRule{
		Destination: &proxyconfig.IstioService{
			Name: "world",
		},
		Route: []*proxyconfig.DestinationWeight{
			{Weight: 80, Labels: map[string]string{"version": "v1"}},
			{Weight: 20, Labels: map[string]string{"version": "v2"}},
		},
	}

	// ExampleIngressRule is an example ingress rule
	ExampleIngressRule = &proxyconfig.IngressRule{
		Destination: &proxyconfig.IstioService{
			Name: "world",
		},
		Port:                   80,
		DestinationServicePort: &proxyconfig.IngressRule_DestinationPort{DestinationPort: 80},
	}

	// ExampleEgressRule is an example egress rule
	ExampleEgressRule = &proxyconfig.EgressRule{
		Destination: &proxyconfig.IstioService{
			Service: "*cnn.com",
		},
		Ports:          []*proxyconfig.EgressRule_Port{{Port: 80, Protocol: "http"}},
		UseEgressProxy: false,
	}

	// ExampleDestinationPolicy is an example destination policy
	ExampleDestinationPolicy = &proxyconfig.DestinationPolicy{
		Destination: &proxyconfig.IstioService{
			Name: "world",
		},
		LoadBalancing: &proxyconfig.LoadBalancing{
			LbPolicy: &proxyconfig.LoadBalancing_Name{Name: proxyconfig.LoadBalancing_RANDOM},
		},
	}
)
View Source
var (
	HelloService = MakeService("hello.default.svc.cluster.local", "10.1.0.0")
	WorldService = MakeService("world.default.svc.cluster.local", "10.2.0.0")
	PortHTTP     = &model.Port{
		Name:     "http",
		Port:     80,
		Protocol: model.ProtocolHTTP,
	}
	ExtHTTPService = MakeExternalHTTPService("httpbin.default.svc.cluster.local",
		"httpbin.org", "")
	ExtHTTPSService = MakeExternalHTTPSService("httpsbin.default.svc.cluster.local",
		"httpbin.org", "")
	Discovery = &ServiceDiscovery{
		services: map[string]*model.Service{
			HelloService.Hostname:   HelloService,
			WorldService.Hostname:   WorldService,
			ExtHTTPService.Hostname: ExtHTTPService,

			ExtHTTPSService.Hostname: ExtHTTPSService,
		},
		versions: 2,
	}
	HelloInstanceV0 = MakeIP(HelloService, 0)
	HelloInstanceV1 = MakeIP(HelloService, 1)
	HelloProxyV0    = proxy.Node{
		Type:      proxy.Sidecar,
		IPAddress: HelloInstanceV0,
		ID:        "v0.default",
		Domain:    "default.svc.cluster.local",
	}
	HelloProxyV1 = proxy.Node{
		Type:      proxy.Sidecar,
		IPAddress: HelloInstanceV1,
		ID:        "v1.default",
		Domain:    "default.svc.cluster.local",
	}
	Ingress = proxy.Node{
		Type:      proxy.Ingress,
		IPAddress: "10.3.3.3",
		ID:        "ingress.default",
		Domain:    "default.svc.cluster.local",
	}
	Egress = proxy.Node{
		Type:      proxy.Egress,
		IPAddress: "10.3.3.4",
		ID:        "egress.default",
		Domain:    "default.svc.cluster.local",
	}
	Router = proxy.Node{
		Type:      proxy.Router,
		IPAddress: "10.3.3.5",
		ID:        "router.default",
		Domain:    "default.svc.cluster.local",
	}
)

Mock values

Functions

func CheckCacheEvents

func CheckCacheEvents(store model.ConfigStore, cache model.ConfigStoreCache, namespace string, n int, t *testing.T)

CheckCacheEvents validates operational invariants of a cache

func CheckCacheFreshness

func CheckCacheFreshness(cache model.ConfigStoreCache, namespace string, t *testing.T)

CheckCacheFreshness validates operational invariants of a cache

func CheckCacheSync

func CheckCacheSync(store model.ConfigStore, cache model.ConfigStoreCache, namespace string, n int, t *testing.T)

CheckCacheSync validates operational invariants of a cache against the non-cached client.

func CheckIstioConfigTypes

func CheckIstioConfigTypes(store model.ConfigStore, namespace string, t *testing.T)

CheckIstioConfigTypes validates that an empty store can ingest Istio config objects

func CheckMapInvariant

func CheckMapInvariant(r model.ConfigStore, t *testing.T, namespace string, n int)

CheckMapInvariant validates operational invariants of an empty config registry

func Compare

func Compare(a, b model.Config) bool

Compare checks two configs ignoring revisions

func Make

func Make(namespace string, i int) model.Config

Make creates a mock config indexed by a number

func MakeExternalHTTPSService

func MakeExternalHTTPSService(hostname, external string, address string) *model.Service

MakeExternalHTTPSService creates mock external service

func MakeExternalHTTPService

func MakeExternalHTTPService(hostname, external string, address string) *model.Service

MakeExternalHTTPService creates mock external service

func MakeIP

func MakeIP(service *model.Service, version int) string

MakeIP creates a fake IP address for a service and instance version

func MakeInstance

func MakeInstance(service *model.Service, port *model.Port, version int) *model.ServiceInstance

MakeInstance creates a mock instance, version enumerates endpoints

func MakeService

func MakeService(hostname, address string) *model.Service

MakeService creates a mock service

Types

type ServiceDiscovery

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

ServiceDiscovery is a mock discovery interface

func NewDiscovery

func NewDiscovery(services map[string]*model.Service, versions int) *ServiceDiscovery

NewDiscovery builds a mock ServiceDiscovery

func (*ServiceDiscovery) GetIstioServiceAccounts

func (sd *ServiceDiscovery) GetIstioServiceAccounts(hostname string, ports []string) []string

GetIstioServiceAccounts gets the Istio service accounts for a service hostname.

func (*ServiceDiscovery) GetService

func (sd *ServiceDiscovery) GetService(hostname string) (*model.Service, bool)

GetService implements discovery interface

func (*ServiceDiscovery) HostInstances

func (sd *ServiceDiscovery) HostInstances(addrs map[string]bool) []*model.ServiceInstance

HostInstances implements discovery interface

func (*ServiceDiscovery) Instances

func (sd *ServiceDiscovery) Instances(hostname string, ports []string,
	labels model.LabelsCollection) []*model.ServiceInstance

Instances implements discovery interface

func (*ServiceDiscovery) ManagementPorts

func (sd *ServiceDiscovery) ManagementPorts(addr string) model.PortList

ManagementPorts implements discovery interface

func (*ServiceDiscovery) Services

func (sd *ServiceDiscovery) Services() []*model.Service

Services implements discovery interface

Jump to

Keyboard shortcuts

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