istio: istio.io/istio/pkg/test/echo/client Index | Files

package client

import "istio.io/istio/pkg/test/echo/client"

Index

Package Files

client.go parsedresponse.go

Variables

var (
    URLFieldRegex     = regexp.MustCompile(string(response.URLField) + "=(.*)")
    ClusterFieldRegex = regexp.MustCompile(string(response.ClusterField) + "=(.*)")
    IPFieldRegex      = regexp.MustCompile(string(response.IPField) + "=(.*)")
)

type Instance Uses

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

Instance is a client of an Echo server that simplifies request/response processing for Forward commands.

func New Uses

func New(address string, tlsSettings *common.TLSSettings) (*Instance, error)

New creates a new echo client.Instance that is connected to the given server address.

func (*Instance) Close Uses

func (c *Instance) Close() error

Close the EchoClient and free any resources.

func (*Instance) ForwardEcho Uses

func (c *Instance) ForwardEcho(ctx context.Context, request *proto.ForwardEchoRequest) (ParsedResponses, error)

ForwardEcho sends the given forward request and parses the response for easier processing. Only fails if the request fails.

type ParsedResponse Uses

type ParsedResponse struct {
    // Body is the body of the response
    Body string
    // ID is a unique identifier of the resource in the response
    ID  string
    // URL is the url the request is sent to
    URL string
    // Version is the version of the resource in the response
    Version string
    // Port is the port of the resource in the response
    Port string
    // Code is the response code
    Code string
    // Host is the host called by the request
    Host string
    // Hostname is the host that responded to the request
    Hostname string
    // The cluster where the server is deployed.
    Cluster string
    // IP is the requester's ip address
    IP  string
    // RawResponse gives a map of all values returned in the response (headers, etc)
    RawResponse map[string]string
}

ParsedResponse represents a response to a single echo request.

func (*ParsedResponse) Count Uses

func (r *ParsedResponse) Count(text string) int

Count occurrences of the given text within the body of this response.

func (*ParsedResponse) IsOK Uses

func (r *ParsedResponse) IsOK() bool

IsOK indicates whether or not the code indicates a successful request.

func (*ParsedResponse) String Uses

func (r *ParsedResponse) String() string

type ParsedResponses Uses

type ParsedResponses []*ParsedResponse

ParsedResponses is an ordered list of parsed response objects.

func ParseForwardedResponse Uses

func ParseForwardedResponse(resp *proto.ForwardEchoResponse) ParsedResponses

func (ParsedResponses) Check Uses

func (r ParsedResponses) Check(check func(int, *ParsedResponse) error) (err error)

func (ParsedResponses) CheckCluster Uses

func (r ParsedResponses) CheckCluster(expected string) error

func (ParsedResponses) CheckClusterOrFail Uses

func (r ParsedResponses) CheckClusterOrFail(t test.Failer, expected string) ParsedResponses

func (ParsedResponses) CheckCode Uses

func (r ParsedResponses) CheckCode(expected string) error

func (ParsedResponses) CheckCodeOrFail Uses

func (r ParsedResponses) CheckCodeOrFail(t test.Failer, expected string) ParsedResponses

func (ParsedResponses) CheckEqualClusterTraffic Uses

func (r ParsedResponses) CheckEqualClusterTraffic(clusters resource.Clusters, precisionPct int) error

CheckEqualClusterTraffic checks that traffic was equally distributed across the given clusters, allowing some percent error. For example, with 100 requests and 20 percent error, each cluster must given received 20±4 responses. Only the passed in clusters will be validated.

func (ParsedResponses) CheckHost Uses

func (r ParsedResponses) CheckHost(expected string) error

func (ParsedResponses) CheckHostOrFail Uses

func (r ParsedResponses) CheckHostOrFail(t test.Failer, expected string) ParsedResponses

func (ParsedResponses) CheckIP Uses

func (r ParsedResponses) CheckIP(expected string) error

func (ParsedResponses) CheckIPOrFail Uses

func (r ParsedResponses) CheckIPOrFail(t test.Failer, expected string) ParsedResponses

func (ParsedResponses) CheckKey Uses

func (r ParsedResponses) CheckKey(key, expected string) error

func (ParsedResponses) CheckOK Uses

func (r ParsedResponses) CheckOK() error

func (ParsedResponses) CheckOKOrFail Uses

func (r ParsedResponses) CheckOKOrFail(t test.Failer) ParsedResponses

func (ParsedResponses) CheckOrFail Uses

func (r ParsedResponses) CheckOrFail(t test.Failer, check func(int, *ParsedResponse) error) ParsedResponses

func (ParsedResponses) CheckPort Uses

func (r ParsedResponses) CheckPort(expected int) error

func (ParsedResponses) CheckPortOrFail Uses

func (r ParsedResponses) CheckPortOrFail(t test.Failer, expected int) ParsedResponses

func (ParsedResponses) CheckReachedClusters Uses

func (r ParsedResponses) CheckReachedClusters(clusters resource.Clusters) error

CheckReachedClusters returns an error if there wasn't at least one response from each of the given clusters. This can be used in combination with echo.Instances.Clusters(), for example:

echoA[0].CallOrFail(t, ...).CheckReachedClusters(echoB.Clusters())

func (ParsedResponses) Count Uses

func (r ParsedResponses) Count(text string) int

Count occurrences of the given text within the bodies of all responses.

func (ParsedResponses) Len Uses

func (r ParsedResponses) Len() int

Len returns the length of the parsed responses.

func (ParsedResponses) Match Uses

func (r ParsedResponses) Match(f func(r *ParsedResponse) bool) ParsedResponses

Match returns a subset of ParsedResponses that match the given predicate.

func (ParsedResponses) String Uses

func (r ParsedResponses) String() string

Package client imports 17 packages (graph) and is imported by 10 packages. Updated 2021-01-16. Refresh now. Tools for package owners.