istio: istio.io/istio/mixer/test/client/env Index | Files

package env

import "istio.io/istio/mixer/test/client/env"

Index

Package Files

attributes.go envoy.go envoy_conf.go http_client.go http_server.go mixer_filter_config.go mixer_server.go ports.go setup.go

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
    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
    SidecarTest
    SidecarConsumerOnlyTest
    TracingHeaderTest
)

All tests should be listed here to get their test ids

func AddHTTPQuota Uses

func AddHTTPQuota(mfConf *MixerFilterConf, quota string, charge int64)

AddHTTPQuota add HTTP quota config

func DisableHTTPCheckReport Uses

func DisableHTTPCheckReport(mfConf *MixerFilterConf, disableCheck, disableReport bool)

DisableHTTPCheckReport disable HTTP check report

func DisableHTTPClientCache Uses

func DisableHTTPClientCache(mfConf *mccpb.HttpClientConfig, checkCache, quotaCache, reportBatch bool)

DisableHTTPClientCache disable HTTP client cache

func DisableTCPCheckReport Uses

func DisableTCPCheckReport(mfConf *mccpb.TcpClientConfig, disableCheck, disableReport bool)

DisableTCPCheckReport disable TCP check report.

func DisableTCPClientCache Uses

func DisableTCPClientCache(mfConf *mccpb.TcpClientConfig, checkCache, quotaCache, reportBatch bool)

DisableTCPClientCache disable TCP client cache

func GetDefaultHTTPClientConf Uses

func GetDefaultHTTPClientConf() *mccpb.HttpClientConfig

GetDefaultHTTPClientConf get default HTTP client config

func GetDefaultHTTPServerConf Uses

func GetDefaultHTTPServerConf() *mccpb.HttpClientConfig

GetDefaultHTTPServerConf get default HTTP server config

func GetDefaultServiceConfig Uses

func GetDefaultServiceConfig() *mccpb.ServiceConfig

GetDefaultServiceConfig get default service config

func GetDefaultTCPServerConf Uses

func GetDefaultTCPServerConf() *mccpb.TcpClientConfig

GetDefaultTCPServerConf get default TCP server config

func HTTPGet Uses

func HTTPGet(url string) (code int, respBody string, err error)

HTTPGet send GET

func HTTPGetWithHeaders Uses

func HTTPGetWithHeaders(l string, headers map[string]string) (code int, respBody string, err error)

HTTPGetWithHeaders send HTTP with headers

func HTTPPost Uses

func HTTPPost(url string, contentType string, reqBody string) (code int, respBody string, err error)

HTTPPost sends POST

func IsPortUsed Uses

func IsPortUsed(port uint16) bool

IsPortUsed checks if a port is used

func SetDefaultServiceConfigMap Uses

func SetDefaultServiceConfigMap(mfConf *MixerFilterConf)

SetDefaultServiceConfigMap set the default service config to the service config map

func SetNetworPolicy Uses

func SetNetworPolicy(mfConf *mccpb.HttpClientConfig, open bool)

SetNetworPolicy set network policy

func SetStatsUpdateInterval Uses

func SetStatsUpdateInterval(mfConf *MixerFilterConf, updateInterval int64)

SetStatsUpdateInterval sets stats update interval for Mixer client filters in seconds.

func SetTCPReportInterval Uses

func SetTCPReportInterval(mfConf *mccpb.TcpClientConfig, reportInterval int64)

SetTCPReportInterval sets TCP filter report interval in seconds

func ShortLiveHTTPPost Uses

func ShortLiveHTTPPost(url string, contentType string, reqBody string) (code int, respBody string, err error)

ShortLiveHTTPPost send HTTP without keepalive

func Verify Uses

func Verify(b *attribute.MutableBag, expectedJSON string) error

Verify verifes an attributeBug with expected json string. Attributes verification rules:

1) If value is *, key must exist, but value is not checked. 1) If value is -, key must NOT exist. 3) At top level attributes, not inside StringMap, all keys must

be listed. Extra keys are NOT allowed

3) 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 Uses

func WaitForHTTPServer(url string) error

WaitForHTTPServer waits for a HTTP server

func WaitForPort Uses

func WaitForPort(port uint16)

WaitForPort waits for a TCP port

type HTTPServer Uses

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

HTTPServer stores data for a HTTP server.

func NewHTTPServer Uses

func NewHTTPServer(port uint16) (*HTTPServer, error)

NewHTTPServer creates a new HTTP server.

func (*HTTPServer) LastRequestHeaders Uses

