istio: Index | Files | Directories

package echo

import ""


Package Files

annotations.go call.go config.go echo.go flags.go instances.go


var (
    SidecarInject                = workloadAnnotation(annotation.SidecarInject.Name, "true")
    SidecarRewriteAppHTTPProbers = workloadAnnotation(annotation.SidecarRewriteAppHTTPProbers.Name, "")
    SidecarBootstrapOverride     = workloadAnnotation(annotation.SidecarBootstrapOverride.Name, "")
    SidecarVolumeMount           = workloadAnnotation(annotation.SidecarUserVolumeMount.Name, "")
    SidecarVolume                = workloadAnnotation(annotation.SidecarUserVolume.Name, "")
    SidecarConfig                = workloadAnnotation(annotation.ProxyConfig.Name, "")
    SidecarInterceptionMode      = workloadAnnotation(annotation.SidecarInterceptionMode.Name, "REDIRECT")

func DefaultCallRetryOptions Uses

func DefaultCallRetryOptions() []retry.Option

DefaultCallRetryOptions returns the default call retry options as specified in command-line flags.

type Annotation Uses

type Annotation struct {
    Name    string
    Type    AnnotationType
    Default AnnotationValue

type AnnotationType Uses

type AnnotationType string
const (
    WorkloadAnnotation AnnotationType = "workload"

type AnnotationValue Uses

type AnnotationValue struct {
    Value string

func NewAnnotationValue Uses

func NewAnnotationValue() *AnnotationValue

func (*AnnotationValue) AsBool Uses

func (v *AnnotationValue) AsBool() bool

func (*AnnotationValue) AsInt Uses

func (v *AnnotationValue) AsInt() int

func (*AnnotationValue) Get Uses

func (v *AnnotationValue) Get() string

func (*AnnotationValue) Set Uses

func (v *AnnotationValue) Set(arg string) *AnnotationValue

func (*AnnotationValue) SetBool Uses

func (v *AnnotationValue) SetBool(arg bool) *AnnotationValue

func (*AnnotationValue) SetInt Uses

func (v *AnnotationValue) SetInt(arg int) *AnnotationValue

type Annotations Uses

type Annotations map[Annotation]*AnnotationValue

func NewAnnotations Uses

func NewAnnotations() Annotations

func (Annotations) Get Uses

func (a Annotations) Get(k Annotation) string

func (Annotations) GetBool Uses

func (a Annotations) GetBool(k Annotation) bool

func (Annotations) GetInt Uses

func (a Annotations) GetInt(k Annotation) int

func (Annotations) Set Uses

func (a Annotations) Set(k Annotation, v string) Annotations

func (Annotations) SetBool Uses

func (a Annotations) SetBool(k Annotation, v bool) Annotations

func (Annotations) SetInt Uses

func (a Annotations) SetInt(k Annotation, v int) Annotations

type Builder Uses

type Builder interface {
    // With adds a new Echo configuration to the Builder. Once built, the instance
    // pointer will be updated to point at the new Instance.
    With(i *Instance, cfg Config) Builder

    // Build and initialize all Echo Instances. Upon returning, the Instance pointers
    // are assigned and all Instances are ready to communicate with each other.
    Build() (Instances, error)
    BuildOrFail(t test.Failer) Instances

Builder for a group of collaborating Echo Instances. Once built, all Instances in the group:

1. Are ready to receive traffic, and
2. Can call every other Instance in the group (i.e. have received Envoy config
   from Pilot).

If a test needs to verify that one Instance is NOT reachable from another, there are a couple of options:

1. Build a group while all Instances ARE reachable. Then apply a policy
   disallowing the communication.
2. Build the source and destination Instances in separate groups and then
   call `source.WaitUntilCallable(destination)`.

type CallOptions Uses

type CallOptions struct {
    // Target instance of the call. Required.
    Target Instance

    // Port on the target Instance. Either Port or PortName must be specified.
    Port *Port

    // PortName of the port on the target Instance. Either Port or PortName must be specified.
    PortName string

    // Scheme to be used when making the call. If not provided, an appropriate default for the
    // port will be used (if feasible).
    Scheme scheme.Instance

    // If true, h2c will be used in HTTP requests
    HTTP2 bool

    // Address specifies the host name or IP address to be used on the request. If not provided,
    // an appropriate default is chosen for the target Instance.
    Address string

    // Path specifies the URL path for the HTTP(s) request.
    Path string

    // Count indicates the number of exchanges that should be made with the service endpoint.
    // If Count <= 0, defaults to 1.
    Count int

    // Headers indicates headers that should be sent in the request. Ignored for WebSocket calls.
    // If no Host header is provided, a default will be chosen for the target service endpoint.
    Headers http.Header

    // Timeout used for each individual request. Must be > 0, otherwise 30 seconds is used.
    Timeout time.Duration

    // Message to be sent if this is a GRPC request
    Message string

    // Method to send. Defaults to HTTP. Only relevant for HTTP.
    Method string

    // Use the custom certificate to make the call. This is mostly used to make mTLS request directly
    // (without proxy) from naked client to test certificates issued by custom CA instead of the Istio self-signed CA.
    Cert, Key, CaCert string

    // FollowRedirects will instruct the call to follow 301 redirects. Otherwise, the original 301 response
    // is returned directly.
    FollowRedirects bool

    // Validator for server responses. If no validator is provided, only the number of responses received
    // will be verified.
    Validator Validator

CallOptions defines options for calling a Endpoint.

type Config Uses

type Config struct {
    // Namespace of the echo Instance. If not provided, a default namespace "apps" is used.
    Namespace namespace.Instance

    // DefaultHostHeader overrides the default Host header for calls (`service.namespace.svc.cluster.local`)
    DefaultHostHeader string

    // Domain of the echo Instance. If not provided, a default will be selected.
    Domain string

    // Service indicates the service name of the Echo application.
    Service string

    // Version indicates the version path for calls to the Echo application.
    Version string

    // Locality (k8s only) indicates the locality of the deployed app.
    Locality string

    // Headless (k8s only) indicates that no ClusterIP should be specified.
    Headless bool

    // ServiceAccount (k8s only) indicates that a service account should be created
    // for the deployment.
    ServiceAccount bool

    // Ports for this application. Port numbers may or may not be used, depending
    // on the implementation.
    Ports []Port

    // WorkloadOnlyPorts for ports only defined in the workload but not in the k8s service.
    // This is used to test the inbound pass-through filter chain.
    WorkloadOnlyPorts []WorkloadPort

    // ServiceAnnotations is annotations on service object.
    ServiceAnnotations Annotations

    // ReadinessTimeout specifies the timeout that we wait the application to
    // become ready.
    ReadinessTimeout time.Duration

    // Subsets contains the list of Subsets config belonging to this echo
    // service instance.
    Subsets []SubsetConfig

    // Cluster to be used in a multicluster environment
    Cluster resource.Cluster

    // TLS settings for echo server
    TLSSettings *common.TLSSettings

    // If enabled, echo will be deployed as a "VM". This means it will run Envoy in the same pod as echo,
    // disable sidecar injection, etc.
    DeployAsVM bool

    // If enabled, ISTIO_META_AUTO_REGISTER_GROUP will be set on the VM and the WorkloadEntry will be created automatically.
    AutoRegisterVM bool

    // The image name to be used to pull the image for the VM. `DeployAsVM` must be enabled.
    VMImage string

    // The set of environment variables to set for `DeployAsVM` instances.
    VMEnvironment map[string]string

    // If enabled, an additional ext-authz container will be included in the deployment. This is mainly used to test
    // the CUSTOM authorization policy when the ext-authz server is deployed locally with the application container in
    // the same pod.
    IncludeExtAuthz bool

Config defines the options for creating an Echo component. nolint: maligned

func (Config) DeepCopy Uses

func (c Config) DeepCopy() Config

DeepCopy creates a clone of IstioEndpoint.

func (Config) FQDN Uses

func (c Config) FQDN() string

FQDN returns the fully qualified domain name for the service.

func (Config) HostHeader Uses

func (c Config) HostHeader() string

HostHeader returns the Host header that will be used for calls to this service.

func (Config) PortByName Uses

func (c Config) PortByName(name string) *Port

PortByName looks up a given port by name

func (Config) String Uses

func (c Config) String() string

String implements the Configuration interface (which implements fmt.Stringer)

type Instance Uses

type Instance interface {

    // Config returns the configuration of the Echo instance.
    Config() Config

    // Address of the service (e.g. Kubernetes cluster IP). May be "" if headless.
    Address() string

    // Workloads retrieves the list of all deployed workloads for this Echo service.
    // Guarantees at least one workload, if error == nil.
    Workloads() ([]Workload, error)
    WorkloadsOrFail(t test.Failer) []Workload

    // Call makes a call from this Instance to a target Instance.
    Call(options CallOptions) (client.ParsedResponses, error)
    CallOrFail(t test.Failer, options CallOptions) client.ParsedResponses

    // CallWithRetry is the same as call, except that it will attempt to retry based on the provided
    // options. If no options are provided, uses defaults.
    CallWithRetry(options CallOptions, retryOptions ...retry.Option) (client.ParsedResponses, error)
    CallWithRetryOrFail(t test.Failer, options CallOptions, retryOptions ...retry.Option) client.ParsedResponses

    // Restart restarts the workloads associated with this echo instance
    Restart() error

Instance is a component that provides access to a deployed echo service.

type Instances Uses

type Instances []Instance

Instances contains the instances created by the builder with methods for filtering

func (Instances) Clusters Uses

func (i Instances) Clusters() resource.Clusters

Clusters returns a list of cluster names that the instances are deployed in

func (Instances) Contains Uses

func (i Instances) Contains(instances ...Instance) bool

func (Instances) Get Uses

func (i Instances) Get(matches Matcher) (Instance, error)

Get finds the first Instance that matches the Matcher.

func (Instances) GetOrFail Uses

func (i Instances) GetOrFail(t test.Failer, matches Matcher) Instance

func (Instances) Match Uses

func (i Instances) Match(matches Matcher) Instances

Match filters instances that matcher the given Matcher

type Matcher Uses

type Matcher func(Instance) bool

Matcher is used to filter matching instances

func InCluster Uses

func InCluster(c resource.Cluster) Matcher

InCluster matches instances deployed on the given cluster.

func InNetwork Uses

func InNetwork(n string) Matcher

InNetwork matches instances deployed in the given network.

func Namespace Uses

func Namespace(namespace string) Matcher

Service matches instances within the given namespace name.

func Service Uses

func Service(value string) Matcher

Service matches instances with have the given service name.

func ServicePrefix Uses

func ServicePrefix(prefix string) Matcher

ServicePrefix matches instances whose service name starts with the given prefix.

func (Matcher) And Uses

func (m Matcher) And(other Matcher) Matcher

And combines two or more matches. Example:


type Port Uses

type Port struct {
    // Name of this port
    Name string

    // Protocol to be used for the port.
    Protocol protocol.Instance

    // ServicePort number where the service can be reached. Does not necessarily
    // map to the corresponding port numbers for the instances behind the
    // service.
    ServicePort int

    // InstancePort number where this instance is listening for connections.
    // This need not be the same as the ServicePort where the service is accessed.
    InstancePort int

    // TLS determines whether the connection will be plain text or TLS. By default this is false (plain text).
    TLS bool

    // ServerFirst determines whether the port will use server first communication, meaning the client will not send the first byte.
    ServerFirst bool

    // InstanceIP determines if echo will listen on the instance IP, or wildcard
    InstanceIP bool

Port exposed by an Echo Instance

type Sidecar Uses

type Sidecar interface {
    // NodeID returns the node ID used for uniquely identifying this sidecar to Pilot.
    NodeID() string

    // Info about the Envoy instance.
    Info() (*envoyAdmin.ServerInfo, error)
    InfoOrFail(t test.Failer) *envoyAdmin.ServerInfo

    // Config of the Envoy instance.
    Config() (*envoyAdmin.ConfigDump, error)
    ConfigOrFail(t test.Failer) *envoyAdmin.ConfigDump

    // WaitForConfig queries the Envoy configuration an executes the given accept handler. If the
    // response is not accepted, the request will be retried until either a timeout or a response
    // has been accepted.
    WaitForConfig(accept func(*envoyAdmin.ConfigDump) (bool, error), options ...retry.Option) error
    WaitForConfigOrFail(t test.Failer, accept func(*envoyAdmin.ConfigDump) (bool, error), options ...retry.Option)

    // Clusters for the Envoy instance
    Clusters() (*envoyAdmin.Clusters, error)
    ClustersOrFail(t test.Failer) *envoyAdmin.Clusters

    // Listeners for the Envoy instance
    Listeners() (*envoyAdmin.Listeners, error)
    ListenersOrFail(t test.Failer) *envoyAdmin.Listeners

    // Logs returns the logs for the sidecar container
    Logs() (string, error)
    // LogsOrFail returns the logs for the sidecar container, or aborts if an error is found
    LogsOrFail(t test.Failer) string

    Stats() (map[string]*dto.MetricFamily, error)
    StatsOrFail(t test.Failer) map[string]*dto.MetricFamily

Sidecar provides an interface to execute queries against a single Envoy sidecar.

type SubsetConfig Uses

type SubsetConfig struct {
    // The version of the deployment.
    Version string
    // Annotations provides metadata hints for deployment of the instance.
    Annotations Annotations

SubsetConfig is the config for a group of Subsets (e.g. Kubernetes deployment).

type Validator Uses

type Validator interface {
    // Validate performs the validation check for this Validator.
    Validate(client.ParsedResponses, error) error

Validator validates that the given responses are expected.

func And Uses

func And(vs ...Validator) Validator

And combines the validators into a chain. If no validators are provided, returns the identity validator that just returns the original error.

func ExpectCluster Uses

func ExpectCluster(expected string) Validator

ExpectCluster returns a validator that checks responses for the given cluster ID.

func ExpectCode Uses

func ExpectCode(expected string) Validator

ExpectCode returns a Validator that checks the responses for the given response code.

func ExpectError Uses

func ExpectError() Validator

ExpectError returns a Validator that is completed when an error occurs.

func ExpectHost Uses

func ExpectHost(expected string) Validator

ExpectHost returns a Validator that checks the responses for the given host header.

func ExpectKey Uses

func ExpectKey(key, expected string) Validator

ExpectKey returns a validator that checks a key matches the provided value

func ExpectOK Uses

func ExpectOK() Validator

ExpectOK returns a Validator that calls CheckOK on the given responses.

func ExpectReachedClusters Uses

func ExpectReachedClusters(clusters resource.Clusters) Validator

ExpectReachedClusters returns a Validator that checks that all provided clusters are reached.

type ValidatorFunc Uses

type ValidatorFunc func(client.ParsedResponses, error) error

ValidatorFunc is a function that serves as a Validator.

func (ValidatorFunc) Validate Uses

func (v ValidatorFunc) Validate(resp client.ParsedResponses, err error) error

type Workload Uses

type Workload interface {
    // PodName gets the original pod name for the workload.
    PodName() string
    // Address returns the network address of the endpoint.
    Address() string

    // Sidecar if one was specified.
    Sidecar() Sidecar

    // ForwardEcho executes specific call from this workload.
    ForwardEcho(context.Context, *proto.ForwardEchoRequest) (client.ParsedResponses, error)

    // Logs returns the logs for the app container
    Logs() (string, error)
    // LogsOrFail returns the logs for the app container, or aborts if an error is found
    LogsOrFail(t test.Failer) string

Workload provides an interface for a single deployed echo server.

type WorkloadPort Uses

type WorkloadPort struct {
    // Port number
    Port int

    // Protocol to be used for this port.
    Protocol protocol.Instance

    // TLS determines whether the connection will be plain text or TLS. By default this is false (plain text).
    TLS bool

    // ServerFirst determines whether the port will use server first communication, meaning the client will not send the first byte.
    ServerFirst bool

Workload port exposed by an Echo instance



Package echo imports 21 packages (graph) and is imported by 13 packages. Updated 2021-01-16. Refresh now. Tools for package owners.