import "istio.io/istio/pkg/test/env"
envoy.go envoy_conf.go http_client.go http_server.go istio.go ports.go setup.go variable.go
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 ( FailedRequestTest uint16 = iota FaultInjectTest NetworkFailureTest XDSTest IstioAuthnTestOriginRejectNoJwt IstioAuthnTestPeerRejectNoJwt IstioAuthnTestPeerRejectNoMtls IstioAuthnTestPeerRejectNoTLS RouteDirectiveTest DynamicAttributeTest DynamicListenerTest PilotPluginTest PilotPluginTCPTest PilotPluginTLSTest PilotMCPTest RbacGlobalPermissiveTest RbacPolicyPermissiveTest GatewayTest SidecarTest SidecarConsumerOnlyTest TracingHeaderTest STSTest STSCacheTest STSRenewTest STSFailureTest STSTimeoutTest STSServerCacheTest STSShortLivedCacheTest SDSTest SDSCertRotation CSRFailure BadCSRResponse )
All tests should be listed here to get their test ids
var ( // ISTIO_OUT environment variable // nolint: golint, stylecheck ISTIO_OUT Variable = "ISTIO_OUT" // LOCAL_OUT environment variable // nolint: golint, stylecheck LOCAL_OUT Variable = "LOCAL_OUT" // REPO_ROOT environment variable // nolint: golint, stylecheck REPO_ROOT Variable = "REPO_ROOT" // HUB is the Docker hub to be used for images. // nolint: golint, stylecheck HUB Variable = "HUB" // TAG is the Docker tag to be used for images. // nolint: golint, stylecheck TAG Variable = "TAG" // BITNAMIHUB is the Docker registry to be used for the bitnami images. // nolint: golint BITNAMIHUB Variable = "BITNAMIHUB" // PULL_POLICY is the image pull policy to use when rendering templates. // nolint: golint, stylecheck PULL_POLICY Variable = "PULL_POLICY" // KUBECONFIG is the list of Kubernetes configuration files. If configuration files are specified on // the command-line, that takes precedence. // nolint: golint, stylecheck KUBECONFIG Variable = "KUBECONFIG" // IstioSrc is the location of istio source ($TOP/src/istio.io/istio IstioSrc = REPO_ROOT.ValueOrDefaultFunc(getDefaultIstioSrc) // IstioOut is the location of the output directory ($TOP/out) IstioOut = verifyFile(ISTIO_OUT, ISTIO_OUT.ValueOrDefaultFunc(getDefaultIstioOut)) // LocalOut is the location of the output directory for the OS we are running in, // not necessarily the OS we are building for LocalOut = verifyFile(LOCAL_OUT, LOCAL_OUT.ValueOrDefaultFunc(getDefaultIstioOut)) // ChartsDir is the Kubernetes Helm chart directory in the repository ChartsDir = path.Join(IstioSrc, "install/kubernetes/helm") // BookInfoRoot is the root folder for the bookinfo samples BookInfoRoot = path.Join(IstioSrc, "samples/bookinfo") // BookInfoKube is the book info folder that contains Yaml deployment files. BookInfoKube = path.Join(BookInfoRoot, "platform/kube") // ServiceAccountFilePath is the helm service account file. ServiceAccountFilePath = path.Join(IstioSrc, "pkg/test/framework/components/redis/service_account.yaml") // OtelCollectorInstallFilePath is the OpenTelemetry installation file. OtelCollectorInstallFilePath = path.Join(IstioSrc, "pkg/test/framework/components/opentelemetry/opentelemetry-collector.yaml") // RedisInstallFilePath is the redis installation file. RedisInstallFilePath = path.Join(IstioSrc, "pkg/test/framework/components/redis/redis.yaml") // StackdriverInstallFilePath is the stackdriver installation file. StackdriverInstallFilePath = path.Join(IstioSrc, "pkg/test/framework/components/stackdriver/stackdriver.yaml") // GCEMetadataServerInstallFilePath is the GCE Metadata Server installation file. GCEMetadataServerInstallFilePath = path.Join(IstioSrc, "pkg/test/framework/components/gcemetadata/gce_metadata_server.yaml") )
var ( // Root folder of this project // This relies on the fact this file is 3 levels up from the root; if this changes, adjust the path below Root = filepath.Join(filepath.Dir(b), "../../..") )
HTTPGet send GET
IsPortUsed checks if a port is used
WaitForHTTPServer waits for a HTTP server
WaitForPort waits for a TCP port
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer stores data for a HTTP server.
func NewHTTPServer(port uint16) (*HTTPServer, error)
NewHTTPServer creates a new HTTP server.
func (s *HTTPServer) LastRequestHeaders() http.Header
LastRequestHeaders returns the headers from the last request and clears the value
func (s *HTTPServer) Start() <-chan error
Start starts the server
func (s *HTTPServer) Stop()
Stop shutdown the server
type Ports struct { ClientProxyPort uint16 ServerProxyPort uint16 TCPProxyPort uint16 AdminPort uint16 BackendPort uint16 DiscoveryPort uint16 STSPort uint16 ExtraPort uint16 // Pilot ports PilotGrpcPort uint16 PilotHTTPPort uint16 }
Ports stores all used ports
NewEnvoyPorts allocate ports for Envoy
NewPorts allocate all ports based on test id.
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 // Dir is the working dir for envoy Dir string // contains filtered or unexported fields }
TestSetup store data for a test.
NewTestSetup creates a new test setup "name" has to be defined in ports.go
CACertPath gets CA cert file path. The path does not change after proxy restarts.
CreateEnvoyConf create envoy config.
GetStatsMap fetches Envoy stats with retry, and returns stats in a map.
JWTTokenPath gets JWT token path. The path does not change after proxy restarts.
LastRequestHeaders returns last backend request headers
Ports get ports object
ReStartEnvoy restarts Envoy
SDSPath gets SDS path. The path does not change after proxy restarts.
SetCheckDict set the checkDict flag
SetDisableHotRestart sets whether disable the HotRestart feature of Envoy
SetNoBackend sets no backend flag
SetNoProxy set NoProxy flag
SetStress set the stress flag
SetUp setups Envoy and Backend server for test.
SilentlyStopProxy ignores errors when stop proxy
TearDown shutdown the servers.
VerifyStats verifies Envoy stats.
VerifyStatsLT verifies that Envoy stats contains stat expectedStat, whose value is less than expectedStatVal.
WaitEnvoyReady waits until envoy receives and applies all config
WaitForStatsUpdateAndGetStats waits for waitDuration seconds to let Envoy update stats, and sends request to Envoy for stats. Returns stats response.
Variable is a wrapper for an environment variable.
Name of the environment variable.
Value of the environment variable.
ValueOrDefault returns the value of the environment variable if it is non-empty. Otherwise returns the value provided.
ValueOrDefaultFunc returns the value of the environment variable if it is non-empty. Otherwise returns the value function provided.
Package env imports 23 packages (graph) and is imported by 33 packages. Updated 2021-01-14. Refresh now. Tools for package owners.