Documentation
¶
Index ¶
- Variables
- func CheckCacheEvents(store model.ConfigStore, cache model.ConfigStoreCache, namespace string, n int, ...)
- func CheckCacheFreshness(cache model.ConfigStoreCache, namespace string, t *testing.T)
- func CheckCacheSync(store model.ConfigStore, cache model.ConfigStoreCache, namespace string, n int, ...)
- func CheckIstioConfigTypes(store model.ConfigStore, namespace string, t *testing.T)
- func CheckMapInvariant(r model.ConfigStore, t *testing.T, namespace string, n int)
- func Compare(a, b model.Config) bool
- func Make(namespace string, i int) model.Config
- func MakeIP(service *model.Service, version int) string
- func MakeInstance(service *model.Service, port *model.Port, version int, az string) *model.ServiceInstance
- func MakeService(hostname, address string) *model.Service
- type ServiceDiscovery
- func (sd *ServiceDiscovery) ClearErrors()
- func (sd *ServiceDiscovery) GetIstioServiceAccounts(hostname string, ports []string) []string
- func (sd *ServiceDiscovery) GetService(hostname string) (*model.Service, error)
- func (sd *ServiceDiscovery) HostInstances(addrs map[string]bool) ([]*model.ServiceInstance, error)
- func (sd *ServiceDiscovery) Instances(hostname string, ports []string, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
- func (sd *ServiceDiscovery) ManagementPorts(addr string) model.PortList
- func (sd *ServiceDiscovery) Services() ([]*model.Service, error)
Constants ¶
This section is empty.
Variables ¶
var ( // Types defines the mock config descriptor Types = model.ConfigDescriptor{model.MockConfig} // ExampleRouteRule is an example route rule ExampleRouteRule = &routing.RouteRule{ Destination: &routing.IstioService{ Name: "world", }, Route: []*routing.DestinationWeight{ {Weight: 80, Labels: map[string]string{"version": "v1"}}, {Weight: 20, Labels: map[string]string{"version": "v2"}}, }, } // ExampleIngressRule is an example ingress rule ExampleIngressRule = &routing.IngressRule{ Destination: &routing.IstioService{ Name: "world", }, Port: 80, DestinationServicePort: &routing.IngressRule_DestinationPort{DestinationPort: 80}, } // ExampleEgressRule is an example egress rule ExampleEgressRule = &routing.EgressRule{ Destination: &routing.IstioService{ Service: "*cnn.com", }, Ports: []*routing.EgressRule_Port{{Port: 80, Protocol: "http"}}, UseEgressProxy: false, } // ExampleDestinationPolicy is an example destination policy ExampleDestinationPolicy = &routing.DestinationPolicy{ Destination: &routing.IstioService{ Name: "world", }, LoadBalancing: &routing.LoadBalancing{ LbPolicy: &routing.LoadBalancing_Name{Name: routing.LoadBalancing_RANDOM}, }, } // ExampleHTTPAPISpec is an example HTTPAPISpec ExampleHTTPAPISpec = &mccpb.HTTPAPISpec{ Attributes: &mpb.Attributes{ Attributes: map[string]*mpb.Attributes_AttributeValue{ "api.service": {Value: &mpb.Attributes_AttributeValue_StringValue{"petstore"}}, }, }, Patterns: []*mccpb.HTTPAPISpecPattern{{ Attributes: &mpb.Attributes{ Attributes: map[string]*mpb.Attributes_AttributeValue{ "api.operation": {Value: &mpb.Attributes_AttributeValue_StringValue{"getPet"}}, }, }, HttpMethod: "GET", Pattern: &mccpb.HTTPAPISpecPattern_UriTemplate{ UriTemplate: "/pets/{id}", }, }}, ApiKeys: []*mccpb.APIKey{{ Key: &mccpb.APIKey_Header{ Header: "X-API-KEY", }, }}, } // ExampleQuotaSpec is an example QuotaSpec ExampleQuotaSpec = &mccpb.QuotaSpec{ Rules: []*mccpb.QuotaRule{{ Match: []*mccpb.AttributeMatch{{ Clause: map[string]*mccpb.StringMatch{ "api.operation": { MatchType: &mccpb.StringMatch_Exact{ Exact: "getPet", }, }, }, }}, Quotas: []*mccpb.Quota{{ Quota: "fooQuota", Charge: 2, }}, }}, } )
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, AuthenticationPolicy: meshconfig.AuthenticationPolicy_INHERIT, } Discovery = &ServiceDiscovery{ services: map[string]*model.Service{ HelloService.Hostname: HelloService, WorldService.Hostname: WorldService, }, 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", } 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 ¶
CheckMapInvariant validates operational invariants of an empty config registry
func MakeInstance ¶
func MakeInstance(service *model.Service, port *model.Port, version int, az string) *model.ServiceInstance
MakeInstance creates a mock instance, version enumerates endpoints
func MakeService ¶
MakeService creates a mock service
Types ¶
type ServiceDiscovery ¶
type ServiceDiscovery struct { WantHostInstances []*model.ServiceInstance ServicesError error GetServiceError error InstancesError error HostInstancesError error // 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) ClearErrors ¶
func (sd *ServiceDiscovery) ClearErrors()
ClearErrors clear errors used for mocking failures during model.ServiceDiscovery interface methods
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, error)
GetService implements discovery interface
func (*ServiceDiscovery) HostInstances ¶
func (sd *ServiceDiscovery) HostInstances(addrs map[string]bool) ([]*model.ServiceInstance, error)
HostInstances implements discovery interface
func (*ServiceDiscovery) Instances ¶
func (sd *ServiceDiscovery) Instances(hostname string, ports []string, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
Instances implements discovery interface
func (*ServiceDiscovery) ManagementPorts ¶
func (sd *ServiceDiscovery) ManagementPorts(addr string) model.PortList
ManagementPorts implements discovery interface