Documentation ¶
Index ¶
- Constants
- func AddHTTPQuota(mfConf *MixerFilterConf, quota string, charge int64)
- func DisableHTTPCheckReport(mfConf *MixerFilterConf, disableCheck, disableReport bool)
- func DisableHTTPClientCache(mfConf *mccpb.HttpClientConfig, checkCache, quotaCache, reportBatch bool)
- func DisableTCPCheckReport(mfConf *mccpb.TcpClientConfig, disableCheck, disableReport bool)
- func DisableTCPClientCache(mfConf *mccpb.TcpClientConfig, checkCache, quotaCache, reportBatch bool)
- func GetDefaultHTTPClientConf() *mccpb.HttpClientConfig
- func GetDefaultHTTPServerConf() *mccpb.HttpClientConfig
- func GetDefaultServiceConfig() *mccpb.ServiceConfig
- func GetDefaultTCPServerConf() *mccpb.TcpClientConfig
- func HTTPGet(url string) (code int, respBody string, err error)
- func HTTPGetWithHeaders(l string, headers map[string]string) (code int, respBody string, err error)
- func HTTPPost(url string, contentType string, reqBody string) (code int, respBody string, err error)
- func IsPortUsed(port uint16) bool
- func SetDefaultServiceConfigMap(mfConf *MixerFilterConf)
- func SetNetworPolicy(mfConf *mccpb.HttpClientConfig, open bool)
- func SetStatsUpdateInterval(mfConf *MixerFilterConf, updateInterval int64)
- func SetTCPReportInterval(mfConf *mccpb.TcpClientConfig, reportInterval int64)
- func ShortLiveHTTPPost(url string, contentType string, reqBody string) (code int, respBody string, err error)
- func Verify(b *attribute.MutableBag, expectedJSON string) error
- func WaitForHTTPServer(url string) error
- func WaitForPort(port uint16)
- type Envoy
- type HTTPServer
- type Handler
- type MixerFilterConf
- type MixerServer
- func (ts *MixerServer) Check(bag attribute.Bag) mixerpb.CheckResponse_PreconditionResult
- func (ts *MixerServer) GetCheck() *attribute.MutableBag
- func (ts *MixerServer) GetReport() *attribute.MutableBag
- func (ts *MixerServer) Quota(bag attribute.Bag, qma mockapi.QuotaArgs) (mockapi.QuotaResponse, rpc.Status)
- func (ts *MixerServer) Report(bag attribute.Bag) rpc.Status
- func (ts *MixerServer) Start() <-chan error
- func (ts *MixerServer) Stop()
- type Ports
- type TestSetup
- func (s *TestSetup) CreateEnvoyConf(path string) error
- func (s *TestSetup) DrainMixerAllChannels()
- func (s *TestSetup) GetMixerCheckCount() int
- func (s *TestSetup) GetMixerQuotaCount() int
- func (s *TestSetup) GetMixerReportCount() int
- func (s *TestSetup) LastRequestHeaders() http.Header
- func (s *TestSetup) MfConfig() *MixerFilterConf
- func (s *TestSetup) NewEnvoy() (*Envoy, error)
- func (s *TestSetup) Ports() *Ports
- func (s *TestSetup) ReStartEnvoy()
- func (s *TestSetup) SetCheckDict(checkDict bool)
- func (s *TestSetup) SetDisableHotRestart(disable bool)
- func (s *TestSetup) SetFiltersBeforeMixer(filters string)
- func (s *TestSetup) SetMixerCheckReferenced(ref *mixerpb.ReferencedAttributes)
- func (s *TestSetup) SetMixerCheckStatus(status rpc.Status)
- func (s *TestSetup) SetMixerQuotaLimit(limit int64)
- func (s *TestSetup) SetMixerQuotaReferenced(ref *mixerpb.ReferencedAttributes)
- func (s *TestSetup) SetMixerQuotaStatus(status rpc.Status)
- func (s *TestSetup) SetMixerRouteDirective(directive *mixerpb.RouteDirective)
- func (s *TestSetup) SetMixerSourceUID(uid string)
- func (s *TestSetup) SetNoBackend(no bool)
- func (s *TestSetup) SetNoMixer(no bool)
- func (s *TestSetup) SetNoProxy(no bool)
- func (s *TestSetup) SetStress(stress bool)
- func (s *TestSetup) SetUp() error
- func (s *TestSetup) TearDown()
- func (s *TestSetup) VerifyCheck(tag string, result string)
- func (s *TestSetup) VerifyCheckCount(tag string, expected int)
- func (s *TestSetup) VerifyQuota(tag string, name string, amount int64)
- func (s *TestSetup) VerifyReport(tag string, result string)
- func (s *TestSetup) VerifyReportCount(tag string, expected int)
- func (s *TestSetup) VerifyStats(expectedStats map[string]int)
- func (s *TestSetup) VerifyStatsLT(actualStats string, expectedStat string, expectedStatVal int)
- func (s *TestSetup) VerifyTwoReports(tag string, result1, result2 string)
- func (s *TestSetup) WaitEnvoyReady()
- func (s *TestSetup) WaitForStatsUpdateAndGetStats(waitDuration int) (string, error)
Constants ¶
const ( FailHeader = "x-istio-backend-fail" FailBody = "Bad request from backend." )
If HTTP header has non empty FailHeader, HTTP server will fail the request with 400 with FailBody in the response body.
const ( CheckCacheHitTest uint16 = iota CheckCacheTest CheckReportAttributesTest CheckReportDisableTest CheckReportLargePostRequestTest DisableCheckCacheTest DisableTCPCheckCallsTest FailedRequestTest FaultInjectTest GlobalDictionaryTest JWTAuthTest MixerInternalFailTest NetworkFailureTest QuotaCacheTest QuotaCallTest ReportBatchTest TCPMixerFilterPeriodicalReportTest TCPMixerFilterTest XDSTest CheckReportIstioAuthnAttributesTestOriginJwtBoundToOrigin CheckReportIstioAuthnAttributesTestOriginJwtBoundToPeer CheckReportIstioAuthnAttributesTestPeerJwtBoundToPeer CheckReportIstioAuthnAttributesTestPeerJwtBoundToOrigin IstioAuthnTestOriginRejectNoJwt IstioAuthnTestPeerRejectNoJwt IstioAuthnTestPeerRejectNoMtls IstioAuthnTestPeerRejectNoTLS RouteDirectiveTest DynamicAttributeTest DynamicListenerTest PilotPluginTest PilotPluginTCPTest PilotPluginTLSTest PilotMCPTest RbacGlobalPermissiveTest RbacPolicyPermissiveTest GatewayTest )
All tests should be listed here to get their test ids
Variables ¶
This section is empty.
Functions ¶
func AddHTTPQuota ¶
func AddHTTPQuota(mfConf *MixerFilterConf, quota string, charge int64)
AddHTTPQuota add HTTP quota config
func DisableHTTPCheckReport ¶
func DisableHTTPCheckReport(mfConf *MixerFilterConf, disableCheck, disableReport bool)
DisableHTTPCheckReport disable HTTP check report
func DisableHTTPClientCache ¶
func DisableHTTPClientCache(mfConf *mccpb.HttpClientConfig, checkCache, quotaCache, reportBatch bool)
DisableHTTPClientCache disable HTTP client cache
func DisableTCPCheckReport ¶
func DisableTCPCheckReport(mfConf *mccpb.TcpClientConfig, disableCheck, disableReport bool)
DisableTCPCheckReport disable TCP check report.
func DisableTCPClientCache ¶
func DisableTCPClientCache(mfConf *mccpb.TcpClientConfig, checkCache, quotaCache, reportBatch bool)
DisableTCPClientCache disable TCP client cache
func GetDefaultHTTPClientConf ¶
func GetDefaultHTTPClientConf() *mccpb.HttpClientConfig
GetDefaultHTTPClientConf get default HTTP client config
func GetDefaultHTTPServerConf ¶
func GetDefaultHTTPServerConf() *mccpb.HttpClientConfig
GetDefaultHTTPServerConf get default HTTP server config
func GetDefaultServiceConfig ¶
func GetDefaultServiceConfig() *mccpb.ServiceConfig
GetDefaultServiceConfig get default service config
func GetDefaultTCPServerConf ¶
func GetDefaultTCPServerConf() *mccpb.TcpClientConfig
GetDefaultTCPServerConf get default TCP server config
func HTTPGetWithHeaders ¶
HTTPGetWithHeaders send HTTP with headers
func HTTPPost ¶
func HTTPPost(url string, contentType string, reqBody string) (code int, respBody string, err error)
HTTPPost sends POST
func SetDefaultServiceConfigMap ¶
func SetDefaultServiceConfigMap(mfConf *MixerFilterConf)
SetDefaultServiceConfigMap set the default service config to the service config map
func SetNetworPolicy ¶
func SetNetworPolicy(mfConf *mccpb.HttpClientConfig, open bool)
SetNetworPolicy set network policy
func SetStatsUpdateInterval ¶
func SetStatsUpdateInterval(mfConf *MixerFilterConf, updateInterval int64)
SetStatsUpdateInterval sets stats update interval for Mixer client filters in seconds.
func SetTCPReportInterval ¶
func SetTCPReportInterval(mfConf *mccpb.TcpClientConfig, reportInterval int64)
SetTCPReportInterval sets TCP filter report interval in seconds
func ShortLiveHTTPPost ¶
func ShortLiveHTTPPost(url string, contentType string, reqBody string) (code int, respBody string, err error)
ShortLiveHTTPPost send HTTP without keepalive
func Verify ¶
func Verify(b *attribute.MutableBag, expectedJSON string) error
Verify verifes an attributeBug with expected json string. Attributes verification rules:
- If value is *, key must exist, but value is not checked.
- If value is -, key must NOT exist.
- At top level attributes, not inside StringMap, all keys must be listed. Extra keys are NOT allowed
- Inside StringMap, not need to list all keys. Extra keys are allowed
Attributes provided from envoy config * source.id and source.namespace are forwarded from client proxy * target.id and target.namespace are from server proxy
HTTP header "x-istio-attributes" is used to forward attributes between proxy. It should be removed before calling mixer and backend.
func WaitForHTTPServer ¶
WaitForHTTPServer waits for a HTTP server
Types ¶
type Envoy ¶
type Envoy struct {
// contains filtered or unexported fields
}
Envoy stores data for Envoy process
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer stores data for a HTTP server.
func NewHTTPServer ¶
func NewHTTPServer(port uint16) (*HTTPServer, error)
NewHTTPServer creates a new HTTP server.
func (*HTTPServer) LastRequestHeaders ¶
func (s *HTTPServer) LastRequestHeaders() http.Header
LastRequestHeaders returns the headers from the last request and clears the value
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler stores data for Check, Quota and Report.
type MixerFilterConf ¶
type MixerFilterConf struct { PerRouteConf *mccpb.ServiceConfig HTTPServerConf *mccpb.HttpClientConfig HTTPClientConf *mccpb.HttpClientConfig TCPServerConf *mccpb.TcpClientConfig }
MixerFilterConf stores config for Mixer filter.
func GetDefaultMixerFilterConf ¶
func GetDefaultMixerFilterConf() *MixerFilterConf
GetDefaultMixerFilterConf get config for Mixer filter
type MixerServer ¶
type MixerServer struct { mockapi.AttributesHandler sync.Mutex // contains filtered or unexported fields }
MixerServer stores data for a mock Mixer server.
func NewMixerServer ¶
func NewMixerServer(port uint16, stress bool, checkDict bool, checkSourceUID string) (*MixerServer, error)
NewMixerServer creates a new Mixer server
func (*MixerServer) Check ¶
func (ts *MixerServer) Check(bag attribute.Bag) mixerpb.CheckResponse_PreconditionResult
Check is called by the mock mixer api
func (*MixerServer) GetCheck ¶
func (ts *MixerServer) GetCheck() *attribute.MutableBag
GetCheck will return a received check
func (*MixerServer) GetReport ¶
func (ts *MixerServer) GetReport() *attribute.MutableBag
GetReport will return a received report
func (*MixerServer) Quota ¶
func (ts *MixerServer) Quota(bag attribute.Bag, qma mockapi.QuotaArgs) (mockapi.QuotaResponse, rpc.Status)
Quota is called by the mock mixer api
func (*MixerServer) Report ¶
func (ts *MixerServer) Report(bag attribute.Bag) rpc.Status
Report is called by the mock mixer api
func (*MixerServer) Start ¶
func (ts *MixerServer) Start() <-chan error
Start starts the mixer server
type Ports ¶
type Ports struct { ClientProxyPort uint16 ServerProxyPort uint16 TCPProxyPort uint16 AdminPort uint16 MixerPort uint16 BackendPort uint16 DiscoveryPort uint16 // Pilot ports, used when testing mixer-pilot integration. PilotGrpcPort uint16 PilotHTTPPort uint16 }
Ports stores all used ports
func NewEnvoyPorts ¶
NewEnvoyPorts allocate ports for Envoy
type TestSetup ¶
type TestSetup struct { FiltersBeforeMixer string // EnvoyTemplate is the bootstrap config used by envoy. EnvoyTemplate string // EnvoyParams contain extra envoy parameters to pass in the CLI (cluster, node) EnvoyParams []string // EnvoyConfigOpt allows passing additional parameters to the EnvoyTemplate EnvoyConfigOpt map[string]interface{} // IstioSrc is the base directory of istio sources. May be set for finding testdata or // other files in the source tree IstioSrc string // IstioOut is the base output directory. IstioOut string // AccessLogPath is the access log path for Envoy AccessLogPath string // Dir is the working dir for envoy Dir string // contains filtered or unexported fields }
TestSetup store data for a test.
func NewTestSetup ¶
NewTestSetup creates a new test setup "name" has to be defined in ports.go
func (*TestSetup) CreateEnvoyConf ¶
CreateEnvoyConf create envoy config.
func (*TestSetup) DrainMixerAllChannels ¶
func (s *TestSetup) DrainMixerAllChannels()
DrainMixerAllChannels drain all channels
func (*TestSetup) GetMixerCheckCount ¶
GetMixerCheckCount get the number of Check calls.
func (*TestSetup) GetMixerQuotaCount ¶
GetMixerQuotaCount get the number of Quota calls.
func (*TestSetup) GetMixerReportCount ¶
GetMixerReportCount get the number of Report calls.
func (*TestSetup) LastRequestHeaders ¶
LastRequestHeaders returns last backend request headers
func (*TestSetup) MfConfig ¶
func (s *TestSetup) MfConfig() *MixerFilterConf
MfConfig get Mixer filter config
func (*TestSetup) SetCheckDict ¶
SetCheckDict set the checkDict flag
func (*TestSetup) SetDisableHotRestart ¶
SetDisableHotRestart sets whether disable the HotRestart feature of Envoy
func (*TestSetup) SetFiltersBeforeMixer ¶
SetFiltersBeforeMixer sets the configurations of the filters before the Mixer filter
func (*TestSetup) SetMixerCheckReferenced ¶
func (s *TestSetup) SetMixerCheckReferenced(ref *mixerpb.ReferencedAttributes)
SetMixerCheckReferenced set Referenced in mocked Check response
func (*TestSetup) SetMixerCheckStatus ¶
SetMixerCheckStatus set Status in mocked Check response
func (*TestSetup) SetMixerQuotaLimit ¶
SetMixerQuotaLimit set mock quota limit
func (*TestSetup) SetMixerQuotaReferenced ¶
func (s *TestSetup) SetMixerQuotaReferenced(ref *mixerpb.ReferencedAttributes)
SetMixerQuotaReferenced set Referenced in mocked Quota response
func (*TestSetup) SetMixerQuotaStatus ¶
SetMixerQuotaStatus set Status in mocked Quota response
func (*TestSetup) SetMixerRouteDirective ¶
func (s *TestSetup) SetMixerRouteDirective(directive *mixerpb.RouteDirective)
SetMixerRouteDirective sets the route directive for Check precondition
func (*TestSetup) SetMixerSourceUID ¶
SetMixerSourceUID sets the expected source.uid at the mixer server gRPC metadata
func (*TestSetup) SetNoBackend ¶
SetNoBackend set NoMixer flag
func (*TestSetup) VerifyCheck ¶
VerifyCheck verifies Check request data.
func (*TestSetup) VerifyCheckCount ¶
VerifyCheckCount verifies the number of Check calls.
func (*TestSetup) VerifyQuota ¶
VerifyQuota verified Quota request data.
func (*TestSetup) VerifyReport ¶
VerifyReport verifies Report request data.
func (*TestSetup) VerifyReportCount ¶
VerifyReportCount verifies the number of Report calls.
func (*TestSetup) VerifyStats ¶
VerifyStats verifies Envoy stats.
func (*TestSetup) VerifyStatsLT ¶
VerifyStatsLT verifies that Envoy stats contains stat expectedStat, whose value is less than expectedStatVal.
func (*TestSetup) VerifyTwoReports ¶
VerifyTwoReports verifies two Report bags, in any order.
func (*TestSetup) WaitEnvoyReady ¶
func (s *TestSetup) WaitEnvoyReady()
WaitEnvoyReady waits until envoy receives and applies all config