func (s *HTTPServer) LastRequestHeaders() http.Header

LastRequestHeaders returns the headers from the last request and clears the value

func (*HTTPServer) Start Uses

func (s *HTTPServer) Start() <-chan error

Start starts the server

func (*HTTPServer) Stop Uses

func (s *HTTPServer) Stop()

Stop shutdown the server

type Handler Uses

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

Handler stores data for Check, Quota and Report.

func (*Handler) Count Uses

func (h *Handler) Count() int

Count get the called counter

type MixerFilterConf Uses

type MixerFilterConf struct {
    PerRouteConf   *mccpb.ServiceConfig
    HTTPServerConf *mccpb.HttpClientConfig
    HTTPClientConf *mccpb.HttpClientConfig
    TCPServerConf  *mccpb.TcpClientConfig
}

MixerFilterConf stores config for Mixer filter.

func GetDefaultMixerFilterConf Uses

func GetDefaultMixerFilterConf() *MixerFilterConf

GetDefaultMixerFilterConf get config for Mixer filter

type MixerServer Uses

type MixerServer struct {
    mockapi.AttributesHandler

    sync.Mutex
    // contains filtered or unexported fields
}

MixerServer stores data for a mock Mixer server.

func NewMixerServer Uses

func NewMixerServer(port uint16, stress bool, checkDict bool, checkSourceUID string) (*MixerServer, error)

NewMixerServer creates a new Mixer server

func (*MixerServer) Check Uses

func (ts *MixerServer) Check(bag attribute.Bag) mixerpb.CheckResponse_PreconditionResult

Check is called by the mock mixer api

func (*MixerServer) GetCheck Uses

func (ts *MixerServer) GetCheck() *attribute.MutableBag

GetCheck will return a received check

func (*MixerServer) GetReport Uses

func (ts *MixerServer) GetReport() *attribute.MutableBag

GetReport will return a received report

func (*MixerServer) Quota Uses

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 Uses

func (ts *MixerServer) Report(bag attribute.Bag) rpc.Status

Report is called by the mock mixer api

func (*MixerServer) Start Uses

func (ts *MixerServer) Start() <-chan error

Start starts the mixer server

func (*MixerServer) Stop Uses

func (ts *MixerServer) Stop()

Stop shutdown the server

type Ports Uses

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 Uses

func NewEnvoyPorts(ports *Ports, name uint16) *Ports

NewEnvoyPorts allocate ports for Envoy

func NewPorts Uses

func NewPorts(name uint16) *Ports

NewPorts allocate all ports based on test id.

type TestSetup Uses

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 Uses

func NewTestSetup(name uint16, t *testing.T) *TestSetup

NewTestSetup creates a new test setup "name" has to be defined in ports.go

func (*TestSetup) CreateEnvoyConf Uses

func (s *TestSetup) CreateEnvoyConf(path string) error

CreateEnvoyConf create envoy config.

func (*TestSetup) DrainMixerAllChannels Uses

func (s *TestSetup) DrainMixerAllChannels()

DrainMixerAllChannels drain all channels

func (*TestSetup) GetMixerCheckCount Uses

func (s *TestSetup) GetMixerCheckCount() int

GetMixerCheckCount get the number of Check calls.

func (*TestSetup) GetMixerQuotaCount Uses

func (s *TestSetup) GetMixerQuotaCount() int

GetMixerQuotaCount get the number of Quota calls.

func (*TestSetup) GetMixerReportCount Uses

func (s *TestSetup) GetMixerReportCount() int

GetMixerReportCount get the number of Report calls.

func (*TestSetup) LastRequestHeaders Uses

func (s *TestSetup) LastRequestHeaders() http.Header

LastRequestHeaders returns last backend request headers

func (*TestSetup) MfConfig Uses

func (s *TestSetup) MfConfig() *MixerFilterConf

MfConfig get Mixer filter config

func (*TestSetup) Ports Uses

func (s *TestSetup) Ports() *Ports

Ports get ports object

func (*TestSetup) ReStartEnvoy Uses

func (s *TestSetup) ReStartEnvoy()

ReStartEnvoy restarts Envoy

func (*TestSetup) SetCheckDict Uses

func (s *TestSetup) SetCheckDict(checkDict bool)

SetCheckDict set the checkDict flag

func (*TestSetup) SetDisableHotRestart Uses

func (s *TestSetup) SetDisableHotRestart(disable bool)

SetDisableHotRestart sets whether disable the HotRestart feature of Envoy

func (*TestSetup) SetFiltersBeforeMixer Uses

