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 HTTPFastGet(url string) (err error)
- 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)
- func WaitForPort(port uint16)
- type Envoy
- type HTTPServer
- type Handler
- type MixerFilterConf
- type MixerServer
- func (ts *MixerServer) Check(bag attribute.Bag, output *attribute.MutableBag) (mockapi.CheckResponse, rpc.Status)
- 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()
- func (ts *MixerServer) Stop()
- type Ports
- type TestSetup
- func (s *TestSetup) CreateEnvoyConf(path string, stress bool, filtersBeforeMixer string, mfConfig *MixerFilterConf, ...) error
- func (s *TestSetup) DrainMixerAllChannels()
- func (s *TestSetup) GetMixerCheckCount() int
- func (s *TestSetup) GetMixerQuotaCount() int
- func (s *TestSetup) GetMixerReportCount() int
- func (s *TestSetup) MfConfig() *MixerFilterConf
- func (s *TestSetup) NewEnvoy(stress bool, filtersBeforeMixer string, mfConf *MixerFilterConf, ports *Ports, ...) (*Envoy, error)
- func (s *TestSetup) Ports() *Ports
- func (s *TestSetup) ReStartEnvoy()
- 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) SetMixerFilterConfVersion(ver string)
- func (s *TestSetup) SetMixerQuotaLimit(limit int64)
- func (s *TestSetup) SetMixerQuotaReferenced(ref *mixerpb.ReferencedAttributes)
- func (s *TestSetup) SetMixerQuotaStatus(status rpc.Status)
- 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(actualStats string, expectedStats map[string]int)
- func (s *TestSetup) VerifyStatsLT(actualStats string, expectedStat string, expectedStatVal int)
- 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 JWTAuthTest MixerInternalFailTest NetworkFailureTest QuotaCacheTest QuotaCallTest ReportBatchTest TCPMixerFilterPeriodicalReportTest TCPMixerFilterTest TCPMixerFilterV1ConfigTest XDSTest CheckReportIstioAuthnAttributesTestOriginJwtBoundToOrigin CheckReportIstioAuthnAttributesTestOriginJwtBoundToPeer CheckReportIstioAuthnAttributesTestPeerJwtBoundToPeer CheckReportIstioAuthnAttributesTestPeerJwtBoundToOrigin IstioAuthnTestOriginRejectNoJwt IstioAuthnTestPeerRejectNoJwt IstioAuthnTestPeerRejectNoMtls IstioAuthnTestPeerRejectNoTLS )
All tests should be listed here to get their test ids
const MixerFilterConfigV1 = "\"v1\": "
MixerFilterConfigV1 is version v1 for Mixer filter config.
const MixerFilterConfigV2 = "\"v2\": "
MixerFilterConfigV2 is version v2 for Mixer filter config.
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 HTTPFastGet ¶
HTTPFastGet only cares about network error. Issue fast request, only care about network error. Don't care about server response.
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 ¶
func WaitForHTTPServer(url string)
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) Start ¶
func (s *HTTPServer) Start()
Start starts the server TODO: Add a channel so this can return an error
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 // contains filtered or unexported fields }
MixerServer stores data for a mock Mixer server.
func NewMixerServer ¶
func NewMixerServer(port uint16, stress bool) (*MixerServer, error)
NewMixerServer creates a new Mixer server
func (*MixerServer) Check ¶
func (ts *MixerServer) Check(bag attribute.Bag, output *attribute.MutableBag) (mockapi.CheckResponse, rpc.Status)
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()
Start starts the mixer server TODO: Add a channel so this can return an error
type Ports ¶
type Ports struct { ClientProxyPort uint16 ServerProxyPort uint16 TCPProxyPort uint16 AdminPort uint16 MixerPort uint16 BackendPort 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 { // 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 // 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 ¶
func (s *TestSetup) CreateEnvoyConf(path string, stress bool, filtersBeforeMixer string, mfConfig *MixerFilterConf, ports *Ports, confVersion string) error
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) MfConfig ¶
func (s *TestSetup) MfConfig() *MixerFilterConf
MfConfig get Mixer filter config
func (*TestSetup) NewEnvoy ¶
func (s *TestSetup) NewEnvoy(stress bool, filtersBeforeMixer string, mfConf *MixerFilterConf, ports *Ports, epoch int, confVersion string, disableHotRestart bool) (*Envoy, error)
NewEnvoy creates a new Envoy struct and starts envoy.
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) SetMixerFilterConfVersion ¶
SetMixerFilterConfVersion sets Mixer filter config version into Envoy config.
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) 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.