Documentation

Index

Constants

const (
	TestAccessLog uint16 = iota
	TestAsymmetricKeys
	TestAsymmetricKeysTraces
	TestAuthJwksCache
	TestBackendAuthDisableAuth
	TestBackendAuthUsingIamIdTokenWithDelegates
	TestBackendAuthWithIamIdToken
	TestBackendAuthWithIamIdTokenRetries
	TestBackendAuthWithIamIdTokenTimeouts
	TestBackendAuthWithImdsIdToken
	TestBackendAuthWithImdsIdTokenRetries
	TestBackendAuthWithImdsIdTokenWhileAllowCors
	TestBackendHttpProtocol
	TestDeadlinesForCatchAllBackend
	TestDeadlinesForDynamicRouting
	TestDeadlinesForGrpcCatchAllBackend
	TestDeadlinesForGrpcDynamicRouting
	TestDifferentOriginPreflightCors
	TestDifferentOriginSimpleCors
	TestDnsResolver
	TestDynamicBackendRoutingTLS
	TestDynamicBackendRoutingMutualTLS
	TestDynamicGrpcBackendTLS
	TestDynamicRouting
	TestDynamicRoutingCorsByEnvoy
	TestDynamicRoutingWithAllowCors
	TestFrontendAndBackendAuthHeaders
	TestGeneratedHeaders
	TestGRPC
	TestGrpcBackendPreflightCors
	TestGrpcBackendSimpleCors
	TestGRPCErrors
	TestGRPCFallback
	TestGRPCInteropMiniStress
	TestGRPCInterops
	TestGRPCJwt
	TestGRPCLongStreaming
	TestGRPCMetadata
	TestGRPCMinistress
	TestGRPCStreaming
	TestGRPCWeb
	TestHttp1Basic
	TestRetryCallServiceManagement
	TestHttp1JWT
	TestHttpHeaders
	TestHttpsClients
	TestIamImdsDataPath
	TestInvalidOpenIDConnectDiscovery
	TestJwtLocations
	TestManagedServiceConfig
	TestMethodOverrideBackendMethod
	TestMethodOverrideBackendBody
	TestMethodOverrideScReport
	TestMultiGrpcServices
	TestPreflightCorsWithBasicPreset
	TestPreflightRequestWithAllowCors
	TestReportGCPAttributes
	TestServiceControlAccessTokenFromIam
	TestServiceControlAccessTokenFromTokenAgent
	TestServiceControlAllHTTPMethod
	TestServiceControlAllHTTPPath
	TestServiceControlAPIKeyCustomLocation
	TestServiceControlAPIKeyDefaultLocation
	TestServiceControlAPIKeyIpRestriction
	TestServiceControlAPIKeyRestriction
	TestServiceControlBasic
	TestServiceControlCache
	TestServiceControlCheckError
	TestServiceControlCheckRetry
	TestServiceControlCheckServerFail
	TestServiceControlCheckTimeout
	TestServiceControlCheckWrongServerName
	TestServiceControlCredentialId
	TestServiceControlFailedRequestReport
	TestServiceControlJwtAuthFail
	TestServiceControlLogHeaders
	TestServiceControlLogJwtPayloads
	TestServiceControlNetworkFailFlagForTimeout
	TestServiceControlNetworkFailFlagForUnavailableCheckResponse
	TestServiceControlProtocolWithGRPCBackend
	TestServiceControlProtocolWithHTTPBackend
	TestServiceControlQuota
	TestServiceControlQuotaExhausted
	TestServiceControlQuotaRetry
	TestServiceControlQuotaUnavailable
	TestServiceControlReportNetworkFail
	TestServiceControlReportResponseCode
	TestServiceControlReportRetry
	TestServiceControlRequestForDynamicRouting
	TestServiceControlRequestWithAllowCors
	TestServiceControlRequestWithoutAllowCors
	TestServiceControlSkipUsage
	TestServiceControlTLSWithValidCert
	TestServiceManagementWithInvalidCert
	TestServiceManagementWithValidCert
	TestStartupDuplicatedPathsWithAllowCors
	TestSimpleCorsWithBasicPreset
	TestSimpleCorsWithRegexPreset
	TestStatistics
	TestStatisticsServiceControlCallStatus
	TestTracesFetchingJwks
	TestTracesServiceControlCheckWithRetry
	TestTracesServiceControlSkipUsage
	TestTracingSampleRate
	TestTranscodingBindings
	TestTranscodingIgnoreQueryParameters
	TestTranscodingPrintOptions
	TestTranscodingErrors
	TestTranscodingServiceUnavailableError
	TestWebsocket
)