func (s *TestSetup) SetFiltersBeforeMixer(filters string)

SetFiltersBeforeMixer sets the configurations of the filters before the Mixer filter

func (*TestSetup) SetMixerCheckReferenced Uses

func (s *TestSetup) SetMixerCheckReferenced(ref *mixerpb.ReferencedAttributes)

SetMixerCheckReferenced set Referenced in mocked Check response

func (*TestSetup) SetMixerCheckStatus Uses

func (s *TestSetup) SetMixerCheckStatus(status rpc.Status)

SetMixerCheckStatus set Status in mocked Check response

func (*TestSetup) SetMixerQuotaLimit Uses

func (s *TestSetup) SetMixerQuotaLimit(limit int64)

SetMixerQuotaLimit set mock quota limit

func (*TestSetup) SetMixerQuotaReferenced Uses

func (s *TestSetup) SetMixerQuotaReferenced(ref *mixerpb.ReferencedAttributes)

SetMixerQuotaReferenced set Referenced in mocked Quota response

func (*TestSetup) SetMixerQuotaStatus Uses

func (s *TestSetup) SetMixerQuotaStatus(status rpc.Status)

SetMixerQuotaStatus set Status in mocked Quota response

func (*TestSetup) SetMixerRouteDirective Uses

func (s *TestSetup) SetMixerRouteDirective(directive *mixerpb.RouteDirective)

SetMixerRouteDirective sets the route directive for Check precondition

func (*TestSetup) SetMixerSourceUID Uses

func (s *TestSetup) SetMixerSourceUID(uid string)

SetMixerSourceUID sets the expected source.uid at the mixer server gRPC metadata

func (*TestSetup) SetNoBackend Uses

func (s *TestSetup) SetNoBackend(no bool)

SetNoBackend set NoMixer flag

func (*TestSetup) SetNoMixer Uses

func (s *TestSetup) SetNoMixer(no bool)

SetNoMixer set NoMixer flag

func (*TestSetup) SetNoProxy Uses

func (s *TestSetup) SetNoProxy(no bool)

SetNoProxy set NoProxy flag

func (*TestSetup) SetStress Uses

func (s *TestSetup) SetStress(stress bool)

SetStress set the stress flag

func (*TestSetup) SetUp Uses

func (s *TestSetup) SetUp() error

SetUp setups Envoy, Mixer, and Backend server for test.

func (*TestSetup) TearDown Uses

func (s *TestSetup) TearDown()

TearDown shutdown the servers.

func (*TestSetup) VerifyCheck Uses

func (s *TestSetup) VerifyCheck(tag string, result string)

VerifyCheck verifies Check request data.

func (*TestSetup) VerifyCheckCount Uses

func (s *TestSetup) VerifyCheckCount(tag string, expected int)

VerifyCheckCount verifies the number of Check calls.

func (*TestSetup) VerifyQuota Uses

func (s *TestSetup) VerifyQuota(tag string, name string, amount int64)

VerifyQuota verified Quota request data.

func (*TestSetup) VerifyReport Uses

func (s *TestSetup) VerifyReport(tag string, result string)

VerifyReport verifies Report request data.

func (*TestSetup) VerifyReportCount Uses

func (s *TestSetup) VerifyReportCount(tag string, expected int)

VerifyReportCount verifies the number of Report calls.

func (*TestSetup) VerifyStats Uses

func (s *TestSetup) VerifyStats(expectedStats map[string]int)

VerifyStats verifies Envoy stats.

func (*TestSetup) VerifyStatsLT Uses

func (s *TestSetup) VerifyStatsLT(actualStats string, expectedStat string, expectedStatVal int)

VerifyStatsLT verifies that Envoy stats contains stat expectedStat, whose value is less than expectedStatVal.

func (*TestSetup) VerifyTwoReports Uses

func (s *TestSetup) VerifyTwoReports(tag string, result1, result2 string)

VerifyTwoReports verifies two Report bags, in any order.

func (*TestSetup) WaitEnvoyReady Uses

func (s *TestSetup) WaitEnvoyReady()

WaitEnvoyReady waits until envoy receives and applies all config

func (*TestSetup) WaitForStatsUpdateAndGetStats Uses

func (s *TestSetup) WaitForStatsUpdateAndGetStats(waitDuration int) (string, error)

WaitForStatsUpdateAndGetStats waits for waitDuration seconds to let Envoy update stats, and sends request to Envoy for stats. Returns stats response.

Package env imports 31 packages (graph) and is imported by 1 packages. Updated 2019-09-26. Refresh now. Tools for package owners.