istio: Index | Files

package test

import ""

Code generated for package test by go-bindata DO NOT EDIT. (@generated) sources: ../../../testdata/config/attributes.yaml ../../../template/apikey/template.yaml ../../../template/authorization/template.yaml ../../../template/checknothing/template.yaml ../../../template/listentry/template.yaml ../../../template/logentry/template.yaml ../../../template/metric/template.yaml ../../../template/quota/template.yaml ../../../template/reportnothing/template.yaml ../../../template/tracespan/tracespan.yaml ../../../test/spyAdapter/template/apa/tmpl.yaml ../../../test/spyAdapter/template/checkoutput/tmpl.yaml


Package Files

env.go fixtures.gen.go fixtures.go integration.go

func Asset Uses

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir Uses

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:


then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo Uses

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames Uses

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset Uses

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset Uses

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets Uses

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func RunTest Uses

func RunTest(
    t *testing.T,
    adapterInfo adapter.InfoFn,
    scenario Scenario,

RunTest performs a Mixer adapter integration test using in-memory Mixer and config store. NOTE: DO NOT invoke this using `t.Run(string, func)` because that would execute func in a separate go routine. Separate go routines would cause the test to fail randomly because fixed ports cannot be assigned and cleaned up deterministically on each iteration.

* adapterInfo provides the InfoFn for the adapter under test. * Scenario provide the adapter/handler/rule configs along with the call parameters (check or report, and attributes)

Optionally, it also takes the test specific SetupFn, TeardownFn, GetStateFn and list of supported templates.

func TemplateApikeyTemplateYaml Uses

func TemplateApikeyTemplateYaml() (*asset, error)

func TemplateApikeyTemplateYamlBytes Uses

func TemplateApikeyTemplateYamlBytes() ([]byte, error)

func TemplateAuthorizationTemplateYaml Uses

func TemplateAuthorizationTemplateYaml() (*asset, error)

func TemplateAuthorizationTemplateYamlBytes Uses

func TemplateAuthorizationTemplateYamlBytes() ([]byte, error)

func TemplateChecknothingTemplateYaml Uses

func TemplateChecknothingTemplateYaml() (*asset, error)

func TemplateChecknothingTemplateYamlBytes Uses

func TemplateChecknothingTemplateYamlBytes() ([]byte, error)

func TemplateListentryTemplateYaml Uses

func TemplateListentryTemplateYaml() (*asset, error)

func TemplateListentryTemplateYamlBytes Uses

func TemplateListentryTemplateYamlBytes() ([]byte, error)

func TemplateLogentryTemplateYaml Uses

func TemplateLogentryTemplateYaml() (*asset, error)

func TemplateLogentryTemplateYamlBytes Uses

func TemplateLogentryTemplateYamlBytes() ([]byte, error)

func TemplateMetricTemplateYaml Uses

func TemplateMetricTemplateYaml() (*asset, error)

func TemplateMetricTemplateYamlBytes Uses

func TemplateMetricTemplateYamlBytes() ([]byte, error)

func TemplateQuotaTemplateYaml Uses

func TemplateQuotaTemplateYaml() (*asset, error)

func TemplateQuotaTemplateYamlBytes Uses

func TemplateQuotaTemplateYamlBytes() ([]byte, error)

func TemplateReportnothingTemplateYaml Uses

func TemplateReportnothingTemplateYaml() (*asset, error)

func TemplateReportnothingTemplateYamlBytes Uses

func TemplateReportnothingTemplateYamlBytes() ([]byte, error)

func TemplateTracespanTracespanYaml Uses

func TemplateTracespanTracespanYaml() (*asset, error)

func TemplateTracespanTracespanYamlBytes Uses

func TemplateTracespanTracespanYamlBytes() ([]byte, error)

func TestSpyadapterTemplateApaTmplYaml Uses

func TestSpyadapterTemplateApaTmplYaml() (*asset, error)

func TestSpyadapterTemplateApaTmplYamlBytes Uses

func TestSpyadapterTemplateApaTmplYamlBytes() ([]byte, error)

func TestSpyadapterTemplateCheckoutputTmplYaml Uses

func TestSpyadapterTemplateCheckoutputTmplYaml() (*asset, error)

func TestSpyadapterTemplateCheckoutputTmplYamlBytes Uses

func TestSpyadapterTemplateCheckoutputTmplYamlBytes() ([]byte, error)

func TestdataConfigAttributesYaml Uses

func TestdataConfigAttributesYaml() (*asset, error)

func TestdataConfigAttributesYamlBytes Uses

func TestdataConfigAttributesYamlBytes() ([]byte, error)

type Call Uses

type Call struct {
    // CallKind can be either CHECK or REPORT
    CallKind CallKind
    // Attrs to call the Mixer with.
    Attrs map[string]interface{}
    // Quotas info to call the Mixer with.
    Quotas map[string]istio_mixer_v1.CheckRequest_QuotaParams

Call represents the input to make a call to Mixer

type CallKind Uses

type CallKind int32

CallKind represents the call to make; check or report.

const (
    // CHECK for  Mixer Check
    CHECK CallKind = iota
    // REPORT for  Mixer Report

type Env Uses

type Env struct {
    // contains filtered or unexported fields

Env is an adapter environment that defers to the testing context t. Tracks all messages logged so they can be tested against.

func NewEnv Uses

func NewEnv(_ *testing.T) *Env

NewEnv returns an adapter environment that redirects logging output to the given testing context.

func (*Env) DebugEnabled Uses

func (e *Env) DebugEnabled() bool

DebugEnabled logs the provided message.

func (*Env) Debugf Uses

func (e *Env) Debugf(format string, args ...interface{})

Debugf logs the provided message.

func (*Env) ErrorEnabled Uses

func (e *Env) ErrorEnabled() bool

ErrorEnabled logs the provided message.

func (*Env) Errorf Uses

func (e *Env) Errorf(format string, args ...interface{}) error

Errorf logs the provided message and returns it as an error.

func (*Env) GetDoneChan Uses

func (e *Env) GetDoneChan() chan struct{}

GetDoneChan returns the channel that returns notification when the async work is done.

func (*Env) GetLogs Uses

func (e *Env) GetLogs() []string

GetLogs returns a snapshot of all logs that've been written to this environment

func (*Env) InfoEnabled Uses

func (e *Env) InfoEnabled() bool

InfoEnabled logs the provided message.

func (*Env) Infof Uses

func (e *Env) Infof(format string, args ...interface{})

Infof logs the provided message.

func (*Env) Logger Uses

func (e *Env) Logger() adapter.Logger

Logger returns a logger that writes to testing.T.Log

func (*Env) NewInformer Uses

func (e *Env) NewInformer(
    clientset kubernetes.Interface,
    objType runtime.Object,
    duration time.Duration,
    listerWatcher func(namespace string) cache.ListerWatcher,
    indexers cache.Indexers) cache.SharedIndexInformer

func (*Env) ScheduleDaemon Uses

func (e *Env) ScheduleDaemon(fn adapter.DaemonFunc)

ScheduleDaemon runs the given function asynchronously.

func (*Env) ScheduleWork Uses

func (e *Env) ScheduleWork(fn adapter.WorkFunc)

ScheduleWork runs the given function asynchronously.

func (*Env) WarnEnabled Uses

func (e *Env) WarnEnabled() bool

WarnEnabled logs the provided message.

func (*Env) Warningf Uses

func (e *Env) Warningf(format string, args ...interface{})

Warningf logs the provided message.

type GetConfigFn Uses

type GetConfigFn func(ctx interface{}) ([]string, error)

GetConfigFn returns configuration that is generated

type GetStateFn Uses

type GetStateFn func(ctx interface{}) (interface{}, error)

GetStateFn returns the adapter specific state upon test execution. The return value becomes part of expected Result.AdapterState.

type Result Uses

type Result struct {
    // AdapterState represents adapter specific baseline data. AdapterState is what the callback function
    // `getState`, passed to `RunTest`, returns.
    AdapterState interface{} `json:"AdapterState"`
    // Returns represents the return data from calls to Mixer
    Returns []Return `json:"Returns"`

Result represents the test baseline

type Return Uses

type Return struct {
    // Check is the response from a check call to Mixer
    Check adapter.CheckResult `json:"Check"`
    // Quota is the response from a check call to Mixer
    Quota map[string]adapter.QuotaResult `json:"Quota"`
    // Error is the error from call to Mixer
    Error spb.Status `json:"Error"`

Return represents the return data from a call to Mixer

type Scenario Uses

type Scenario struct {
    // Configs is a list of CRDs that Mixer will read.
    Configs []string

    // GetConfig specifies a way fetch configuration after the initial  setup
    GetConfig GetConfigFn

    // ParallelCalls is a list of test calls to be made to Mixer
    // in parallel.
    ParallelCalls []Call

    // SingleThreaded makes only one call at a time.
    SingleThreaded bool

    // Setup is a callback function that will be called at the beginning of the test. It is
    // meant to be used for things like starting a local backend server. Setup function returns a
    // context (interface{}) which is passed back into the Teardown and the GetState functions.
    // pass nil if no setup needed
    Setup SetupFn

    // Teardown is a callback function that will be called at the end of the test. It is
    // meant to be used for things like stopping a local backend server that might have been started during Setup.
    // pass nil if no teardown is needed
    Teardown TeardownFn

    // GetState lets the test provide any (interface{}) adapter specific data to be part of baseline.
    // Example: for prometheus adapter, the actual metric reported to the local backend can be embedded into the
    // expected json baseline.
    // pass nil if no adapter specific state is part of baseline.
    GetState GetStateFn

    // Templates supported by Mixer.
    // If `Templates` is not specified, the default templates inside
    // are made available to the Mixer.
    Templates map[string]template.Info

    // Want is the expected serialized json for the Result struct.
    // Result.AdapterState is what the callback function `getState`, passed to `RunTest`, returns.
    // New test can start of with an empty "{}" string and then
    // get the baseline from the failure logs upon execution.
    Want string

    SetError SetErrorFn

Scenario fully defines an adapter integration test

type SetErrorFn Uses

type SetErrorFn func(ctx interface{}) error

SetErrorFn function will be called just before test begins and setup and config is done. This can be used to introduce errors in the test

type SetupFn Uses

type SetupFn func() (ctx interface{}, err error)

SetupFn functions will be called at the beginning of the test

type TeardownFn Uses

type TeardownFn func(ctx interface{})

TeardownFn functions will be called at the end of the test

type VerifyResultFn Uses

type VerifyResultFn func(ctx interface{}, result *Result) error

VerifyResultFn if specified is used to do verification.

Package test imports 30 packages (graph). Updated 2020-06-04. Refresh now. Tools for package owners.