istio: Index | Files

package env

import ""


Package Files

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

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

    // PULL_POLICY is the image pull policy to use when rendering templates.
    // nolint: golint, stylecheck

    // KUBECONFIG is the list of Kubernetes configuration files. If configuration files are specified on
    // the command-line, that takes precedence.
    // nolint: golint, stylecheck

    // IstioSrc is the location of istio source ($TOP/src/
    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), "../../..")

func CheckFileExists Uses

func CheckFileExists(path string) error

func HTTPGet Uses

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

HTTPGet send GET

func IsPortUsed Uses

func IsPortUsed(port uint16) bool

IsPortUsed checks if a port is used

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 Ports Uses

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

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 {

    // 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) CACertPath Uses

func (s *TestSetup) CACertPath() string

CACertPath gets CA cert file path. The path does not change after proxy restarts.

func (*TestSetup) CreateEnvoyConf Uses

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

CreateEnvoyConf create envoy config.

func (*TestSetup) GetStatsMap Uses

func (s *TestSetup) GetStatsMap() (map[string]uint64, error)

GetStatsMap fetches Envoy stats with retry, and returns stats in a map.

func (*TestSetup) JWTTokenPath Uses

func (s *TestSetup) JWTTokenPath() string

JWTTokenPath gets JWT token path. The path does not change after proxy restarts.

func (*TestSetup) LastRequestHeaders Uses

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

LastRequestHeaders returns last backend request headers

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

func (s *TestSetup) SDSPath() string

SDSPath gets SDS path. The path does not change after proxy restarts.

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

func (s *TestSetup) SetNoBackend(no bool)

SetNoBackend sets no backend 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 and Backend server for test.

func (*TestSetup) SilentlyStopProxy Uses

func (s *TestSetup) SilentlyStopProxy(silent bool)

SilentlyStopProxy ignores errors when stop proxy

func (*TestSetup) TearDown Uses

func (s *TestSetup) TearDown()

TearDown shutdown the servers.

func (*TestSetup) VerifyStats Uses

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

VerifyStats verifies Envoy stats.

func (*TestSetup) VerifyStatsLT Uses

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

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

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.

type Variable Uses

type Variable string

Variable is a wrapper for an environment variable.

func (Variable) Name Uses

func (e Variable) Name() string

Name of the environment variable.

func (Variable) Value Uses

func (e Variable) Value() string

Value of the environment variable.

func (Variable) ValueOrDefault Uses

func (e Variable) ValueOrDefault(defaultValue string) string

ValueOrDefault returns the value of the environment variable if it is non-empty. Otherwise returns the value provided.

func (Variable) ValueOrDefaultFunc Uses

func (e Variable) ValueOrDefaultFunc(defaultValueFunc func() string) string

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.