All integration tests should be listed here to get their test ids


const (
	FakeProjectID = "test-project-id"
)

Variables

This section is empty.

Functions

func CheckDnsResolverHealth

func CheckDnsResolverHealth(dnsResolverAddress, host, expectIp string) error

func GenerateCert

func GenerateCert(certPath, keyPath string) (*tls.Certificate, error)

GenerateCert generates a certificate from the root cert and key pair.

func GrpcConnectionCheck

func GrpcConnectionCheck(addr string, opts *HealthCheckOptions) error

BasicGrpcConnectionCheck performs a basic connectivity check to the underlying server using the standard gRPC connectivity semantics. https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md This can be used if the server does not support the gRPC health checking protocol, but is generally less accurate.

func GrpcHealthCheck

func GrpcHealthCheck(addr string, opts *HealthCheckOptions) error

GrpcHealthCheck checks the service running on the specified port using the standard gRPC health checking protocol. https://github.com/grpc/grpc/blob/master/doc/health-checking.md Does not support authentication. Supports retries and timeouts. Recommended to use over BasicGrpcConnectionCheck is the underlying server supports the protocol.

func HttpConnectionCheck

func HttpConnectionCheck(host string, port string, opts *HealthCheckOptions) error

func HttpHealthCheck

func HttpHealthCheck(uri string, opts *HealthCheckOptions) error

HttpHealthCheck checks the service running at the specified port and path for a 200 OK response. Does not support authentication. Supports retries and timeouts.

func IsPortUsed

func IsPortUsed(port uint16) bool

IsPortUsed checks if a port is used

func NewDnsResolver

func NewDnsResolver(port uint16, records map[string]string) *dns.Server

func QueryDnsResolver

func QueryDnsResolver(dnsResolverAddress, target string) ([]*net.IP, error)

Types

type Cmd

type Cmd struct {
	*exec.Cmd
	// contains filtered or unexported fields
}

func (*Cmd) StartAndWait

func (c *Cmd) StartAndWait() error

StartAndWait starts the command and waits for startWaitTime.

func (*Cmd) StopAndWait

func (c *Cmd) StopAndWait() error

StopAndWait stops the command and waits for stopWaitTime, and kills the command if it doesn't stop.

type ConfigManagerServer

type ConfigManagerServer struct {
	*Cmd
	// contains filtered or unexported fields
}

func NewConfigManagerServer

func NewConfigManagerServer(debugMode bool, ports *Ports, args []string) (*ConfigManagerServer, error)

func (ConfigManagerServer) CheckHealth

func (s ConfigManagerServer) CheckHealth() error

func (ConfigManagerServer) String

func (s ConfigManagerServer) String() string

type EchoHTTPServer

type EchoHTTPServer struct {
	*Cmd
}

Echo stores data for Echo HTTP backend process.

func NewEchoHTTPServer

func NewEchoHTTPServer(port uint16, enableHttps bool, enableRootPathHandler, useWrongCert bool, mtlsCertFile string, disableHttp2 bool) (*EchoHTTPServer, error)

type Envoy

type Envoy struct {
	*Cmd
	// contains filtered or unexported fields
}

Envoy stores data for Envoy process

func NewEnvoy

func NewEnvoy(args []string, bootstrapArgs []string, confPath string, ports *Ports, testId uint16) (*Envoy, error)

NewEnvoy creates a new Envoy struct and starts envoy.

func (Envoy) CheckHealth

func (s Envoy) CheckHealth() error

func (Envoy) String

func (s Envoy) String() string

type FakeJwtService

type FakeJwtService struct {
	ProviderMap map[string]*MockJwtProvider
}

func NewFakeJwtService

func NewFakeJwtService() *FakeJwtService

Returns a FakeJwtService that is ready to use. All servers will be started.

func (*FakeJwtService) ResetReqCnt

func (fjs *FakeJwtService) ResetReqCnt(provider string)

func (*FakeJwtService) SetupInvalidOpenId

func (fjs *FakeJwtService) SetupInvalidOpenId() error

Setup invalid providers that do not follow the OpenID Connect Discovery protocol.

func (*FakeJwtService) SetupJwt

func (fjs *FakeJwtService) SetupJwt(requestedProviders map[string]bool, ports *Ports) error

Setup non-OpenId providers.

func (*FakeJwtService) SetupValidOpenId

func (fjs *FakeJwtService) SetupValidOpenId() error

This method setup OpenId providers. It can only be called sequentially or in one goroutine during parallel execution because the OpenId providers use hard-coded ports and parallel run will cause the competition for ports.

func (*FakeJwtService) TearDown

func (fjs *FakeJwtService) TearDown()

Stops all running servers.

type FakeTraceServer

type FakeTraceServer struct {
	cloudtracegrpc.TraceServiceServer

	RcvSpan chan *cloudtracepb.Span
	// contains filtered or unexported fields
}

FakeTraceServer implements the cloud trace v2 RPCs (see cloudtracegrpc.TraceServiceServer)

func NewFakeStackdriver

func NewFakeStackdriver() *FakeTraceServer

func (*FakeTraceServer) BatchWriteSpans

func (s *FakeTraceServer) BatchWriteSpans(ctx context.Context, req *cloudtracepb.BatchWriteSpansRequest) (*emptypb.Empty, error)

func (*FakeTraceServer) CreateSpan

func (s *FakeTraceServer) CreateSpan(ctx context.Context, span *cloudtracepb.Span) (*cloudtracepb.Span, error)

func (*FakeTraceServer) RetrieveSpanNames

func (s *FakeTraceServer) RetrieveSpanNames() ([]string, error)

func (*FakeTraceServer) StartStackdriverServer

func (s *FakeTraceServer) StartStackdriverServer(port uint16)

func (*FakeTraceServer) StopAndWait

func (s *FakeTraceServer) StopAndWait()

func (*FakeTraceServer) VerifyInvariants

func (s *FakeTraceServer) VerifyInvariants() error

When the test is over, there should be no more spans left.

type GrpcEchoGrpcServer

type GrpcEchoGrpcServer struct {
	*Cmd
}

func NewGrpcEchoGrpcServer

func NewGrpcEchoGrpcServer(port uint16) (*GrpcEchoGrpcServer, error)

type GrpcInteropGrpcServer

type GrpcInteropGrpcServer struct {
	*Cmd
}

func NewGrpcInteropGrpcServer

func NewGrpcInteropGrpcServer(port uint16) (*GrpcInteropGrpcServer, error)

type HealthCheckOptions

type HealthCheckOptions struct {
	HealthCheckRetries      int
	HealthCheckRetryBackoff time.Duration
	HealthCheckDeadline     time.Duration
}

Options to configure retries, timeouts, etc. for the retry helpers.

func NewHealthCheckOptions

func NewHealthCheckOptions() *HealthCheckOptions

Constructs a HealthCheckOptions with the default values.

type HealthChecker

type HealthChecker interface {
	fmt.Stringer
	CheckHealth() error
}

All registered HealthCheckers must implement this interface

type HealthRegistry

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

Registry of Health Checkers

func NewHealthRegistry

func NewHealthRegistry() *HealthRegistry

func (*HealthRegistry) DeregisterHealthChecker

func (hr *HealthRegistry) DeregisterHealthChecker(checker HealthChecker)

func (*HealthRegistry) RegisterHealthChecker

func (hr *HealthRegistry) RegisterHealthChecker(checker HealthChecker)

func (*HealthRegistry) RunAllHealthChecks

func (hr *HealthRegistry) RunAllHealthChecks() error

Runs all registered health checks in parallel. Will return error if any health check fails.

type MockIamServer

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

