import "istio.io/istio/pkg/test/echo/client"
var ( URLFieldRegex = regexp.MustCompile(string(response.URLField) + "=(.*)") ClusterFieldRegex = regexp.MustCompile(string(response.ClusterField) + "=(.*)") IPFieldRegex = regexp.MustCompile(string(response.IPField) + "=(.*)") )
type Instance struct {
// contains filtered or unexported fields
}
Instance is a client of an Echo server that simplifies request/response processing for Forward commands.
New creates a new echo client.Instance that is connected to the given server address.
Close the EchoClient and free any resources.
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 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 (r *ParsedResponse) Count(text string) int
Count occurrences of the given text within the body of this response.
func (r *ParsedResponse) IsOK() bool
IsOK indicates whether or not the code indicates a successful request.
func (r *ParsedResponse) String() string
type ParsedResponses []*ParsedResponse
ParsedResponses is an ordered list of parsed response objects.
func ParseForwardedResponse(resp *proto.ForwardEchoResponse) ParsedResponses
func (r ParsedResponses) Check(check func(int, *ParsedResponse) error) (err error)
func (r ParsedResponses) CheckCluster(expected string) error
func (r ParsedResponses) CheckClusterOrFail(t test.Failer, expected string) ParsedResponses
func (r ParsedResponses) CheckCode(expected string) error
func (r ParsedResponses) CheckCodeOrFail(t test.Failer, expected string) ParsedResponses
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 (r ParsedResponses) CheckHost(expected string) error
func (r ParsedResponses) CheckHostOrFail(t test.Failer, expected string) ParsedResponses
func (r ParsedResponses) CheckIP(expected string) error
func (r ParsedResponses) CheckIPOrFail(t test.Failer, expected string) ParsedResponses
func (r ParsedResponses) CheckKey(key, expected string) error
func (r ParsedResponses) CheckOK() error
func (r ParsedResponses) CheckOKOrFail(t test.Failer) ParsedResponses
func (r ParsedResponses) CheckOrFail(t test.Failer, check func(int, *ParsedResponse) error) ParsedResponses
func (r ParsedResponses) CheckPort(expected int) error
func (r ParsedResponses) CheckPortOrFail(t test.Failer, expected int) ParsedResponses
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 (r ParsedResponses) Count(text string) int
Count occurrences of the given text within the bodies of all responses.
func (r ParsedResponses) Len() int
Len returns the length of the parsed responses.
func (r ParsedResponses) Match(f func(r *ParsedResponse) bool) ParsedResponses
Match returns a subset of ParsedResponses that match the given predicate.
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.