Documentation ¶
Index ¶
- Variables
- func CreateMockStorageClass(testCtx *testutil.TestContext, storageClassName string) *storagev1.StorageClass
- func CreateVolumeSnapshotClass(testCtx *testutil.TestContext, storageProvisioner string) *snapshotv1.VolumeSnapshotClass
- func DeletePodLabelKey(ctx context.Context, testCtx testutil.TestContext, podName, labelKey string)
- func GetDefaultStorageClass(testCtx *testutil.TestContext) *storagev1.StorageClass
- func InitInstanceSetStatus(testCtx testutil.TestContext, its *workloads.InstanceSet, ...)
- func InitStatefulSetStatus(testCtx testutil.TestContext, statefulset *appsv1.StatefulSet, ...)
- func IsMockVolumeSnapshotEnabled(testCtx *testutil.TestContext, storageClassName string) bool
- func ListAndCheckDeployment(testCtx *testutil.TestContext, key types.NamespacedName) *appsv1.DeploymentList
- func ListAndCheckInstanceSet(testCtx *testutil.TestContext, key types.NamespacedName) *workloads.InstanceSetList
- func ListAndCheckInstanceSetItemsCount(testCtx *testutil.TestContext, key types.NamespacedName, cnt int) *workloads.InstanceSetList
- func ListAndCheckInstanceSetWithComponent(testCtx *testutil.TestContext, key types.NamespacedName, componentName string) *workloads.InstanceSetList
- func ListAndCheckPodCountWithComponent(testCtx *testutil.TestContext, key types.NamespacedName, componentName string, ...) *corev1.PodList
- func ListAndCheckStatefulSet(testCtx *testutil.TestContext, key types.NamespacedName) *appsv1.StatefulSetList
- func ListAndCheckStatefulSetItemsCount(testCtx *testutil.TestContext, key types.NamespacedName, cnt int) *appsv1.StatefulSetList
- func ListAndCheckStatefulSetWithComponent(testCtx *testutil.TestContext, key types.NamespacedName, componentName string) *appsv1.StatefulSetList
- func MockDeploymentReady(deploy *appsv1.Deployment, rsAvailableReason, rsName string)
- func MockDisableVolumeSnapshot(testCtx *testutil.TestContext, storageClassName string)
- func MockEnableVolumeSnapshot(testCtx *testutil.TestContext, storageClassName string)
- func MockInstanceSetReady(its *workloads.InstanceSet, pods ...*corev1.Pod)
- func MockPodAvailable(pod *corev1.Pod, lastTransitionTime metav1.Time)
- func MockPodIsTerminating(ctx context.Context, testCtx testutil.TestContext, pod *corev1.Pod)
- func MockStatefulSetReady(sts *appsv1.StatefulSet)
- func NewFakeInstanceSet(name string, replicas int) *workloads.InstanceSet
- func NewFakeInstanceSetPod(its *workloads.InstanceSet, ordinal int) *corev1.Pod
- func NewFakeStatefulSet(name string, replicas int) *appsv1.StatefulSet
- func NewFakeStatefulSetPod(set *appsv1.StatefulSet, ordinal int) *corev1.Pod
- func PatchInstanceSetStatus(testCtx *testutil.TestContext, stsName string, ...)
- func PatchStatefulSetStatus(testCtx *testutil.TestContext, stsName string, status appsv1.StatefulSetStatus)
- func RemovePodFinalizer(ctx context.Context, testCtx testutil.TestContext, pod *corev1.Pod)
- func SetGetReturnedObject(out client.Object, expectedObj client.Object)
- func SetListReturnedObjects(list client.ObjectList, objects []runtime.Object) error
- func SetupK8sMock() (*gomock.Controller, *mock_client.MockClient)
- func UpdatePodStatusScheduleFailed(ctx context.Context, testCtx testutil.TestContext, podName, namespace string)
- type CallMockGetReturnedOptions
- type CallMockListReturnedOptions
- type CallMockOptions
- type CallMockPatchReturnedOptions
- type CallMockReturnedOptions
- func WithCreateReturned(action HandleCreateReturnedObject, times ...CallMockOptions) CallMockReturnedOptions
- func WithGetReturned(action HandleGetReturnedObject, times ...CallMockOptions) CallMockReturnedOptions
- func WithListReturned(action HandleListReturnedObject, times ...CallMockOptions) CallMockReturnedOptions
- func WithPatchReturned(action HandlePatchReturnedObject, times ...CallMockOptions) CallMockReturnedOptions
- type CallbackFn
- type CallerFunction
- type DoReturnedFunction
- type Getter
- type HandleCreateReturnedObject
- type HandleGetReturnedObject
- type HandleListReturnedObject
- type HandlePatchReturnedObject
- type K8sClientMockHelper
- func (helper *K8sClientMockHelper) Client() client.Client
- func (helper *K8sClientMockHelper) Controller() *gomock.Controller
- func (helper *K8sClientMockHelper) Finish()
- func (helper *K8sClientMockHelper) MockCreateMethod(options ...any)
- func (helper *K8sClientMockHelper) MockDeleteMethod(options ...any)
- func (helper *K8sClientMockHelper) MockGetMethod(options ...any)
- func (helper *K8sClientMockHelper) MockListMethod(options ...any)
- func (helper *K8sClientMockHelper) MockPatchMethod(options ...any)
- func (helper *K8sClientMockHelper) MockStatusMethod() *mock_client.MockStatusWriter
- func (helper *K8sClientMockHelper) MockUpdateMethod(options ...any)
- func (helper *K8sClientMockHelper) StatusWriter() *mock_client.MockStatusWriter
- type MockGetReturned
- type Mysql
- type Tunnel
Constants ¶
This section is empty.
Variables ¶
var (
DefaultStorageClassName = "default-sc-for-testing"
)
Functions ¶
func CreateMockStorageClass ¶
func CreateMockStorageClass(testCtx *testutil.TestContext, storageClassName string) *storagev1.StorageClass
func CreateVolumeSnapshotClass ¶
func CreateVolumeSnapshotClass(testCtx *testutil.TestContext, storageProvisioner string) *snapshotv1.VolumeSnapshotClass
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 InitInstanceSetStatus ¶
func InitInstanceSetStatus(testCtx testutil.TestContext, its *workloads.InstanceSet, controllerRevision string)
func InitStatefulSetStatus ¶
func InitStatefulSetStatus(testCtx testutil.TestContext, statefulset *appsv1.StatefulSet, controllerRevision string)
func IsMockVolumeSnapshotEnabled ¶
func IsMockVolumeSnapshotEnabled(testCtx *testutil.TestContext, storageClassName string) bool
func ListAndCheckDeployment ¶
func ListAndCheckDeployment(testCtx *testutil.TestContext, key types.NamespacedName) *appsv1.DeploymentList
func ListAndCheckInstanceSet ¶ added in v0.9.0
func ListAndCheckInstanceSet(testCtx *testutil.TestContext, key types.NamespacedName) *workloads.InstanceSetList
func ListAndCheckInstanceSetItemsCount ¶ added in v0.9.0
func ListAndCheckInstanceSetItemsCount(testCtx *testutil.TestContext, key types.NamespacedName, cnt int) *workloads.InstanceSetList
func ListAndCheckInstanceSetWithComponent ¶ added in v0.9.0
func ListAndCheckInstanceSetWithComponent(testCtx *testutil.TestContext, key types.NamespacedName, componentName string) *workloads.InstanceSetList
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 ¶
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 MockDisableVolumeSnapshot ¶
func MockDisableVolumeSnapshot(testCtx *testutil.TestContext, storageClassName string)
func MockEnableVolumeSnapshot ¶
func MockEnableVolumeSnapshot(testCtx *testutil.TestContext, storageClassName string)
func MockInstanceSetReady ¶ added in v0.9.0
func MockInstanceSetReady(its *workloads.InstanceSet, pods ...*corev1.Pod)
MockInstanceSetReady mocks the ITS workload to ready state.
func MockPodAvailable ¶
MockPodAvailable mocks pod is available
func MockPodIsTerminating ¶
MockPodIsTerminating mocks pod is terminating.
func MockStatefulSetReady ¶
func MockStatefulSetReady(sts *appsv1.StatefulSet)
MockStatefulSetReady mocks the StatefulSet workload is ready.
func NewFakeInstanceSet ¶
func NewFakeInstanceSet(name string, replicas int) *workloads.InstanceSet
NewFakeInstanceSet creates a fake ITS workload object for testing.
func NewFakeInstanceSetPod ¶
func NewFakeInstanceSetPod(its *workloads.InstanceSet, ordinal int) *corev1.Pod
NewFakeInstanceSetPod creates a fake pod of the ITS workload for testing.
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 PatchInstanceSetStatus ¶
func PatchInstanceSetStatus(testCtx *testutil.TestContext, stsName string, status workloads.InstanceSetStatus)
func PatchStatefulSetStatus ¶
func PatchStatefulSetStatus(testCtx *testutil.TestContext, stsName string, status appsv1.StatefulSetStatus)
func RemovePodFinalizer ¶
RemovePodFinalizer removes the pod finalizer to delete the pod finally.
func SetListReturnedObjects ¶
func SetListReturnedObjects(list client.ObjectList, objects []runtime.Object) error
func SetupK8sMock ¶
func SetupK8sMock() (*gomock.Controller, *mock_client.MockClient)
func UpdatePodStatusScheduleFailed ¶
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 ¶
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 ¶
func WithCreateReturned ¶
func WithCreateReturned(action HandleCreateReturnedObject, times ...CallMockOptions) CallMockReturnedOptions
func WithGetReturned ¶
func WithGetReturned(action HandleGetReturnedObject, times ...CallMockOptions) CallMockReturnedOptions
func WithListReturned ¶
func WithListReturned(action HandleListReturnedObject, times ...CallMockOptions) CallMockReturnedOptions
func WithPatchReturned ¶
func WithPatchReturned(action HandlePatchReturnedObject, times ...CallMockOptions) CallMockReturnedOptions
type CallbackFn ¶
type CallerFunction ¶
type DoReturnedFunction ¶
type DoReturnedFunction = any
type HandleCreateReturnedObject ¶
func WithCreatedFailedResult ¶
func WithCreatedFailedResult() HandleCreateReturnedObject
func WithCreatedSucceedResult ¶
func WithCreatedSucceedResult() HandleCreateReturnedObject
type HandleGetReturnedObject ¶
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, get ...Getter) 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 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 ¶
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) MockStatusMethod ¶
func (helper *K8sClientMockHelper) MockStatusMethod() *mock_client.MockStatusWriter
func (*K8sClientMockHelper) MockUpdateMethod ¶
func (helper *K8sClientMockHelper) MockUpdateMethod(options ...any)
func (*K8sClientMockHelper) StatusWriter ¶
func (helper *K8sClientMockHelper) StatusWriter() *mock_client.MockStatusWriter