env

package
v0.0.0-...-d8a8f93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const (
	CheckCacheHitTest uint16 = iota
	CheckCacheTest
	CheckReportAttributesTest
	CheckReportDisableTest
	CheckReportLargePostRequestTest
	DisableCheckCacheTest
	DisableTCPCheckCallsTest
	FailedRequestTest
	FaultInjectTest
	JWTAuthTest
	MixerInternalFailTest
	NetworkFailureTest
	QuotaCacheTest
	QuotaCallTest
	ReportBatchTest
	TCPMixerFilterPeriodicalReportTest
	TCPMixerFilterTest
	XDSTest
	CheckReportIstioAuthnAttributesTestOriginJwtBoundToOrigin
	CheckReportIstioAuthnAttributesTestOriginJwtBoundToPeer
	CheckReportIstioAuthnAttributesTestPeerJwtBoundToPeer
	CheckReportIstioAuthnAttributesTestPeerJwtBoundToOrigin
	IstioAuthnTestOriginRejectNoJwt
	IstioAuthnTestPeerRejectNoJwt
	IstioAuthnTestPeerRejectNoMtls
	IstioAuthnTestPeerRejectNoTLS
	RouteDirectiveTest
	DynamicAttributeTest
	DynamicListenerTest
)

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 HTTPFastGet

func HTTPFastGet(url string) (err error)

HTTPFastGet only cares about network error. Issue fast request, only care about network error. Don't care about server response.

func HTTPGet

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

HTTPGet send GET

func HTTPGetWithHeaders

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

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 IsPortUsed

func IsPortUsed(port uint16) bool

IsPortUsed checks if a port is used

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:

  1. If value is *, key must exist, but value is not checked.
  2. 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
  4. 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

func WaitForPort

func WaitForPort(port uint16)

WaitForPort waits for a TCP port

Types

type Envoy

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

Envoy stores data for Envoy process

func (*Envoy) Start

func (s *Envoy) Start() error

Start starts the envoy process

func (*Envoy) Stop

func (s *Envoy) Stop() error

Stop stops the 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

func (*HTTPServer) Start

func (s *HTTPServer) Start()

Start starts the server TODO: Add a channel so this can return an error

func (*HTTPServer) Stop

func (s *HTTPServer) Stop()

Stop shutdown the server

type Handler

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

Handler stores data for Check, Quota and Report.

func (*Handler) Count

func (h *Handler) Count() int

Count get the called counter

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

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

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

func (*MixerServer) Stop

func (ts *MixerServer) Stop()

Stop shutdown the 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

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

NewEnvoyPorts allocate ports for Envoy

func NewPorts

func NewPorts(name uint16) *Ports

NewPorts allocate all ports based on test id.

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
	// contains filtered or unexported fields
}

TestSetup store data for a test.

func NewTestSetup

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

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

CreateEnvoyConf create envoy config.

func (*TestSetup) DrainMixerAllChannels

func (s *TestSetup) DrainMixerAllChannels()

DrainMixerAllChannels drain all channels

func (*TestSetup) GetMixerCheckCount

func (s *TestSetup) GetMixerCheckCount() int

GetMixerCheckCount get the number of Check calls.

func (*TestSetup) GetMixerQuotaCount

func (s *TestSetup) GetMixerQuotaCount() int

GetMixerQuotaCount get the number of Quota calls.

func (*TestSetup) GetMixerReportCount

func (s *TestSetup) GetMixerReportCount() int

GetMixerReportCount get the number of Report calls.

func (*TestSetup) LastRequestHeaders

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

LastRequestHeaders returns last backend request headers

func (*TestSetup) MfConfig

func (s *TestSetup) MfConfig() *MixerFilterConf

MfConfig get Mixer filter config

func (*TestSetup) NewEnvoy

func (s *TestSetup) NewEnvoy() (*Envoy, error)

NewEnvoy creates a new Envoy struct and starts envoy.

func (*TestSetup) Ports

func (s *TestSetup) Ports() *Ports

Ports get ports object

func (*TestSetup) ReStartEnvoy

func (s *TestSetup) ReStartEnvoy()

ReStartEnvoy restarts Envoy

func (*TestSetup) SetDisableHotRestart

func (s *TestSetup) SetDisableHotRestart(disable bool)

SetDisableHotRestart sets whether disable the HotRestart feature of Envoy

func (*TestSetup) SetFiltersBeforeMixer

func (s *TestSetup) SetFiltersBeforeMixer(filters string)

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

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

SetMixerCheckStatus set Status in mocked Check response

func (*TestSetup) SetMixerQuotaLimit

func (s *TestSetup) SetMixerQuotaLimit(limit int64)

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

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

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) SetNoBackend

func (s *TestSetup) SetNoBackend(no bool)

SetNoBackend set NoMixer flag

func (*TestSetup) SetNoMixer

func (s *TestSetup) SetNoMixer(no bool)

SetNoMixer set NoMixer flag

func (*TestSetup) SetNoProxy

func (s *TestSetup) SetNoProxy(no bool)

SetNoProxy set NoProxy flag

func (*TestSetup) SetStress

func (s *TestSetup) SetStress(stress bool)

SetStress set the stress flag

func (*TestSetup) SetUp

func (s *TestSetup) SetUp() error

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

func (*TestSetup) TearDown

func (s *TestSetup) TearDown()

TearDown shutdown the servers.

func (*TestSetup) VerifyCheck

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

VerifyCheck verifies Check request data.

func (*TestSetup) VerifyCheckCount

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

VerifyCheckCount verifies the number of Check calls.

func (*TestSetup) VerifyQuota

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

VerifyQuota verified Quota request data.

func (*TestSetup) VerifyReport

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

VerifyReport verifies Report request data.

func (*TestSetup) VerifyReportCount

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

VerifyReportCount verifies the number of Report calls.

func (*TestSetup) VerifyStats

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

VerifyStats verifies Envoy stats.

func (*TestSetup) VerifyStatsLT

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) WaitEnvoyReady

func (s *TestSetup) WaitEnvoyReady()

WaitEnvoyReady waits until envoy receives and applies all config

func (*TestSetup) WaitForStatsUpdateAndGetStats

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL