import "istio.io/istio/pkg/test/framework/resource"
cluster.go context.go dumper.go environment.go flags.go matcher.go resource.go settings.go setup.go
type Cluster interface { fmt.Stringer kube.ExtendedClient // 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.
Clusters is an ordered list of Cluster instances.
ByNetwork returns a map of network name to a subset of clusters
Configs returns the subset that are config clusters.
Default returns the first cluster in the list.
GetByName returns the Cluster with the given name or nil if it is not in the list.
GetOrDefault returns the given cluster if non-nil. Otherwise returns the first Cluster in the list.
IsMulticluster is a utility method that indicates whether there are multiple Clusters available.
Names returns the deduped list of names of the clusters.
Primaries returns the subset that are primary clusters.
Remotes returns the subset that are remote clusters.
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 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.
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 interface { Resource 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(Context) (Environment, error)
NilEnvironmentFactory is an EnvironmentFactory that returns nil.
type EnvironmentFactory func(ctx Context) (Environment, error)
EnvironmentFactory creates an Environment.
FakeID used for testing.
FakeResource used for testing.
func (f *FakeResource) GetOtherValue() string
GetOtherValue is an additional method used to distinguish this resource API from others.
func (f *FakeResource) ID() ID
ID for the resource instance. This is allocated by the framework and passed here.
type Matcher struct {
// contains filtered or unexported fields
}
Matcher reimplements the logic of Go's -test.run. The code is mostly directly copied from Go's source.
Resource of a resource.
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 // -test.run 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 istio.io/rev=XXX. Revision string // Skip VM related parts for all the tests. SkipVM bool }
Settings is the set of arguments to the test driver.
DefaultSettings returns a default settings instance.
SettingsFromCommandLine returns settings obtained from command-line flags. flag.Parse must be called before calling this function.
Clone settings
RunDir is the name of the dir to output, for this particular run.
String implements fmt.Stringer
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.