istio: Index | Files

package resource

import ""


Package Files

cluster.go context.go dumper.go environment.go flags.go matcher.go resource.go settings.go setup.go

type Cluster Uses

type Cluster interface {

    // Name of this cluster
    Name() string

    // NetworkName the cluster is on
    NetworkName() string

    // IsPrimary returns true if this is a primary cluster, containing an instance
    // of the Istio control plane.
    IsPrimary() bool

    // IsConfig returns true if this is a config cluster, used as the source of
    // Istio config for one or more control planes.
    IsConfig() bool

    // IsRemote returns true if this is a remote cluster, which uses a control plane
    // residing in another cluster.
    IsRemote() bool

    // Primary returns the primary cluster for this cluster. Will return itself if
    // IsPrimary.
    Primary() Cluster

    // PrimaryName returns the name of the primary cluster for this cluster.
    PrimaryName() string

    // Config returns the config cluster for this cluster. Will return itself if
    // IsConfig.
    Config() Cluster

    // ConfigName returns the name of the config cluster for this cluster.
    ConfigName() string

Cluster in a multicluster environment.

type Clusters Uses

type Clusters []Cluster

Clusters is an ordered list of Cluster instances.

func (Clusters) ByNetwork Uses

func (c Clusters) ByNetwork() map[string]Clusters

ByNetwork returns a map of network name to a subset of clusters

func (Clusters) Configs Uses

func (c Clusters) Configs(excluded ...Cluster) Clusters

Configs returns the subset that are config clusters.

func (Clusters) Default Uses

func (c Clusters) Default() Cluster

Default returns the first cluster in the list.

func (Clusters) GetByName Uses

func (c Clusters) GetByName(name string) Cluster

GetByName returns the Cluster with the given name or nil if it is not in the list.

func (Clusters) GetOrDefault Uses

func (c Clusters) GetOrDefault(cluster Cluster) Cluster

GetOrDefault returns the given cluster if non-nil. Otherwise returns the first Cluster in the list.

func (Clusters) IsMulticluster Uses

func (c Clusters) IsMulticluster() bool

IsMulticluster is a utility method that indicates whether there are multiple Clusters available.

func (Clusters) Names Uses

func (c Clusters) Names() []string

Names returns the deduped list of names of the clusters.

func (Clusters) Primaries Uses

func (c Clusters) Primaries(excluded ...Cluster) Clusters

Primaries returns the subset that are primary clusters.

func (Clusters) Remotes Uses

func (c Clusters) Remotes(excluded ...Cluster) Clusters

Remotes returns the subset that are remote clusters.

func (Clusters) String Uses

func (c Clusters) String() string

type ConfigManager Uses

type ConfigManager interface {
    // ApplyYAML applies the given config yaml text via Galley.
    ApplyYAML(ns string, yamlText ...string) error

    // ApplyYAMLOrFail applies the given config yaml text via Galley.
    ApplyYAMLOrFail(t test.Failer, ns string, yamlText ...string)

    // ApplyYAMLInCluster applies the given config yaml text via Galley in a specific cluster.
    ApplyYAMLInCluster(c Cluster, ns string, yamlText ...string) error

    // ApplyYAMLInClusterOrFail applies the given config yaml text via Galley in a specific cluster.
    ApplyYAMLInClusterOrFail(t test.Failer, c Cluster, ns string, yamlText ...string)

    // DeleteYAML deletes the given config yaml text via Galley.
    DeleteYAML(ns string, yamlText ...string) error

    // DeleteYAMLOrFail deletes the given config yaml text via Galley.
    DeleteYAMLOrFail(t test.Failer, ns string, yamlText ...string)

    // ApplyYAMLDir recursively applies all the config files in the specified directory
    ApplyYAMLDir(ns string, configDir string) error

    // DeleteYAMLDir recursively deletes all the config files in the specified directory
    DeleteYAMLDir(ns string, configDir string) error

    // WithFilePrefix sets the prefix used for intermediate files.
    WithFilePrefix(prefix string) ConfigManager

ConfigManager is an interface for applying/deleting yaml resources.

type Context Uses

type Context interface {

    // TrackResource tracks a resource in this context. If the context is closed, then the resource will be
    // cleaned up.
    TrackResource(r Resource) ID

    // GetResource accepts either a *T or *[]*T where T implements Resource.
    // For a non-slice pointer, the value will be assigned to the first matching resource.
    // For a slice pointer, the matching resources from this scope and its parent(s) will be appended.
    // If ref is not a pointer, an error will be returned.
    // If there is no match for a non-slice pointer, an error will be returned.
    GetResource(ref interface{}) error

    // The Environment in which the tests run
    Environment() Environment

    // Clusters in this Environment. There will always be at least one.
    Clusters() Clusters

    // Settings returns common settings
    Settings() *Settings

    // CreateDirectory creates a new subdirectory within this context.
    CreateDirectory(name string) (string, error)

    // CreateTmpDirectory creates a new temporary directory within this context.
    CreateTmpDirectory(prefix string) (string, error)

    // Config returns a ConfigManager that writes config to the provide clusers. If
    // no clusters are provided, writes to all clusters.
    Config(clusters ...Cluster) ConfigManager

Context is the core context interface that is used by resources.

type Dumper Uses

type Dumper interface {
    Dump(ctx Context)

Dumper is an interface that is implemented by all components that can dump their state. In CI, it is useful to get as much context as possible when a test fails. Dumper allows dumping of state from a test.

type Environment Uses

type Environment interface {

    EnvironmentName() string

    // Clusters in this Environment. There will always be at least one.
    Clusters() Clusters

    IsMultinetwork() bool

Environment is the ambient environment that the test runs in.

func NilEnvironmentFactory Uses

func NilEnvironmentFactory(Context) (Environment, error)

NilEnvironmentFactory is an EnvironmentFactory that returns nil.

type EnvironmentFactory Uses

type EnvironmentFactory func(ctx Context) (Environment, error)

EnvironmentFactory creates an Environment.

type FakeID Uses

type FakeID string

FakeID used for testing.

func (FakeID) String Uses

func (id FakeID) String() string

type FakeResource Uses

type FakeResource struct {
    IDValue    string
    OtherValue string

FakeResource used for testing.

func (*FakeResource) GetOtherValue Uses

func (f *FakeResource) GetOtherValue() string

GetOtherValue is an additional method used to distinguish this resource API from others.

func (*FakeResource) ID Uses

func (f *FakeResource) ID() ID

type ID Uses

type ID interface {

ID for the resource instance. This is allocated by the framework and passed here.

type Matcher Uses

type Matcher struct {
    // contains filtered or unexported fields

func NewMatcher Uses

func NewMatcher(regex string) (*Matcher, error)

Matcher reimplements the logic of Go's The code is mostly directly copied from Go's source.

func (*Matcher) MatchTest Uses

func (m *Matcher) MatchTest(testName string) bool

type Resource Uses

type Resource interface {
    // ID used for debugging the resource instance.
    ID() ID

Resource of a resource.

type Settings Uses

type Settings struct {
    // Name of the test
    TestID string

    RunID uuid.UUID

    // Do not cleanup the resources after the test run.
    NoCleanup bool

    // Indicates that the tests are running in CI Mode
    CIMode bool

    // Should the tests fail if usage of deprecated stuff (e.g. Envoy flags) is detected
    FailOnDeprecation bool

    // Local working directory root for creating temporary directories / files in. If left empty,
    // os.TempDir() will be used.
    BaseDir string

    // The number of times to retry failed tests.
    // This should not be depended on as a primary means for reducing test flakes.
    Retries int

    // If enabled, namespaces will be reused rather than created with dynamic names each time.
    // This is useful when combined with NoCleanup, to allow quickly iterating on tests.
    StableNamespaces bool

    // The label selector that the user has specified.
    SelectorString string

    // The regex specifying which tests to skip. This follows inverted semantics of golang's
    // flag, which only supports positive match. If an entire package is meant to be
    // excluded, it can be filtered with `go list` and explicitly passing the list of desired
    // packages. For example: `go test $(go list ./... | grep -v bad-package)`.
    SkipString  string
    SkipMatcher *Matcher

    // The label selector, in parsed form.
    Selector label.Selector

    // EnvironmentFactory allows caller to override the environment creation. If nil, a default is used based
    // on the known environment names.
    EnvironmentFactory EnvironmentFactory

    // The revision label on a namespace for injection webhook.
    // If set to XXX, all the namespaces created with istio-injection=enabled will be replaced with
    Revision string

    // Skip VM related parts for all the tests.
    SkipVM bool

Settings is the set of arguments to the test driver.

func DefaultSettings Uses

func DefaultSettings() *Settings

DefaultSettings returns a default settings instance.

func SettingsFromCommandLine Uses

func SettingsFromCommandLine(testID string) (*Settings, error)

SettingsFromCommandLine returns settings obtained from command-line flags. flag.Parse must be called before calling this function.

func (*Settings) Clone Uses

func (s *Settings) Clone() *Settings

Clone settings

func (*Settings) RunDir Uses

func (s *Settings) RunDir() string

RunDir is the name of the dir to output, for this particular run.

func (*Settings) String Uses

func (s *Settings) String() string

String implements fmt.Stringer

type SetupFn Uses

type SetupFn func(ctx Context) error

SetupFn is a function used for performing setup actions.

Package resource imports 12 packages (graph) and is imported by 41 packages. Updated 2021-01-23. Refresh now. Tools for package owners.