Documentation ¶
Index ¶
- Constants
- func AggregateReport(pb *scpb.ReportRequest, n int64)
- func CheckAPIKey(t *testing.T, scCheck *ServiceRequest, wantApiKey string, desc string)
- func CheckHeaderExist(headers http.Header, wantHeaderName string, valueChecker HeaderValueChecker) bool
- func CheckScRequest(t *testing.T, scRequests []*ServiceRequest, wantScRequests []interface{}, ...)
- func CommonArgs() []string
- func CompareErrors(gotError, wantError error) error
- func CreateCheck(er *ExpectedCheck) scpb.CheckRequest
- func CreateReport(er *ExpectedReport) scpb.ReportRequest
- func DoWithHeaders(url, method, message string, headers map[string]string) (http.Header, []byte, error)
- func DoWithHeadersAndTimeout(url, method, message string, headers map[string]string, timeout time.Duration) (http.Header, []byte, error)
- func ESPv2Version() string
- func Elapsed(what string) func()
- func FetchStats(adminPort uint16) (StatCounters, StatHistograms, error)
- func HttpResponseCodeToStatusCode(code int) int
- func ProtoDiff(x, y proto.Message) string
- func RpcStatusDeterministicJsonFormat(jsonBytes []byte) string
- func StringDiff(x, y string) string
- func UnmarshalCheckRequest(data []byte) (*scpb.CheckRequest, error)
- func UnmarshalQuotaRequest(data []byte) (*scpb.AllocateQuotaRequest, error)
- func UnmarshalReportRequest(data []byte) (*scpb.ReportRequest, error)
- func VerifyCheck(body []byte, ec *ExpectedCheck) error
- func VerifyQuota(body []byte, er *ExpectedQuota) error
- func VerifyReport(body []byte, er *ExpectedReport) error
- func VerifyReportRequestOperationLabel(body []byte, label, value string) error
- func VerifyServiceControlResp(desc string, wantScRequests []interface{}, scRequests []*ServiceRequest) error
- type ComputedQuantiles
- type ExpectHeaderHandler
- type ExpectedCheck
- type ExpectedQuota
- type ExpectedReport
- type HeaderValueChecker
- type Histogram
- type MetricCreator
- type MetricValueInfo
- type MetricValueType
- type Point
- type RetryServiceHandler
- type ServiceAccountForTest
- type ServiceRequest
- type ServiceRequestType
- type StatCounters
- type StatHistograms
- type Stats
- type StatsData
Constants ¶
const ( CheckRequest = 1 + iota QuotaRequest ReportRequest )
const ( OK = 0 CANCELLED = 1 UNKNOWN = 2 INVALID_ARGUMENT = 3 DEADLINE_EXCEEDED = 4 NOT_FOUND = 5 ALREADY_EXISTS = 6 PERMISSION_DENIED = 7 UNAUTHENTICATED = 16 RESOURCE_EXHAUSTED = 8 FAILED_PRECONDITION = 9 ABORTED = 10 OUT_OF_RANGE = 11 UNIMPLEMENTED = 12 INTERNAL = 13 UNAVAILABLE = 14 DATA_LOSS = 15 )
const (
// Path with filtering for ESPv2 stats.
ESpv2FiltersStatsPath = "/stats?format=json&usedonly&filter=http.ingress_http.(backend_auth|service_control|path_rewrite)"
)
Variables ¶
This section is empty.
Functions ¶
func AggregateReport ¶
func AggregateReport(pb *scpb.ReportRequest, n int64)
AggregateReport aggregates N report body into one, as all metric values * N, and its LowEntries appended N times.
func CheckAPIKey ¶
func CheckAPIKey(t *testing.T, scCheck *ServiceRequest, wantApiKey string, desc string)
func CheckHeaderExist ¶
func CheckHeaderExist(headers http.Header, wantHeaderName string, valueChecker HeaderValueChecker) bool
CheckHeaderExist will check for the given header name in the headers. If a value is provided, it will check the value is contained in the original header value.
func CheckScRequest ¶
func CheckScRequest(t *testing.T, scRequests []*ServiceRequest, wantScRequests []interface{}, desc string)
func CommonArgs ¶
func CommonArgs() []string
func CompareErrors ¶
CompareErrors compare the `got error` and `want error` and report failure if they don't match.
func CreateCheck ¶
func CreateCheck(er *ExpectedCheck) scpb.CheckRequest
func CreateReport ¶
func CreateReport(er *ExpectedReport) scpb.ReportRequest
CreateReport makes a service_controller.proto ReportRequest out of an ExpectedReport
func DoWithHeaders ¶
func DoWithHeaders(url, method, message string, headers map[string]string) (http.Header, []byte, error)
DoWithHeaders performs a GET/POST/PUT/DELETE/PATCH request to a specified url with given headers and message(if provided).
func DoWithHeadersAndTimeout ¶
func DoWithHeadersAndTimeout(url, method, message string, headers map[string]string, timeout time.Duration) (http.Header, []byte, error)
DoWithHeadersAndTimeout performs a GET/POST/PUT/DELETE/PATCH request to a specified url with given headers and message(if provided). If a non-0 timeout is provided, the client will cancel the request when the time limit is reached.
func ESPv2Version ¶
func ESPv2Version() string
func FetchStats ¶
func FetchStats(adminPort uint16) (StatCounters, StatHistograms, error)
func ProtoDiff ¶
ProtoDiff returns git diff style line-by-line diff between marshalled proto. Lines prefixed with '-' are missing in y and lines prefixed with '+' are extra in y.
func RpcStatusDeterministicJsonFormat ¶
RpcStatusDeterministicJsonFormat converts the unordered json format of rpcStatus to an ordered one.
func StringDiff ¶
StringDiff returns git diff style line-by-line diff between two strings. Lines prefixed with '-' are missing in y and lines prefixed with '+' are extra in y.
func UnmarshalCheckRequest ¶
func UnmarshalCheckRequest(data []byte) (*scpb.CheckRequest, error)
UnmarshalCheckRequest returns proto CheckRequest given data.
func UnmarshalQuotaRequest ¶
func UnmarshalQuotaRequest(data []byte) (*scpb.AllocateQuotaRequest, error)
UnmarshalQuotaRequest returns proto AllocateQuotaRequest given data.
func UnmarshalReportRequest ¶
func UnmarshalReportRequest(data []byte) (*scpb.ReportRequest, error)
UnmarshalReportRequest returns proto ReportRequest given data.
func VerifyCheck ¶
func VerifyCheck(body []byte, ec *ExpectedCheck) error
VerifyCheck verify if the response body is the expected CheckRequest. If the verification fails, it returns an error.
func VerifyQuota ¶
func VerifyQuota(body []byte, er *ExpectedQuota) error
VerifyQuota verify if the response body is the expected AllocateQuotaRequest. If the verification fails, it returns an error.
func VerifyReport ¶
func VerifyReport(body []byte, er *ExpectedReport) error
VerifyReport verify if the response body is the expected ReportRequest. If the verification fails, it returns an error.
func VerifyReportRequestOperationLabel ¶
VerifyReportRequestOperationLabel verifies whether a ReportRequest has the correct value for the label specified
func VerifyServiceControlResp ¶
func VerifyServiceControlResp(desc string, wantScRequests []interface{}, scRequests []*ServiceRequest) error
Types ¶
type ComputedQuantiles ¶
ComputedQuantiles is the struct to represent the computed quantile for each histogram.
type ExpectHeaderHandler ¶
func (*ExpectHeaderHandler) ServeHTTP ¶
func (h *ExpectHeaderHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ExpectedCheck ¶
type ExpectedQuota ¶
type ExpectedReport ¶
type ExpectedReport struct { Aggregate int64 Version string ServiceName string ServiceConfigID string ApiVersion string ApiMethod string ApiName string ApiKeyInOperationAndLogEntry string ApiKeyInLogEntryOnly string ApiKeyState string ProducerProjectID string ConsumerProjectID string URL string Location string HttpMethod string LogMessage string ResponseCode int HttpStatusCode int GrpcStatusCode string Referer string StatusCode string ErrorCause string FrontendProtocol string BackendProtocol string Platform string JwtAuthCredentialId string RequestHeaders string ResponseHeaders string ResponseCodeDetail string JwtPayloads string Trace string }
type HeaderValueChecker ¶
type Histogram ¶
type Histogram struct { // Cq represents computed_quantiles. Cq []ComputedQuantiles `json:"computed_quantiles,omitempty"` // Sq represents supported_quantiles. Sq []interface{} `json:"supported_quantiles,omitempty"` }
Histogram is the struct which is an optional part of StatsData.
type MetricCreator ¶
type MetricCreator int
const ( MTProducer MetricCreator = 1 + iota MTConsumer MTProducerByConsumer MTProducerUnderGrpcStream MTConsumerUnderGrpcStream )
type MetricValueInfo ¶
type MetricValueInfo struct { MetricCreator MetricCreator MetricValueType MetricValueType // Whether to use this metric when creating a ExpectedReport ShouldInit bool }
type MetricValueType ¶
type MetricValueType int
const ( Int64 MetricValueType = 1 + iota Distribution )
type Point ¶
type Point struct { Cumulative float64 `json:"cumulative,omitempty"` Interval float64 `json:"interval,omitempty"` }
Point is the struct to decode the values of computed_quantiles.
type RetryServiceHandler ¶
func (*RetryServiceHandler) ServeHTTP ¶
func (h *RetryServiceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ServiceAccountForTest ¶
type ServiceAccountForTest struct { MockTokenServer *util.MockServer FileName string }
func NewServiceAccountForTest ¶
func NewServiceAccountForTest() (*ServiceAccountForTest, error)
type ServiceRequest ¶
type ServiceRequest struct { ReqType ServiceRequestType ReqHeader http.Header ReqBody []byte }
type ServiceRequestType ¶
type ServiceRequestType int