testutil

package
v0.6.0-beta.18 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeletePodLabelKey

func DeletePodLabelKey(ctx context.Context, testCtx testutil.TestContext, podName, labelKey string)

DeletePodLabelKey deletes the specified label of the pod.

func GetDefaultStorageClass

func GetDefaultStorageClass(testCtx *testutil.TestContext) *storagev1.StorageClass

func InitStatefulSetStatus

func InitStatefulSetStatus(testCtx testutil.TestContext, statefulset *appsv1.StatefulSet, controllerRevision string)

func ListAndCheckDeployment added in v0.6.0

func ListAndCheckDeployment(testCtx *testutil.TestContext, key types.NamespacedName) *appsv1.DeploymentList

func ListAndCheckPodCountWithComponent

func ListAndCheckPodCountWithComponent(testCtx *testutil.TestContext, key types.NamespacedName, componentName string, cnt int) *corev1.PodList

func ListAndCheckStatefulSet

func ListAndCheckStatefulSet(testCtx *testutil.TestContext, key types.NamespacedName) *appsv1.StatefulSetList

func ListAndCheckStatefulSetItemsCount added in v0.6.0

func ListAndCheckStatefulSetItemsCount(testCtx *testutil.TestContext, key types.NamespacedName, cnt int) *appsv1.StatefulSetList

func ListAndCheckStatefulSetWithComponent

func ListAndCheckStatefulSetWithComponent(testCtx *testutil.TestContext, key types.NamespacedName, componentName string) *appsv1.StatefulSetList

func MockDeploymentReady

func MockDeploymentReady(deploy *appsv1.Deployment, rsAvailableReason, rsName string)

MockDeploymentReady mocks deployment is ready

func MockPodAvailable

func MockPodAvailable(pod *corev1.Pod, lastTransitionTime metav1.Time)

MockPodAvailable mocks pod is available

func MockPodIsTerminating

func MockPodIsTerminating(ctx context.Context, testCtx testutil.TestContext, pod *corev1.Pod)

MockPodIsTerminating mocks pod is terminating.

func MockStatefulSetReady

func MockStatefulSetReady(sts *appsv1.StatefulSet)

MockStatefulSetReady mocks the StatefulSet workload is ready.

func NewFakeStatefulSet

func NewFakeStatefulSet(name string, replicas int) *appsv1.StatefulSet

NewFakeStatefulSet creates a fake StatefulSet workload object for testing.

func NewFakeStatefulSetPod

func NewFakeStatefulSetPod(set *appsv1.StatefulSet, ordinal int) *corev1.Pod

NewFakeStatefulSetPod creates a fake pod of the StatefulSet workload for testing.

func PatchStatefulSetStatus

func PatchStatefulSetStatus(testCtx *testutil.TestContext, stsName string, status appsv1.StatefulSetStatus)

func RemovePodFinalizer

func RemovePodFinalizer(ctx context.Context, testCtx testutil.TestContext, pod *corev1.Pod)

RemovePodFinalizer removes the pod finalizer to delete the pod finally.

func SetGetReturnedObject

func SetGetReturnedObject(out client.Object, expectedObj client.Object)

func SetListReturnedObjects

func SetListReturnedObjects(list client.ObjectList, objects []runtime.Object) error

func SetupK8sMock

func SetupK8sMock() (*gomock.Controller, *mock_client.MockClient)

func UpdatePodStatusScheduleFailed added in v0.6.0

func UpdatePodStatusScheduleFailed(ctx context.Context, testCtx testutil.TestContext, podName, namespace string)

UpdatePodStatusScheduleFailed updates the pod status to mock the schedule failure.

Types

type CallMockGetReturnedOptions

type CallMockGetReturnedOptions = func(callHelper *callHelper, call *gomock.Call, _ HandleGetReturnedObject) error

type CallMockListReturnedOptions

type CallMockListReturnedOptions = func(callHelper *callHelper, call *gomock.Call, _ HandleListReturnedObject) error

type CallMockOptions

type CallMockOptions = func(call *gomock.Call)

func WithAnyTimes

func WithAnyTimes() CallMockOptions

func WithFailed

func WithFailed(err error, times ...CallMockOptions) CallMockOptions

func WithMaxTimes

func WithMaxTimes(n int) CallMockOptions

func WithMinTimes

