framework

package
v0.0.0-...-5d90d19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiserverCert

func ApiserverCert() string

ApiserverCert returns the generated kube-apiserver certificate authority

func ApiserverConfig

func ApiserverConfig() *rest.Config

ApiserverConfig returns a rest.Config to connect to the test instance.

func ApiserverToken

func ApiserverToken() string

ApiserverToken returns the token used for authentication

func ApiserverURL

func ApiserverURL() string

ApiserverURL returns the URL of the kube-apiserver instance started by TestMain.

func EtcdURL

func EtcdURL() string

EtcdURL returns the URL to connect to the etcd instance launched for this test environment. This can be shared as long as each component uses a unique key prefix.

func MustDecodeYAML

func MustDecodeYAML(yamlStr string, into interface{})

MustDecodeYAML decodes YAML into the given object. It will panic if the decode fails.

func TestMain

func TestMain(tests func() int)

TestMain starts etcd, kube-apiserver, and vitess-operator before running tests.

Types

type Fixture

type Fixture struct {
	*testing.T
	// contains filtered or unexported fields
}

Fixture is a collection of scaffolding for each integration test method.

func NewFixture

func NewFixture(ctx context.Context, t *testing.T) *Fixture

NewFixture creates a new test fixture. Each Test*() function should create its own fixture and immediately defer a call to that fixture's TearDown() method.

func (*Fixture) Client

func (f *Fixture) Client() client.Client

Client returns the Kubernetes client.

func (*Fixture) Context

func (f *Fixture) Context() context.Context

Context returns the Context for the running test.

func (*Fixture) CreateNamespace

func (f *Fixture) CreateNamespace(ctx context.Context, namespace string) *corev1.Namespace

CreateNamespace creates a namespace that will be deleted after this test finishes.

func (*Fixture) CreateVitessCluster

func (f *Fixture) CreateVitessCluster(namespace, name string, vt *planetscalev2.VitessCluster) *planetscalev2.VitessCluster

CreateVitessCluster creates a VitessCluster that will be deleted after this test finishes.

func (*Fixture) CreateVitessClusterYAML

func (f *Fixture) CreateVitessClusterYAML(namespace, name, vtYAML string) *planetscalev2.VitessCluster

CreateVitessClusterYAML creates a VitessCluster (from YAML input) that will be deleted after this test finishes.

func (*Fixture) ExpectPods

func (f *Fixture) ExpectPods(listOpts *client.ListOptions, expectedCount int) *corev1.PodList

ExpectPods waits up to a default timeout for the given selector to match the expected number of Pods. If the timeout expires, the test is aborted.

func (*Fixture) MustGet

func (f *Fixture) MustGet(namespace, name string, obj client.Object)

MustGet waits up to a default timeout for the named object to exist and then returns it. If the timeout expires before the object appears, the test is aborted.

func (*Fixture) TearDown

func (f *Fixture) TearDown()

TearDown cleans up resources created through this instance of the test fixture.

func (*Fixture) WaitFor

func (f *Fixture) WaitFor(condition string, check func() error)

WaitFor polls the check function until it returns true, with a default interval and timeout. This is meant for use in integration tests, so frequent polling is fine.

The check function should return nil if it is satisfied, or a non-nil error indicating why it's not satisfied.

If the timeout expires before the check function is satisfied, the test will be aborted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL