testutil

package
v1.7.14 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DateRegex = "20\\d\\d"
View Source
var DefaultRetry = wait.Backoff{
	Duration: 10 * time.Microsecond,
	Factor:   1.0,
	Jitter:   0.1,
	Steps:    500,
}
View Source
var RuntimeObjCmpOpts = []cmp.Option{
	cmpopts.IgnoreTypes(metav1.TypeMeta{}),
	cmpopts.IgnoreFields(metav1.ObjectMeta{}, "ResourceVersion", "SelfLink", "Generation", "CreationTimestamp"),
}
View Source
var SkippedPaths = map[string]bool{
	"Godeps":      true,
	"third_party": true,
	"_gopath":     true,
	"_artifacts":  true,
	"_output":     true,
	".git":        true,
	"vendor":      true,
	"external":    true,
	"3rdparty":    true,
	"deploy":      true,
}

Functions

func AssertDiff

func AssertDiff(t *testing.T, expected interface{}, actual interface{})

AssertDiff compares an expected interface with an actual interface and fails if the two interfaces do not match. This func removes all metadata calico annotations.

func InitScheme

func InitScheme(t *testing.T) *runtime.Scheme

func ReadOrUpdateGoldenFile

func ReadOrUpdateGoldenFile(t *testing.T, content string, update bool) string

func RequireClusterToBeReadyEventually added in v1.7.13

func RequireClusterToBeReadyEventually(t *testing.T, sb testenv.DiffingSandbox, b ClusterBuilder)

func RequireClusterToBeReadyEventuallyTimeout added in v1.7.13

func RequireClusterToBeReadyEventuallyTimeout(t *testing.T, sb testenv.DiffingSandbox, b ClusterBuilder, timeout time.Duration)

RequireClusterToBeReadyEventuallyTimeout tests to see if a statefulset has started correctly and all of the pods are running.

func RequireDatabaseToFunction added in v1.7.13

func RequireDatabaseToFunction(t *testing.T, sb testenv.DiffingSandbox, b ClusterBuilder)

RequireDatabaseToFunction tests that the database is functioning correctly

func RequireDbContainersToUseImage added in v1.7.13

func RequireDbContainersToUseImage(t *testing.T, sb testenv.DiffingSandbox, cr *api.CrdbCluster)

RequireDbContainersToUseImage checks that the database is using the correct image

func RequireDecommissionNode added in v1.7.13

func RequireDecommissionNode(t *testing.T, sb testenv.DiffingSandbox, b ClusterBuilder, numNodes int32)

RequireDecommisionNode requires that proper nodes are decommisioned

func RequireDownGradeOptionSet added in v1.7.13

func RequireDownGradeOptionSet(t *testing.T, sb testenv.DiffingSandbox, b ClusterBuilder, version string)

func RequirePVCToResize added in v1.7.13

func RequirePVCToResize(t *testing.T, sb testenv.DiffingSandbox, b ClusterBuilder, quantity apiresource.Quantity)

RequirePVCToResize checks that the PVCs are resized correctly

func Yamlizers

func Yamlizers(t *testing.T, scheme *runtime.Scheme) (func([]byte) runtime.Object, func(runtime.Object, io.Writer) error)

Types

type Action

type Action interface {
	Verb() string
	GVR() schema.GroupVersionResource
	Key() client.ObjectKey
}

func NewCreateAction

func NewCreateAction(key client.ObjectKey, gvr schema.GroupVersionResource) Action

func NewGetAction

func NewGetAction(key client.ObjectKey, gvr schema.GroupVersionResource) Action

type ClusterBuilder

type ClusterBuilder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(name string) ClusterBuilder

func (ClusterBuilder) Cluster

func (b ClusterBuilder) Cluster() *resource.Cluster

func (ClusterBuilder) Cr

func (b ClusterBuilder) Cr() *api.CrdbCluster

func (ClusterBuilder) Namespaced

func (b ClusterBuilder) Namespaced(namespace string) ClusterBuilder

func (ClusterBuilder) WithCockroachDBVersion added in v1.7.13

func (b ClusterBuilder) WithCockroachDBVersion(version string) ClusterBuilder

func (ClusterBuilder) WithHTTPPort

func (b ClusterBuilder) WithHTTPPort(port int32) ClusterBuilder

func (ClusterBuilder) WithImage

func (b ClusterBuilder) WithImage(image string) ClusterBuilder