func WithMinTimes(n int) CallMockOptions

func WithSucceed

func WithSucceed(times ...CallMockOptions) CallMockOptions

func WithTimes

func WithTimes(n int) CallMockOptions

type CallMockPatchReturnedOptions

type CallMockPatchReturnedOptions = func(callHelper *callHelper, call *gomock.Call, _ HandlePatchReturnedObject) error

type CallMockReturnedOptions

type CallMockReturnedOptions = func(callHelper *callHelper, call *gomock.Call)

func WithCreateReturned added in v0.6.0

func WithCreateReturned(action HandleCreateReturnedObject, times ...CallMockOptions) CallMockReturnedOptions

type CallbackFn

type CallbackFn = func(sequence int, r []runtime.Object)

type CallerFunction

type CallerFunction = func() *gomock.Call

type DoReturnedFunction

type DoReturnedFunction = any

type HandleCreateReturnedObject added in v0.6.0

type HandleCreateReturnedObject = func(obj client.Object) error

func WithCreatedFailedResult added in v0.6.0

func WithCreatedFailedResult() HandleCreateReturnedObject

func WithCreatedSucceedResult added in v0.6.0

func WithCreatedSucceedResult() HandleCreateReturnedObject

type HandleGetReturnedObject

type HandleGetReturnedObject = func(key client.ObjectKey, obj client.Object) error

func WithConstructGetResult

func WithConstructGetResult(mockObj client.Object) HandleGetReturnedObject

func WithConstructSequenceResult

func WithConstructSequenceResult(mockObjs map[client.ObjectKey][]MockGetReturned) HandleGetReturnedObject

func WithConstructSimpleGetResult

func WithConstructSimpleGetResult(mockObjs []client.Object) HandleGetReturnedObject

type HandleListReturnedObject

type HandleListReturnedObject = func(list client.ObjectList) error

func WithConstructListReturnedResult

func WithConstructListReturnedResult(r []runtime.Object) HandleListReturnedObject

func WithConstructListSequenceResult

func WithConstructListSequenceResult(mockObjsList [][]runtime.Object, fns ...CallbackFn) HandleListReturnedObject

type HandlePatchReturnedObject

type HandlePatchReturnedObject = func(obj client.Object, patch client.Patch) error

type K8sClientMockHelper

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

func NewK8sMockClient

func NewK8sMockClient() *K8sClientMockHelper

func (*K8sClientMockHelper) Client

func (helper *K8sClientMockHelper) Client() client.Client

func (*K8sClientMockHelper) Controller

func (helper *K8sClientMockHelper) Controller() *gomock.Controller

func (*K8sClientMockHelper) Finish

func (helper *K8sClientMockHelper) Finish()

func (*K8sClientMockHelper) MockCreateMethod added in v0.6.0

func (helper *K8sClientMockHelper) MockCreateMethod(options ...any)

func (*K8sClientMockHelper) MockDeleteMethod

func (helper *K8sClientMockHelper) MockDeleteMethod(options ...any)

func (*K8sClientMockHelper) MockGetMethod

func (helper *K8sClientMockHelper) MockGetMethod(options ...any)

func (*K8sClientMockHelper) MockListMethod

func (helper *K8sClientMockHelper) MockListMethod(options ...any)

func (*K8sClientMockHelper) MockPatchMethod

func (helper *K8sClientMockHelper) MockPatchMethod(options ...any)

func (*K8sClientMockHelper) MockUpdateMethod

func (helper *K8sClientMockHelper) MockUpdateMethod(options ...any)

type MockGetReturned

type MockGetReturned struct {
	Object client.Object
	Err    error
}

type Mysql

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

Mysql represents MySQL output bindings.

func (*Mysql) Close

func (m *Mysql) Close() error

Close closes the DB.

func (*Mysql) GetRole

func (m *Mysql) GetRole(ctx context.Context) (string, error)

func (*Mysql) Init

func (m *Mysql) Init(metadata map[string]string) error

Init initializes the MySQL binding.

type Tunnel

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

func OpenTunnel

func OpenTunnel(svc *corev1.Service) (*Tunnel, error)

func (*Tunnel) Close

func (t *Tunnel) Close() error

func (*Tunnel) GetMySQLConn

func (t *Tunnel) GetMySQLConn() (*Mysql, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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