MockIamServer mocks the Metadata server.

func NewIamMetadata

func NewIamMetadata(pathResp map[string]string, wantNumFails int, respTime time.Duration) *MockIamServer

NewMockMetadata creates a new HTTP server.

func (*MockIamServer) GetRequestBody

func (m *MockIamServer) GetRequestBody() (string, error)

func (*MockIamServer) GetRequestToken

func (m *MockIamServer) GetRequestToken() (string, error)

func (*MockIamServer) GetURL

func (m *MockIamServer) GetURL() string

GetURL returns the URL of the MockIamServer.

type MockJwtProvider

type MockJwtProvider struct {
	AuthProvider *scpb.AuthProvider
	// contains filtered or unexported fields
}

MockJwtProvider mocks the Jwt provider.

func (*MockJwtProvider) GetReqCnt

func (m *MockJwtProvider) GetReqCnt() int

func (*MockJwtProvider) GetURL

func (m *MockJwtProvider) GetURL() string

type MockMetadataServer

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

MockMetadataServer mocks the Metadata server.

func NewMockMetadata

func NewMockMetadata(pathResp map[string]string, wantNumFails int) *MockMetadataServer

NewMockMetadata creates a new HTTP server.

func (*MockMetadataServer) GetReqCnt

func (m *MockMetadataServer) GetReqCnt(reqURI string) int

func (*MockMetadataServer) GetURL

func (m *MockMetadataServer) GetURL() string

GetURL returns the URL of the MockMetadataServer.

type MockServiceCtrl

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

MockServiceMrg mocks the Service Management server.

func NewMockServiceCtrl

func NewMockServiceCtrl(serviceName, rolloutId string) *MockServiceCtrl

NewMockServiceCtrl creates a new HTTP server.

func (*MockServiceCtrl) CacheRequest

func (m *MockServiceCtrl) CacheRequest(req *utils.ServiceRequest)

func (*MockServiceCtrl) GetAllRequests

func (m *MockServiceCtrl) GetAllRequests() []*utils.ServiceRequest

GetRequests returns a slice of requests received.

func (*MockServiceCtrl) GetRequestCount

func (m *MockServiceCtrl) GetRequestCount() int

func (*MockServiceCtrl) GetRequests

func (m *MockServiceCtrl) GetRequests(n int) ([]*utils.ServiceRequest, error)

GetRequests returns a slice of requests received.

func (*MockServiceCtrl) GetURL

func (m *MockServiceCtrl) GetURL() string

GetURL returns the URL of MockServiceCtrl.

func (*MockServiceCtrl) IncrementRequestCount

func (m *MockServiceCtrl) IncrementRequestCount()

IncrementRequestCount increments the request count of MockServiceCtrl.

func (*MockServiceCtrl) OverrideCheckHandler

func (m *MockServiceCtrl) OverrideCheckHandler(checkHandler http.Handler)

OverrideCheckHandler overrides the service control check handler before setup.

func (*MockServiceCtrl) OverrideQuotaHandler

func (m *MockServiceCtrl) OverrideQuotaHandler(quotaHandler http.Handler)

OverrideQuoatHandler overrides the service control quota handler before setup.

func (*MockServiceCtrl) OverrideReportHandler

func (m *MockServiceCtrl) OverrideReportHandler(reportHandler http.Handler)

OverrideReportHandler overrides the service control report handler before setup.

func (*MockServiceCtrl) ResetRequestCount

func (m *MockServiceCtrl) ResetRequestCount()

ResetRequestCount resets the request count of MockServiceCtrl.

func (*MockServiceCtrl) SetCert

func (m *MockServiceCtrl) SetCert(serverCerts *tls.Certificate)

SetCert sets the server cert for ServiceControl server, so it acts as a HTTPS server

func (*MockServiceCtrl) SetCheckResponse

func (m *MockServiceCtrl) SetCheckResponse(checkResponse *scpb.CheckResponse)

SetCheckResponse sets the response for the check of the service control.

func (*MockServiceCtrl) SetCheckResponseStatus

func (m *MockServiceCtrl) SetCheckResponseStatus(status int)

SetCheckResponseStatus sets the response status code for the check of the service control.

func (*MockServiceCtrl) SetGetRequestsTimeout

func (m *MockServiceCtrl) SetGetRequestsTimeout(timeout time.Duration)

SetGetRequestsTimeout sets the timeout for GetRequests.

func (*MockServiceCtrl) SetQuotaResponse

func (m *MockServiceCtrl) SetQuotaResponse(quotaResponse *scpb.AllocateQuotaResponse)

SetCheckResponse sets the response for the check of the service control.

func (*MockServiceCtrl) SetQuotaResponseStatus

func (m *MockServiceCtrl) SetQuotaResponseStatus(status int)

SetQuotaResponseStatus sets the response status code for the quota of the service control.

func (*MockServiceCtrl) SetReportResponseStatus

func (m *MockServiceCtrl) SetReportResponseStatus(statusCode int)

SetReportResponseStatus sets the status of the report response of the service control.

func (*MockServiceCtrl) SetRolloutIdConfigIdInReport

func (m *MockServiceCtrl) SetRolloutIdConfigIdInReport(newRolloutId string)

SetReportResponseStatus sets the status of the report response of the service control.

func (*MockServiceCtrl) SetURL

func (m *MockServiceCtrl) SetURL(url string)

GetURL returns the URL of MockServiceCtrl.

func (*MockServiceCtrl) Setup

func (m *MockServiceCtrl) Setup()

func (*MockServiceCtrl) VerifyRequestCount

func (m *MockServiceCtrl) VerifyRequestCount(wantRequestCount int) error

VerifyRequestCount Verifies the current exact request count with the want request count

type MockServiceMrg

type MockServiceMrg struct {
	ServiceConfig *confpb.Service

	ConfigsHandler http.Handler

	LastServiceConfig []byte
	// contains filtered or unexported fields
}

MockServiceMrg mocks the Service Management server. All requests must be ProtoOverHttp.

func NewMockServiceMrg

func NewMockServiceMrg(serviceName, rolloutId string, serviceConfig *confpb.Service) *MockServiceMrg

NewMockServiceMrg creates a new HTTP server.

func (*MockServiceMrg) ServeHTTP

func (m *MockServiceMrg) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP responds to requests with static service config message.

func (*MockServiceMrg) SetCert

func (m *MockServiceMrg) SetCert(serverCerts *tls.Certificate)

SetCert sets the server cert for ServiceMrg server, so it acts as a HTTPS server

func (*MockServiceMrg) SetRolloutId

func (m *MockServiceMrg) SetRolloutId(newRolloutId string)

func (*MockServiceMrg) Start

func (m *MockServiceMrg) Start() (URL string)

Start launches a mock ServiceManagement server.

type Ports

type Ports struct {
	BackendServerPort         uint16
	DynamicRoutingBackendPort uint16
	ListenerPort              uint16
	DiscoveryPort             uint16
	AdminPort                 uint16
	FakeStackdriverPort       uint16
	DnsResolverPort           uint16
	JwtRangeBase              uint16
}

Ports stores all used ports and other ids for shared resources

func NewPorts

func NewPorts(testId uint16) *Ports

NewPorts allocate all ports based on test id.

type RetryHandler

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

Handles responding with errors for a specified number of retries. Has the ability to debounce multiple requests made within a time interval.

func NewRetryHandler

func NewRetryHandler(wantNumFails int) *RetryHandler

type StatsVerifier

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

func NewStatsVerifier

func NewStatsVerifier(ports *Ports) *StatsVerifier

func (StatsVerifier) CheckExpectedCounters

func (sv StatsVerifier) CheckExpectedCounters(wantCounters utils.StatCounters) error

func (StatsVerifier) CheckExpectedHistograms

func (sv StatsVerifier) CheckExpectedHistograms(wantHistograms utils.StatHistograms) error

func (StatsVerifier) CheckHealth

func (sv StatsVerifier) CheckHealth() error

func (StatsVerifier) String

func (sv StatsVerifier) String() string

func (StatsVerifier) VerifyInvariants

func (sv StatsVerifier) VerifyInvariants() error