func (ClusterBuilder) WithMaxUnavailable

func (b ClusterBuilder) WithMaxUnavailable(max *int32) ClusterBuilder

func (ClusterBuilder) WithNodeCount

func (b ClusterBuilder) WithNodeCount(c int32) ClusterBuilder

func (ClusterBuilder) WithNodeTLS

func (b ClusterBuilder) WithNodeTLS(secret string) ClusterBuilder

func (ClusterBuilder) WithPVDataStore

func (b ClusterBuilder) WithPVDataStore(size, storageClass string) ClusterBuilder

func (ClusterBuilder) WithTLS

func (b ClusterBuilder) WithTLS() ClusterBuilder

func (ClusterBuilder) WithUID

func (b ClusterBuilder) WithUID(uid string) ClusterBuilder

type CreateAction

type CreateAction struct {
	// contains filtered or unexported fields
}

func (CreateAction) GVR

func (CreateAction) Key

func (a CreateAction) Key() client.ObjectKey

func (CreateAction) Verb

func (a CreateAction) Verb() string

type FakeClient

type FakeClient struct {

	// ReactionChain is the list of reactors that will be attempted for every
	// request in the order they are tried.
	ReactionChain []Reactor
	// contains filtered or unexported fields
}

FakeClient is inspired and taken from https://github.com/kubernetes/client-go/

func NewFakeClient

func NewFakeClient(scheme *runtime.Scheme, objs ...runtime.Object) *FakeClient

func (*FakeClient) AddReactor

func (c *FakeClient) AddReactor(verb string, resource string, reaction ReactionFunc)

func (*FakeClient) Create

func (c *FakeClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

func (*FakeClient) Delete

func (c *FakeClient) Delete(_ context.Context, obj client.Object, opts ...client.DeleteOption) error

func (*FakeClient) DeleteAllOf

func (c *FakeClient) DeleteAllOf(_ context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error

func (*FakeClient) Get

func (c *FakeClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error

func (*FakeClient) List

func (c *FakeClient) List(_ context.Context, list client.ObjectList, opts ...client.ListOption) error

func (*FakeClient) Patch

func (c *FakeClient) Patch(_ context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

func (*FakeClient) RESTMapper

func (c *FakeClient) RESTMapper() meta.RESTMapper

func (*FakeClient) Scheme

func (c *FakeClient) Scheme() *runtime.Scheme

func (*FakeClient) Status

func (c *FakeClient) Status() client.StatusWriter

func (*FakeClient) Update

func (c *FakeClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

type GetAction

type GetAction struct {
	// contains filtered or unexported fields
}

func (GetAction) GVR

func (GetAction) Key

func (a GetAction) Key() client.ObjectKey

func (GetAction) Verb

func (a GetAction) Verb() string

type ReactionFunc

type ReactionFunc func(action Action) (handled bool, err error)

ReactionFunc is a function returning `handled` set to true if no further processing is required and an error if one needs to be raised

type Reactor

type Reactor interface {
	// Handles indicates whether or not this Reactor deals with a given
	// action.
	Handles(action Action) bool
	// React handles the action and returns results.  It may choose to
	// delegate by indicated handled=false.
	React(action Action) (handled bool, err error)
}

Reactor is an interface to allow the composition of reaction functions.

type Step added in v1.7.13

type Step struct {
	Name string
	Test func(t *testing.T)
}

Step is used to build a test

type Steps added in v1.7.13

type Steps []Step

Steps

func (Steps) Run added in v1.7.13

func (ss Steps) Run(t *testing.T)

Run execs the various Steps that describe Tests

func (Steps) WithStep added in v1.7.13

func (ss Steps) WithStep(s Step) Steps

WithSteps appends Steps

type ValidateHeaders

type ValidateHeaders struct {
	// contains filtered or unexported fields
}

ValidateHeaders represents a project that that needs to be scanned.

func NewValidateHeaders

func NewValidateHeaders(fileNames *[]string, rootDir string, boilerplateDir string, forceExtension string) ValidateHeaders

NewValidateHeaders creates a new struct used to validate a project.

func (ValidateHeaders) Validate

func (v ValidateHeaders) Validate() (nonconformingFilesPtr *[]string, err error)

Validate iterates over a set of files and returns a slice of files that do not have the proper headers. A slice of files are returned that containes the filenames of files that do not have a header that matches the boilerplate.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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