istio: istio.io/istio/pkg/test/framework/resource Index | Files | Directories

package resource

import "istio.io/istio/pkg/test/framework/resource"

Index

Package Files

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

type Cluster Uses

type Cluster interface {
    fmt.Stringer
    kube.ExtendedClient

    // Name of this cluster
    Name() string

    // NetworkName the cluster is on
    NetworkName() string

    // Index of this Cluster within the Environment
    Index() ClusterIndex
}

Cluster in a multicluster environment.

type ClusterIndex Uses

type ClusterIndex int

ClusterIndex is the index of a cluster within the Environment

type Clusters Uses

type Clusters []Cluster

Clusters is an ordered list of Cluster instances.

func (Clusters) Default Uses

func (c Clusters) Default() Cluster

Default returns the first cluster 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.

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)

    // 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 {
    yml.FileWriter

    // 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()
}

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 {
    Resource

    EnvironmentName() string

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

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

type FakeCluster struct {
    kube.ExtendedClient

    NameValue        string
    NetworkNameValue string
    IndexValue       int
}

FakeCluster used for testing.

func (FakeCluster) Index Uses

func (m FakeCluster) Index() ClusterIndex

func (FakeCluster) Name Uses

func (m FakeCluster) Name() string

func (FakeCluster) NetworkName Uses

func (m FakeCluster) NetworkName() string

func (FakeCluster) String Uses

func (m FakeCluster) String() string

type FakeEnvironment Uses

type FakeEnvironment struct {
    Name        string
    NumClusters int
    IDValue     string
}

FakeEnvironment for testing.

func (FakeEnvironment) Clusters Uses

func (f FakeEnvironment) Clusters() Clusters

func (FakeEnvironment) EnvironmentName Uses

func (f FakeEnvironment) EnvironmentName() string

func (FakeEnvironment) ID Uses

func (f FakeEnvironment) ID() ID

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 {
    fmt.Stringer
}

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

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 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
}

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.

Directories

PathSynopsis
environment

Package resource imports 10 packages (graph) and is imported by 50 packages. Updated 2020-08-05. Refresh now. Tools for package owners.